- Timestamp:
- Nov 14, 2005 6:22:44 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/module_maker/_config.inc.php
r18 r19 6 6 $common_base = realpath($_SERVER['argv'][1]); 7 7 8 9 if ( 2 == $_SERVER['argc']&& '' != $common_base && is_dir($common_base)) {8 // Test argument. 9 if ($_SERVER['argc'] > 1 && '' != $common_base && is_dir($common_base)) { 10 10 // First arg is path to current site. Realpath removes trailing /s 11 11 define('COMMON_BASE', $common_base); 12 12 } else { 13 die("Error: Single argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n"); 13 die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n"); 14 } 15 16 // Make sure necessary files exist. 17 if (!file_exists(COMMON_BASE . '/global/db_auth.inc.php')) { 18 die("Error: First argument directory must contain the global/db_auth.inc.php file with valid MySQL credentials.\n"); 14 19 } 15 20 -
trunk/bin/module_maker/form_template.cli.php
r18 r19 33 33 } 34 34 35 $exclude = array('added_by_ admin_id', 'added_datetime', 'hit_count', 'modified_datetime', 'modified_by_admin_id');35 $exclude = array('added_by_user_id', 'added_datetime', 'hit_count', 'modified_datetime', 'modified_by_user_id'); 36 36 $primary_key_field = ''; 37 37 $output = array(); -
trunk/bin/module_maker/list_template.cli.php
r18 r19 87 87 } else if (preg_match('/(amount|_rate)/i', $field)) { 88 88 $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>"; 89 } else if (preg_match('/(added_by_ admin_id)/i', $field)) {89 } else if (preg_match('/(added_by_user_id)/i', $field)) { 90 90 $listrows[] = "<\x3fphp echo oTxt(\$list[\$i]['added_admin_username']); \x3f>"; 91 } else if (preg_match('/(modified_by_ admin_id)/i', $field)) {91 } else if (preg_match('/(modified_by_user_id)/i', $field)) { 92 92 $listrows[] = "<\x3fphp echo oTxt(\$list[\$i]['modified_admin_username']); \x3f>"; 93 93 } else if ('rank' == $field) { … … 146 146 <tr> 147 147 <td class="nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['______RECORD_NAME______'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> </td> 148 <td class="nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['______RECORD_NAME______'])) \x3f>" href="<\x3fphp echo App::oHREF("/admin/ record_versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> </td>148 <td class="nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['______RECORD_NAME______'])) \x3f>" href="<\x3fphp echo App::oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> </td> 149 149 150 150 E_O_F; -
trunk/bin/module_maker/skel/adm_form.ihtml
r18 r19 9 9 <tr> 10 10 <td> </td> 11 <td valign="top"> 12 <?php if (!empty($frm['submit_caption'])) { ?><input type="submit" name="submit" value="<?php echo oTxt($frm['submit_caption']); ?>" /><?php } ?> 13 <?php if (!empty($frm['repeat_caption'])) { ?><input type="submit" name="repeat" value="<?php echo oTxt($frm['repeat_caption']); ?>" /><?php } ?> 14 <?php if (!empty($frm['reset_caption'])) { ?><input type="submit" name="reset" value="<?php echo oTxt($frm['reset_caption']); ?>" /><?php } ?> 15 <?php if (!empty($frm['cancel_caption'])) { ?><input type="submit" name="cancel" value="<?php echo oTxt($frm['cancel_caption']); ?>" /><?php } ?> 16 </td> 11 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td> 17 12 </tr> 18 13 %ADM_FORM_TABLE_ROWS% 19 14 <tr> 20 15 <td> </td> 21 <td valign="top"> 22 <?php if (!empty($frm['submit_caption'])) { ?><input type="submit" name="submit" value="<?php echo oTxt($frm['submit_caption']); ?>" /><?php } ?> 23 <?php if (!empty($frm['repeat_caption'])) { ?><input type="submit" name="repeat" value="<?php echo oTxt($frm['repeat_caption']); ?>" /><?php } ?> 24 <?php if (!empty($frm['reset_caption'])) { ?><input type="submit" name="reset" value="<?php echo oTxt($frm['reset_caption']); ?>" /><?php } ?> 25 <?php if (!empty($frm['cancel_caption'])) { ?><input type="submit" name="cancel" value="<?php echo oTxt($frm['cancel_caption']); ?>" /><?php } ?> 26 </td> 16 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td> 27 17 </tr> 28 18 </table> -
trunk/bin/module_maker/skel/adm_list.ihtml
r18 r19 27 27 <tr> 28 28 <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> </td> 29 <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF('/admin/ record_versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> </td>29 <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> </td> 30 30 %ADM_LIST_ROWS% 31 31 <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['______RECORD_NAME______'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> </td> -
trunk/bin/module_maker/skel/admin.php
r18 r19 217 217 218 218 // Lock this record. 219 $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm[' address']);219 $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm['<##>']); 220 220 221 221 // Set misc values for the form. … … 277 277 278 278 // Create version. 279 $version = new RecordVersion( );279 $version = new RecordVersion($GLOBALS['auth']); 280 280 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']); 281 281 … … 300 300 301 301 // Create version. 302 $version = new RecordVersion( );302 $version = new RecordVersion($GLOBALS['auth']); 303 303 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']); 304 304 … … 349 349 a2.username AS modified_admin_username 350 350 FROM %DB_TBL% 351 LEFT JOIN admin_tbl a1 ON (%DB_TBL%.added_by_ admin_id = a1.admin_id)352 LEFT JOIN admin_tbl a2 ON (%DB_TBL%.modified_by_ admin_id = a2.admin_id)351 LEFT JOIN admin_tbl a1 ON (%DB_TBL%.added_by_user_id = a1.admin_id) 352 LEFT JOIN admin_tbl a2 ON (%DB_TBL%.modified_by_user_id = a2.admin_id) 353 353 $where_clause 354 354 " . $so->getSortOrderSQL() . " -
trunk/bin/module_maker/sql.cli.php
r18 r19 73 73 // Toggle types. 74 74 $c[$field] = "'\" . isset(\$frm['$field']) . \"'"; 75 } else if ('added_by_ admin_id' == $field || 'modified_by_admin_id' == $field) {75 } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) { 76 76 // Toggle types. 77 77 $c[$field] = "'\" . addslashes(\$auth->getVal('user_id')) . \"'"; … … 94 94 // Insert SQL. 95 95 if (!isset($op) || 'insert' == $op) { 96 $insert_skip_columns = array('modified_datetime', 'modified_by_ admin_id');96 $insert_skip_columns = array('modified_datetime', 'modified_by_user_id'); 97 97 $insert_c = array(); 98 98 foreach ($c as $k=>$v) { … … 120 120 // Update SQL. 121 121 if (!isset($op) || 'update' == $op) { 122 $update_skip_columns = array('added_datetime', 'added_by_ admin_id');122 $update_skip_columns = array('added_datetime', 'added_by_user_id'); 123 123 $comma = ''; 124 124 $key_eq_val = ''; … … 181 181 // Search SQL 182 182 if (!isset($op) || 'search' == $op) { 183 $search_skip_columns = array('added_datetime', 'added_by_ admin_id', 'modified_datetime', 'modified_by_admin_id', 'publish', 'featured');183 $search_skip_columns = array('added_datetime', 'added_by_user_id', 'modified_datetime', 'modified_by_user_id', 'publish', 'featured'); 184 184 $search_columns = $db_tbl . '.' . join(" LIKE '%\" . addslashes(\$qry_words[\$i]) . \"%'\n OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns)); 185 185 echo <<<E_O_F -
trunk/bin/module_maker/validation.cli.php
r18 r19 34 34 35 35 // Exclude these fields. 36 $exclude = array('added_by_ admin_id', 'added_datetime', 'hit_count', 'modified_datetime', 'modified_by_admin_id');36 $exclude = array('added_by_user_id', 'added_datetime', 'hit_count', 'modified_datetime', 'modified_by_user_id'); 37 37 38 38 // Loop through columns -
trunk/lib/App.inc.php
r18 r19 87 87 88 88 // Directory in which to store log files. 89 'log_directory' => null,89 'log_directory' => '', 90 90 91 91 // PHP error log. … … 112 112 'log_to_email_address' => null, 113 113 114 // SMS Email address to receive log event SMS messages 114 // SMS Email address to receive log event SMS messages. 115 115 'log_to_sms_address' => null, 116 117 // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>' 116 117 // The from address used for system emails. 118 'envelope_sender_address' => '', 119 120 // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'. 118 121 'signing_key' => 'aae6abd6209d82a691a9f96384a7634a', 119 122 ); … … 190 193 return $this->_params[$param]; 191 194 } else { 192 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);195 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE); 193 196 return null; 194 197 } -
trunk/lib/RecordVersion.inc.php
r18 r19 59 59 function RecordVersion($auth_object) 60 60 { 61 if (!is_a($auth_object, 'Auth_SQL')) { 62 trigger_error('Passed argument is not a valid Auth_SQL object.', E_USER_ERROR); 63 } 64 61 65 $this->_auth = $auth_object; 62 66 -
trunk/services/admins.php
r18 r19 21 21 22 22 /****************************************************************************** 23 * CO DE CONFIG23 * CONFIG 24 24 *****************************************************************************/ 25 25 … … 31 31 32 32 // Instantiate a sorting object with the default sort and order. Add SQL for each column. 33 $so = new SortOrder('admin_id', 'DESC'); 34 $so->setColumn('admin_id', 'admin_id ASC', 'admin_id DESC'); 35 $so->setColumn('username', 'username ASC', 'username DESC'); 36 $so->setColumn('userpass', 'userpass ASC', 'userpass DESC'); 37 $so->setColumn('first_name', 'first_name ASC', 'first_name DESC'); 38 $so->setColumn('last_name', 'last_name ASC', 'last_name DESC'); 39 $so->setColumn('phone', 'phone ASC', 'phone DESC'); 40 $so->setColumn('email', 'email ASC', 'email DESC'); 41 $so->setColumn('priv', 'priv ASC', 'priv DESC'); 42 $so->setColumn('seconds_online', 'seconds_online ASC', 'seconds_online DESC'); 43 $so->setColumn('added_datetime', 'added_datetime ASC', 'added_datetime DESC'); 44 $so->setColumn('last_login_datetime', 'last_login_datetime ASC', 'last_login_datetime DESC'); 45 $so->setColumn('last_access_datetime', 'last_access_datetime ASC', 'last_access_datetime DESC'); 46 $so->setColumn('last_login_ip', 'last_login_ip ASC', 'last_login_ip DESC'); 33 $so = new SortOrder('admin_tbl.admin_id', 'DESC'); 34 $so->setColumn('admin_tbl.admin_id', 'admin_tbl.admin_id ASC', 'admin_tbl.admin_id DESC'); 35 $so->setColumn('admin_tbl.username', 'admin_tbl.username ASC', 'admin_tbl.username DESC'); 36 $so->setColumn('admin_tbl.userpass', 'admin_tbl.userpass ASC', 'admin_tbl.userpass DESC'); 37 $so->setColumn('admin_tbl.first_name', 'admin_tbl.first_name ASC', 'admin_tbl.first_name DESC'); 38 $so->setColumn('admin_tbl.last_name', 'admin_tbl.last_name ASC', 'admin_tbl.last_name DESC'); 39 $so->setColumn('admin_tbl.email', 'admin_tbl.email ASC', 'admin_tbl.email DESC'); 40 $so->setColumn('admin_tbl.user_type', 'admin_tbl.user_type ASC', 'admin_tbl.user_type DESC'); 41 $so->setColumn('admin_tbl.seconds_online', 'admin_tbl.seconds_online ASC', 'admin_tbl.seconds_online DESC'); 42 $so->setColumn('admin_tbl.last_login_datetime', 'admin_tbl.last_login_datetime ASC', 'admin_tbl.last_login_datetime DESC'); 43 $so->setColumn('admin_tbl.last_access_datetime', 'admin_tbl.last_access_datetime ASC', 'admin_tbl.last_access_datetime DESC'); 44 $so->setColumn('admin_tbl.last_login_ip', 'admin_tbl.last_login_ip ASC', 'admin_tbl.last_login_ip DESC'); 45 $so->setColumn('admin_tbl.added_by_user_id', 'admin_tbl.added_by_user_id ASC', 'admin_tbl.added_by_user_id DESC'); 46 $so->setColumn('admin_tbl.modified_by_user_id', 'admin_tbl.modified_by_user_id ASC', 'admin_tbl.modified_by_user_id DESC'); 47 $so->setColumn('admin_tbl.added_datetime', 'admin_tbl.added_datetime ASC', 'admin_tbl.added_datetime DESC'); 48 $so->setColumn('admin_tbl.modified_datetime', 'admin_tbl.modified_datetime ASC', 'admin_tbl.modified_datetime DESC'); 47 49 48 50 // Instantiate page numbers. Total items are set and calculation is done in the getRecordList function. … … 192 194 193 195 // If the username was changed during edit, verify. 194 if (getFormData(' priv') == 'root' && 'root' != $auth->getVal('priv')) {195 $fv->addError(' priv', sprintf(_("You do not have clearance to create a user with root privileges."), null));196 if (getFormData('user_type') == 'root' && 'root' != $auth->getVal('user_type')) { 197 $fv->addError('user_type', sprintf(_("You do not have clearance to create a user with root privileges."), null)); 196 198 } 197 199 … … 207 209 208 210 $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters.")); 209 210 $fv->stringLength('phone', 0, 255, _("<strong>Phone</strong> must contain less than 256 characters.")); 211 $fv->validatePhone('phone'); 212 211 212 $fv->isEmpty('email', _("<strong>Email</strong> cannot be blank.")); 213 213 $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters.")); 214 214 $fv->validateEmail('email'); 215 215 216 $fv->stringLength('county', 0, 255, _("<strong>County</strong> has an invalid selection.")); 217 218 $fv->stringLength('priv', 0, 255, _("<strong>Priv</strong> has an invalid selection.")); 216 $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank.")); 217 $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection.")); 219 218 } 220 219 221 220 function &addRecordForm() 222 221 { 223 // set default values for the reset of the fields. 224 $frm['priv'] = 'admin'; 225 $frm['new_op'] = 'insert'; 226 $frm['submit_caption'] = _("Add admin"); 227 $frm['repeat_caption'] = _("Add & repeat"); 228 $frm['cancel_caption'] = _("Cancel"); 222 // Set default values for the reset of the fields. 223 $frm = array( 224 'admin_id' => '', 225 'username' => '', 226 'userpass' => '', 227 'first_name' => '', 228 'last_name' => '', 229 'email' => '', 230 'user_type' => '', 231 'seconds_online' => '0', 232 'last_login_datetime' => '0000-00-00 00:00:00', 233 'last_access_datetime' => '0000-00-00 00:00:00', 234 'last_login_ip' => '0.0.0.0', 235 'added_by_user_id' => '', 236 'modified_by_user_id' => '', 237 'added_datetime' => '0000-00-00 00:00:00', 238 'modified_datetime' => '0000-00-00 00:00:00', 239 'new_op' => 'insert', 240 'submit_buttons' => array( 241 'submit' => _("Add Admin"), 242 'repeat' => _("Add & repeat"), 243 'cancel' => _("Cancel"), 244 ), 245 ); 229 246 230 247 return $frm; … … 237 254 if ($lock->isLocked() && !$lock->isMine()) { 238 255 $lock->dieErrorPage(); 239 } else { 240 // Get the information for the form. 241 $qid = DB::query(" 242 SELECT * from admin_tbl 243 WHERE admin_id = '" . addslashes($id) . "' 244 "); 245 if (!$frm = mysql_fetch_assoc($qid)) { 246 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 247 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); 248 App::dieBoomerangURL(); 249 } 250 251 // Lock this record. 252 $lock->set('admin_tbl', 'admin_id', $id, $frm['address']); 253 254 // Set misc values for the form. 255 $frm['old_username'] = $frm['username']; 256 $frm['userpass'] = '***************'; 257 $frm['new_op'] = 'update'; 258 $frm['submit_caption'] = _("Save changes"); 259 $frm['repeat_caption'] = _("Save & edit next"); 260 $frm['reset_caption'] = _("Reset"); 261 $frm['cancel_caption'] = _("Cancel"); 262 $frm['admin_id'] = $id; 263 264 return $frm; 265 } 256 } 257 258 // Get the information for the form. 259 $qid = DB::query(" 260 SELECT * 261 FROM admin_tbl 262 WHERE admin_id = '" . addslashes($id) . "' 263 "); 264 if (!$frm = mysql_fetch_assoc($qid)) { 265 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 266 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); 267 App::dieBoomerangURL(); 268 } 269 270 // Lock this record. 271 $lock->set('admin_tbl', 'admin_id', $id, $frm['username']); 272 273 // Set misc values for the form. 274 $frm = array_merge(array( 275 'admin_id' => '', 276 'old_username' => $frm['username'], 277 'username' => '', 278 // 'userpass' => '****************', 279 'first_name' => '', 280 'last_name' => '', 281 'email' => '', 282 'user_type' => '', 283 'seconds_online' => '0', 284 'last_login_datetime' => '0000-00-00 00:00:00', 285 'last_access_datetime' => '0000-00-00 00:00:00', 286 'last_login_ip' => '0.0.0.0', 287 'added_by_user_id' => '', 288 'modified_by_user_id' => '', 289 'added_datetime' => '0000-00-00 00:00:00', 290 'modified_datetime' => '0000-00-00 00:00:00', 291 'new_op' => 'update', 292 'submit_buttons' => array( 293 'submit' => _("Save changes"), 294 'repeat' => _("Save & edit next"), 295 'reset' => _("Reset"), 296 'cancel' => _("Cancel"), 297 ), 298 ), $frm, array('userpass' => '****************')); 299 300 return $frm; 266 301 } 267 302 … … 280 315 // Get the information for this object. 281 316 $qid = DB::query(" 282 SELECT username, privfrom admin_tbl317 SELECT username, user_type from admin_tbl 283 318 WHERE admin_id = '" . addslashes($id) . "' 284 319 "); 285 if (! list($name, $ priv) = mysql_fetch_row($qid)) {320 if (! list($name, $user_type) = mysql_fetch_row($qid)) { 286 321 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 287 322 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); … … 292 327 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); 293 328 list($num_admins) = mysql_fetch_row($qid); 294 if ('root' == $ priv && 'root' != $auth->getVal('priv')) {329 if ('root' == $user_type && 'root' != $auth->getVal('user_type')) { 295 330 // Only root users can delete root users! 296 331 App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__); … … 325 360 first_name, 326 361 last_name, 327 phone,328 362 email, 329 priv, 363 user_type, 364 added_by_user_id, 330 365 added_datetime 331 366 ) VALUES ( … … 333 368 '" . addslashes($frm['first_name']) . "', 334 369 '" . addslashes($frm['last_name']) . "', 335 '" . addslashes($frm['phone']) . "',336 370 '" . addslashes($frm['email']) . "', 337 '" . addslashes($frm['priv']) . "', 371 '" . addslashes($frm['user_type']) . "', 372 '" . addslashes($auth->getVal('user_id')) . "', 338 373 NOW() 339 374 ) … … 344 379 $auth->setPassword($last_insert_id, $frm['userpass']); 345 380 346 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 381 // Create version. 382 $version = new RecordVersion($GLOBALS['auth']); 383 $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']); 384 385 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 347 386 348 387 return $last_insert_id; … … 373 412 first_name = '" . addslashes($frm['first_name']) . "', 374 413 last_name = '" . addslashes($frm['last_name']) . "', 375 phone = '" . addslashes($frm['phone']) . "',376 414 email = '" . addslashes($frm['email']) . "', 377 priv = '" . addslashes($frm['priv']) . "' 415 user_type = '" . addslashes($frm['user_type']) . "', 416 modified_by_user_id = '" . addslashes($auth->getVal('user_id')) . "', 417 modified_datetime = NOW() 378 418 WHERE admin_id = '" . addslashes($frm['admin_id']) . "' 379 419 "); 380 420 381 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 421 // Create version. 422 $version = new RecordVersion($GLOBALS['auth']); 423 $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']); 424 425 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 382 426 383 427 // Unlock record. … … 391 435 global $so; 392 436 393 // Build search query if $qry is not empty. 394 $sql_delim = 'WHERE'; 395 $search_where_clause = ''; 396 $qry = getFormData('search_query'); 397 if (!empty($qry)) { 398 $qry_words = preg_split('/[^\w]/', $qry); 437 $where_clause = ''; 438 439 // Build search query if available. 440 if (getFormData('search_query', false)) { 441 $qry_words = preg_split('/[^\w]/', getFormData('search_query')); 399 442 for ($i=0; $i<sizeof($qry_words); $i++) { 400 $search_where_clause .= " 401 $sql_delim ( 402 username LIKE '%" . addslashes($qry_words[$i]) . "%' 403 OR first_name LIKE '%" . addslashes($qry_words[$i]) . "%' 404 OR last_name LIKE '%" . addslashes($qry_words[$i]) . "%' 405 OR phone LIKE '%" . addslashes($qry_words[$i]) . "%' 406 OR email LIKE '%" . addslashes($qry_words[$i]) . "%' 407 OR priv LIKE '%" . addslashes($qry_words[$i]) . "%' 443 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " 444 ( 445 admin_tbl.username LIKE '%" . addslashes($qry_words[$i]) . "%' 446 OR admin_tbl.first_name LIKE '%" . addslashes($qry_words[$i]) . "%' 447 OR admin_tbl.last_name LIKE '%" . addslashes($qry_words[$i]) . "%' 448 OR admin_tbl.email LIKE '%" . addslashes($qry_words[$i]) . "%' 408 449 ) 409 450 "; 410 $sql_delim = 'AND'; 411 } 412 } 413 414 $where_clause = ''; 451 } 452 } 453 415 454 if (getFormData('search_query', false)) { 416 455 // Search query. 417 456 $where_clause = $search_where_clause; 418 457 } 419 if (getFormData('filter_admin_ priv', false)) {458 if (getFormData('filter_admin_user_type', false)) { 420 459 // Limit by filter. 421 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " priv = '" . addslashes(getFormData('filter_admin_priv')) . "'";460 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " user_type = '" . addslashes(getFormData('filter_admin_user_type')) . "'"; 422 461 } 423 462 424 463 // Count the total number of records so we can do something about the page numbers. 425 $qid = DB::query("SELECT COUNT(*) FROM admin_tbl $where_clause"); 464 $qid = DB::query(" 465 SELECT COUNT(*) 466 FROM admin_tbl 467 $where_clause 468 "); 426 469 list($num_results) = mysql_fetch_row($qid); 427 470 … … 432 475 // Final SQL, with sort and page limiters. 433 476 $sql = " 434 SELECT * FROM admin_tbl 477 SELECT 478 admin_tbl.*, 479 a1.username AS added_admin_username, 480 a2.username AS modified_admin_username 481 FROM admin_tbl 482 LEFT JOIN admin_tbl a1 ON (admin_tbl.added_by_user_id = a1.admin_id) 483 LEFT JOIN admin_tbl a2 ON (admin_tbl.modified_by_user_id = a2.admin_id) 435 484 $where_clause 436 485 " . $so->getSortOrderSQL() . " … … 449 498 } 450 499 451 if (SessionCache::isCached($_SERVER['PHP_SELF']) && FALSE) { ///500 if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) { 452 501 // Get the cached results. 453 502 $list = SessionCache::getCache($_SERVER['PHP_SELF']); … … 460 509 } 461 510 462 // Cache the results. 463 SessionCache::putCache($list, $_SERVER['PHP_SELF']); 511 if (isset($list) && !empty($list)) { 512 // Cache the results. 513 SessionCache::putCache($list, $_SERVER['PHP_SELF']); 514 } 464 515 } 465 516 -
trunk/services/templates/admin_form.ihtml
r18 r19 7 7 <input type="hidden" name="old_username" value="<?php echo $frm['old_username']; ?>"> 8 8 9 <table border="0" cellspacing="0" cellpadding="4">9 <table> 10 10 <tr> 11 <td class="formlabel" align="right" valign="top"> </td> 12 <td valign="top"> 13 <?php if (!empty($frm['submit_caption'])) { ?><input type="submit" class="formsubmitbutton" name="submit" value="<?php echo oTxt($frm['submit_caption']); ?>" /><?php } ?> 14 <?php if (!empty($frm['repeat_caption'])) { ?><input type="submit" class="formsubmitbutton" name="repeat" value="<?php echo oTxt($frm['repeat_caption']); ?>" /><?php } ?> 15 <?php if (!empty($frm['reset_caption'])) { ?><input type="submit" class="formsubmitbutton" name="reset" value="<?php echo oTxt($frm['reset_caption']); ?>" /><?php } ?> 16 <?php if (!empty($frm['cancel_caption'])) { ?><input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo oTxt($frm['cancel_caption']); ?>" /><?php } ?> 17 </td> 11 <td> </td> 12 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td> 18 13 </tr> 19 14 <tr> 20 <td class="formlabel" align="right" valign="top"<?php $fv->err('username', ' style="color:#f33;"') ?>><?php echo _("Username"); ?></td>15 <td class="formlabel" align="right" valign="top"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></td> 21 16 <td valign="top"> 22 17 <input type="text" class="forminputtext" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>"> … … 24 19 </tr> 25 20 <tr> 26 <td class="formlabel" align="right" valign="top"<?php $fv->err('userpass', ' style="color:#f33;"') ?>><?php echo _("Password"); ?></td>21 <td class="formlabel" align="right" valign="top"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></td> 27 22 <td valign="top"> 28 23 <input type="password" class="forminputtext" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>"> … … 30 25 </tr> 31 26 <tr> 32 <td class="formlabel" align="right" valign="top"<?php $fv->err('first_name', ' style="color:#f33;"') ?>><?php echo _("First name"); ?></td>27 <td class="formlabel" align="right" valign="top"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></td> 33 28 <td valign="top"> 34 29 <input type="text" class="forminputtext" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>"> … … 36 31 </tr> 37 32 <tr> 38 <td class="formlabel" align="right" valign="top"<?php $fv->err('last_name', ' style="color:#f33;"') ?>><?php echo _("Last name"); ?></td>33 <td class="formlabel" align="right" valign="top"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></td> 39 34 <td valign="top"> 40 35 <input type="text" class="forminputtext" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>"> … … 42 37 </tr> 43 38 <tr> 44 <td class="formlabel" align="right" valign="top"<?php $fv->err('phone', ' style="color:#f33;"') ?>><?php echo _("Phone"); ?></td> 45 <td valign="top"> 46 <input type="text" class="forminputtext" size="50" name="phone" value="<?php echo oTxt($frm['phone']); ?>"> 47 </td> 48 </tr> 49 <tr> 50 <td class="formlabel" align="right" valign="top"<?php $fv->err('email', ' style="color:#f33;"') ?>><?php echo _("Email"); ?></td> 39 <td class="formlabel" align="right" valign="top"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></td> 51 40 <td valign="top"> 52 41 <input type="text" class="forminputtext" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>"> … … 54 43 </tr> 55 44 <tr> 56 <td class="formlabel" align="right" valign="top"<?php $fv->err(' priv', ' style="color:#f33;"') ?>><?php echo _("Priv"); ?></td>45 <td class="formlabel" align="right" valign="top"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></td> 57 46 <td valign="top"> 58 <select name=" priv">59 <?php printSetSelectForm('admin_tbl', ' priv', $frm['priv'], true); ?>47 <select name="user_type"> 48 <?php printSetSelectForm('admin_tbl', 'user_type', $frm['user_type'], true); ?> 60 49 </select> 61 50 </td> 62 51 </tr> 63 52 <tr> 64 <td class="formlabel" align="right" valign="top"> </td> 65 <td valign="top"> 66 <?php if (!empty($frm['submit_caption'])) { ?><input type="submit" class="formsubmitbutton" name="submit" value="<?php echo oTxt($frm['submit_caption']); ?>" /><?php } ?> 67 <?php if (!empty($frm['repeat_caption'])) { ?><input type="submit" class="formsubmitbutton" name="repeat" value="<?php echo oTxt($frm['repeat_caption']); ?>" /><?php } ?> 68 <?php if (!empty($frm['reset_caption'])) { ?><input type="submit" class="formsubmitbutton" name="reset" value="<?php echo oTxt($frm['reset_caption']); ?>" /><?php } ?> 69 <?php if (!empty($frm['cancel_caption'])) { ?><input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo oTxt($frm['cancel_caption']); ?>" /><?php } ?> 70 </td> 53 <td> </td> 54 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td> 71 55 </tr> 72 56 </table> -
trunk/services/templates/admin_list.ihtml
r18 r19 2 2 <?php $fv->printErrorMessages(); ?> 3 3 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 4 <?php $carry_queries = array('search_query', 'filter_admin_ priv'); ?>4 <?php $carry_queries = array('search_query', 'filter_admin_user_type'); ?> 5 5 <?php App::printHiddenSession(false); ?> 6 6 <div id="commandbox"> … … 8 8 <br /> 9 9 10 <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: username, first & last name, phone, email, county.")); ?>" />11 <input type="submit" name="list" value="<?php echo _("Search"); ?>" class="formsubmitbutton" /> 12 13 <!-- <select name="filter_admin_priv"> -->14 <!-- <?php printSetSelectForm('admin_tbl', 'filter_admin_priv', getFormData('filter_admin_priv'), true); ?> -->15 <!-- </select>-->16 <!-- <input type="submit" name="list" value="Filter by privilege" class="formsubmitbutton"> -->10 <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" /> 11 <!-- 12 <select name="filter_<##>"> 13 <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '—', city, '—', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?> 14 </select> 15 --> 16 <input type="submit" name="list" value="<?php echo _("Search"); ?>" /> 17 17 </div> 18 18 19 19 <?php include 'list_info.ihtml'; ?> 20 20 21 <table class="list" border="0" cellpadding="2" cellspacing="0">21 <table class="list"> 22 22 <tr> 23 <th class="padleft"> </th> 24 <th class="padleft"><?php $so->printSortHeader('admin_id', _("ID"), 'ASC'); ?></th> 25 <th class="padleft"><?php $so->printSortHeader('username', _("Username"), 'ASC'); ?></th> 26 <th class="padleft"><?php $so->printSortHeader('first_name', _("First"), 'ASC'); ?> 27 <?php $so->printSortHeader('last_name', _("Last name"), 'ASC'); ?></th> 28 <th class="padleft"><?php $so->printSortHeader('last_access_datetime', _("Logged-in"), 'DESC'); ?></th> 29 <th class="padleft"><?php $so->printSortHeader('seconds_online', _("Total min logged-in"), 'DESC'); ?></th> 30 <th class="padleft"><?php $so->printSortHeader('last_login_ip', _("Last remote addr"), 'ASC'); ?></th> 31 <th class="padleft"> </th> 23 <th> </th> 24 <th> </th> 25 <th><?php echo $so->printSortHeader('admin_tbl.admin_id', _("ID"), 'ASC'); ?></th> 26 <th><?php echo $so->printSortHeader('admin_tbl.username', _("Username"), 'ASC'); ?></th> 27 <th><?php echo $so->printSortHeader('admin_tbl.first_name', _("First"), 'ASC'); ?> <?php echo $so->printSortHeader('admin_tbl.last_name', _("Last name"), 'ASC'); ?></th> 28 <th><?php echo $so->printSortHeader('admin_tbl.email', _("Email"), 'ASC'); ?></th> 29 <th><?php echo $so->printSortHeader('admin_tbl.user_type', _("User type"), 'ASC'); ?></th> 30 <th><?php echo $so->printSortHeader('admin_tbl.seconds_online', _("Min online"), 'ASC'); ?></th> 31 <th><?php echo $so->printSortHeader('admin_tbl.last_login_datetime', _("Last login"), 'ASC'); ?></th> 32 <th><?php echo $so->printSortHeader('admin_tbl.last_login_ip', _("Remote host"), 'ASC'); ?></th> 33 <th><?php echo $so->printSortHeader('admin_tbl.added_datetime', _("Added"), 'ASC'); ?></th> 34 <th><?php echo $so->printSortHeader('admin_tbl.added_by_user_id', _("by admin"), 'ASC'); ?></th> 35 <th><?php echo $so->printSortHeader('admin_tbl.modified_datetime', _("Last modified"), 'ASC'); ?></th> 36 <th> </th> 32 37 </tr> 33 <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items ; $i++) { ?>38 <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?> 34 39 <tr> 35 <td class="padleft nowrap"> 36 <a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF('/admin/admins.php?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> 37 </td> 38 <td class="padleft nowrap"><?php echo $list[$i]['admin_id']; ?> </td> 39 <td class="padleft nowrap"><?php echo oTxt($list[$i]['username']); ?> </td> 40 <td class="padleft nowrap"><a href="mailto:<?php echo oTxt($list[$i]['email']); ?>"><?php echo oTxt($list[$i]['first_name']); ?> 41 <?php echo oTxt($list[$i]['last_name']); ?></a> </td> 42 <td class="padleft nowrap"><a href="#" style="text-decoration:none;" title="<?php printf(_("Last accessed %s"), $list[$i]['last_access_datetime']) ?>"><?php echo $auth->isLoggedIn($list[$i]['admin_id']) ? '<strong>' . _("yes") . '</strong>' : _("no"); ?></a> </td> 43 <td class="padleft nowrap"><?php echo round($list[$i]['seconds_online'] / 60); ?> </td> 44 <td class="padleft nowrap"><?php echo gethostbyaddr($list[$i]['last_login_ip']); ?> </td> 45 <td class="padleft right nowrap"> 46 <a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF('/admin/admins.php?op=del&admin_id=' . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> 47 </td> 40 <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> </td> 41 <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=admin_tbl&record_key=admin_id&boomerang=true&record_val=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> </td> 42 <td class="nowrap"><?php echo oTxt($list[$i]['admin_id'], true); ?> </td> 43 <td class="nowrap"><?php echo oTxt($list[$i]['username'], true); ?> </td> 44 <td class="nowrap"><?php echo oTxt($list[$i]['first_name'], true); ?> <?php echo oTxt($list[$i]['last_name'], true); ?> </td> 45 <td class="nowrap"><?php echo oTxt($list[$i]['email'], true); ?> </td> 46 <td class="nowrap"><?php echo oTxt($list[$i]['user_type'], true); ?> </td> 47 <td class="nowrap"><?php echo round($list[$i]['seconds_online'] / 60); ?> </td> 48 <td class="nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['last_login_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['last_login_datetime'])); ?> </td> 49 <td class="nowrap"><?php echo gethostbyaddr($list[$i]['last_login_ip']); ?> </td> 50 <td class="nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['added_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['added_datetime'])); ?> </td> 51 <td class="nowrap"><?php echo oTxt($list[$i]['added_admin_username'], true); ?> </td> 52 <td class="nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> </td> 53 <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> </td> 48 54 </tr> 49 55 <?php } ?> -
trunk/services/templates/passwd.ihtml
r18 r19 6 6 <table border="0" cellspacing="0" cellpadding="4"> 7 7 <tr> 8 <td class="formlabel" align="right" valign="top"<?php $fv->err('oldpassword', ' style="color:#f33;"') ?>><?php echo _("Old password"); ?></td>8 <td class="formlabel" align="right" valign="top"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></td> 9 9 <td valign="top"><input type="password" class="forminputtext" size="25" name="oldpassword" /></td> 10 10 </tr> 11 11 <tr> 12 <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword', ' style="color:#f33;"') ?>><?php echo _("New password"); ?></td>12 <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></td> 13 13 <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword" /></td> 14 14 </tr> 15 15 <tr> 16 <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword2', ' style="color:#f33;"') ?>><?php echo _("New password again"); ?></td>16 <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></td> 17 17 <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword2" /></td> 18 18 </tr> -
trunk/services/versions.php
r18 r19 17 17 *****************************************************************************/ 18 18 19 $version = new RecordVersion( );19 $version = new RecordVersion($GLOBALS['auth']); 20 20 21 21 // These values must be kept across requests.
Note: See TracChangeset
for help on using the changeset viewer.