Changeset 42
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 86 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/file_importer.php
r41 r42 27 27 $file_text = join('', file($file)); 28 28 fclose($fp); 29 29 30 30 // Do something with file contents. 31 31 preg_match('/BALANCE:\s*\$([\.\d]+)/', $file_text, $amt); … … 68 68 69 69 /** 70 * Find all files in directories recursivly with a specified file extension. 70 * Find all files in directories recursivly with a specified file extension. 71 71 * 72 72 * @param string $dir the full path to the directory to scan … … 80 80 { 81 81 static $output; 82 82 83 83 $dir_handle = opendir($dir); 84 84 while ($dir_handle && ($file = readdir($dir_handle)) !== false) { -
trunk/bin/module_maker/form_template.cli.php
r41 r42 40 40 if (is_array($cols) && !empty($cols)) { 41 41 foreach ($cols as $col) { 42 42 43 43 // Human readable. 44 44 $field = $col[0]; … … 48 48 $primary_key_field = $field; 49 49 } 50 50 51 51 // Column types like this are usually single toggle checkboxes. 52 52 if (preg_match("/enum\('true'\)/", $col[1])) { 53 53 $type = 'toggle'; 54 54 } 55 55 56 56 if (in_array($field, $exclude) || $primary_key_field == $field) { 57 57 // Don't add a field for this column. 58 58 continue; 59 59 } 60 60 61 61 // Select menu from the column of a related database table. 62 62 if (preg_match('/.*_id$/i', $field)) { … … 79 79 continue; 80 80 } 81 81 82 82 // File upload. 83 83 if (preg_match('/file|image/i', $field)) { … … 96 96 continue; 97 97 } 98 98 99 99 // Password field. 100 100 if (preg_match('/pass/i', $field)) { … … 109 109 continue; 110 110 } 111 111 112 112 switch ($type) { 113 113 114 114 // Select menu (or radio buttons) 115 115 case 'enum' : … … 125 125 E_O_F; 126 126 break; 127 127 128 128 // Set checkboxes 129 129 case 'set' : … … 137 137 E_O_F; 138 138 break; 139 139 140 140 // Single checkbox 141 141 case 'toggle' : … … 149 149 E_O_F; 150 150 break; 151 151 152 152 // Textarea 153 153 case 'tinytext' : … … 168 168 E_O_F; 169 169 break; 170 171 170 171 172 172 // Text 173 173 case 'tinyint' : … … 179 179 case 'integer' : 180 180 case 'bigint' : 181 181 182 182 case 'float' : 183 183 case 'float' : … … 188 188 case 'dec' : 189 189 case 'numeric' : 190 190 191 191 case 'date' : 192 192 case 'datetime' : … … 194 194 case 'time' : 195 195 case 'year' : 196 196 197 197 case 'char' : 198 198 case 'varchar' : -
trunk/bin/module_maker/list_template.cli.php
r41 r42 49 49 if (is_array($cols) && !empty($cols)) { 50 50 foreach ($cols as $col) { 51 51 52 52 // Human readable. 53 53 $field = $col[0]; 54 54 $title = ucfirst(str_replace('_', ' ', $field)); 55 55 $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]); 56 56 57 57 // Get primary key. 58 58 if ('PRI' == $col[3]) { 59 59 $primary_key = $field; 60 60 } 61 61 62 62 // Column headers. 63 63 $headers[$field] = $title; 64 64 65 65 // Column data. 66 66 if (preg_match("/enum\('true'\)/", $col[1])) { … … 111 111 <span class="nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span> 112 112 <br /> 113 113 114 114 <input type="text" class="small" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" /> 115 115 <select name="filter_<##>"> -
trunk/bin/module_maker/module.cli.php
r41 r42 17 17 } else { 18 18 die(basename($_SERVER['argv'][0]) . " Error: invalid arguments. Try like this: 19 19 20 20 " . basename($_SERVER['argv'][0]) . " site_directory name_singular name_plural [clean] 21 21 … … 46 46 break; 47 47 default : 48 48 49 49 } 50 50 … … 91 91 trashFile("$public_dir/$public_script"); 92 92 trashFile("$public_tpl_dir/$public_list_template"); 93 trashFile("$public_tpl_dir/$public_detail_template"); 93 trashFile("$public_tpl_dir/$public_detail_template"); 94 94 echo "End file cleanup\n"; 95 95 die; … … 163 163 if (is_array($cols) && !empty($cols)) { 164 164 foreach ($cols as $col) { 165 165 166 166 // Human readable. 167 167 $field = $col[0]; … … 169 169 $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]); 170 170 $default = $col[4]; 171 171 172 172 // Get primary key. 173 173 // if ('PRI' == $col[3]) { 174 174 // $primary_key = $field; 175 175 // } 176 176 177 177 // Our form will require type="multipart/form-data". 178 178 if (preg_match('/file|image/i', $field)) { 179 179 $upload_file_capability = true; 180 180 } 181 181 182 182 // Column headers. 183 183 $headers[$field] = $field_title; 184 184 185 185 // Get php code for printing variables. 186 186 $public_list_page_vars[] = "<\x3fphp echo oTxt(\$" . $module_name_singular . "_list[\$i]['$field']); \x3f>"; … … 222 222 // Form arguments 223 223 $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />"; 224 224 225 225 // Include statement. 226 226 $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n"; … … 245 245 // Copy uploaded image name into form data. 246 246 \$_POST['<##>'] = isset(\$_FILES['<##>']) ? \$_FILES['<##>']['name'] : ''; 247 247 248 248 249 249 E_O_F; … … 261 261 $replace['admin_upload_insert'] = <<<E_O_F 262 262 263 263 // Upload files with prepended primary key. 264 264 \$new_file = \$upload->process('<##>', \$%PRIMARY_KEY% . '_' . getFormData('<##>')); 265 265 … … 443 443 if ('var' == $op) { 444 444 if (isset($replace[$_SERVER['argv'][5]])) { 445 445 echo "\n\n" . $replace[$_SERVER['argv'][5]] . "\n\n"; 446 446 } else if (isset($skel_files[$_SERVER['argv'][5]])) { 447 447 echo "\n\n" . preg_replace($search, $replace, $skel_files[$_SERVER['argv'][5]]) . "\n\n"; … … 540 540 global $user_trash_folder; 541 541 static $file_prefix; 542 542 543 543 if (!isset($file_prefix)) { 544 544 $file_prefix = time(); … … 546 546 $file_prefix++; 547 547 } 548 548 549 549 // Make user trash folder. 550 550 if (!dir($user_trash_folder)) { -
trunk/bin/module_maker/skel/adm_list.ihtml
r41 r42 7 7 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span> 8 8 <br /> 9 9 10 10 <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: <##> %SEARCH_FIELDS%.")); ?>" /> 11 11 <select name="filter_<##>"> -
trunk/bin/module_maker/skel/admin.php
r41 r42 26 26 * CONFIG 27 27 *****************************************************************************/ 28 28 29 29 // Titles and navigation header. 30 30 $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']); 31 31 32 32 // The object to validate form input. 33 33 $fv = new FormValidator(); … … 215 215 // Get the information for the form. 216 216 $qid = DB::query(" 217 SELECT * 217 SELECT * 218 218 FROM %DB_TBL% 219 219 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "' … … 227 227 // Lock this record. 228 228 $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm['<##>']); 229 229 230 230 // Set misc values for the form. 231 231 $frm = array_merge(array( … … 246 246 { 247 247 global $lock; 248 248 249 249 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 250 250 if ($lock->isLocked() && !$lock->isMine()) { … … 254 254 // Break the cache because we are changing the list data. 255 255 SessionCache::breakCache($_SERVER['PHP_SELF']); 256 256 257 257 // Get the information for this object. 258 258 $qid = DB::query(" 259 SELECT <##> 259 SELECT <##> 260 260 FROM %DB_TBL% 261 261 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "' … … 266 266 App::dieBoomerangURL(); 267 267 } 268 268 269 269 // Delete the record. 270 270 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'"); 271 271 272 272 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 273 273 … … 279 279 { 280 280 global $auth; 281 281 282 282 // Break the cache because we are changing the list data. 283 283 SessionCache::breakCache($_SERVER['PHP_SELF']); 284 284 285 285 %INSERT% 286 286 $last_insert_id = mysql_insert_id(DB::getDBH()); … … 289 289 $version = RecordVersion::getInstance($GLOBALS['auth']); 290 290 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']); 291 291 292 292 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__); 293 293 294 294 return $last_insert_id; 295 295 } … … 298 298 { 299 299 global $auth, $lock; 300 300 301 301 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']); 302 302 if ($lock->isLocked() && !$lock->isMine()) { … … 308 308 309 309 %UPDATE% 310 310 311 311 // Create version. 312 312 $version = RecordVersion::getInstance($GLOBALS['auth']); … … 323 323 global $page; 324 324 global $so; 325 325 326 326 $where_clause = ''; 327 327 328 328 // Build search query if available. 329 329 if (getFormData('search_query', false)) { … … 333 333 } 334 334 } 335 335 336 336 if (getFormData('filter_<##>', false)) { 337 337 // Limit by filter. 338 338 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . addslashes(getFormData('filter_<##>')) . "'"; 339 339 } 340 340 341 341 // Count the total number of records so we can do something about the page numbers. 342 342 $qid = DB::query(" 343 SELECT COUNT(*) 344 FROM %DB_TBL% 343 SELECT COUNT(*) 344 FROM %DB_TBL% 345 345 $where_clause 346 346 "); 347 347 list($num_results) = mysql_fetch_row($qid); 348 348 349 349 // Set page numbers now we know (needed for next step). 350 350 $page->setTotalItems($num_results); 351 351 $page->calculate(); 352 352 353 353 // Final SQL, with sort and page limiters. 354 354 $sql = " 355 SELECT 356 %DB_TBL%.*, 355 SELECT 356 %DB_TBL%.*, 357 357 a1.username AS added_admin_username, 358 358 a2.username AS modified_admin_username … … 364 364 " . $page->getLimitSQL() . " 365 365 "; 366 366 367 367 // A unique key for this query, with the total_items in case db records 368 368 // were added since the last cache. This identifies a unique set of … … 375 375 Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 376 376 } 377 377 378 378 if (SessionCache::isCached($_SERVER['PHP_SELF'])) { 379 379 // Get the cached results. … … 386 386 $list[] = $row; 387 387 } 388 388 389 389 if (isset($list) && !empty($list)) { 390 390 // Cache the results. … … 397 397 398 398 function updateRank($ranks) 399 { 399 { 400 400 if (!is_array($ranks)) { 401 401 App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__); … … 405 405 // Break the cache because we are changing the list data. 406 406 SessionCache::breakCache($_SERVER['PHP_SELF']); 407 407 408 408 // Count the ranks with invalid numbers 409 409 $unspecified_counter = 0; 410 410 411 411 // Go through the array of new ranks. 412 412 foreach ($ranks as $id => $new_rank) { … … 414 414 // Unspecified entries receive a sort order of 10000. 415 415 $new_rank = 10000; 416 $unspecified_counter++; 416 $unspecified_counter++; 417 417 } 418 418 DB::query(" … … 422 422 "); 423 423 } 424 424 425 425 App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__); 426 426 if ($unspecified_counter > 0) { -
trunk/bin/module_maker/skel/public.php
r41 r42 1 1 <?php 2 2 /** 3 * %PUBLIC_SCRIPT% 3 * %PUBLIC_SCRIPT% 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 * … … 18 18 // Titles and navigation header. 19 19 $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']); 20 $nav->setFeature(array('title'=>true)); 20 $nav->setFeature(array('title'=>true)); 21 21 22 22 // Instantiate page numbers. Total items are set and calculation is done in the getRecordList function. … … 32 32 33 33 if (getFormData('%PRIMARY_KEY%', false)) { 34 34 35 35 // Get requested record. 36 36 $qid = DB::query(" … … 52 52 WHERE %PRIMARY_KEY% = '" . addslashes(getFormData('%PRIMARY_KEY%')) . "' 53 53 "); 54 54 55 55 // Set title and main template. 56 56 $nav->addPage($item['<##>']); … … 58 58 59 59 } else { 60 60 61 61 // Get the DEFAULT list. 62 62 $%NAME_SINGULAR%_list = array(); 63 63 $qid = DB::query(" 64 SELECT * 65 FROM %DB_TBL% 66 WHERE publish = 'true' 64 SELECT * 65 FROM %DB_TBL% 66 WHERE publish = 'true' 67 67 " . $so->getSortOrderSQL() . " 68 68 LIMIT 100 … … 71 71 $%NAME_SINGULAR%_list[] = $row; 72 72 } 73 73 74 74 // Set page numbers for default list. 75 75 $page->setTotalItems(sizeof($%NAME_SINGULAR%_list)); 76 76 $page->calculate(); 77 77 78 78 79 79 // Get the FEATURED list. 80 80 $featured_list = array(); 81 81 $qid = DB::query(" 82 SELECT * 83 FROM %DB_TBL% 82 SELECT * 83 FROM %DB_TBL% 84 84 WHERE publish = 'true' 85 85 AND featured = 'true' … … 89 89 $featured_list[] = $row; 90 90 } 91 91 92 92 // Get the POPULAR list. 93 93 $popular_list = array(); 94 94 $qid = DB::query(" 95 SELECT * 96 FROM %DB_TBL% 97 WHERE publish = 'true' 95 SELECT * 96 FROM %DB_TBL% 97 WHERE publish = 'true' 98 98 ORDER BY hit_count DESC LIMIT 10 99 99 "); … … 101 101 $popular_list[] = $row; 102 102 } 103 103 104 104 // Get the RECENT list. 105 105 $recent_list = array(); 106 106 $qid = DB::query(" 107 SELECT * 108 FROM %DB_TBL% 109 WHERE publish = 'true' 107 SELECT * 108 FROM %DB_TBL% 109 WHERE publish = 'true' 110 110 ORDER BY added_datetime DESC LIMIT 10 111 111 "); … … 113 113 $recent_list[] = $row; 114 114 } 115 115 116 116 // Set main template. 117 117 $main_template = '%PUBLIC_LIST_TEMPLATE%'; 118 } 118 } 119 119 120 120 // We have the data, and no errors, so here come the templates. -
trunk/bin/module_maker/skel/public_list.ihtml
r41 r42 11 11 <p> 12 12 <em><?php echo date(App::getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> — <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?> 13 13 14 14 <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?> 15 15 <br /><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a> 16 16 <?php } ?> 17 17 </p> 18 <?php 18 <?php 19 19 } 20 20 if ($page->total_pages > 1) { … … 30 30 ?> 31 31 <h2><?php echo _("Featured %NAME_PLURAL%"); ?></h2> 32 <?php 32 <?php 33 33 foreach ($featured_list as $item) { 34 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php 34 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php 35 35 } 36 36 } … … 42 42 ?> 43 43 <h2><?php echo _("Popular %NAME_PLURAL%"); ?></h2> 44 <?php 44 <?php 45 45 foreach ($popular_list as $item) { 46 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php 46 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php 47 47 } 48 48 } … … 54 54 ?> 55 55 <h2><?php echo _("Recent %NAME_PLURAL%"); ?></h2> 56 <?php 56 <?php 57 57 foreach ($recent_list as $item) { 58 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php 58 ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php 59 59 } 60 60 } -
trunk/bin/module_maker/sql.cli.php
r41 r42 56 56 if (is_array($cols) && !empty($cols)) { 57 57 foreach ($cols as $col) { 58 58 59 59 // Human readable. 60 60 $field = $col[0]; 61 61 $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]); 62 62 $is_primary_key = ('PRI' == $col[3]); 63 63 64 64 $sort_columns .= "\$so->setColumn('$field', '$field ASC', '$field DESC');\n"; 65 65 66 66 if ($is_primary_key) { 67 67 // This is the primary key. Deal with separately. … … 84 84 } 85 85 } 86 86 87 87 } else { 88 88 die(basename($_SERVER['argv'][0]) . " Warning: $db_tbl does not have any columns.\n"); -
trunk/bin/module_maker/validation.cli.php
r41 r42 38 38 // Loop through columns 39 39 if (is_array($cols) && !empty($cols)) { 40 40 41 41 $o = array(); 42 42 43 43 foreach ($cols as $col) { 44 44 45 45 // Human readable. 46 46 $field = $col[0]; … … 49 49 $is_primary_key = ('PRI' == $col[3]); 50 50 $unsigned = preg_match('/\s*unsigned\s*$/i', $col[1]); 51 51 52 52 if (in_array($field, $exclude)) { 53 53 continue; 54 54 } 55 55 56 56 // ----------- isEmpty ------------ 57 57 $o[] = "\$fv->isEmpty('$field', _(\"<strong>$title</strong> cannot be blank.\"));"; … … 68 68 $len_type = 'setenum'; 69 69 break; 70 70 71 71 case 'date' : 72 72 case 'datetime' : … … 77 77 $max_length = 127; 78 78 break; 79 79 80 80 case 'tinytext' : 81 81 case 'tinyblob' : … … 85 85 $max_length = 255; 86 86 break; 87 87 88 88 case 'text' : 89 89 case 'blob' : … … 91 91 $max_length = 65535; 92 92 break; 93 93 94 94 case 'mediumtext' : 95 95 case 'mediumblob' : … … 97 97 $max_length = 16777215; 98 98 break; 99 99 100 100 case 'longtext' : 101 101 case 'longblob' : … … 103 103 $max_length = 4294967295; 104 104 break; 105 105 106 106 case 'tinyint' : 107 107 case 'bit' : … … 116 116 } 117 117 break; 118 118 119 119 case 'smallint' : 120 120 $len_type = 'num'; … … 127 127 } 128 128 break; 129 129 130 130 case 'mediumint' : 131 131 $len_type = 'num'; … … 138 138 } 139 139 break; 140 140 141 141 case 'int' : 142 142 case 'integer' : … … 150 150 } 151 151 break; 152 152 153 153 case 'bigint' : 154 154 $len_type = 'num'; … … 161 161 } 162 162 break; 163 163 164 164 case 'float' : 165 165 $len_type = 'num'; … … 167 167 $max = 3.40282E+38; 168 168 break; 169 169 170 170 case 'double' : 171 171 case 'double precision' : … … 178 178 $max = 1.79769E+308; 179 179 break; 180 180 181 181 default : 182 182 $len_type = null; … … 192 192 $o[] = "\$fv->numericRange('$field', $min, $max, _(\"<strong>$title</strong> must be a valid number between $min and $max.\"));"; 193 193 } 194 194 195 195 // ----------- type check ------------ 196 196 switch ($type) { 197 197 198 198 case 'enum' : 199 199 200 200 case 'set' : 201 201 break; 202 202 203 203 case 'char' : 204 204 case 'varchar' : 205 205 206 206 case 'tinytext' : 207 207 case 'text' : … … 214 214 // $o[] = "\$fv->isString('$field', _(\"<strong>$title</strong> must be a string.\"));"; // Pretty useless 215 215 break; 216 216 217 217 case 'tinyint' : 218 218 case 'bit' : … … 226 226 $o[] = "\$fv->isInteger('$field', _(\"<strong>$title</strong> must be an integer.\")$negative_ok);"; 227 227 break; 228 228 229 229 case 'float' : 230 230 case 'float' : … … 238 238 $o[] = "\$fv->isFloat('$field', _(\"<strong>$title</strong> must be a valid number.\")$negative_ok);"; 239 239 break; 240 240 241 241 case 'date' : 242 242 case 'datetime' : … … 244 244 $o[] = "\$fv->checkRegex('$field', '/^\d{4}-\d{2}-\d{2}$/', true, _(\"<strong>$title</strong> must be a valid date in YYYY-MM-DD format.\"));"; 245 245 break; 246 246 247 247 case 'timestamp' : 248 248 $o[] = "\$fv->checkRegex('$field', '/^\d{14}$/', true, _(\"<strong>$title</strong> must be a valid mysql timestamp in YYYYMMDDhhmmss format.\"));"; 249 249 break; 250 250 251 251 case 'time' : 252 252 $o[] = "\$fv->checkRegex('$field', '/^\d{1,3}:\d{2}:\d{2}$/', true, _(\"<strong>$title</strong> must be a valid time in hh:mm:ss format.\"));"; 253 253 break; 254 254 255 255 case 'year' : 256 256 $o[] = "\$fv->checkRegex('$field', '/^\d{4}$/', true, _(\"<strong>$title</strong> must be a valid year in YYYY format.\"));"; 257 257 break; 258 258 259 259 default : 260 260 break; 261 261 } 262 262 263 263 if (preg_match('/email/', $field)) { 264 264 $o[] = "\$fv->validateEmail('$field');"; … … 266 266 $o[] = "\$fv->validatePhone('$field');"; 267 267 } 268 268 269 269 // Blank between cols? 270 270 $o[] = ''; … … 278 278 279 279 echo "function validateInput() 280 { 280 { 281 281 global \$fv; 282 282 -
trunk/docs/coding_standards.txt
r41 r42 7 7 ====================================================================== 8 8 9 We're following the PEAR coding standards, with minor modifications. 9 We're following the PEAR coding standards, with minor modifications. 10 10 11 11 This is essential reading: … … 20 20 21 21 Auth_SQL.inc.php One PHP Class to be included. The filename is the 22 type of class, underscore, name. Or if in subdirs, 22 type of class, underscore, name. Or if in subdirs, 23 23 this could be /Auth/SQL.inc.php while the class name 24 24 remains "Auth_SQL" … … 29 29 directly in the web root. 30 30 31 script.cli.php A command-line executable script, possibly executed 31 script.cli.php A command-line executable script, possibly executed 32 32 with CRON, usually outputs TEXT, not HTML. 33 33 … … 43 43 44 44 Use an indent of 4 spaces, with no tabs. Code and especially comments should 45 be wrapped <= 80 characters. Exceptions are made in the case where code 45 be wrapped <= 80 characters. Exceptions are made in the case where code 46 46 readability is significantly improved with longer lines. 47 47 … … 80 80 action1; 81 81 break; 82 82 83 83 case 2: 84 84 action2; 85 85 break; 86 86 87 87 default: 88 88 defaultaction; 89 89 break; 90 90 91 91 } 92 92 … … 137 137 ====================================================================== 138 138 139 When functions return boolean values, use 'return false;' or 'return true;' 139 When functions return boolean values, use 'return false;' or 'return true;' 140 140 as opposed to 'return 0;' or 'return 1;' or 'return(-1);'. 141 141 … … 149 149 150 150 $something = $blah . funky() . ".\".=" . $blab; 151 151 152 152 is better than: 153 153 154 154 $something = $blah.funky().".\".=".$blab; 155 155 … … 159 159 ====================================================================== 160 160 161 Use the single quote marks ' to enclose simple strings whenever possible. 162 Double quote marks " require extra parsing and thus slow things down, but 163 are necessary if entities there must be swapped-out such as variables or 161 Use the single quote marks ' to enclose simple strings whenever possible. 162 Double quote marks " require extra parsing and thus slow things down, but 163 are necessary if entities there must be swapped-out such as variables or 164 164 control characters. 165 165 … … 196 196 ====================================================================== 197 197 198 Function comments should follow the Javadoc standard, with detailed 198 Function comments should follow the Javadoc standard, with detailed 199 199 function comments and one-line pointers along the way: 200 200 http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html 201 201 202 202 <?php 203 203 /** … … 215 215 { 216 216 $qid = DB::query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false); 217 217 218 218 $row = mysql_fetch_row($qid); 219 219 if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $match)) { … … 283 283 ====================================================================== 284 284 285 All HTML should be valid XHTML 1.0 verfied with the 285 All HTML should be valid XHTML 1.0 verfied with the 286 286 W3C Markup Validation Service: http://validator.w3.org/ 287 287 … … 302 302 <td nowrap="nowrap">Example</td> 303 303 304 All tags must be properly closed. Tags without a closing part must follow the 304 All tags must be properly closed. Tags without a closing part must follow the 305 305 XHTML convention and end with a space and a slash: 306 306 -
trunk/docs/example_config.inc.php
r41 r42 12 12 // To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php'; 13 13 if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) { 14 14 trigger_error('_config.inc.php include must be specified with an absolute file path (eg: "require_once dirname(__FILE__) . \'/_config.inc.php\';"', E_USER_ERROR); 15 15 } 16 16 … … 19 19 define('COMMON_BASE', realpath(dirname(__FILE__) . '/../')); 20 20 21 // The DocRoot for this application. SITE_BASE is ifferent from $_SERVER['DOCUMENT_ROOT'] because the 21 // The DocRoot for this application. SITE_BASE is ifferent from $_SERVER['DOCUMENT_ROOT'] because the 22 22 // latter does not change when using the apache Alias directive or URL Rewriting to define a site. 23 23 define('SITE_BASE', dirname(__FILE__)); -
trunk/docs/file_layout.txt
r41 r42 5 5 ====================================================================================== 6 6 7 codebase/ 8 bin/ 7 codebase/ 8 bin/ 9 9 (generic command-line scripts and applications) 10 10 file_importer.php … … 16 16 list_template.cli.php 17 17 module.cli.php 18 skel/ 18 skel/ 19 19 (templates for generating modules) 20 20 adm_form.ihtml … … 32 32 file_layout.txt 33 33 software_licence.txt 34 todo.txt 34 todo.txt 35 35 lib/ 36 36 App.inc.php (functions dealing with sessions, href/url/IP manipulation, directories.) … … 61 61 Upload.inc.php (class that manages uploading of files.) 62 62 Utilities.inc.php (functions for general utility: setting defaults, num/string functions, etc.) 63 services/ 63 services/ 64 64 (codebase scripts that are only useful when web accessible, i.e. to be used in a doc root) 65 65 admins.php … … 79 79 ====================================================================================== 80 80 81 global/ 81 global/ 82 82 (global level configuration and libraries for a group of sites/apps) 83 83 config.inc.php (system-wide configuration) 84 84 db_auth.inc.php (db-authentication for CLI scripts. chown'ed by user executing cron, NOT apache). 85 85 86 docs/ 86 docs/ 87 87 (documents specific to a group of sites/apps) 88 88 tei_db.mysql (db schema) 89 90 bin/ 89 90 bin/ 91 91 (global level command-line scripts) 92 93 admin/ 92 93 admin/ 94 94 (DocumentRoot for the admin application) 95 95 _config.inc.php … … 107 107 versions.php (manage db record versions) 108 108 109 html/ 109 html/ 110 110 (DocumentRoot of main site application) 111 111 _config.inc.php (configuration options and defaults specific to this site. included first in each script.) -
trunk/docs/revision_history.txt
r41 r42 10 10 - will still run if info missing: db creds, log dir, session info. 11 11 - can be located in /usr/local/lib/php if necessary, so accessible by all sites. 12 12 13 13 remove interdependencies: 14 14 - App() is the only dependency for other classes. It includes Utilities.inc.php silently. 15 15 - Update libs requiring external files, such as html templates and email templates, classes now self-contained. 16 16 17 17 Things with modified interfaces: 18 18 - App … … 41 41 - lang 42 42 - $dbh database handler 43 43 44 44 App object: 45 45 - object belongs to a realm, keeping messages and session data within specific site/app. 46 46 - uses the singleton pattern so only one instance of App exists for each app. 47 47 - app object can be accessed globally without reference to object name by calling methods statically, e.g. App:logMsg() 48 - seperate application and codebase parameters from site configuration variables. 48 - seperate application and codebase parameters from site configuration variables. 49 49 Use $app->getParam('var') or App::getParam('var') to get app params. 50 50 F or site configurations do whatever you want (I'm using $cfg['node']['features'] format for configurations) 51 51 52 52 App configuration parameters 53 53 - defaults part of the app class -
trunk/lib/App.inc.php
r41 r42 9 9 * @version 1.0 10 10 */ 11 11 12 12 // Message Types. 13 13 define('MSG_ERR', 1); … … 20 20 21 21 class App { 22 22 23 23 // Name of this application. 24 24 var $app = '_app_'; … … 29 29 // Instance of database object. 30 30 var $db; 31 31 32 32 // Array of query arguments will be carried persistently between requests. 33 33 var $_carry_queries = array(); … … 46 46 // The location the user will go if the system doesn't knew where else to send them. 47 47 'redirect_home_url' => '/', 48 48 49 49 // SSL URL used when redirecting with App::sslOn(). 50 50 'ssl_domain' => null, 51 51 'ssl_enabled' => false, 52 52 53 53 // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag. 54 54 'character_set' => 'utf-8', … … 63 63 'session_name' => 'Strangecode', 64 64 'session_use_cookies' => true, 65 65 66 66 // Use database? 67 67 'enable_db' => false, … … 69 69 // Use db-based sessions? 70 70 'enable_db_session_handler' => false, 71 71 72 72 // DB passwords should be set as apache environment variables in httpd.conf, readable only by root. 73 73 'db_server' => 'localhost', … … 80 80 'db_debug' => false, // TRUE = display db errors. 81 81 'db_die_on_failure' => false, // TRUE = script stops on db error. 82 82 83 83 // For classes that require db tables, do we check that a table exists and create if missing? 84 84 'db_create_tables' => true, … … 89 89 // Don't display errors by default; it is preferable to log them to a file. 90 90 'display_errors' => false, 91 91 92 92 // Directory in which to store log files. 93 93 'log_directory' => '', … … 112 112 'log_sms_priority' => false, 113 113 'log_screen_priority' => false, 114 114 115 115 // Email address to receive log event emails. 116 116 'log_to_email_address' => null, 117 117 118 118 // SMS Email address to receive log event SMS messages. 119 119 'log_to_sms_address' => null, 120 120 121 121 // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'. 122 122 'signing_key' => 'aae6abd6209d82a691a9f96384a7634a', 123 123 ); 124 124 125 125 /** 126 126 * This method enforces the singleton pattern for this class. Only one application is running at a time. … … 140 140 return $instance; 141 141 } 142 142 143 143 /** 144 144 * Constructor. … … 149 149 $this->app .= $app; 150 150 } 151 151 152 152 // Initialize default parameters. 153 153 $this->_params = array_merge($this->_params, $this->_param_defaults); … … 184 184 $this =& App::getInstance(); 185 185 } 186 186 187 187 if ($param === null) { 188 188 return $this->_params; … … 194 194 } 195 195 } 196 196 197 197 /** 198 198 * Begin running this application. … … 207 207 return false; 208 208 } 209 209 210 210 // Error reporting. 211 211 ini_set('error_reporting', $this->getParam('error_reporting')); … … 215 215 ini_set('error_log', $this->getParam('log_directory') . '/' . $this->getParam('php_error_log')); 216 216 } 217 218 217 218 219 219 /** 220 220 * 1. Start Database. 221 221 */ 222 222 223 223 if ($this->getParam('enable_db')) { 224 224 225 225 // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root. 226 226 if (!empty($_SERVER['DB_SERVER'])) { … … 236 236 $this->setParam(array('db_pass' => $_SERVER['DB_PASS'])); 237 237 } 238 238 239 239 // The only instance of the DB object. 240 240 require_once dirname(__FILE__) . '/DB.inc.php'; 241 241 242 242 $this->db =& DB::getInstance(); 243 243 244 244 $this->db->setParam(array( 245 245 'db_server' => $this->getParam('db_server'), … … 255 255 $this->db->connect(); 256 256 } 257 258 257 258 259 259 /** 260 260 * 2. Start PHP session. 261 261 */ 262 262 263 263 // Skip session for some user agents. 264 264 if (preg_match('/Atomz|ApacheBench|Wget/i', getenv('HTTP_USER_AGENT'))) { 265 265 $this->setParam(array('enable_session' => false)); 266 266 } 267 267 268 268 if (true === $this->getParam('enable_session')) { 269 269 270 270 // Set the session ID to one provided in GET/POST. This is necessary for linking 271 271 // between domains and keeping the same session. … … 273 273 session_id($ses); 274 274 } 275 275 276 276 if (true === $this->getParam('enable_db_session_handler') && true === $this->getParam('enable_db')) { 277 277 // Database session handling. … … 282 282 )); 283 283 } 284 284 285 285 // Session parameters. 286 286 ini_set('session.use_cookies', $this->getParam('session_use_cookies')); … … 289 289 ini_set('session.entropy_length', '512'); 290 290 session_name($this->getParam('session_name')); 291 291 292 292 // Start the session. 293 293 session_start(); 294 294 295 295 if (!isset($_SESSION[$this->app])) { 296 296 // Access session data using: $_SESSION['...']. … … 302 302 } 303 303 } 304 305 304 305 306 306 /** 307 307 * 3. Misc setup. … … 319 319 $this->setParam(array('signing_key' => $_SERVER['SIGNING_KEY'])); 320 320 } 321 321 322 322 // Character set. This should also be printed in the html header template. 323 323 header('Content-type: text/html; charset=' . $this->getParam('character_set')); 324 324 325 325 $this->running = true; 326 326 } 327 327 328 328 /** 329 329 * Stop running this application. … … 340 340 $this->running = false; 341 341 } 342 343 342 343 344 344 /** 345 345 * Add a message to the string globalmessage, which is printed in the header. … … 359 359 $this =& App::getInstance(); 360 360 } 361 361 362 362 $message = trim($message); 363 363 … … 365 365 return false; 366 366 } 367 367 368 368 // Save message in session under unique key to avoid duplicate messages. 369 369 $_SESSION[$this->app]['messages'][md5($type . $message . $file . $line)] = array( 370 'type' => $type, 370 'type' => $type, 371 371 'message' => $message, 372 372 'file' => $file, 373 373 'line' => $line 374 374 ); 375 375 376 376 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 377 378 } 379 } 380 377 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__); 378 } 379 } 380 381 381 /** 382 382 * Prints the HTML for displaying raised messages. … … 405 405 echo '<div class="error">' . $message['message'] . '</div>'; 406 406 break; 407 407 408 408 case MSG_WARNING: 409 409 echo '<div class="warning">' . $message['message'] . '</div>'; 410 410 break; 411 411 412 412 case MSG_SUCCESS: 413 413 echo '<div class="success">' . $message['message'] . '</div>'; 414 414 break; 415 415 416 416 case MSG_NOTICE: 417 417 default: 418 418 echo '<div class="notice">' . $message['message'] . '</div>'; 419 419 break; 420 420 421 421 } 422 422 ?></div><?php 423 423 } 424 424 } 425 425 426 426 /** 427 427 * Logs a message to a user defined log file. Additional actions to take for … … 448 448 $this =& App::getInstance(); 449 449 } 450 450 451 451 // If priority is not specified, assume the worst. 452 452 if (!$this->logPriorityToString($priority)) { … … 454 454 $priority = LOG_EMERG; 455 455 } 456 456 457 457 // If log file is not specified, don't log to a file. 458 458 if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) { … … 461 461 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE); 462 462 } 463 463 464 464 // Make sure to log in the system's locale. 465 465 $locale = setlocale(LC_TIME, 0); 466 466 setlocale(LC_TIME, 'C'); 467 467 468 468 // Data to be stored for a log event. 469 469 $event = array(); … … 478 478 $event['message'] = strip_tags(preg_replace('/\s+/', ' ', $message), (!empty($strip_tags_allow[1]) ? join('> ', $strip_tags_allow[1]) . '>' : null)); 479 479 $event_str = '[' . join('] [', $event) . ']'; 480 480 481 481 // FILE ACTION 482 482 if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) { 483 483 error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename')); 484 484 } 485 485 486 486 // EMAIL ACTION 487 487 if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) { … … 494 494 mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com'); 495 495 } 496 496 497 497 // SMS ACTION 498 498 if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) { … … 502 502 mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com'); 503 503 } 504 504 505 505 // SCREEN ACTION 506 506 if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { 507 507 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 508 508 } 509 509 510 510 // Restore original locale. 511 511 setlocale(LC_TIME, $locale); 512 512 } 513 513 514 514 /** 515 515 * Returns the string representation of a LOG_* integer constant. … … 536 536 } 537 537 } 538 538 539 539 /** 540 540 * Sets which query arguments will be carried persistently between requests. 541 * Values in the _carry_queries array will be copied to URLs (via App::url()) and 541 * Values in the _carry_queries array will be copied to URLs (via App::url()) and 542 542 * to hidden input values (via printHiddenSession()). 543 543 * 544 544 * @access public 545 * @param string $query_key The key of the query argument to save. 545 * @param string $query_key The key of the query argument to save. 546 546 * @author Quinn Comendant <quinn@strangecode.com> 547 547 * @since 14 Nov 2005 19:24:52 … … 552 552 $this =& App::getInstance(); 553 553 } 554 554 555 555 // If not already set, and there is a non-empty value provided in the request... 556 556 if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) { 557 557 // Copy the value of the specified query argument into the _carry_queries array. 558 559 } 560 } 561 558 $this->_carry_queries[$query_key] = getFormData($query_key); 559 } 560 } 561 562 562 /** 563 563 * Outputs a fully qualified URL with a query of all the used (ie: not empty) 564 * keys and values, including optional queries. This allows mindless retention 564 * keys and values, including optional queries. This allows mindless retention 565 565 * of query arguments across page requests. If cookies are not 566 566 * used, the session id will be propogated in the URL. … … 588 588 return false; 589 589 } 590 590 591 591 // Get any provided query arguments to include in the final URL. 592 592 // If FALSE is a provided here, DO NOT carry the queries. … … 611 611 } 612 612 } 613 613 614 614 // Get the first delimiter that is needed in the url. 615 615 $delim = strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?'; 616 616 617 617 618 618 $q = ''; 619 619 if ($do_carry_queries) { … … 628 628 } 629 629 } 630 630 631 631 // Include the necessary SID if the following is true: 632 632 // - no cookie in http request OR cookies disabled in App … … 634 634 // - the link stays on our site 635 635 // - transparent SID propogation with session.use_trans_sid is not being used OR url begins with protocol (using_trans_sid has no effect here) 636 // OR 636 // OR 637 637 // - we must include the SID because we say so (it's used in a context where cookies will not be effective, ie. moving from http to https) 638 638 // AND … … 642 642 ( 643 643 ( 644 !isset($_COOKIE[session_name()]) 644 !isset($_COOKIE[session_name()]) 645 645 || !$this->getParam('session_use_cookies') 646 ) 646 ) 647 647 && $this->getParam('enable_session') 648 && isMyDomain($url) 649 && 648 && isMyDomain($url) 649 && 650 650 ( 651 651 !ini_get('session.use_trans_sid') 652 652 || preg_match('!^(http|https)://!i', $url) 653 653 ) 654 ) 654 ) 655 655 || $always_include_sid 656 656 ) … … 679 679 $this =& App::getInstance(); 680 680 } 681 681 682 682 $url = $this->url($url, $carry_args, $always_include_sid); 683 683 684 684 // Replace any & not followed by an html or unicode entity with it's & equivalent. 685 685 $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&', $url); 686 686 687 687 return $url; 688 688 } 689 689 690 690 /** 691 691 * Prints a hidden form element with the PHPSESSID when cookies are not used, as well 692 * as hidden form elements for GET_VARS that might be in use. 692 * as hidden form elements for GET_VARS that might be in use. 693 693 * 694 694 * @param mixed $carry_args Additional url arguments to carry in the query, … … 707 707 return false; 708 708 } 709 709 710 710 // Get any provided query arguments to include in the final hidden form data. 711 711 // If FALSE is a provided here, DO NOT carry the queries. … … 730 730 } 731 731 } 732 732 733 733 // For each existing POST value, we create a hidden input to carry it through a form. 734 734 if ($do_carry_queries) { … … 740 740 } 741 741 } 742 742 743 743 // Include the SID if cookies are disabled. 744 744 if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) { … … 746 746 } 747 747 } 748 748 749 749 /** 750 750 * Uses an http header to redirect the client to the given $url. If sessions are not used … … 769 769 return false; 770 770 } 771 771 772 772 if ('' == $url) { 773 773 // If URL is not specified, use the redirect_home_url. 774 774 $url = $this->getParam('redirect_home_url'); 775 775 } 776 776 777 777 if (preg_match('!^/!', $url)) { 778 778 // If relative URL is given, prepend correct local hostname. … … 783 783 784 784 $url = $this->url($url, $carry_args, $always_include_sid); 785 785 786 786 header(sprintf('Location: %s', $url)); 787 787 $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 788 788 789 789 // End this application. 790 790 // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close … … 792 792 die; 793 793 } 794 794 795 795 /** 796 796 * Redirects a user by calling the App::dieURL(). It will use: … … 808 808 return false; 809 809 } 810 810 811 811 // Get URL from stored boomerang. Allow non specific URL if ID not valid. 812 812 if ($this->validBoomerangURL($id, true)) { … … 829 829 $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 830 830 } 831 832 831 832 833 833 // A redirection will never happen immediatly twice. 834 834 // Set the time so ensure this doesn't happen. … … 836 836 $this->dieURL($url, $carry_args); 837 837 } 838 838 839 839 /** 840 840 * Set the URL to return to when App::dieBoomerangURL() is called. … … 855 855 // A redirection will never happen immediatly after setting the boomerangURL. 856 856 // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more. 857 857 858 858 if ('' != $url && is_string($url)) { 859 859 // Delete any boomerang request keys in the query string. 860 860 $url = preg_replace('/boomerang=[\w]+/', '', $url); 861 861 862 862 if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) { 863 863 // If the URL currently exists in the boomerang array, delete. … … 866 866 } 867 867 } 868 868 869 869 if (isset($id)) { 870 870 $_SESSION[$this->app]['boomerang']['url'][$id] = $url; … … 879 879 } 880 880 } 881 881 882 882 /** 883 883 * Return the URL set for the specified $id. … … 894 894 return false; 895 895 } 896 896 897 897 if (isset($id)) { 898 898 if (isset($_SESSION[$this->app]['boomerang']['url'][$id])) { … … 907 907 } 908 908 } 909 909 910 910 /** 911 911 * Delete the URL set for the specified $id. … … 922 922 return false; 923 923 } 924 924 925 925 $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 926 926 … … 931 931 } 932 932 } 933 933 934 934 /** 935 935 * Check if a valid boomerang URL value has been set. … … 947 947 return false; 948 948 } 949 949 950 950 if (!isset($_SESSION[$this->app]['boomerang']['url'])) { 951 951 return false; 952 952 } 953 953 954 954 // Time is the timestamp of a boomerangURL redirection, or setting of a boomerangURL. 955 955 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 956 956 // or a boomerang being set. 957 957 $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0; 958 958 959 959 $url = ''; 960 960 if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) { … … 964 964 $url = end($_SESSION[$this->app]['boomerang']['url']); 965 965 } 966 966 967 967 $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 968 968 … … 981 981 return false; 982 982 } 983 983 984 984 $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 985 985 return true; … … 995 995 $this =& App::getInstance(); 996 996 } 997 997 998 998 if (function_exists('apache_get_modules')) { 999 999 $modules = apache_get_modules(); 1000 1000 } else { 1001 1001 // It's safe to assume we have mod_ssl if we can't determine otherwise. 1002 1002 $modules = array('mod_ssl'); 1003 1003 } 1004 1004 1005 1005 if ('on' != getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) { 1006 1006 $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__); … … 1009 1009 } 1010 1010 } 1011 1012 1011 1012 1013 1013 /** 1014 1014 * to enforce the user to connect via http (port 80) by redirecting them to … … 1022 1022 } 1023 1023 1024 1024 1025 1025 } // End. 1026 1026 -
trunk/lib/Auth_File.inc.php
r41 r42 86 86 { 87 87 $user_id = trim($user_id); 88 88 89 89 $this->clearAuth(); 90 90 … … 189 189 } 190 190 break; 191 default : 191 default : 192 192 App::logMsg('Encryption type not found.', LOG_ERR, __FILE__, __LINE__); 193 193 } … … 209 209 } 210 210 break; 211 default : 211 default : 212 212 App::logMsg('Encryption type not found.', LOG_ERR, __FILE__, __LINE__); 213 213 } -
trunk/lib/Auth_SQL.inc.php
r41 r42 8 8 9 9 // Available encryption types for class Auth_SQL. 10 define('AUTH_ENCRYPT_MD5', 'md5'); 11 define('AUTH_ENCRYPT_CRYPT', 'crypt'); 12 define('AUTH_ENCRYPT_SHA1', 'sha1'); 13 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext'); 10 define('AUTH_ENCRYPT_MD5', 'md5'); 11 define('AUTH_ENCRYPT_CRYPT', 'crypt'); 12 define('AUTH_ENCRYPT_SHA1', 'sha1'); 13 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext'); 14 14 15 15 class Auth_SQL { … … 22 22 // Default param values. 23 23 var $_default_params = array( 24 24 25 25 // Message displayed by requireLogin(). 26 26 'login_required_message' => 'Please login', 27 27 28 28 // Automatically create table and verify columns. Better set to false after site launch. 29 29 'create_table' => true, 30 30 31 31 // The database table containing users to authenticate. 32 32 'db_table' => 'user_tbl', 33 33 34 34 // The name of the primary key for the db_table. 35 35 'db_primary_key' => 'user_id', 36 36 37 37 // The name of the username key for the db_table. 38 38 'db_username_column' => 'username', 39 39 40 40 // If using the db_login_table feature, specify the db_login_table. The primary key must match the primary key for the db_table. 41 41 'db_login_table' => 'user_login_tbl', 42 42 43 43 // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above. 44 44 'encryption_type' => AUTH_ENCRYPT_MD5, … … 50 50 // This applies to admins and users. In seconds. 21600 seconds = 6 hours. 51 51 'login_timeout' => 21600, 52 52 53 53 // The maximum amount of time a user is allowed to be idle before their session expires. They will be forced to login again if they expire. 54 54 // This applies to admins and users. In seconds. 3600 seconds = 1 hour. … … 65 65 'login_abuse_max_ips' => 5, 66 66 67 // The IP address subnet size threshold. Uses a CIDR notation network mask (see CIDR cheatsheet at bottom). 68 // Any integar between 0 and 32 is permitted. Setting this to '24' permits any address in a 67 // The IP address subnet size threshold. Uses a CIDR notation network mask (see CIDR cheatsheet at bottom). 68 // Any integar between 0 and 32 is permitted. Setting this to '24' permits any address in a 69 69 // class C network (255.255.255.0) to be considered the same. Setting to '32' compares each IP absolutely. 70 70 // Setting to '0' ignores all IPs, thus disabling login_abuse checking. 71 71 'login_abuse_ip_bitmask' => 32, 72 72 73 // Specify usernames to exclude from the account abuse detection system. This is specified as a hardcoded array provided at 73 // Specify usernames to exclude from the account abuse detection system. This is specified as a hardcoded array provided at 74 74 // class instantiation time, or can be saved in the db_table under the login_abuse_exempt field. 75 75 'login_abuse_exempt_usernames' => array(), 76 76 77 77 // An array of IP blocks that are bypass the remote_addr comparison check. Useful for dynamic IPs or those behind proxy servers. 78 78 'trusted_networks' => array(), … … 80 80 // Allow user accounts to be blocked? Requires the user table to have the columns 'blocked' and 'blocked_reason' 81 81 'blocking' => false, 82 82 83 83 // Use a db_login_table to detect excessive logins. This requires blocking to be enabled. 84 84 'abuse_detection' => false, … … 106 106 } 107 107 } 108 108 109 109 /** 110 110 * Setup the database tables for this class. … … 117 117 { 118 118 static $_db_tested = false; 119 119 120 120 if ($recreate_db || !$_db_tested && $this->getParam('create_table')) { 121 121 122 122 // User table. 123 123 if ($recreate_db) { … … 154 154 155 155 if (!DB::columnExists($this->getParam('db_table'), array( 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 156 $this->getParam('db_primary_key'), 157 $this->getParam('db_username_column'), 158 'userpass', 159 'first_name', 160 'last_name', 161 'email', 162 'user_type', 163 'login_abuse_exempt', 164 'blocked', 165 'blocked_reason', 166 'abuse_warning_level', 167 'seconds_online', 168 'last_login_datetime', 169 'last_access_datetime', 170 'last_login_ip', 171 'added_by_user_id', 172 'modified_by_user_id', 173 'added_datetime', 174 'modified_datetime', 175 175 ), false, false)) { 176 176 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__); 177 177 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 178 178 } 179 179 180 180 // Login table is used for abuse_detection features. 181 181 if ($this->getParam('abuse_detection')) { … … 192 192 KEY remote_ip_binary (remote_ip_binary) 193 193 )"); 194 194 195 195 if (!DB::columnExists($this->getParam('db_login_table'), array( 196 196 $this->getParam('db_primary_key'), … … 202 202 } 203 203 } 204 } 204 } 205 205 $_db_tested = true; 206 206 } … … 239 239 } 240 240 } 241 241 242 242 /** 243 243 * Set the params of an auth object. … … 279 279 { 280 280 $this->initDB(); 281 281 282 282 DB::query(" 283 UPDATE " . $this->_params['db_table'] . " SET 283 UPDATE " . $this->_params['db_table'] . " SET 284 284 seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)), 285 285 last_login_datetime = '0000-00-00 00:00:00' … … 301 301 { 302 302 $this->initDB(); 303 303 304 304 // Query DB for user matching credentials. 305 305 $qid = DB::query(" 306 SELECT *, " . $this->_params['db_primary_key'] . " AS user_id 306 SELECT *, " . $this->_params['db_primary_key'] . " AS user_id 307 307 FROM " . $this->_params['db_table'] . " 308 308 WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "' 309 309 AND BINARY userpass = '" . addslashes($this->encryptPassword($password)) . "' 310 310 "); 311 311 312 312 // Return user data if found. 313 313 if ($user_data = mysql_fetch_assoc($qid)) { … … 331 331 { 332 332 $this->initDB(); 333 333 334 334 $this->clearAuth(); 335 335 … … 351 351 'user_data' => $user_data 352 352 ); 353 353 354 354 /** 355 355 * Check if the account is blocked, respond in context to reason. Cancel the login if blocked. … … 357 357 if ($this->getParam('blocking')) { 358 358 if (!empty($user_data['blocked'])) { 359 359 360 360 App::logMsg(sprintf('%s %s (%s) login failed due to blocked account: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__); 361 361 362 362 switch ($user_data['blocked_reason']) { 363 363 case 'account abuse' : … … 368 368 break; 369 369 } 370 370 371 371 // No login: user is blocked! 372 372 $this->clearAuth(); … … 374 374 } 375 375 } 376 376 377 377 /** 378 378 * Check the db_login_table for too many logins under this account. … … 412 412 DB::query(" 413 413 INSERT INTO " . $this->_params['db_login_table'] . " ( 414 " . $this->_params['db_primary_key'] . ", 415 login_datetime, 414 " . $this->_params['db_primary_key'] . ", 415 login_datetime, 416 416 remote_ip_binary 417 417 ) VALUES ( … … 422 422 "); 423 423 } 424 424 425 425 // Update user table with this login. 426 426 DB::query(" … … 431 431 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "' 432 432 "); 433 433 434 434 // We're logged-in! 435 435 return true; … … 449 449 { 450 450 $this->initDB(); 451 451 452 452 if (isset($user_id)) { 453 453 // Check the login status of a specific user. … … 465 465 return $_SESSION[$this->_sess]['authenticated']; 466 466 } 467 467 468 468 // Tesing login should occur once. This is the first time. Set flag. 469 469 $this->_authentication_tested = true; … … 472 472 if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) { 473 473 $user_in_trusted_network = true; 474 App::logMsg(sprintf('%s%s accessing from trusted network %s', 475 ucfirst($this->_auth), 474 App::logMsg(sprintf('%s%s accessing from trusted network %s', 475 ucfirst($this->_auth), 476 476 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' . $this->getVal('username') . ')' : ''), 477 477 $trusted_net … … 479 479 } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) { 480 480 $user_in_trusted_network = true; 481 App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com', 482 ucfirst($this->_auth), 481 App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com', 482 ucfirst($this->_auth), 483 483 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' . $this->getVal('username') . ')' : '') 484 484 ), LOG_INFO, __FILE__, __LINE__); … … 486 486 $user_in_trusted_network = false; 487 487 } 488 488 489 489 // Test login with information stored in session. Skip IP matching for users from trusted networks. 490 490 if (isset($_SESSION[$this->_sess]) … … 500 500 // Update the DB with the last_access_datetime and increment the seconds_online. 501 501 DB::query(" 502 UPDATE " . $this->_params['db_table'] . " SET 502 UPDATE " . $this->_params['db_table'] . " SET 503 503 seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1, 504 504 last_access_datetime = '" . $this->getVal('last_access_datetime') . "' … … 517 517 App::raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__); 518 518 } 519 519 520 520 // Log the reason for login expiration. 521 521 $expire_reasons = array(); … … 565 565 * This sets the 'blocked' field for a user in the db_table, and also 566 566 * adds an optional reason 567 * 567 * 568 568 * @param string $reason The reason for blocking the account. 569 569 */ … … 571 571 { 572 572 $this->initDB(); 573 573 574 574 if ($this->getParam('blocking')) { 575 575 if (strlen(addslashes($reason)) > 255) { … … 577 577 App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__); 578 578 } 579 579 580 580 // Get user_id if specified. 581 581 $user_id = isset($user_id) ? $user_id : $this->getVal('user_id'); … … 590 590 591 591 /** 592 * Unblocks a user in the db_table, and clears any blocked_reason. 592 * Unblocks a user in the db_table, and clears any blocked_reason. 593 593 */ 594 594 function unblockAccount($user_id=null) 595 595 { 596 596 $this->initDB(); 597 597 598 598 if ($this->getParam('blocking')) { 599 599 // Get user_id if specified. … … 615 615 */ 616 616 function usernameExists($username) 617 { 618 $this->initDB(); 619 617 { 618 $this->initDB(); 619 620 620 $qid = DB::query(" 621 SELECT 1 621 SELECT 1 622 622 FROM " . $this->_params['db_table'] . " 623 623 WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "' … … 633 633 */ 634 634 function getUsername($user_id) 635 { 636 $this->initDB(); 637 635 { 636 $this->initDB(); 637 638 638 $qid = DB::query(" 639 639 SELECT " . $this->_params['db_username_column'] . " … … 679 679 return $str; 680 680 } 681 681 682 682 /** 683 683 * … … 689 689 return $password; 690 690 break; 691 691 692 692 case AUTH_ENCRYPT_CRYPT : 693 693 return crypt($password, crypt($password)); 694 694 break; 695 695 696 696 case AUTH_ENCRYPT_SHA1 : 697 697 return sha1($password); 698 698 break; 699 699 700 700 case AUTH_ENCRYPT_MD5 : 701 701 default : … … 706 706 707 707 /** 708 * 708 * 709 709 */ 710 710 function setPassword($user_id=null, $password) 711 { 712 $this->initDB(); 713 711 { 712 $this->initDB(); 713 714 714 // Get user_id if specified. 715 715 $user_id = isset($user_id) ? $user_id : $this->getVal('user_id'); 716 716 717 717 // Issue the password change query. 718 718 DB::query(" 719 UPDATE " . $this->_params['db_table'] . " 719 UPDATE " . $this->_params['db_table'] . " 720 720 SET userpass = '" . addslashes($this->encryptPassword($password)) . "' 721 721 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "' … … 733 733 { 734 734 $this->initDB(); 735 735 736 736 // Get user_id if specified. 737 737 $user_id = isset($user_id) ? $user_id : $this->getVal('user_id'); 738 738 739 739 // Reset password of a specific user. 740 740 $qid = DB::query(" … … 746 746 return false; 747 747 } 748 748 749 749 // Make sure user has an email on record. 750 750 if (!isset($user_data['email']) || '' == trim($user_data['email'])) { … … 754 754 // Get new password. 755 755 $password = $this->generatePassword(); 756 756 757 757 // Update password query. 758 758 $this->setPassword($user_id, $password); … … 791 791 )); 792 792 $email->send(); 793 793 794 794 return array( 795 'username' => $user_data[$this->_params['db_username_column']], 795 'username' => $user_data[$this->_params['db_username_column']], 796 796 'userpass' => $password 797 797 ); 798 798 } 799 799 800 800 /** 801 801 * If the current user has access to the specified $security_zone, return true. 802 * If the optional $priv is supplied, test that against the zone. 802 * If the optional $priv is supplied, test that against the zone. 803 803 * 804 804 * @param constant $security_zone string of comma delimited priviliges for the zone … … 811 811 $zone_members = preg_split('/,\s*/', $security_zone); 812 812 $priv = empty($priv) ? $this->getVal('priv') : $priv; 813 814 // If the current user's privilege level is NOT in that array or if the 813 814 // If the current user's privilege level is NOT in that array or if the 815 815 // user has no privilege, return false. Otherwise the user is clear. 816 816 if (!in_array($priv, $zone_members) || empty($priv)) { … … 820 820 } 821 821 } 822 822 823 823 /** 824 824 * This function tests a list of arguments $security_zone against the priv that the current user has. 825 * If the user doesn't have one of the supplied privs, die. 825 * If the user doesn't have one of the supplied privs, die. 826 826 * 827 827 * @param constant $security_zone string of comma delimited priviliges for the zone … … 831 831 return true; 832 832 $zone_members = preg_split('/,\s*/', $security_zone); 833 834 /* If the current user's privilege level is NOT in that array or if the 833 834 /* If the current user's privilege level is NOT in that array or if the 835 835 * user has no privilege, DIE with a message. */ 836 836 if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) { … … 845 845 // CIDR cheatsheet 846 846 // 847 // Netmask Netmask (binary) CIDR Notes 847 // Netmask Netmask (binary) CIDR Notes 848 848 // _____________________________________________________________________________ 849 849 // 255.255.255.255 11111111.11111111.11111111.11111111 /32 Host (single addr) … … 856 856 // 255.255.255.128 11111111.11111111.11111111.10000000 /25 126 useable 857 857 // 255.255.255.0 11111111.11111111.11111111.00000000 /24 "Class C" 254 useable 858 // 858 // 859 859 // 255.255.254.0 11111111.11111111.11111110.00000000 /23 2 Class C's 860 860 // 255.255.252.0 11111111.11111111.11111100.00000000 /22 4 Class C's … … 865 865 // 255.255.128.0 11111111.11111111.10000000.00000000 /17 128 Class C's 866 866 // 255.255.0.0 11111111.11111111.00000000.00000000 /16 "Class B" 867 // 867 // 868 868 // 255.254.0.0 11111111.11111110.00000000.00000000 /15 2 Class B's 869 869 // 255.252.0.0 11111111.11111100.00000000.00000000 /14 4 Class B's … … 874 874 // 255.128.0.0 11111111.10000000.00000000.00000000 /9 128 Class B's 875 875 // 255.0.0.0 11111111.00000000.00000000.00000000 /8 "Class A" 876 // 876 // 877 877 // 254.0.0.0 11111110.00000000.00000000.00000000 /7 878 878 // 252.0.0.0 11111100.00000000.00000000.00000000 /6 -
trunk/lib/AuthorizeNet.inc.php
r41 r42 37 37 38 38 require_once dirname(__FILE__) . '/Utilities.inc.php'; 39 39 40 40 class AuthorizeNet 41 41 { … … 232 232 return ( 233 233 strtolower($this->getResult('x_md5_hash')) == strtolower(md5( 234 $this->md5_hash_value . 235 $this->getParam('x_login') . 236 $this->getResult('x_trans_id') . 234 $this->md5_hash_value . 235 $this->getParam('x_login') . 236 $this->getResult('x_trans_id') . 237 237 $this->getResult('x_amount') 238 238 )) -
trunk/lib/CSS.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * CSS.inc.css 3 * CSS.inc.css 4 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 5 * … … 13 13 // Include these style sheets. 14 14 var $_css_files = array('default' => array()); 15 15 16 16 // Cache style sheets? 17 17 var $_params = array( … … 19 19 'character_set' => 'utf-8', 20 20 ); 21 21 22 22 /** 23 23 * Set (or overwrite existing) parameters by passing an array of new parameters. … … 52 52 } 53 53 } 54 54 55 55 /** 56 56 * Add a file-path to the array of files to include as CSS. … … 64 64 { 65 65 if (!is_array($apps)) { 66 66 $apps = array($apps); 67 67 } 68 68 … … 103 103 sort($files_mtime, SORT_NUMERIC); 104 104 $latest_mtime = array_pop($files_mtime); 105 105 106 106 if ($this->_params['cache_css']) { 107 107 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $latest_mtime) . ' GMT'); … … 114 114 header('Content-Type: text/css; charset=' . $this->_params['character_set']); 115 115 } 116 116 117 117 /** 118 118 * Include CSS files specified by setFile(). … … 130 130 return false; 131 131 } 132 132 133 133 foreach ($this->_css_files[$app] as $file) { 134 134 include $file; 135 135 } 136 136 } 137 137 138 138 } 139 139 ?> -
trunk/lib/Captcha.inc.php
r41 r42 1 <?php 1 <?php 2 2 /** 3 3 * Captcha.inc.php … … 10 10 */ 11 11 class Captcha { 12 12 13 13 var $secret_key = 'some random seed text for the md5'; 14 14 var $ascii_numbers = array( … … 95 95 ) 96 96 ); 97 97 98 98 /** 99 99 * Print ASCII number. … … 109 109 if (preg_match('/[^\d]/', $num)) { 110 110 App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__); 111 111 return false; 112 112 } 113 113 114 114 // Number must be an array of strings. 115 115 $num = preg_split('// ', strval($num), -1, PREG_SPLIT_NO_EMPTY); … … 124 124 $output .= "\n"; 125 125 } 126 126 127 127 return $output; 128 128 } 129 129 130 130 /** 131 131 * Prints a form to enter captcha, including the required hidden hash form. … … 148 148 <?php 149 149 } 150 151 /** 152 * Validate submitted number against ascii captcha. 150 151 /** 152 * Validate submitted number against ascii captcha. 153 153 * Regenerate md5 hash from submitted captcha number and compare with posted hash. 154 154 * … … 164 164 165 165 if ('' == $number . $hash) { 166 166 return false; 167 167 } 168 168 … … 182 182 return rand(1000, 9999); 183 183 } 184 184 185 185 /** 186 186 * Generate md5 hash of number using secret key. … … 196 196 return md5($this->secret_key . $input); 197 197 } 198 198 199 199 } 200 200 -
trunk/lib/DB.inc.php
r41 r42 9 9 * @version 1.0.1 10 10 */ 11 11 12 12 class DB { 13 13 … … 35 35 'db_die_on_failure' => false, // TRUE = script stops on db error. 36 36 ); 37 37 38 38 // Translate between HTML and MySQL character set names. 39 39 var $mysql_character_sets = array( … … 41 41 'iso-8859-1' => 'latin1', 42 42 ); 43 43 44 44 // Caches. 45 45 var $existing_tables; 46 46 var $table_columns; 47 47 48 48 /** 49 49 * This method enforces the singleton pattern for this class. … … 63 63 return $instance; 64 64 } 65 65 66 66 /** 67 67 * Constructor. … … 119 119 } 120 120 } 121 121 122 122 /** 123 123 * Connect to database with credentials in params. … … 132 132 $this =& DB::getInstance(); 133 133 } 134 134 135 135 if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) { 136 136 App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); 137 137 return false; 138 138 } 139 139 140 140 // Connect to database. Always create a new link to the server. 141 if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) { 141 if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) { 142 142 // Select database 143 143 mysql_select_db($this->getParam('db_name'), $this->dbh); 144 144 } 145 145 146 146 // Test for connection errors. 147 147 if (!$this->dbh || mysql_error($this->dbh)) { … … 164 164 } 165 165 } 166 166 167 167 // DB connection success! 168 168 $this->_connected = true; … … 173 173 return true; 174 174 } 175 175 176 176 /** 177 177 * Close db connection. … … 186 186 $this =& DB::getInstance(); 187 187 } 188 189 if (!$this->_connected) { 190 return false; 191 } 192 193 mysql_close($this->dbh); 194 } 195 188 189 if (!$this->_connected) { 190 return false; 191 } 192 193 mysql_close($this->dbh); 194 } 195 196 196 /** 197 197 * Return the current database handler. … … 207 207 $this =& DB::getInstance(); 208 208 } 209 209 210 210 if (!$this->_connected) { 211 211 return false; … … 214 214 return $this->dbh; 215 215 } 216 216 217 217 /** 218 218 * Returns connection status … … 226 226 return $this->_connected; 227 227 } 228 228 229 229 /** 230 230 * A wrapper for mysql_query. Allows us to set the database link_identifier, … … 238 238 { 239 239 static $_query_count = 0; 240 241 if (!isset($this) || !is_a($this, 'DB')) { 242 $this =& DB::getInstance(); 243 } 244 240 241 if (!isset($this) || !is_a($this, 'DB')) { 242 $this =& DB::getInstance(); 243 } 244 245 245 if (!$this->_connected) { 246 246 return false; … … 252 252 echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n"; 253 253 } 254 254 255 255 // Execute! 256 256 $qid = mysql_query($query, $this->dbh); 257 257 258 258 // Error checking. 259 259 if (!$qid || mysql_error($this->dbh)) { … … 269 269 } 270 270 } 271 271 272 272 return $qid; 273 273 } 274 274 275 275 /** 276 * Loads a list of tables in the current database into an array, and returns 276 * Loads a list of tables in the current database into an array, and returns 277 277 * true if the requested table is found. Use this function to enable/disable 278 * funtionality based upon the current available db tables or to dynamically 278 * funtionality based upon the current available db tables or to dynamically 279 279 * create tables if missing. 280 280 * … … 284 284 */ 285 285 function tableExists($table, $use_cached_results=true) 286 { 287 if (!isset($this) || !is_a($this, 'DB')) { 288 $this =& DB::getInstance(); 289 } 290 286 { 287 if (!isset($this) || !is_a($this, 'DB')) { 288 $this =& DB::getInstance(); 289 } 290 291 291 if (!$this->_connected) { 292 292 return false; … … 307 307 } 308 308 } 309 309 310 310 /** 311 311 * Tests if the given array of columns exists in the specified table. … … 318 318 */ 319 319 function columnExists($table, $columns, $strict=true, $use_cached_results=true) 320 { 321 if (!isset($this) || !is_a($this, 'DB')) { 322 $this =& DB::getInstance(); 323 } 324 320 { 321 if (!isset($this) || !is_a($this, 'DB')) { 322 $this =& DB::getInstance(); 323 } 324 325 325 if (!$this->_connected) { 326 326 return false; … … 331 331 return false; 332 332 } 333 333 334 334 // For single-value columns. 335 335 if (!is_array($columns)) { 336 336 $columns = array($columns); 337 337 } 338 338 339 339 if (!isset($this->table_columns[$table]) || !$use_cached_results) { 340 340 // Populate and cache array of current columns for this table. … … 345 345 } 346 346 } 347 347 348 348 if ($strict) { 349 349 // Do an exact comparison of table schemas. … … 359 359 } 360 360 } 361 361 362 362 /** 363 363 * Reset cached items. … … 372 372 $this->table_columns = null; 373 373 } 374 374 375 375 } // End. 376 376 -
trunk/lib/DBSessionHandler.inc.php
r41 r42 9 9 10 10 class DBSessionHandler { 11 11 12 12 var $db; // DB object. 13 13 … … 20 20 'create_table' => true, // Automatically create table and verify columns. Better set to false after site launch. 21 21 ); 22 22 23 23 /** 24 24 * Constructor 25 25 * 26 26 * @access public 27 * @param 28 * @return 27 * @param 28 * @return 29 29 * @author Quinn Comendant <quinn@strangecode.com> 30 30 * @since 18 Jul 2005 11:02:50 … … 33 33 { 34 34 $this->_params = array_merge($this->_params, $params); 35 35 36 36 if (isset($db)) { 37 37 if (is_a($db, 'DB')) { 38 38 if ($db->isConnected()) { 39 39 // Use existing db connection. 40 40 $this->db =& $db; 41 41 } else { 42 42 App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__); 43 43 } 44 44 } else { 45 45 App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__); … … 48 48 // Create our own new db connection. 49 49 require_once dirname(__FILE__) . '/DB.inc.php'; 50 50 51 51 $this->db =& new DB(); 52 52 $this->db->setParam(array( … … 59 59 'db_die_on_failure' => $this->_params['db_die_on_failure'], 60 60 )); 61 61 62 62 // Connect to database. 63 63 $this->db->connect(); … … 67 67 trigger_error('Invalid DB object or unable to connect to database.', E_USER_ERROR); 68 68 } 69 69 70 70 // Get create tables config from global context. 71 71 if (!is_null(App::getParam('db_create_tables'))) { 72 72 $this->_params['create_table'] = App::getParam('db_create_tables'); 73 73 } 74 74 75 75 // Ensure db table is fit. 76 76 $this->initDB(); 77 77 78 78 ini_set('session.save_handler', 'user'); 79 79 session_set_save_handler( … … 97 97 { 98 98 static $_db_tested = false; 99 99 100 100 if ($recreate_db || !$_db_tested && $this->_params['create_table']) { 101 101 if ($recreate_db) { … … 110 110 KEY last_access (last_access) 111 111 )"); 112 112 113 113 if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) { 114 114 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__); 115 115 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR); 116 116 } 117 } 117 } 118 118 $_db_tested = true; 119 119 } … … 121 121 function dbSessionOpen($save_path, $sess_name) 122 122 { 123 return true; 123 return true; 124 124 } 125 125 126 126 function dbSessionClose() 127 127 { 128 128 return true; 129 129 } 130 130 131 131 function dbSessionRead($session_id) 132 132 { 133 // Select the data belonging to session $session_id from the session table 133 // Select the data belonging to session $session_id from the session table 134 134 $qid = $this->db->query("SELECT session_data FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'"); 135 135 136 136 // Return the session data that was found 137 137 if (mysql_num_rows($qid) == 1) { … … 139 139 return $row[0]; 140 140 } 141 141 142 142 // NOTICE: Output is expected to be an empty string always rather than 'false'. 143 143 return ''; 144 144 } 145 145 146 146 function dbSessionWrite($session_id, $session_data) 147 { 147 { 148 148 // Write the serialized session data ($session_data) to the session table 149 149 $this->db->query("REPLACE INTO " . $this->_params['db_table'] . "(session_id, session_data, last_access) VALUES ('" . addslashes($session_id) . "', '" . addslashes($session_data) . "', null)"); 150 151 return true; 150 151 return true; 152 152 } 153 153 154 154 function dbSessionDestroy($session_id) 155 155 { 156 156 // Delete from the table all data for the session $session_id 157 157 $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'"); 158 159 return true; 158 159 return true; 160 160 } 161 161 162 162 function dbSessionGarbage($max_lifetime=4000) 163 163 { 164 164 // Delete old values from the session table 165 165 $qid = $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE UNIX_TIMESTAMP(last_access) < " . (time() - $max_lifetime)); 166 167 return true; 166 167 return true; 168 168 } 169 169 } -
trunk/lib/Email.inc.php
r41 r42 40 40 'regex' => null 41 41 ); 42 42 43 43 // String that contains the email body. 44 44 var $_template; 45 45 46 46 // String that contains the email body after replacements. 47 47 var $_template_replaced; … … 58 58 { 59 59 // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatination . dot. 60 // This matches an email address as complex as: 60 // This matches an email address as complex as: 61 61 // Bob Smith <bob&smith's/dep=sales!@smith-wick.ca.us> (Sales department) 62 62 // ...and something as simple as: 63 63 // x@x.com 64 64 $this->setParam(array('regex' => '/^(?:[^,@]*\s+|[^,@]*(<)|)' // Display name 65 . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)' // Local-part 65 . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)' // Local-part 66 66 . '@' // @ 67 67 . '((?:(\[)|[A-Z0-9]?)' // Domain, first char … … 165 165 } 166 166 } 167 167 168 168 /** 169 169 * Replace variables in template with argument data. … … 179 179 if (!isset($this->_template)) { 180 180 App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__); 181 182 } 183 181 return false; 182 } 183 184 184 // Ensure replacements argument is an array. 185 185 if (!is_array($replacements)) { 186 186 App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__); 187 188 } 189 187 return false; 188 } 189 190 190 // Apply regex pattern to search elements. 191 191 $search = array_keys($replacements); … … 194 194 // Replacement values. 195 195 $replace = array_values($replacements); 196 196 197 197 // Search and replace all values at once. 198 198 $this->_template_replaced = preg_replace($search, $replace, $this->_template); … … 213 213 // Use arguments if provided. 214 214 if (isset($to)) { 215 215 $this->setParam(array('to' => $to)); 216 216 } 217 217 if (isset($from)) { 218 218 $this->setParam(array('from' => $from)); 219 219 } 220 220 if (isset($subject)) { 221 221 $this->setParam(array('subject' => $subject)); 222 222 } 223 223 if (isset($headers)) { 224 224 $this->setParam(array('headers' => $headers)); 225 225 } 226 226 227 227 // Ensure required values exist. 228 228 if (!isset($this->_template)) { 229 229 App::logMsg(sprintf('Cannot send email. Template not set.', null), LOG_ERR, __FILE__, __LINE__); 230 230 return false; 231 231 } else if (!isset($this->_params['to'])) { 232 232 App::logMsg(sprintf('Cannot send email. TO not defined.', null), LOG_ERR, __FILE__, __LINE__); 233 233 return false; 234 234 } else if (!isset($this->_params['from'])) { 235 235 App::logMsg(sprintf('Cannot send email. FROM not defined.', null), LOG_ERR, __FILE__, __LINE__); 236 236 return false; 237 237 } else if (!isset($this->_params['subject'])) { 238 238 App::logMsg(sprintf('Cannot send email. SUBJECT not defined.', null), LOG_ERR, __FILE__, __LINE__); 239 239 return false; 240 240 } … … 245 245 // Ensure all placeholders have been replaced. Find anything with {...} characters. 246 246 if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) { 247 248 return false; 249 } 250 247 App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__); 248 return false; 249 } 250 251 251 // Final "to" header can have multiple addresses if in an array. 252 252 $final_to = is_array($this->_params['to']) ? join(', ', $this->_params['to']) : $this->_params['to']; 253 253 254 254 // From headers are custom headers. 255 255 $headers = array('From' => $this->_params['from']); … … 259 259 $headers = array_merge($this->_params['headers'], $headers); 260 260 } 261 261 262 262 // Process headers. 263 263 $final_headers = array(); … … 266 266 } 267 267 $final_headers = join("\r\n", $final_headers); 268 268 269 269 // This is the address where delivery problems are sent to. We must strip off everything except the local@domain part. 270 270 $envelope_sender_header = sprintf('-f %s', preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU', '$1', $this->_params['from'])); 271 271 272 272 // Check for mail header injection attacks. 273 273 $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header)); 274 274 if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) { 275 276 275 App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__); 276 sleep(3); 277 277 return false; 278 278 } … … 283 283 return false; 284 284 } 285 285 286 286 return true; 287 287 } 288 288 289 289 /** 290 290 * Validates an email address based on the recommendations in RFC 3696. 291 * Is more loose than restrictive, to allow the many valid variants of 291 * Is more loose than restrictive, to allow the many valid variants of 292 292 * email addresses while catching the most common mistakes. Checks an array too. 293 293 * http://www.faqs.org/rfcs/rfc822.html -
trunk/lib/FormValidator.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * FormValidator.inc.php 3 * FormValidator.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 * … … 25 25 class FormValidator 26 26 { 27 27 28 28 /** 29 29 * Array filling with errors. The key will be the name of the form where … … 31 31 */ 32 32 var $errors = array(); 33 33 34 34 /** 35 35 * Return the current list of errors. … … 43 43 return $this->errors; 44 44 } 45 45 46 46 /** 47 47 * Add an error to the errors stack. … … 64 64 ); 65 65 } 66 66 67 67 /** 68 68 * Check whether any errors have been triggered. … … 70 70 * @param string $form_name the name of the incoming form variable 71 71 * 72 * @return bool true if any errors were found, or if found for 72 * @return bool true if any errors were found, or if found for 73 73 * a variable of $form_name, false otherwise 74 74 */ … … 78 78 foreach ($this->errors as $err) { 79 79 if ($err['name'] == $form_name) { 80 return true; 80 return true; 81 81 } 82 82 } … … 115 115 echo '<div class="error">' . $err['message'] . '</div>'; 116 116 break; 117 117 118 118 case MSG_WARNING: 119 119 echo '<div class="warning">' . $err['message'] . '</div>'; 120 120 break; 121 121 122 122 case MSG_SUCCESS: 123 123 echo '<div class="success">' . $err['message'] . '</div>'; 124 124 break; 125 125 126 126 case MSG_NOTICE: 127 127 default: … … 134 134 } 135 135 } 136 136 137 137 /** 138 138 * If this form has an error, print an error marker like "<<". … … 164 164 function notEmpty($form_name, $msg='') 165 165 { 166 166 167 167 $val = trim(getFormData($form_name)); 168 168 if ($val != '') { … … 184 184 function isEmpty($form_name, $msg='') 185 185 { 186 186 187 187 $val = trim(getFormData($form_name)); 188 188 if ($val == '') { … … 255 255 /** 256 256 * Check whether input is a float. Don't just use is_float() because the 257 * data coming from the user is *really* a string. Integers will also 257 * data coming from the user is *really* a string. Integers will also 258 258 * pass this test. 259 259 * … … 293 293 } 294 294 } 295 295 296 296 /** 297 297 * Check whether input matches the specified perl regular expression 298 * pattern. 298 * pattern. 299 299 * 300 300 * @param string $form_name the name of the incoming form variable … … 325 325 } 326 326 } 327 327 328 328 /** 329 329 * Tests if the string length is between specified values. Whitespace excluded for min. … … 339 339 { 340 340 $val = getFormData($form_name); 341 341 342 342 if (strlen(trim($val)) < $min || strlen($val) > $max) { 343 343 $this->addError($form_name, $msg); … … 375 375 /** 376 376 * Validates an email address based on the recommendations in RFC 3696. 377 * Is more loose than restrictive, to allow the many valid variants of 377 * Is more loose than restrictive, to allow the many valid variants of 378 378 * email addresses while catching the most common mistakes. 379 379 * http://www.faqs.org/rfcs/rfc822.html … … 403 403 return false; 404 404 } 405 405 406 406 // We have a match! Here are the captured subpatterns, on which further tests are run. 407 407 $local = $e_parts[2]; … … 415 415 return false; 416 416 } 417 417 418 418 // Check domain exists: It's a domain if ip2long fails; Checkdnsrr ensures a MX record exists; Gethostbyname() ensures the domain exists. 419 419 if (ip2long($domain) == '-1' && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) { … … 422 422 return false; 423 423 } 424 424 425 425 return true; 426 426 } … … 431 431 // return false; 432 432 // } 433 // 433 // 434 434 // // Test email address format. 435 435 // if ($allow_fullname) { … … 444 444 // } 445 445 // } 446 // 446 // 447 447 // // Test length. 448 448 // if (!$this->stringLength($form_name, 0, 255, sprintf(_("<strong>Email address</strong> must contain less than 256 characters."), $email))) { … … 450 450 // return false; 451 451 // } 452 // 452 // 453 453 // // Check domain exists and has valid MX record. 454 454 // preg_match('/^[^<>@]*<?[^\s@\[\]<>()]+\@([A-Za-z0-9.-]+\.[A-Za-z]{2,5})>?$/i', $email, $matches); … … 460 460 // } 461 461 // } 462 // 462 // 463 463 // return true; 464 464 // } … … 476 476 { 477 477 $phone = getFormData($form_name); 478 478 479 479 return $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <strong>%s</strong> is not valid."), $phone)) 480 480 && $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <strong>%s</strong> is too long"), $phone)); … … 499 499 } 500 500 } 501 502 501 502 503 503 /** 504 504 * Verifies credit card number. … … 515 515 $cc_num = getFormData($form_name); 516 516 } 517 517 518 518 if ('' == $cc_num) { 519 519 return false; 520 520 } 521 521 522 522 // Innocent until proven guilty 523 523 $card_is_valid = true; 524 524 525 525 // Get rid of any non-digits 526 526 $cc_num = preg_replace('/[^\d]/', '', $cc_num); 527 527 528 528 // Perform card-specific checks, if applicable 529 529 switch (strtolower($cc_type)) { … … 558 558 break; 559 559 } 560 560 561 561 // The Luhn formula works right to left, so reverse the number. 562 562 $cc_num = strrev($cc_num); 563 563 564 564 $luhn_total = 0; 565 565 … … 573 573 $digit *= 2; 574 574 } 575 575 576 576 // If the result is two digits, add them. 577 577 if (strlen($digit) == 2) { 578 578 $digit = substr($digit,0,1) + substr($digit,1,1); 579 579 } 580 580 581 581 // Add the current digit to the $luhn_total. 582 582 $luhn_total += $digit; 583 583 } 584 584 585 585 // If it passed (or bypassed) the card-specific check and the Total is evenly divisible by 10, it's cool! 586 586 if ($card_is_valid && $luhn_total % 10 == 0) { … … 609 609 } 610 610 } 611 611 612 612 } // THE END 613 613 -
trunk/lib/Google_API.inc.php
r41 r42 9 9 10 10 // Example of use: 11 // 11 // 12 12 // require_once 'Google_API.php'; 13 13 // $google = new Google_API('your license key'); … … 40 40 */ 41 41 var $_licenseKey = ''; 42 42 43 43 /** 44 44 * @var object … … 46 46 */ 47 47 var $_soapClient = NULL; 48 48 49 49 /** 50 50 * Constructor. … … 60 60 ); 61 61 } 62 62 63 63 /** 64 64 * Retrieves a page by URL from the Google Cache. … … 82 82 return $result; 83 83 } 84 84 85 85 /** 86 86 * Retrieves a spelling suggestion for a phrase. … … 100 100 ); 101 101 } 102 102 103 103 /** 104 104 * Performs a web search. … … 129 129 ); 130 130 } 131 131 132 132 /** 133 133 * @param string … … 149 149 } 150 150 } 151 151 152 152 /** 153 153 * getFault … … 155 155 * returns a simple native php array containing the fault data 156 156 * 157 * @return array 157 * @return array 158 158 * @access public 159 159 */ -
trunk/lib/ImageThumb.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * ImageThumb.inc.php 3 * ImageThumb.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 20 20 21 21 class ImageThumb { 22 22 23 23 // The location for images to create thumbnails from. 24 24 var $source_dir = null; 25 25 26 26 // Specifications for thumbnail images. 27 var $spec; 28 27 var $spec; 28 29 29 // Array of acceptable file extensions (lowercase). 30 30 var $valid_file_extensions = array('jpg', 'jpeg', 'gif', 'png'); 31 32 // The uploaded files will be owned by user 'apache'. Set world-read/write 31 32 // The uploaded files will be owned by user 'apache'. Set world-read/write 33 33 // if the website admin needs to read/delete these files. Must be at least 0400 with owner=apache. 34 34 var $dest_file_perms = 0644; 35 35 36 36 // Must be at least 0700 with owner=apache. 37 37 var $dest_dir_perms = 0777; … … 42 42 var $cjpeg_binary = '/usr/bin/cjpeg'; 43 43 var $_valid_binaries = true; 44 44 45 45 // Display messages raised in this object? 46 46 var $display_messages = true; … … 76 76 function setSourceDirectory($source_dir) 77 77 { 78 78 79 79 // Set the source directory path, stripping any extra slashes if needed. 80 80 $this->source_dir = preg_replace('!/+$!', '', $source_dir); 81 81 82 82 if (!is_dir($this->source_dir)) { 83 83 App::logMsg(sprintf('ImageThumb error: source directory not found: %s', $this->source_dir), LOG_ERR, __FILE__, __LINE__); … … 108 108 $allow_upscaling = isset($spec['allow_upscaling']) ? $spec['allow_upscaling'] : false; 109 109 $keep_filesize = isset($spec['keep_filesize']) ? $spec['keep_filesize'] : null; 110 110 111 111 // Define pnmscale arguments. 112 112 switch ($scaling_type) { … … 144 144 break; 145 145 } 146 146 147 147 // Define cjpeg arguments. 148 148 $cjpeg_args = sprintf(' -optimize -quality %s ', escapeshellcmd($quality)); 149 149 $cjpeg_args .= (true === $progressive) ? ' -progressive ' : ''; 150 150 151 151 $this->spec[] = array( 152 152 'dest_dir' => $dest_dir, … … 185 185 } 186 186 } 187 187 188 188 // If > 0, there was a problem creating dest dirs. 189 189 return (0 == $return_val); … … 203 203 return false; 204 204 } 205 205 206 206 // Ensure we have a source. 207 207 if (!isset($this->source_dir)) { … … 209 209 return false; 210 210 } 211 211 212 212 // To keep this script running even if user tries to stop browser. 213 ignore_user_abort(true); 214 if (!ini_get('safe_mode')) { 215 set_time_limit(300); 216 } 217 213 ignore_user_abort(true); 214 if (!ini_get('safe_mode')) { 215 set_time_limit(300); 216 } 217 218 218 // Confirm source image exists. 219 219 if (!file_exists($this->source_dir . '/' . $file_name)) { … … 222 222 return false; 223 223 } 224 224 225 225 // Confirm source image is readable. 226 226 if (!is_readable($this->source_dir . '/' . $file_name)) { … … 229 229 return false; 230 230 } 231 231 232 232 // Confirm source image contains data. 233 233 if (filesize($this->source_dir . '/' . $file_name) < 1) { … … 236 236 return false; 237 237 } 238 238 239 239 // Confirm source image has a valid file extension. 240 240 if (!$this->validFileExtension($file_name)) { … … 243 243 return false; 244 244 } 245 245 246 246 // Output file will be a jpg. Set file extension. 247 247 $file_name = substr($file_name, 0, strrpos($file_name, '.')) . '.jpg'; … … 249 249 // This remains zero until something goes wrong. 250 250 $final_return_val = 0; 251 251 252 252 foreach ($this->spec as $s) { 253 253 254 254 // Skip existing thumbnails with file size below $s['keep_filesize']. 255 255 if (file_exists(realpath($this->source_dir . '/' . $s['dest_dir'] . '/' . $file_name)) && isset($s['keep_filesize'])) { … … 260 260 } 261 261 } 262 262 263 263 // Determine if original file size is smaller than specified thumbnail size. Do not scale-up if allow_upscaling config is set to false. 264 264 $image_size = getimagesize(realpath($this->source_dir . '/' . $file_name)); … … 269 269 $pnmscale_args = $s['pnmscale_args']; 270 270 } 271 271 272 272 // Execute the command that creates the thumbnail. 273 273 $command = sprintf('%s %s/%s | %s %s | %s %s > %s/%s', … … 278 278 escapeshellcmd($pnmscale_args), 279 279 escapeshellcmd($this->cjpeg_binary), 280 escapeshellcmd($s['cjpeg_args']), 280 escapeshellcmd($s['cjpeg_args']), 281 281 escapeshellcmd(realpath($this->source_dir . '/' . $s['dest_dir'])), 282 282 escapeshellcmd($file_name) … … 292 292 App::logMsg(sprintf('Image %s failed resizing with return value: %s%s', $s['dest_dir'] . '/' . $file_name, $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__); 293 293 } 294 294 295 295 // Return from the command will be > 0 if there was an error. 296 296 $final_return_val += $return_val; 297 297 } 298 298 299 299 // If > 0, there was a problem thumbnailing. 300 300 return (0 == $final_return_val); … … 314 314 return false; 315 315 } 316 316 317 317 // Get all files in source directory. 318 318 $dir_handle = opendir($this->source_dir); … … 323 323 } 324 324 } 325 325 326 326 // Process each found file. 327 327 if (is_array($files) && !empty($files)) { … … 350 350 return false; 351 351 } 352 352 353 353 $ret = 0; 354 354 foreach ($this->spec as $s) { … … 379 379 return false; 380 380 } 381 381 382 382 $file_path_name = $this->source_dir . '/' . $file_name; 383 383 if (!unlink($file_path_name)) { … … 388 388 return true; 389 389 } 390 390 391 391 /** 392 392 * Returns true if file exists. … … 403 403 return false; 404 404 } 405 405 406 406 return file_exists($this->source_dir . '/' . $file_name); 407 407 } 408 408 409 409 /** 410 410 * Tests if extention of $file_name is in the array valid_file_extensions. … … 419 419 return in_array(strtolower($ext[1]), $this->valid_file_extensions); 420 420 } 421 421 422 422 /** 423 423 * An alias for App::raiseMsg that only sends messages if display_messages is true. -
trunk/lib/MCVE.inc.php
r41 r42 19 19 var $connected = false; 20 20 var $conn; 21 21 22 22 function MCVE($username, $password) 23 23 { … … 28 28 } 29 29 if ('' == $username || '' == $password) { 30 30 App::logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__); 31 31 } 32 32 $this->username = $username; … … 39 39 return true; 40 40 } 41 41 42 42 // Initialize SSL structures and definitions. 43 43 MCVE_InitEngine($ca_bundle_file); 44 44 45 45 // Allocate Connection Structures 46 46 $this->conn = MCVE_InitConn(); 47 47 48 48 // Set Connection Method and Locations 49 49 switch ($this->connect_method) { … … 69 69 App::logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__); 70 70 } 71 71 72 72 // Put connection into non-blocking mode, meaning that the client must 73 73 // loop waiting for the transaction to complete. You should always specify … … 78 78 return false; 79 79 } 80 80 81 81 // Maximum of 30s per transaction allowed. Timeout occurs on server-end, not client-end 82 82 if (!MCVE_SetTimeout($this->conn, $this->timeout)) { … … 84 84 return false; 85 85 } 86 86 87 87 // Connect to MCVE, if there's an error, print the exact reason for connection failure 88 88 if (!MCVE_Connect($this->conn)) { … … 91 91 return false; 92 92 } 93 93 94 94 $this->connected = true; 95 95 } 96 96 97 97 function beginTrans() 98 98 { … … 103 103 return $tid; 104 104 } 105 105 106 106 function transParam($tid, $key, $var1, $var2=null) 107 107 { … … 111 111 return MCVE_TransParam($this->conn, $tid, $key, $var1, $var2); 112 112 } 113 113 114 114 } 115 115 116 116 function sendTrans($tid, $type='', $hide_msg=false) 117 117 { … … 121 121 return false; 122 122 } 123 124 // Perform actual communication with MCVE engine. 123 124 // Perform actual communication with MCVE engine. 125 125 // If blocking method is used, loop until transaction is complete 126 126 if ($this->blocking != 1) { … … 130 130 } 131 131 } 132 132 133 133 $ret_status = MCVE_ReturnStatus($this->conn, $tid); 134 134 $ret_code = MCVE_ReturnCode($this->conn, $tid); 135 135 $ret_text = mcve_text_code($ret_code); 136 136 $verbiage = MCVE_TransactionText($this->conn, $tid); 137 137 138 138 // Check to see if transaction was successful or not using a strict success/fail function 139 139 if ($ret_status == MCVE_FAIL) { … … 144 144 App::raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__); 145 145 } 146 App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."), 146 App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."), 147 147 MCVE_TransactionAuth($this->conn, $tid), 148 148 MCVE_TransactionBatch($this->conn, $tid), … … 158 158 } 159 159 } 160 160 161 161 function disconnect($tid) 162 162 { … … 165 165 // MCVE_DestroyConn though 166 166 MCVE_DeleteTrans($this->conn, $tid); 167 167 168 168 // Clean up and close MCVE. 169 169 MCVE_DestroyConn($this->conn); 170 170 MCVE_DestroyEngine(); 171 171 172 172 $this->connected = false; 173 173 } -
trunk/lib/Nav.inc.php
r41 r42 3 3 * The Nav:: class provides a system for working with navigation elements. 4 4 * Currently it supports storing page titles and URLs for printing breadcrumbs 5 * and titles, as well as setting page features such as hiding the page title on 5 * and titles, as well as setting page features such as hiding the page title on 6 6 * some pages but not others. 7 7 * … … 60 60 ); 61 61 } 62 62 63 63 /** 64 64 * Set the features of the current page. Future versions of this class … … 73 73 { 74 74 $page_id = $this->_calculatePageID($page_id); 75 75 76 76 if (isset($features) && is_array($features) && isset($this->pages[sizeof($this->pages)-1]['features']) && is_array($this->pages[sizeof($this->pages)-1]['features'])) { 77 77 // Set features for specified page. … … 96 96 * OUTPUT 97 97 *****************************************************************************/ 98 98 99 99 /** 100 100 * Get the value of a feature for specified page_id or current page if page_id not specified (future use). … … 108 108 { 109 109 $page_id = $this->_calculatePageID($page_id); 110 110 111 111 if (isset($this->pages[$page_id]['features'][$feature])) { 112 112 switch ($feature) { … … 123 123 } 124 124 125 125 126 126 /** 127 127 * Returns the title of current page. … … 134 134 { 135 135 $page_id = $this->_calculatePageID($page_id); 136 136 137 137 if ($this->getFeature('title', $page_id)) { 138 138 return oTxt($this->pages[$page_id]['title'], true); … … 163 163 { 164 164 $page_id = $this->_calculatePageID($page_id); 165 165 166 166 if ($this->getFeature('path', $page_id)) { 167 167 $path = ''; … … 202 202 { 203 203 $page_id = $this->_calculatePageID($page_id); 204 204 205 205 if ($this->getFeature('breadcrumbs')) { 206 206 $breadcrumbs = ''; … … 232 232 $pathmark = $this->path_delimiter; 233 233 $crumb_count--; 234 234 235 235 if ($curr_id === $page_id) { 236 236 // Reached requested page. … … 253 253 echo $this->getBreadcrumbs($page_id); 254 254 } 255 255 256 256 /** 257 257 * Returns a string if the queried page is the current page. One use is to print … … 272 272 } 273 273 } 274 274 275 275 /** 276 276 * Returns the ID of the current page, or the adjusted ID for a given page ID. … … 289 289 } 290 290 } 291 292 } 291 292 } 293 293 // End of class. 294 294 -
trunk/lib/NodeHeirarchy.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * NodeHeirarchy.inc.php 3 * NodeHeirarchy.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 23 23 * @version 1.0 24 24 */ 25 25 26 26 class NodeHeirarchy { 27 27 … … 50 50 51 51 /** 52 * Boolean indicating whether or not we've set 52 * Boolean indicating whether or not we've set 53 53 * the 'active' node type and id. 54 54 * @var bool $node_init 55 55 */ 56 56 var $node_init = false; 57 57 58 58 /** 59 59 * Constructor … … 66 66 $this->params = $params; 67 67 } 68 68 69 69 /** 70 70 * Defines the default child_type and child_id for this object. … … 85 85 return $this->toStringID($old_type, $old_id); 86 86 } 87 87 88 88 /** 89 89 * Takes a node type and id and returns them as a serialized identifier like … … 121 121 } 122 122 } 123 123 124 124 /** 125 125 * Takes a singlar node identifier and returns it as components of an array. … … 156 156 } 157 157 } 158 158 159 159 // Make sure this is not empty and an array, even if it has only one value. 160 160 if ('' == $parents) { … … 165 165 $parents = array($parents); 166 166 } 167 167 168 168 // Remove duplicates. 169 169 $parents = array_unique($parents); 170 170 171 171 // Test that this node does not already exist and that the new parents 172 172 // do exist before we continue. … … 182 182 App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__); 183 183 return false; 184 } 185 } 186 184 } 185 } 186 187 187 // Insert new nodes with the new parents. 188 188 foreach ($parents as $parent_string) { … … 190 190 DB::query(" 191 191 INSERT INTO node_tbl ( 192 parent_type, 193 parent_id, 194 child_type, 195 child_id, 192 parent_type, 193 parent_id, 194 child_type, 195 child_id, 196 196 relationship_type, 197 197 title 198 198 ) VALUES ( 199 '" . addslashes($parent['node_type']) . "', 200 '" . addslashes($parent['node_id']) . "', 201 '" . addslashes($child_type) . "', 202 '" . addslashes($child_id) . "', 199 '" . addslashes($parent['node_type']) . "', 200 '" . addslashes($parent['node_id']) . "', 201 '" . addslashes($child_type) . "', 202 '" . addslashes($child_id) . "', 203 203 " . (is_null($relationship_type) ? "NULL" : "'" . addslashes($relationship_type) . "'") . ", 204 204 '" . addslashes($title) . "' … … 267 267 * 268 268 * @return bool false on error, true otherwise. 269 */ 269 */ 270 270 function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='') 271 271 { … … 279 279 } 280 280 } 281 281 282 282 // Make sure this is not empty and an array, even if it has only one value. 283 283 if (empty($new_parents)) { … … 288 288 $new_parents = array($new_parents); 289 289 } 290 290 291 291 // Remove duplicates. 292 292 $new_parents = array_unique($new_parents); … … 299 299 App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__); 300 300 return false; 301 } 301 } 302 302 if ($this->isAncestor($child_type, $child_id, $parent['node_type'], $parent['node_id'])) { 303 303 App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__); 304 304 App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__); 305 305 return false; 306 } 307 } 308 306 } 307 } 308 309 309 if (empty($title)) { 310 310 // Select the title of the node we are moving, so we can add it again with the same info. … … 317 317 list($title) = mysql_fetch_row($qid); 318 318 } 319 319 320 320 // Delete the nodes with the old parents. 321 321 DB::query(" … … 326 326 "); 327 327 App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__); 328 328 329 329 // Insert new nodes with the new parents. 330 330 $this->insertNode($new_parents, $child_type, $child_id, $relationship_type, $title); 331 331 332 332 return true; 333 333 } … … 356 356 $qid = DB::query(" 357 357 SELECT parent_type, parent_id 358 FROM node_tbl 358 FROM node_tbl 359 359 WHERE child_type = '" . addslashes($child_type) . "' 360 AND child_id = '" . addslashes($child_id) . "' 360 AND child_id = '" . addslashes($child_id) . "' 361 361 "); 362 362 363 363 $parents = array(); 364 364 while ($row = mysql_fetch_assoc($qid)) { … … 391 391 } 392 392 } 393 393 394 394 $qid = DB::query(" 395 395 SELECT child_type, child_id, title, subnode_quantity 396 FROM node_tbl 396 FROM node_tbl 397 397 WHERE child_type = '" . addslashes($child_type) . "' 398 398 AND child_id = '" . addslashes($child_id) . "' 399 399 "); 400 400 401 401 $children = array(); 402 402 while ($row = mysql_fetch_assoc($qid)) { … … 432 432 } 433 433 } 434 434 435 435 $in_clause = ''; 436 436 if (isset($type_constraint)) { … … 440 440 $in_clause = "AND child_type IN ('" . join("','", array_map('addslashes', $type_constraint)) . "')"; 441 441 } 442 442 443 443 $qid = DB::query(" 444 444 SELECT * 445 FROM node_tbl 445 FROM node_tbl 446 446 WHERE parent_type = '" . addslashes($child_type) . "' 447 447 AND parent_id = '" . addslashes($child_id) . "' … … 449 449 " . addslashes($order) . " 450 450 "); 451 451 452 452 $children = array(); 453 453 while ($row = mysql_fetch_assoc($qid)) { … … 464 464 * Give the number of children a category has. We are talking about the 465 465 * direct children, on the next level. 466 * 466 * 467 467 * @param string optional $parent The name of the parent from where we begin. 468 468 * @param string $type_constraint An array of node types to restrict the search to. … … 481 481 } 482 482 } 483 483 484 484 $in_clause = ''; 485 485 if (isset($type_constraint)) { … … 492 492 $qid = DB::query(" 493 493 SELECT COUNT(*) 494 FROM node_tbl 494 FROM node_tbl 495 495 WHERE parent_type = '" . addslashes($child_type) . "' 496 496 AND parent_id = '" . addslashes($child_id) . "' … … 519 519 } 520 520 } 521 521 522 522 if ($this->getNumberChildren($child_type, $child_id) <= 0) { 523 523 return true; … … 544 544 $family_tree = $this->getAllAncestors($considered_parent_type, $considered_parent_id); 545 545 $family_tree = $this->toStringID($family_tree, -1); 546 546 547 547 if (in_array($this->toStringID($child_type, $child_id), $family_tree)) { 548 548 return true; … … 571 571 static $output = array(); 572 572 static $return_flag; 573 573 574 574 $qid = DB::query(" 575 575 SELECT parent_type, parent_id, child_type, child_id, title, subnode_quantity … … 583 583 continue; 584 584 } 585 585 586 586 // Build a linear path to root...no wormholes. 587 587 if ($enough_already && $go_linear) { … … 589 589 } 590 590 $enough_already = true; 591 591 592 592 // To prevent duplicates, only add the new found node 593 593 // if not already in the array of ancestors. … … 596 596 $output[] = $row; 597 597 } 598 598 599 599 $this->getAllAncestors($row['parent_type'], $row['parent_id'], $go_linear, false); 600 600 } … … 630 630 } 631 631 } 632 632 633 633 if (isset($parent_type) && isset($parent_id)) { 634 634 $qid = DB::query(" … … 665 665 * @param string $order SQL to append to the query of the getChildren 666 666 * call. Ex: 'ORDER BY child_id DESC' 667 * @return array Details of from the node table of all nodes below the 667 * @return array Details of from the node table of all nodes below the 668 668 * specified node: (type, id, title, indent level, selected status) 669 669 */ … … 672 672 static $output = array(); 673 673 static $is_a_leaf = array(); 674 674 675 675 if (!isset($child_type) || !isset($child_id)) { 676 676 if ($this->node_init) { … … 682 682 } 683 683 } 684 684 685 685 if (!is_array($preselected)) { 686 686 $preselected = array($preselected); 687 687 } 688 688 689 689 if ($_return_flag && $include_curr) { 690 690 $my_children = $this->getNode($child_type, $child_id); … … 709 709 $output[] = $row; 710 710 unset($row); 711 711 712 712 // This is so we test if each node is a string only once. We store the result in the is_a_leaf array statically. 713 713 if (!isset($is_a_leaf[$this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])])) { … … 731 731 732 732 } 733 734 733 734 735 735 /** 736 736 * Counts the number of items linked to each parent node … … 744 744 // Reset all the category counters to zero. 745 745 DB::query("UPDATE node_tbl SET subnode_quantity = 0"); 746 746 747 747 // Get all the nodes. 748 748 $qid = DB::query("SELECT DISTINCT child_type, child_id FROM node_tbl"); 749 749 750 750 // For each node count the number of children... 751 751 while (list($child_type, $child_id) = mysql_fetch_row($qid)) { … … 757 757 } 758 758 } 759 759 760 760 /** 761 761 * Used internally by setSubnodeQty to add the quantity of subnodes to … … 772 772 $qid = DB::query(" 773 773 SELECT parent_type, parent_id 774 FROM node_tbl 774 FROM node_tbl 775 775 WHERE child_type = '" . addslashes($child_type) . "' 776 AND child_id = '" . addslashes($child_id) . "' 776 AND child_id = '" . addslashes($child_id) . "' 777 777 ",false); 778 778 while ((list($parent_type, $parent_id) = mysql_fetch_row($qid)) && $parent_id > 0) { -
trunk/lib/PEdit.inc.php
r41 r42 2 2 /** 3 3 * PEdit:: provides a mechanism to store text in php variables 4 * which will be printed to the client browser under normal 4 * which will be printed to the client browser under normal 5 5 * circumstances, but an authenticated user can 'edit' the document-- 6 6 * data stored in vars will be shown in html form elements to be editied … … 16 16 * require_once 'codebase/lib/PEdit.inc.php'; 17 17 * $p = new PEdit($auth->hasClearance('pedit')); 18 * 18 * 19 19 * $title = <<<P_E_D_I_T_title 20 20 * Using Burritos to Improve Student Learnin' 21 21 * P_E_D_I_T_title; 22 22 * $p->set($title, 'title', 'textbox'); 23 * 23 * 24 24 * // Begin content. Include a header or something right here. 25 25 * $p->printContent('title'); 26 * 26 * 27 27 * // Prints beginning form tags and special hidden forms. (Only happens if page is NOT a archived version.) 28 28 * $p->formBegin(); 29 * 29 * 30 30 * // Print editing form elements. (Only happens if op == Edit.) 31 31 * $p->printForm('title'); 32 * 32 * 33 33 * // Print versions list. (Only happens if op == Versions.) 34 34 * $p->printVersions(); 35 * 35 * 36 36 * // Prints ending form tags and command buttons.(Only happens if page is NOT a archived version.) 37 37 * $p->formEnd(); 38 38 * 39 * @author Quinn Comendant <quinn@strangecode.com> 40 * @concept Beau Smith <beau@beausmith.com> 39 * @author Quinn Comendant <quinn@strangecode.com> 40 * @concept Beau Smith <beau@beausmith.com> 41 41 * @version 1.1 42 42 */ … … 51 51 // Tags that are not stripped from the POSTed data. 52 52 var $allowed_tags = '<p><h1><h2><h3><h4><h5><h6><div><br><hr><a><img><i><em><b><strong><small><blockquote><ul><ol><li><dl><dt><dd><map><area><table><tr><td>'; 53 54 55 /** 53 54 55 /** 56 56 * Constructs a new PEdit object. Initializes what file is being operated on 57 * (SCRIPT_FILENAME) and what that operation is. The two 57 * (SCRIPT_FILENAME) and what that operation is. The two 58 58 * operations that actually modify data (save, restore) are treated differently 59 59 * than view operations (versions, '' - default). They die redirect so you see 60 60 * the page you just modified. 61 * 62 * @access public 63 * 64 * @param optional array $params A hash containing connection parameters. 65 */ 61 * 62 * @access public 63 * 64 * @param optional array $params A hash containing connection parameters. 65 */ 66 66 function PEdit($authorized=false) 67 67 { … … 69 69 $this->_authorized = true; 70 70 } 71 71 72 72 $this->_filename = $_SERVER['SCRIPT_FILENAME']; 73 73 if (empty($this->_filename)) { … … 75 75 die; 76 76 } 77 77 78 78 $this->op = getFormData('op'); 79 79 80 80 switch ($this->op) { 81 81 case 'Save' : … … 91 91 } 92 92 } 93 93 94 94 /** 95 95 * Stores a variable in the pedit data array with the content name, and type of form. 96 * 97 * @access public 98 * 96 * 97 * @access public 98 * 99 99 * @param string $content The variable containing the text to store. 100 * @param string $name The name of the variable. 101 * @param string $type The type of form element to use. 102 * @param optional int $form_size The size of the form element. 100 * @param string $name The name of the variable. 101 * @param string $type The type of form element to use. 102 * @param optional int $form_size The size of the form element. 103 103 */ 104 104 function set($content, $name, $type, $form_size=null) 105 105 { 106 106 $this->_data[$name] = array( 107 'type' => $type, 108 'content' => $content, 107 'type' => $type, 108 'content' => $content, 109 109 'form_size' => $form_size 110 110 ); 111 111 } 112 112 113 113 /** 114 114 * Stores a checkbox variable in the pedit data array with the content name, and type of form. 115 * 116 * @access public 117 * 115 * 116 * @access public 117 * 118 118 * @param string $content The variable containing the text to store. 119 * @param string $name The name of the variable. 120 * @param string $corresponding_text The text that corresponds to this checkbox. 119 * @param string $name The name of the variable. 120 * @param string $corresponding_text The text that corresponds to this checkbox. 121 121 */ 122 122 function setCheckbox($content, $name, $corresponding_text) … … 124 124 if (isset($content) && isset($name) && isset($corresponding_text)) { 125 125 $this->_data[$name] = array( 126 'type' => 'checkbox', 127 'content' => $content, 126 'type' => 'checkbox', 127 'content' => $content, 128 128 'corresponding_text' => $corresponding_text 129 129 ); … … 131 131 } 132 132 133 /** 133 /** 134 134 * Tests if we are should display page contents. 135 * 136 * @access public 135 * 136 * @access public 137 137 * 138 138 * @return bool true if we are displaying page normally, false if editing page, or viewing versions. 139 */ 139 */ 140 140 function displayMode() 141 141 { … … 144 144 } 145 145 } 146 147 148 /** 146 147 148 /** 149 149 * Prints an HTML list of versions of current file, with the filesize 150 * and links to view and restore the file. 151 * 152 * @access public 153 */ 150 * and links to view and restore the file. 151 * 152 * @access public 153 */ 154 154 function printVersions() 155 155 { … … 168 168 <td nowrap="nowrap"><p> [<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&with_file=' . $v['filename'] . '&file_hash=' . md5('frog_guts' . $this->_filename)); ?>"><?php echo _("restore"); ?></a>]</p></td> 169 169 </tr> 170 <?php 170 <?php 171 171 } 172 172 ?></table><?php … … 176 176 } 177 177 178 /** 178 /** 179 179 * Returns the contents of a data variable. The variable must first be 'set'. 180 * 181 * @access public 182 * 183 * @param string $name The name of the variable to return. 180 * 181 * @access public 182 * 183 * @param string $name The name of the variable to return. 184 184 * 185 185 * @return string The trimmed content of the named data. 186 */ 186 */ 187 187 function getContent($name, $preserve_html=true) 188 188 { … … 198 198 } 199 199 200 /** 200 /** 201 201 * Prints the contents of a data variable. The variable must first be 'set'. 202 * 203 * @access public 204 * 205 * @param string $name The name of the variable to print. 206 */ 202 * 203 * @access public 204 * 205 * @param string $name The name of the variable to print. 206 */ 207 207 function printContent($name, $preserve_html=true) 208 208 { 209 209 echo $this->getContent($name, $preserve_html); 210 210 } 211 212 /** 213 * Prints the HTML forms corresponding to pedit variables. Each variable 211 212 /** 213 * Prints the HTML forms corresponding to pedit variables. Each variable 214 214 * must first be 'set'. 215 * 216 * @access public 217 * 218 * @param string $name The name of the variable. 219 */ 215 * 216 * @access public 217 * 218 * @param string $name The name of the variable. 219 */ 220 220 function printForm($name) 221 221 { … … 245 245 } 246 246 } 247 248 /** 247 248 /** 249 249 * Loops through the PEdit data array and prints all the HTML forms corresponding 250 250 * to all pedit variables, in the order in which they were 'set'. 251 * 252 * @access public 253 */ 251 * 252 * @access public 253 */ 254 254 function printAllForms() 255 255 { … … 260 260 } 261 261 } 262 263 /** 264 * Prints the beginning <form> HTML tag, as well as hidden input forms. 265 * 266 * @return bool False if unauthorized or current page is a version. 267 */ 262 263 /** 264 * Prints the beginning <form> HTML tag, as well as hidden input forms. 265 * 266 * @return bool False if unauthorized or current page is a version. 267 */ 268 268 function formBegin() 269 269 { … … 289 289 } 290 290 } 291 292 /** 291 292 /** 293 293 * Prints the endig </form> HTML tag, as well as buttons used during 294 * different operations. 295 * 296 * @return bool False if unauthorized or current page is a version. 297 */ 294 * different operations. 295 * 296 * @return bool False if unauthorized or current page is a version. 297 */ 298 298 function formEnd() 299 299 { … … 330 330 } 331 331 } 332 333 /** 332 333 /** 334 334 * Saves the POSTed data by overwriting the pedit variables in the 335 * current file. 336 * 337 * @access private 338 * 339 * @return bool False if unauthorized or on failure. True on success. 340 */ 335 * current file. 336 * 337 * @access private 338 * 339 * @return bool False if unauthorized or on failure. True on success. 340 */ 341 341 function _writeData() 342 342 { … … 368 368 } 369 369 } 370 370 371 371 // Search and replace all blocks. 372 372 $whole_file = preg_replace($search, $replace, $whole_file); … … 383 383 return false; 384 384 } 385 385 386 386 // Open file for writing and truncate to zero length. 387 387 if (is_writable($this->_filename) && $fp = fopen($this->_filename, 'w')) { … … 402 402 } 403 403 } 404 405 /** 406 * Makes a copy of the current file with the unix timestamp appended to the 404 405 /** 406 * Makes a copy of the current file with the unix timestamp appended to the 407 407 * filename. Deletes old versions based on threshold of age and qty. 408 * 409 * @access private 410 * 408 * 409 * @access private 410 * 411 411 * @param optional boolean $do_cleanup Set to false to turn off the 412 412 * cleanup routine. 413 * 414 * @return bool False if unauthorized or on failure. True on success. 415 */ 413 * 414 * @return bool False if unauthorized or on failure. True on success. 415 */ 416 416 function _createVersion($do_cleanup=true) 417 417 { … … 425 425 } 426 426 $versions = $this->_getVersions(); 427 427 428 428 // Clean up old versions. 429 429 if (is_array($versions) && sizeof($versions) > $this->versions_min_qty && $do_cleanup) { … … 431 431 $oldest = array_pop($versions); 432 432 // Loop while minimum X qty && minimum X days worth but never more than 100 qty. 433 while ((sizeof($versions) > $this->versions_min_qty 434 && $oldest['unixtime'] < mktime(date('H'),date('i'),date('s'),date('m'),date('d')-$this->versions_min_days,date('Y'))) 433 while ((sizeof($versions) > $this->versions_min_qty 434 && $oldest['unixtime'] < mktime(date('H'),date('i'),date('s'),date('m'),date('d')-$this->versions_min_days,date('Y'))) 435 435 || sizeof($versions) > 100) { 436 436 unlink(dirname($this->_filename) . '/' . $oldest['filename']); … … 444 444 return false; 445 445 } 446 446 447 447 return true; 448 448 } 449 450 /** 451 * Returns an array of all archived versions of the current file, 449 450 /** 451 * Returns an array of all archived versions of the current file, 452 452 * sorted with newest versions at the top of the array. 453 * 453 * 454 454 * @access private 455 455 * 456 * @return array Array of versions. 457 */ 456 * @return array Array of versions. 457 */ 458 458 function _getVersions() 459 459 { … … 464 464 preg_match('/.+__(\d+)\.php/', $version, $time); 465 465 $versions[] = array( 466 'filename' => $version, 467 'unixtime' => $time[1], 466 'filename' => $version, 467 'unixtime' => $time[1], 468 468 'filesize' => filesize(dirname($this->_filename) . '/' . $version) 469 469 ); … … 478 478 } 479 479 } 480 481 /** 480 481 /** 482 482 * Makes a version backup of the current file, then copies the specified 483 * archived version over the current file. 484 * 485 * @access private 486 * 483 * archived version over the current file. 484 * 485 * @access private 486 * 487 487 * @param string $with_file Filename of archived version to restore. 488 488 * 489 * @return bool False if unauthorized. True on success. 490 */ 489 * @return bool False if unauthorized. True on success. 490 */ 491 491 function _restoreVersion($with_file) 492 492 { … … 494 494 return false; 495 495 } 496 496 497 497 if (is_writable($this->_filename)) { 498 498 // Make certain a version is created. … … 501 501 return false; 502 502 } 503 504 // Do the actual copy. 503 504 // Do the actual copy. 505 505 if (!copy(dirname($this->_filename) . '/' . $with_file, $this->_filename)) { 506 506 App::logMsg(sprintf('PEdit error: failed copying old version: %s', $with_file), LOG_NOTICE, __FILE__, __LINE__); 507 507 return false; 508 508 } 509 509 510 510 // Success! 511 511 return true; … … 515 515 } 516 516 } 517 517 518 518 } // End class. 519 519 -
trunk/lib/PageNumbers.inc.php
r41 r42 14 14 * @version 1.61 15 15 */ 16 16 17 17 require_once dirname(__FILE__) . '/Prefs.inc.php'; 18 18 19 19 class PageNumbers { 20 20 21 21 var $total_items; // Total quantity of items. 22 22 var $total_pages; // The total number of pages. … … 32 32 var $set_page_number_initialized = false; 33 33 var $set_total_items_initialized = false; 34 34 35 35 // These are initialized in the constructor. 36 36 var $per_page_options; … … 43 43 var $right_dbl_arrow; 44 44 var $right_dbl_arrow_disabled; 45 45 46 46 /** 47 47 * PageNumbers constructor. All arguments are depreciated. Use set* functions instead. … … 51 51 // Default options for the quantity per page links. 52 52 $this->per_page_options = array(25, 50, 100, 200); 53 53 54 54 // Default options for the page number links. 55 55 $this->left_arrow = _("back"); … … 61 61 $this->right_dbl_arrow = '<strong>»</strong>'; 62 62 $this->right_dbl_arrow_disabled = '<span style="color: #aaaaaa;"><strong>»</strong></span>'; 63 64 // Default url base. This will be set manually after instantiation 63 64 // Default url base. This will be set manually after instantiation 65 65 // in special cases like using a /my/page/# scheme. 66 66 $this->url_base = $_SERVER['PHP_SELF'] . '?page_number='; 67 67 } 68 68 69 69 /** 70 70 * Set the number of items per page. … … 88 88 $this->set_per_page_initialized = true; 89 89 } 90 90 91 91 /** 92 92 * Set the current page number. … … 112 112 $this->set_page_number_initialized = true; 113 113 } 114 114 115 115 /** 116 116 * Set the total number of items. … … 119 119 { 120 120 if (is_numeric($total_items) && $total_items > 0) { 121 $this->total_items = $total_items; 122 } else { 123 $this->total_items = 0; 121 $this->total_items = $total_items; 122 } else { 123 $this->total_items = 0; 124 124 } 125 125 $this->set_total_items_initialized = true; 126 126 } 127 127 128 128 /** 129 129 * After $total_items or other options are set, this function calculates 130 * all the other numbers needed. If you set any variables manually, 130 * all the other numbers needed. If you set any variables manually, 131 131 * for example if $page_number comes from 132 132 * some place other than the GET or POST array, you should call this … … 146 146 App::logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__); 147 147 } 148 148 149 149 // If the specified page exceedes total pages or is less than 1, set the page to 1. 150 150 if ($this->_per_page * $this->current_page >= $this->total_items + $this->_per_page || $this->_per_page * $this->current_page < 1) { 151 151 $this->current_page = 1; 152 152 } 153 153 154 154 // The first item to be shown on this page. 155 155 $this->first_item = ($this->current_page - 1) * $this->_per_page; 156 156 157 157 // The last item to be shown on this page. 158 158 if ($this->total_items < $this->current_page * $this->_per_page) { … … 161 161 $this->last_item = $this->current_page * $this->_per_page - 1; 162 162 } 163 163 164 164 // Zeroing. Just in case. Paranoia. Yeah, negative numbers perturb me. 165 165 if ($this->first_item < 1) { … … 172 172 $this->total_items = 0; 173 173 } 174 174 175 175 // The total number of pages. 176 176 $this->total_pages = ceil($this->total_items / $this->_per_page); 177 177 178 178 // Figure out how many page number links to print. 179 179 if ($this->total_pages >= $this->max_num_links) { … … 183 183 } 184 184 } 185 185 186 186 /** 187 187 * Returns the SQL code to limit query to items that are on current page. … … 195 195 return ''; 196 196 } 197 } 197 } 198 198 199 199 /** … … 221 221 /** 222 222 * Outputs an App::oHREF compatible url that goes to the page $page_number. 223 * Depends on $this->base_url to build the url onto. This is used in the 223 * Depends on $this->base_url to build the url onto. This is used in the 224 224 * page_number.ihtml template. 225 225 * … … 247 247 { 248 248 $page_numbers = array(); 249 249 250 250 for ($i = 1; $i < $this->total_pages; $i++) { 251 251 $page_numbers[] = array( … … 255 255 ); 256 256 } 257 257 258 258 return $page_numbers; 259 259 } … … 267 267 { 268 268 $page_numbers_string = ''; 269 269 270 270 if ($this->current_page > $this->total_pages - floor($this->_num_links / 2)) { 271 271 $high_num = $this->total_pages; … … 278 278 $high_num = $low_num + $this->_num_links - 1; 279 279 } 280 280 281 281 if ($this->current_page != 1) { 282 282 // Print "first" and "previous" page links. … … 299 299 } 300 300 } 301 301 302 302 if ($this->_num_links > 0) { 303 303 // Print the current page number. 304 304 $page_numbers_string .= sprintf('<strong>%s</strong> ', $this->current_page); 305 305 } 306 306 307 307 if ($this->current_page < $this->total_pages) { 308 308 // Print links to specific page numbers after the current page. … … 325 325 } 326 326 } 327 327 328 328 return $page_numbers_string; 329 329 } 330 330 331 331 function printPageNumbers($carry_args=null) 332 332 { 333 333 echo $this->getPageNumbers($carry_args); 334 334 } 335 335 336 336 } 337 337 -
trunk/lib/PageSequence.inc.php
r41 r42 10 10 * @version 1.01 11 11 */ 12 12 13 13 require_once dirname(__FILE__) . '/Prefs.inc.php'; 14 14 … … 19 19 var $sequence_title = ''; 20 20 var $seq = '_sequence_'; 21 var $idle_timeout; 22 21 var $idle_timeout; 22 23 23 /** 24 24 * Constructor. Sets the title of this sequence and initializes session variables. … … 33 33 $this->seq .= $params['sequence_title']; 34 34 } 35 35 36 36 // How long before resetting session? 60 minutes. 37 37 $this->idle_timeout = isset($params['idle_timeout']) ? $params['idle_timeout'] : 3600; 38 38 39 39 // Where is user to be redirected after startOver function call? 40 40 $this->start_url = isset($params['start_url']) ? $params['start_url'] : $_SERVER['PHP_SELF']; 41 41 42 42 // Initialize vars if not set. 43 43 if (!isset($_SESSION[$this->seq]['steps'])) { … … 50 50 $_SESSION[$this->seq]['defaults'] = array(); 51 51 } 52 52 53 53 // Manage timeout. 54 54 $this->_auto_timeout(); 55 55 } 56 57 /** 58 * Create a new step at the end (or specified position) of the $steps array. 56 57 /** 58 * Create a new step at the end (or specified position) of the $steps array. 59 59 * 60 60 * @param string $step_id Uniqie identifyer for this step. … … 85 85 ); 86 86 } 87 87 88 88 /** 89 89 * Set the features of a step. Current step if step_id not specified. … … 123 123 } 124 124 } 125 125 126 126 /** 127 127 * Set the current step id. Which step are we on? … … 142 142 } 143 143 } 144 144 145 145 /** 146 146 * Get the current step id. … … 157 157 } 158 158 } 159 159 160 160 /** 161 161 * Get the current step number. … … 179 179 foreach ($_SESSION[$this->seq]['steps'] as $pos=>$step) { 180 180 if ($step['id'] == $step_id) { 181 return $pos; 181 return $pos; 182 182 } 183 183 } … … 186 186 } 187 187 } 188 188 189 189 /** 190 190 * Returns the ID of the step with required=true and completed=false 191 * and active=true that falls before specified step_id. 191 * and active=true that falls before specified step_id. 192 192 * 193 193 * @param string $curr_step_id ID or number of current step. … … 212 212 return $curr_step_id; 213 213 } 214 214 215 215 /** 216 216 * Returns the next step in the steps array or the first active required … … 235 235 return null; 236 236 } 237 237 238 238 /** 239 239 * To set a set as 'completed'. … … 246 246 $_SESSION[$this->seq]['steps'][$pos]['completed'] = true; 247 247 } 248 248 249 249 /** 250 250 * Prints the a link that returns to the form for a step. … … 262 262 } 263 263 } 264 264 265 265 /** 266 266 * Saves given $step_data (usually coming from $_POST) into $_SESSION … … 279 279 } 280 280 } 281 281 282 282 /** 283 283 * Returns the value saved in $_SESSION for a specific data key. … … 297 297 } 298 298 } 299 299 300 300 /** 301 301 * Deletes all data saved in $_SESSION. … … 330 330 } 331 331 } 332 332 333 333 /** 334 334 * Saves given array (usually coming from $_POST) into $_SESSION … … 341 341 $_SESSION[$this->seq]['data'] = array_merge($_SESSION[$this->seq]['data'], $step_data); 342 342 } 343 343 344 344 /** 345 345 * Reset all vars. … … 354 354 $_SESSION[$this->seq]['last_access_time'] = time(); 355 355 } 356 356 357 357 /** 358 358 * Template function to be extended with custom SQL code. … … 365 365 return false; 366 366 } 367 367 368 368 /** 369 369 * Template function to be extended with custom SQL code. … … 376 376 return false; 377 377 } 378 379 378 379 380 380 } // END CLASS 381 381 -
trunk/lib/PayPal.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * The PayPal:: class provides functions for creating PayPal buttons and for 3 * The PayPal:: class provides functions for creating PayPal buttons and for 4 4 * receiving PayPal's Instant Payment Notification (IPN) service. 5 5 * … … 8 8 */ 9 9 class PayPal { 10 10 11 11 // General object parameters. 12 12 var $_params = array( … … 14 14 'test_mode' => false, 15 15 ); 16 17 // Options used for specific buttons and links. 16 17 // Options used for specific buttons and links. 18 18 var $_default_button_options = array(); 19 19 20 20 // Array of buttons created by newButton(). 21 21 var $_buttons = array(); 22 22 23 23 // Store the response from the last IPN. 24 24 var $_ipn_response; 25 25 26 26 /** 27 27 * Constructor. … … 38 38 $url = 'www.paypal.com'; 39 39 } 40 40 41 41 $this->_default_button_options = array( 42 42 '_global' => array( … … 59 59 ); 60 60 } 61 62 /** 63 * Updates the _default_button_options array with options used for 61 62 /** 63 * Updates the _default_button_options array with options used for 64 64 * specific buttons, or all buttons if $type is null. 65 65 * 66 66 * @access public 67 67 * 68 * @param mixed $type The type of button to set defaults. If null, 68 * @param mixed $type The type of button to set defaults. If null, 69 69 * sets the global button types. 70 70 * @param array $options Options to set for button. … … 78 78 return false; 79 79 } 80 80 81 81 if (is_null($type) || '_global' == $type) { 82 82 $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options); … … 85 85 return false; 86 86 } 87 87 88 88 $this->_default_button_options[$type] = array_merge($this->_default_button_options[$type], $options); 89 89 return true; 90 90 } 91 91 92 92 /** 93 93 * Creates a new element in the _buttons array. Uses _default_button_options … … 108 108 return false; 109 109 } 110 110 111 111 if (!is_array($options) || empty($options)) { 112 112 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 113 113 return false; 114 114 } 115 115 116 116 if (isset($this->_buttons[$name])) { 117 117 App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__); 118 118 } 119 119 120 120 $this->_buttons[$name] = array( 121 121 'type' => $type, … … 141 141 return false; 142 142 } 143 143 144 144 $query_string = ''; 145 145 $delim = ''; … … 156 156 $search = array('/%2F/'); 157 157 $replace = array('/'); 158 158 159 159 return $this->_buttons[$name]['options']['link_url'] . preg_replace($search, $replace, $query_string); 160 160 } … … 183 183 ?> 184 184 <form action="<?php echo $this->_buttons[$name]['options']['button_url']; ?>" method="post"> 185 <?php 185 <?php 186 186 if (is_array($this->_buttons[$name]['options']) && !empty($this->_buttons[$name]['options'])) { 187 187 foreach ($this->_buttons[$name]['options'] as $key=>$val) { … … 192 192 } 193 193 } 194 } 194 } 195 195 ?> 196 196 <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" /> … … 241 241 function incomingIPNRequest() 242 242 { 243 if ($_SERVER['REQUEST_METHOD'] == 'POST' 243 if ($_SERVER['REQUEST_METHOD'] == 'POST' 244 244 && $_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded' 245 245 && !empty($_POST)) { … … 258 258 */ 259 259 function processIPN() 260 { 260 { 261 261 if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) { 262 262 App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); … … 266 266 $url = parse_url($this->getParam('paypal_url')); 267 267 } 268 268 269 269 // Read POST request and add 'cmd'. 270 270 $received_data = getPost(); … … 273 273 $return_data .= '&' . $post_key . '=' . urlencode($post_val); 274 274 } 275 275 276 276 // Set the port number based on the scheme. 277 if ($url['scheme'] == "https") { 277 if ($url['scheme'] == "https") { 278 278 $url['port'] = 443; 279 279 $ssl = 'ssl://'; … … 282 282 $ssl = ''; 283 283 } 284 284 285 285 // Open connection to PayPal server. 286 $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30); 286 $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30); 287 287 288 288 if (!$fp) { … … 290 290 return false; 291 291 } else { 292 fputs($fp, "POST {$url['path']} HTTP/1.1\r\n"); 293 fputs($fp, "Host: {$url['host']}\r\n"); 294 fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 295 fputs($fp, "Content-length: " . strlen($return_data) . "\r\n"); 296 fputs($fp, "Connection: close\r\n\r\n"); 297 fputs($fp, $return_data . "\r\n\r\n"); 298 292 fputs($fp, "POST {$url['path']} HTTP/1.1\r\n"); 293 fputs($fp, "Host: {$url['host']}\r\n"); 294 fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 295 fputs($fp, "Content-length: " . strlen($return_data) . "\r\n"); 296 fputs($fp, "Connection: close\r\n\r\n"); 297 fputs($fp, $return_data . "\r\n\r\n"); 298 299 299 // Loop through the response lines from the server. 300 300 $this->_ipn_response = ''; … … 303 303 } 304 304 fclose($fp); 305 305 306 306 App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__); 307 307 return true; 308 308 } 309 309 } 310 310 311 311 /** 312 312 * Checks the response received from PayPal's IPN upon calling processIPN(). … … 322 322 return false; 323 323 } 324 324 325 325 if (empty($this->_ipn_response)) { 326 326 App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__); 327 327 return false; 328 328 } 329 329 330 330 if (preg_match('/VERIFIED/', $this->_ipn_response)) { 331 331 App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__); … … 339 339 } 340 340 } 341 342 341 342 343 343 } // End of class. 344 344 -
trunk/lib/Prefs.inc.php
r41 r42 30 30 */ 31 31 var $params = array(); 32 33 32 33 34 34 /** 35 35 * Prefs constructor. … … 43 43 /** 44 44 * Sets the default value of a preference. The pref will be set only if 45 * is not set already. 45 * is not set already. 46 46 * 47 47 * @param string $pref The name of the preference to modify. … … 56 56 $scope =& $this->scope; 57 57 } 58 58 59 59 // No empty values allowed. 60 60 if ('' == $pref || '' == $val || '' == $scope) { 61 61 return false; 62 62 } 63 63 64 64 // Initialized the prefs array. 65 65 if (!isset($_SESSION['_prefs'])) { 66 66 $_SESSION['_prefs'] = array(); 67 67 } 68 68 69 69 // In case boolean or null values are passed as a string. 70 70 if ($val == 'true') { … … 84 84 85 85 /** 86 * Sets the given preferences to the specific value, 86 * Sets the given preferences to the specific value, 87 87 * 88 88 * @param string $pref The name of the preference to modify. … … 97 97 $scope =& $this->scope; 98 98 } 99 99 100 100 // No empty values allowed. 101 101 if ('' == $pref || '' == $val || '' == $scope) { 102 102 return false; 103 103 } 104 104 105 105 // Initialized the prefs array. 106 106 if (!isset($_SESSION['_prefs'])) { 107 107 $_SESSION['_prefs'] = array(); 108 108 } 109 109 110 110 // In case boolean or null values are passed as a string. 111 111 if ($val == 'true') { … … 120 120 return true; 121 121 } 122 122 123 123 /** 124 124 * Returns the value of the requested preference. … … 134 134 $scope =& $this->scope; 135 135 } 136 136 137 137 return (isset($_SESSION['_prefs'][$scope][$pref])) ? $_SESSION['_prefs'][$scope][$pref] : null; 138 138 } 139 139 140 140 /** 141 141 * To see if a preference has been set. … … 152 152 $scope =& $this->scope; 153 153 } 154 154 155 155 return isset($_SESSION['_prefs'][$scope][$pref]); 156 156 } 157 157 158 158 /** 159 159 * Clear a set preference value. … … 167 167 $scope =& $this->scope; 168 168 } 169 169 170 170 if (isset($_SESSION['_prefs'][$scope][$pref])) { 171 171 unset($_SESSION['_prefs'][$scope][$pref]); … … 181 181 * preferences listed in the $prefs hash. 182 182 * 183 * @return mixed True on success or a PEAR_Error object on failure. 183 * @return mixed True on success or a PEAR_Error object on failure. 184 184 */ 185 185 function retrieve() … … 192 192 // FIXME: Database query goes here.... 193 193 return false; 194 194 195 195 $_SESSION['_prefs']['loaded'] = true; 196 196 } … … 211 211 return true; 212 212 } 213 213 214 214 /* 215 215 * If a list of preferences to store hasn't been provided in … … 221 221 $prefs = array_merge($_SESSION['_prefs'], $prefs); 222 222 } 223 223 224 224 if (!is_array($prefs) || empty($prefs)) { 225 225 App::raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__); 226 226 App::dieBoomerangURL(); 227 227 } 228 228 229 229 // FIXME: Database query goes here.... 230 230 return false; -
trunk/lib/RecordLock.inc.php
r41 r42 33 33 { 34 34 static $instances = array(); 35 35 36 36 if (!isset($instances[$auth_object->getVal('auth_name')])) { 37 37 $instances[$auth_object->getVal('auth_name')] = new RecordLock($auth_object); … … 53 53 54 54 $this->_auth = $auth_object; 55 55 56 56 // Get create tables config from global context. 57 57 if (!is_null(App::getParam('db_create_tables'))) { … … 70 70 { 71 71 static $_db_tested = false; 72 72 73 73 if ($recreate_db || !$_db_tested && $this->getParam('create_table')) { 74 74 if ($recreate_db) { … … 89 89 KEY record_val (record_val) 90 90 )"); 91 91 92 92 if (!DB::columnExists($this->getParam('db_table'), array( 93 94 95 96 97 98 99 93 'lock_id', 94 'record_table', 95 'record_key', 96 'record_val', 97 'title', 98 'set_by_admin_id', 99 'lock_datetime', 100 100 ), false, false)) { 101 101 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__); 102 102 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 103 103 } 104 } 104 } 105 105 $_db_tested = true; 106 106 } … … 151 151 // Expire old locks. 152 152 $this->_auto_timeout(); 153 153 154 154 if (is_numeric($record_table_or_lock_id) && !isset($record_key) && !isset($record_val)) { 155 155 // Get lock data by lock_id. 156 156 $qid = DB::query(" 157 SELECT * FROM " . $this->getParam('db_table') . " 157 SELECT * FROM " . $this->getParam('db_table') . " 158 158 WHERE lock_id = '" . addslashes($record_table_or_lock_id) . "' 159 159 "); … … 161 161 // Get lock data by record specs 162 162 $qid = DB::query(" 163 SELECT * FROM " . $this->getParam('db_table') . " 163 SELECT * FROM " . $this->getParam('db_table') . " 164 164 WHERE record_table = '" . addslashes($record_table_or_lock_id) . "' 165 165 AND record_key = '" . addslashes($record_key) . "' … … 189 189 190 190 /** 191 * Returns the status of who set the lock. Use this to ignore locks set by 191 * Returns the status of who set the lock. Use this to ignore locks set by 192 192 * the current user. 193 193 * … … 197 197 { 198 198 $this->initDB(); 199 199 200 200 if (isset($this->data['lock_id'])) { 201 201 $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'"); … … 221 221 */ 222 222 function set($record_table, $record_key, $record_val, $title='') 223 { 223 { 224 224 $this->initDB(); 225 225 226 226 // Expire old locks. 227 227 $this->_auto_timeout(); 228 228 229 229 // Remove previous locks if exist. Is this better than using a REPLACE INTO? 230 230 DB::query(" 231 DELETE FROM " . $this->getParam('db_table') . " 231 DELETE FROM " . $this->getParam('db_table') . " 232 232 WHERE record_table = '" . addslashes($record_table) . "' 233 233 AND record_key = '" . addslashes($record_key) . "' 234 234 AND record_val = '" . addslashes($record_val) . "' 235 235 "); 236 236 237 237 // Set new lock. 238 238 DB::query(" … … 254 254 "); 255 255 $lock_id = mysql_insert_id(DB::getDBH()); 256 256 257 257 // Must register this locked record as the current. 258 258 $this->select($lock_id); 259 259 260 260 return $lock_id; 261 261 } … … 270 270 // Expire old locks. 271 271 $this->_auto_timeout(); 272 272 273 273 // Delete a specific lock. 274 274 DB::query(" 275 DELETE FROM " . $this->getParam('db_table') . " 275 DELETE FROM " . $this->getParam('db_table') . " 276 276 WHERE lock_id = '" . addslashes($this->data['lock_id']) . "' 277 277 "); 278 278 279 279 App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__); 280 280 } … … 284 284 */ 285 285 function removeAll($user_id=null) 286 { 286 { 287 287 $this->initDB(); 288 288 289 289 // Expire old locks. 290 290 $this->_auto_timeout(); 291 291 292 292 if (isset($user_id)) { 293 293 // Delete specific user's locks. … … 309 309 310 310 $this->initDB(); 311 311 312 312 if (!$_timeout_run) { 313 313 // Delete all old locks. 314 314 DB::query(" 315 DELETE FROM " . $this->getParam('db_table') . " 315 DELETE FROM " . $this->getParam('db_table') . " 316 316 WHERE DATE_ADD(lock_datetime, INTERVAL '" . $this->getParam('auto_timeout') . "' SECOND) < NOW() 317 317 "); … … 337 337 <?php App::printHiddenSession() ?> 338 338 <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" /> 339 339 340 340 <p><?php 341 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 342 $this->getTitle(), 343 $this->getEditor(), 341 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 342 $this->getTitle(), 343 $this->getEditor(), 344 344 date('i', $this->getSecondsElapsed() + 60) 345 345 ); 346 346 ?></p> 347 347 348 348 <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?> 349 349 <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p> 350 350 <input type="submit" name="unlock" value="<?php echo _("Unlock"); ?>" /> 351 351 <?php } ?> 352 352 353 353 <input type="submit" name="cancel" value="<?php echo _("Cancel"); ?>" /> 354 354 </form> -
trunk/lib/RecordVersion.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * The RecordVersion:: class provides a system for saving, reviewing, and 3 * The RecordVersion:: class provides a system for saving, reviewing, and 4 4 * restoring versions of a record of any DB table. All the data in the record is 5 5 * serialized, compressed, and saved in a blob in the version_tbl. Restoring a 6 6 * version simply does a REPLACE INTO of the data. It is very simple, and works 7 7 * with multiple database tables, but the drawback is that relationships for 8 * a record cannot be retained. For example, an article from an article_tbl can 8 * a record cannot be retained. For example, an article from an article_tbl can 9 9 * be saved, but not categories associated to the record in a category_article_tbl. 10 10 * The restored article will simple retain the relationships that the previous … … 40 40 { 41 41 static $instances = array(); 42 42 43 43 if (!isset($instances[$auth_object->getVal('auth_name')])) { 44 44 $instances[$auth_object->getVal('auth_name')] = new RecordVersion($auth_object); … … 58 58 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR); 59 59 } 60 60 61 61 $this->_auth = $auth_object; 62 62 63 63 // Get create tables config from global context. 64 64 if (!is_null(App::getParam('db_create_tables'))) { … … 66 66 } 67 67 } 68 68 69 69 /** 70 70 * Setup the database table for this class. … … 77 77 { 78 78 static $_db_tested = false; 79 79 80 80 if ($recreate_db || !$_db_tested && $this->getParam('create_table')) { 81 81 if ($recreate_db) { … … 98 98 KEY record_val (record_val) 99 99 )"); 100 100 101 101 if (!DB::columnExists($this->getParam('db_table'), array( 102 102 'version_id', … … 113 113 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 114 114 } 115 } 115 } 116 116 $_db_tested = true; 117 117 } … … 160 160 { 161 161 $this->initDB(); 162 162 163 163 // Get current record. 164 164 if (!$record = $this->getCurrent($record_table, $record_key, $record_val)) { … … 166 166 return false; 167 167 } 168 168 169 169 // Clean-up old versions. 170 170 $this->deleteOld($record_table, $record_key, $record_val); 171 171 172 172 // Save as new version. 173 173 DB::query(" … … 206 206 { 207 207 $this->initDB(); 208 208 209 209 // Get version data. 210 210 $qid = DB::query(" 211 SELECT * FROM " . $this->getParam('db_table') . " 211 SELECT * FROM " . $this->getParam('db_table') . " 212 212 WHERE version_id = '" . addslashes($version_id) . "' 213 213 "); … … 228 228 // SQLize the keys of the specified versioned record. 229 229 $replace_keys = join(",\n", array_map('addslashes', array_keys($data))); 230 230 231 231 // SQLize the keys of the values of the specified versioned record. (These are more complex because we need to account for SQL null values.) 232 232 $replace_values = ''; … … 236 236 $comma = ','; 237 237 } 238 238 239 239 // Replace current record with specified versioned record. 240 240 DB::query(" … … 245 245 ) 246 246 "); 247 247 248 248 return $record; 249 249 } … … 252 252 * Version garbage collection. Deletes versions older than min_days 253 253 * when quantity of versions exceeds min_qty. If quantity 254 * exceeds 100 within min_days, the oldest are deleted to bring the 254 * exceeds 100 within min_days, the oldest are deleted to bring the 255 255 * quantity back down to min_qty. 256 256 * … … 264 264 { 265 265 $this->initDB(); 266 266 267 267 // Get total number of versions for this record. 268 268 $qid = DB::query(" … … 273 273 "); 274 274 list($v_count) = mysql_fetch_row($qid); 275 275 276 276 if ($v_count > $this->getParam('min_qty')) { 277 277 if ($v_count > $this->getParam('max_qty')) { … … 329 329 { 330 330 $this->initDB(); 331 331 332 332 // Get versions of this record. 333 333 $qid = DB::query(" … … 358 358 { 359 359 $this->initDB(); 360 360 361 361 // Get version data. 362 362 $qid = DB::query(" 363 SELECT * FROM " . $this->getParam('db_table') . " 363 SELECT * FROM " . $this->getParam('db_table') . " 364 364 WHERE version_id = '" . addslashes($version_id) . "' 365 365 "); … … 377 377 { 378 378 $this->initDB(); 379 379 380 380 // Get version data. 381 381 $qid = DB::query(" 382 SELECT * FROM " . $this->getParam('db_table') . " 382 SELECT * FROM " . $this->getParam('db_table') . " 383 383 WHERE version_id = '" . addslashes($version_id) . "' 384 384 "); … … 401 401 { 402 402 $this->initDB(); 403 403 404 404 $qid = DB::query(" 405 405 SELECT * FROM " . addslashes($record_table) . " -
trunk/lib/ScriptTimer.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * ScriptTimer.inc.php 3 * ScriptTimer.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ 6 6 7 7 class ScriptTimer { 8 8 … … 10 10 var $_timing_start_times; 11 11 var $_timing_stop_times; 12 12 13 13 function start($name='default') 14 14 { 15 15 $this->_timing_start_times[$name] = explode(' ', microtime()); 16 16 } 17 17 18 18 function stop($name='default') 19 19 { 20 20 $this->_timing_stop_times[$name] = explode(' ', microtime()); 21 21 } 22 22 23 23 function getTime($name='default') 24 24 { … … 26 26 return 0; 27 27 } 28 28 29 29 if (!isset($this->_timing_stop_times[$name])) { 30 30 $stop_time = explode(' ', microtime()); … … 32 32 $stop_time = $this->_timing_stop_times[$name]; 33 33 } 34 34 35 35 // Do the big numbers first so the small ones aren't lost. 36 36 $current = $stop_time[1] - $this->_timing_start_times[$name][1]; 37 37 $current += $stop_time[0] - $this->_timing_start_times[$name][0]; 38 38 39 39 return sprintf($this->time_format, $current); 40 40 } -
trunk/lib/SessionCache.inc.php
r41 r42 88 88 * @param str $var_id An identifyer for the cached object. 89 89 * @param bool $force_it_in If we have something really big that we 90 * still want to cache, setting this true 90 * still want to cache, setting this true 91 91 * allows this. 92 92 * … … 106 106 $serialized_var = serialize($var); 107 107 $serialized_var_len = strlen($serialized_var); 108 108 109 109 if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) { 110 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 111 111 return false; 112 112 } 113 113 114 114 if ($serialized_var_len >= $this->getParam('hard_limit')) { 115 115 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); … … 122 122 unset($_SESSION['_session_cache'][$var_id]); 123 123 // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least. 124 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 124 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 125 125 && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) { 126 126 array_shift($_SESSION['_session_cache']); … … 128 128 } 129 129 $_SESSION['_session_cache'][$var_id] =& $serialized_var; 130 130 131 131 if ($serialized_var_len >= 1024000) { 132 132 App::logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__); 133 133 } 134 134 135 135 return $var_id; 136 136 } 137 138 /** 139 * Retrives an object from the session cache and returns it unserialized. 137 138 /** 139 * Retrives an object from the session cache and returns it unserialized. 140 140 * It also moves it to the top of the stack, which makes it such that the 141 141 * cache flushing mechanism of putCache deletes the oldest referenced items … … 155 155 return false; 156 156 } 157 157 158 158 $var_id = md5($var_id); 159 159 if (isset($_SESSION['_session_cache'][$var_id])) { … … 168 168 } 169 169 } 170 170 171 171 /** 172 172 * Tells you if the object is cached. … … 189 189 return isset($_SESSION['_session_cache'][$var_id]); 190 190 } 191 191 192 192 /** 193 193 * Tells you if the object is cached. -
trunk/lib/SortOrder.inc.php
r41 r42 13 13 * @requires This class requires Utilities.inc.php 14 14 * @requires This class requires Prefs.inc.php 15 * 15 * 16 16 * @author Quinn Comendant <quinn@strangecode.com> 17 17 * @version 1.6.1 … … 22 22 23 23 class SortOrder { 24 24 25 25 var $_columns; 26 26 var $sort_by; … … 30 30 var $default_sort; 31 31 var $default_order; 32 32 33 33 /** 34 34 * Constructor. Finds the current sort by and order. … … 40 40 */ 41 41 function SortOrder($default_sort = '', $default_order = '') 42 { 42 { 43 43 $this->setDefault($default_sort, $default_order); 44 44 45 45 $this->default_sort = $default_sort; 46 46 $this->default_order = $default_order; 47 47 } 48 48 49 49 /** 50 * Build an array of valid sort SQL for each DB column. This SQL is reference 50 * Build an array of valid sort SQL for each DB column. This SQL is reference 51 51 * by the name and 'asc' or 'desc'. 52 52 * … … 62 62 ); 63 63 } 64 64 65 65 /** 66 66 * Set sort and order values. This is how you set new sort values after … … 88 88 $this->sort_by = $default_sort; 89 89 } 90 90 91 91 // Which sort order to use? 92 92 // (1) By GET or POST specification, if available. … … 103 103 } 104 104 } 105 106 105 106 107 107 /** 108 108 * Set sort and order values. This is how you set new sort values after … … 121 121 Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']); 122 122 } 123 123 124 124 // Set new order value. 125 125 if (isset($order)) { … … 128 128 } 129 129 } 130 131 130 131 132 132 /** 133 133 * Returns the SQL code to sort by set column and set order. … … 149 149 return ''; 150 150 } 151 } 152 153 151 } 152 153 154 154 /** 155 155 * Prints a link for a column header with URL sort determining logic. … … 171 171 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php 172 172 } 173 } 173 } 174 174 175 175 } -
trunk/lib/SpellCheck.inc.php
r41 r42 9 9 * @version 1.1 10 10 */ 11 11 12 12 /* Implementation example: 13 13 -------------------------------------------------------------------------------- … … 17 17 // Instantiate with parameters. In this example we'll set the language and the path to the personal wordlist file. 18 18 $spell = new SpellCheck(array( 19 'language' => 'en', 19 'language' => 'en', 20 20 'personal_wordlist' => '/tmp/my_custom_dict' 21 21 )); … … 49 49 'highlight_end' => '</strong>', 50 50 ); 51 51 52 52 var $_pspell_cfg_handle; 53 53 var $_pspell_handle; 54 54 var $_use_personal_wordlist = false; 55 55 var $_errors = array(); 56 56 57 57 /** 58 58 * Constructor. 59 59 * 60 60 * @param array $params Array of parameters (key => val pairs). 61 61 */ 62 62 function SpellCheck($params) 63 63 { 64 65 66 67 68 64 if (!is_array($params) || empty($params)) { 65 trigger_error('SpellCheck parameters not set properly', E_USER_ERROR); 66 } 67 68 $this->setParam($params); 69 69 70 70 $this->_pspell_cfg_handle = pspell_config_create($this->getParam('language')); … … 75 75 if ('' != $this->getParam('personal_wordlist')) { 76 76 if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) { 77 77 App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__); 78 78 } else { 79 79 pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist')); … … 118 118 } 119 119 } 120 120 121 121 /** 122 122 * Check whether any errors have been triggered. … … 136 136 $this->_errors = array(); 137 137 } 138 138 139 139 /** 140 140 * Check one word. … … 156 156 } 157 157 } 158 158 159 159 /** 160 160 * Suggest the correct spelling for one misspelled word. … … 171 171 return pspell_suggest($this->_pspell_handle, $word); 172 172 } 173 173 174 174 /** 175 175 * Add a word to a personal list. … … 186 186 if ($this->_use_personal_wordlist) { 187 187 if (pspell_add_to_personal($this->_pspell_handle, $word)) { 188 189 return true; 190 191 192 193 194 } 195 } 196 188 App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__); 189 return true; 190 } else { 191 App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__); 192 return false; 193 } 194 } 195 } 196 197 197 /** 198 198 * Save personal list to file. … … 217 217 } 218 218 } 219 219 220 220 /** 221 221 * Returns an array of suggested words for each mispelled word in the given text. … … 252 252 } 253 253 } 254 254 255 255 /** 256 256 * Checks all words in a given string. … … 284 284 } 285 285 } 286 286 287 287 /** 288 288 * Returns a given string with misspelled words highlighted. … … 310 310 return join('', $words); 311 311 } 312 312 313 313 /** 314 314 * Prints the HTML for correcting all mispellings found in the text of one $_FORM element. … … 326 326 <input name="<?php echo $form_name ?>" type="hidden" value="<?php echo getFormData($form_name) ?>" /> 327 327 <?php 328 328 329 329 $form_words = $this->getStringSuggestions(getFormData($form_name)); 330 330 if (is_array($form_words) && !empty($form_words)) { … … 337 337 <option value="<?php echo $original_word ?>">(<?php echo $original_word ?>)</option> 338 338 <?php 339 339 340 340 foreach ($words as $suggestion) { 341 341 ?> … … 343 343 <?php 344 344 } 345 345 346 346 ?> 347 347 </select> … … 356 356 } 357 357 } 358 358 359 359 /** 360 360 * Tests if any form spelling corrections have been submitted. … … 370 370 return (false !== getFormData('spelling_suggestions', false)) || (false !== getFormData('spelling_corrections', false)); 371 371 } 372 372 373 373 /** 374 374 * Replace the misspelled words in the text of a specified form with the corrections. -
trunk/lib/TemplateGlue.inc.php
r41 r42 6 6 7 7 /** 8 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set 8 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set 9 9 * environment variable. Files must reside within and be relative to env "DOCUMENT_ROOT". 10 10 * … … 19 19 20 20 /** 21 * Returns an image tag for image specified in $src. 21 * Returns an image tag for image specified in $src. 22 22 * 23 23 * @param string $src File name of the image, including path and file extension. … … 28 28 { 29 29 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 30 30 31 31 if (true === ($gis = @getimagesize($filepath)) && !preg_match('/width|height/', $extra)) { 32 32 $image_size = $gis[3]; … … 34 34 $image_size = ''; 35 35 } 36 36 37 37 return sprintf('<img src="%s" %s alt="%s" %s />', 38 38 $src, … … 44 44 45 45 /** 46 * Prints an image tag for image specified in $src. 46 * Prints an image tag for image specified in $src. 47 47 * 48 48 * @param string $src File name of the image, including path and file extension. … … 58 58 * Finds the values of an enumeration or set column of a MySQL database, returning them in an array. 59 59 * Use this to generate a pull-down menu of options or to validate the existance 60 * of options. (Quinn 10 Feb 2001) 60 * of options. (Quinn 10 Feb 2001) 61 61 * 62 62 * @param string $db_table database table to lookup … … 67 67 { 68 68 $qid = DB::query("SHOW COLUMNS FROM " . addslashes($db_table) . " LIKE '" . addslashes($db_col) . "'",false); 69 69 70 70 $row = mysql_fetch_row($qid); 71 71 if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { … … 79 79 /** 80 80 * Prints option fields for a select form. Works only with enum or set 81 * data types in table columns. 81 * data types in table columns. 82 82 * 83 83 * @param string $db_table database table to lookup … … 134 134 /** 135 135 * Prints checkbox fields. Works only with enum or set 136 * data types in table columns. 136 * data types in table columns. 137 137 * 138 138 * @param string $db_table database table to lookup … … 143 143 */ 144 144 function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null) 145 { 145 { 146 146 ?> 147 147 <table> … … 152 152 $preselected = explode(',', $preselected); 153 153 } 154 154 155 155 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 156 156 // Here we assume in all the values of an array are 'on' that we can find the data … … 160 160 $preselected = array_keys($preselected); 161 161 } 162 163 // Retreive values of a Set or ENUM database column. 162 163 // Retreive values of a Set or ENUM database column. 164 164 $values = getSetEnumFieldValues($db_table, $db_col); 165 165 166 166 // Initialize the HTML table generation vars. 167 167 $num_cells = sizeof($values) - 1; … … 184 184 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 185 185 $col_cnt++; 186 186 187 187 // Look for preselected value. 188 188 if (in_array($v, $preselected)) { … … 212 212 /** 213 213 * Prints radio select fields. Works only with enum or set 214 * data types in table columns. 214 * data types in table columns. 215 215 * 216 216 * @param string $db_table database table to lookup … … 221 221 */ 222 222 function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null) 223 { 223 { 224 224 ?> 225 225 <table> … … 230 230 $preselected = explode(',', $preselected); 231 231 } 232 232 233 233 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 234 234 // Here we assume in all the values of an array are 'on' that we can find the data … … 238 238 $preselected = array_keys($preselected); 239 239 } 240 241 // Retreive values of a Set or ENUM database column. 240 241 // Retreive values of a Set or ENUM database column. 242 242 $values = getSetEnumFieldValues($db_table, $db_col); 243 243 244 244 // Initialize the HTML table generation vars. 245 245 $num_cells = sizeof($values) - 1; … … 262 262 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 263 263 $col_cnt++; 264 264 265 265 // Look for preselected value. 266 266 if (in_array($v, $preselected)) { … … 283 283 284 284 /** 285 * Prints a pulldown menu containing the specified values and keys of a table. 285 * Prints a pulldown menu containing the specified values and keys of a table. 286 286 * 287 287 * @param string $db_table database table to lookup … … 305 305 <?php 306 306 } 307 307 308 308 // When the 'blank' value needs a specific key->val pair. 309 309 if (is_array($blank)) { … … 323 323 /** 324 324 * Prints checkbox fields. Works only with enum or set 325 * data types in table columns. 325 * data types in table columns. 326 326 * 327 327 * @param string $db_table database table to lookup … … 339 339 $preselected = explode(',', $preselected); 340 340 } 341 341 342 342 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 343 343 // Here we assume in all the values of an array are 'on' that we can find the data … … 347 347 $preselected = array_keys($preselected); 348 348 } 349 349 350 350 $qid = DB::query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false); 351 351 while ($row = mysql_fetch_assoc($qid)) { 352 352 $values[] = $row; 353 353 } 354 354 355 355 // Rearrange array so sort is in vertical columns. FIXME: doesn't work. 356 356 // if ($vert_columns) { … … 378 378 return false; 379 379 } 380 380 381 381 // Initialize the HTML table generation vars. 382 382 $num_cells = sizeof($values) - 1; … … 396 396 $row_cnt++; 397 397 } 398 398 399 399 if ($col_cnt < $cols_lastrow) { 400 400 $lastrow_add = $col_cnt; … … 402 402 $lastrow_add = $cols_lastrow; 403 403 } 404 404 405 405 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 406 406 $col_cnt++; 407 407 408 408 // Look for preselected value. 409 409 if (in_array($box[$val_column], $preselected)) { … … 412 412 $checked = ''; 413 413 } 414 414 415 415 // Print a cell with basic named checkboxes. 416 416 $html_name = $val_column . '[' . $box[$val_column] . ']'; … … 420 420 <?php /// FIXME: class=normal? 421 421 } 422 422 423 423 if ($col_cnt < $columns) { 424 424 // This last cell must expand to fill the last blank cells. -
trunk/lib/Upload.inc.php
r41 r42 1 1 <?php 2 2 /** 3 * Upload.inc.php 3 * Upload.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 * … … 22 22 23 23 class Upload { 24 24 25 25 // General object parameters. 26 26 var $_params = array( 27 27 28 28 // Which messages do we pass to raiseMsg? 29 29 'display_messages' => UPLOAD_MSG_ALL, 30 30 31 31 // Existing files will be overwritten when there is a name conflict? 32 32 'allow_overwriting' => false, … … 222 222 'ice' => 'x-conference/x-cooltalk', 223 223 ); 224 224 225 225 /** 226 226 * Set (or overwrite existing) parameters by passing an array of new parameters. … … 232 232 { 233 233 if (isset($params) && is_array($params)) { 234 234 235 235 // Enforce valid upload_path parameter. 236 236 if (isset($params['upload_path'])) { … … 249 249 $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']); 250 250 } 251 251 252 252 // Merge new parameters with old overriding only those passed. 253 253 $this->_params = array_merge($this->_params, $params); … … 276 276 /** 277 277 * Process uploaded files. Processes files existing within the specified $_FILES['form_name'] array. 278 * It tests for errors, cleans the filename, optionally sets custom file names. It will process 278 * It tests for errors, cleans the filename, optionally sets custom file names. It will process 279 279 * multiple files automatically if the file form element is an array (<input type="file" name="myfiles[]" />). 280 280 * … … 296 296 return false; 297 297 } 298 298 299 299 // Ensure the file form element specified actually exists. 300 300 if (!isset($_FILES[$form_name])) { … … 303 303 return false; 304 304 } 305 305 306 306 if (is_array($_FILES[$form_name]['name'])) { 307 307 $files = $_FILES[$form_name]; … … 318 318 319 319 // To keep this script running even if user tries to stop browser. 320 ignore_user_abort(true); 320 ignore_user_abort(true); 321 321 ini_set('max_execution_time', 300); 322 322 ini_set('max_input_time', 300); … … 332 332 continue; 333 333 } 334 334 335 335 // Determine final file name. 336 336 if ($num == 1) { … … 362 362 // Clean the file name of bad characters. 363 363 $file_name = $this->cleanFileName($file_name); 364 364 365 365 // If the file name has no extension, use the mime-type extension. 366 366 if (!preg_match('/\.[^.]{1,5}$/', $file_name) && function_exists('mime_content_type')) { … … 369 369 } 370 370 } 371 371 372 372 // Set the path and file name. 373 373 $file_path_name = $this->getParam('upload_path') . '/' . $file_name; 374 375 374 375 376 376 // Check The php upload error messages. 377 377 if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) { … … 407 407 continue; 408 408 } 409 409 410 410 // Check to be sure it's an uploaded file. 411 411 if (!is_uploaded_file($files['tmp_name'][$i])) { … … 415 415 continue; 416 416 } 417 417 418 418 // Check to be sure the file is not empty. 419 419 if ($files['size'][$i] < 1) { … … 423 423 continue; 424 424 } 425 425 426 426 // Check to be sure the file has a valid file name extension. 427 427 if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) { … … 431 431 continue; 432 432 } 433 433 434 434 // Check to be sure the file has a unique file name. 435 435 if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) { … … 439 439 continue; 440 440 } 441 441 442 442 // Move the file to the final place. 443 443 if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) { … … 462 462 } 463 463 } 464 464 465 465 // Return names of files uploaded (or empty array when none processed). 466 466 return $new_file_names; 467 467 } 468 468 469 469 /** 470 470 * Remove file within upload path. … … 481 481 return false; 482 482 } 483 483 484 484 $file_path_name = $this->getParam('upload_path') . '/' . $file_name; 485 485 … … 495 495 } 496 496 } 497 497 498 498 /** 499 499 * Renames a file within the upload path. … … 511 511 return false; 512 512 } 513 513 514 514 $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name; 515 515 $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name; … … 529 529 } 530 530 } 531 531 532 532 /** 533 533 * Tests if a file exists within the current upload_path. … … 544 544 return false; 545 545 } 546 546 547 547 return file_exists($this->getParam('upload_path') . '/' . $file_name); 548 548 } 549 549 550 550 /** 551 * Get filename by glob pattern. Searches a directory for an image that matches the 551 * Get filename by glob pattern. Searches a directory for an image that matches the 552 552 * specified glob pattern and returns the filename of the first file found. 553 553 * … … 620 620 return isset($ext[1]) ? $ext[1] : ''; 621 621 } 622 622 623 623 /** 624 624 * An alias for App::raiseMsg that only sends messages configured by display_messages. -
trunk/lib/Utilities.inc.php
r41 r42 64 64 65 65 /** 66 * Returns text with appropriate html translations. 66 * Returns text with appropriate html translations. 67 67 * 68 68 * @param string $txt Text to clean. 69 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 69 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 70 70 * characters into HTML entities. This allows HTML to pass 71 71 * through unmunged. … … 85 85 $search['retain_left_angle'] = '/</'; 86 86 $replace['retain_left_angle'] = '<'; 87 87 88 88 $search['retain_right_angle'] = '/>/'; 89 89 $replace['retain_right_angle'] = '>'; 90 90 91 91 $search['retain_single_quote'] = '/'/'; 92 92 $replace['retain_single_quote'] = "'"; 93 93 94 94 $search['retain_double_quote'] = '/"/'; 95 95 $replace['retain_double_quote'] = '"'; … … 104 104 105 105 /** 106 * Returns text with stylistic modifications. 106 * Returns text with stylistic modifications. 107 107 * 108 108 * @param string $txt Text to clean. … … 125 125 $search['single_quotes'] = '/(^|[^\w=])(?:\'|'|‘)([^\']+?)(?:\'|'|’)([^\w]|$)/'; 126 126 $replace['single_quotes'] = '\\1‘\\2’\\3'; 127 127 128 128 // em--dashes become em—dashes 129 129 $search['em_dash'] = '/(\s*[^!<-])--([^>-]\s*)/'; … … 133 133 } 134 134 135 135 136 136 /** 137 137 * Generates a hexadecibal html color based on provided word. … … 159 159 } 160 160 break; 161 161 162 162 case 1 : 163 163 default : … … 219 219 $units = array('B', 'KB', 'MB', 'GB', 'TB'); 220 220 $ii = count($units) - 1; 221 221 222 222 // Max unit 223 223 $unit = array_search((string) $unit, $units); … … 225 225 $unit = $ii; 226 226 } 227 227 228 228 // Loop 229 229 $i = 0; … … 232 232 $i++; 233 233 } 234 234 235 235 return sprintf($format, $size, $units[$i]); 236 236 } … … 264 264 * @param mixed $var The variable that is being set. 265 265 * @param mixed $default What to set it to if $val is not currently set. 266 * @return mixed The resulting value of $var. 266 * @return mixed The resulting value of $var. 267 267 */ 268 268 function setDefault(&$var, $default='') … … 307 307 */ 308 308 function urlEncodeArray($data, $prefix='', $_return=true) { 309 309 310 310 // Data is stored in static variable. 311 311 static $args; 312 312 313 313 if (is_array($data)) { 314 314 foreach ($data as $key => $val) { … … 323 323 $args[$prefix] = urlencode($data); 324 324 } 325 325 326 326 if ($_return) { 327 327 // This is not a recursive execution. All recursion is complete. … … 343 343 */ 344 344 function urlEncodeArrayToString($data, $prefix='') { 345 345 346 346 $array_args = urlEncodeArray($data, $prefix); 347 347 $url_args = ''; … … 378 378 * Prints the word "checked" if a variable is set, and optionally matches 379 379 * the desired value, otherwise prints nothing, 380 * used for printing the word "checked" in a checkbox form input. 380 * used for printing the word "checked" in a checkbox form input. 381 381 * 382 382 * @param mixed $var the variable to compare … … 404 404 * prints the word "selected" if a variable is set, and optionally matches 405 405 * the desired value, otherwise prints nothing, 406 * otherwise prints nothing, used for printing the word "checked" in a 407 * select form input 406 * otherwise prints nothing, used for printing the word "checked" in a 407 * select form input 408 408 * 409 409 * @param mixed $var the variable to compare … … 450 450 * 451 451 * @param array $date String date to convert. 452 * @param array $format Date format to pass to date(). 452 * @param array $format Date format to pass to date(). 453 453 * Default produces MySQL datetime: 0000-00-00 00:00:00. 454 454 * @return string SQL-safe date. … … 462 462 $sql_date = date($format, strtotime($date)); 463 463 } 464 464 465 465 return $sql_date; 466 466 } … … 477 477 { 478 478 static $magic_quotes_gpc; 479 479 480 480 if (!isset($magic_quotes_gpc)) { 481 481 $magic_quotes_gpc = get_magic_quotes_gpc(); 482 482 } 483 483 484 484 if ($magic_quotes_gpc) { 485 485 if (!is_array($var)) { … … 562 562 App::logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__); 563 563 } 564 564 565 565 if (!isset($seed_key)) { 566 566 $seed_key = App::getParam('signing_key'); … … 606 606 /** 607 607 * Sends empty output to the browser and flushes the php buffer so the client 608 * will see data before the page is finished processing. 608 * will see data before the page is finished processing. 609 609 */ 610 610 function flushBuffer() { … … 682 682 { 683 683 static $urls = array(); 684 684 685 685 if (!isset($urls[$url])) { 686 686 if (!preg_match('|\w{1,}\.\w{2,5}/|', $url)) { … … 695 695 696 696 /** 697 * Takes a URL and returns it without the query or anchor portion 697 * Takes a URL and returns it without the query or anchor portion 698 698 * 699 699 * @param string $url any kind of URI … … 706 706 707 707 /** 708 * Returns the remote IP address, taking into consideration proxy servers. 708 * Returns the remote IP address, taking into consideration proxy servers. 709 709 * 710 710 * @param bool $dolookup If true we resolve to IP to a host name, … … 740 740 $networks = array($networks); 741 741 } 742 742 743 743 $ip_binary = sprintf('%032b', ip2long($ip)); 744 744 foreach ($networks as $network) { … … 758 758 } 759 759 } 760 760 761 761 return false; 762 762 } 763 763 764 764 /** 765 * Returns a fully qualified URL to the current script, including the query. 765 * Returns a fully qualified URL to the current script, including the query. 766 766 * 767 767 * @return string a full url to the current script … … 796 796 /** 797 797 * Translates text 798 * 798 * 799 799 * @access public 800 800 * @param string $text the text to be translated … … 804 804 return $text; 805 805 } 806 806 807 807 /** 808 808 * Translates text 809 * 809 * 810 810 * @access public 811 811 * @param string $text the text to be translated … … 815 815 return $text; 816 816 } 817 817 818 818 /** 819 819 * Translates text by domain 820 * 820 * 821 821 * @access public 822 822 * @param string $domain the language to translate the text into … … 827 827 return $text; 828 828 } 829 829 830 830 /** 831 831 * Translates text by domain and category 832 * 832 * 833 833 * @access public 834 834 * @param string $domain the language to translate the text into … … 840 840 return $text; 841 841 } 842 842 843 843 /** 844 844 * Binds the text domain 845 * 845 * 846 846 * @access public 847 847 * @param string $domain the language to translate the text into 848 * @param string 848 * @param string 849 849 * @return string translated text 850 850 */ … … 852 852 return $domain; 853 853 } 854 854 855 855 /** 856 856 * Sets the text domain 857 * 857 * 858 858 * @access public 859 859 * @param string $domain the language to translate the text into -
trunk/services/admins.php
r41 r42 1 1 <?php 2 2 /** 3 * admins.php 3 * admins.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 23 23 * CONFIG 24 24 *****************************************************************************/ 25 25 26 26 // Titles and navigation header. 27 27 $nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']); 28 28 29 29 // The object to validate form input. 30 30 $fv = new FormValidator(); … … 60 60 * MAIN 61 61 *****************************************************************************/ 62 62 63 63 // We may want to use the add/edit interface from another script, so this 64 64 // allows us to remember which page we came from so we can go back there. … … 208 208 $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank.")); 209 209 $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters.")); 210 210 211 211 $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank.")); 212 212 $fv->stringLength('userpass', 6, 36, _("<strong>Passwords</strong> must be between 6 and 36 characters long.")); 213 213 214 214 $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters.")); 215 215 216 216 $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters.")); 217 217 … … 219 219 $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters.")); 220 220 $fv->validateEmail('email'); 221 221 222 222 $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank.")); 223 223 $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection.")); … … 265 265 // Get the information for the form. 266 266 $qid = DB::query(" 267 SELECT * 267 SELECT * 268 268 FROM admin_tbl 269 269 WHERE admin_id = '" . addslashes($id) . "' … … 274 274 App::dieBoomerangURL(); 275 275 } 276 276 277 277 // Lock this record. 278 278 $lock->set('admin_tbl', 'admin_id', $id, $frm['username']); 279 279 280 280 // Set misc values for the form. 281 281 $frm = array_merge(array( … … 312 312 { 313 313 global $auth, $lock; 314 314 315 315 $lock->select('admin_tbl', 'admin_id', $id); 316 316 if ($lock->isLocked() && !$lock->isMine()) { … … 320 320 // Break the cache because we are changing the list data. 321 321 SessionCache::breakCache($_SERVER['PHP_SELF']); 322 322 323 323 // Get the information for this object. 324 324 $qid = DB::query(" … … 331 331 App::dieBoomerangURL(); 332 332 } 333 333 334 334 // Get the information for this object. 335 335 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); … … 357 357 { 358 358 global $auth; 359 359 360 360 // Break the cache because we are changing the list data. 361 361 SessionCache::breakCache($_SERVER['PHP_SELF']); 362 362 363 363 // Insert record data. 364 364 DB::query(" … … 382 382 "); 383 383 $last_insert_id = mysql_insert_id(DB::getDBH()); 384 384 385 385 // Set admin password. 386 386 $auth->setPassword($last_insert_id, $frm['userpass']); 387 387 388 388 // Create version. 389 389 $version = RecordVersion::getInstance($GLOBALS['auth']); 390 390 $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']); 391 391 392 392 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 393 393 394 394 return $last_insert_id; 395 395 } … … 398 398 { 399 399 global $auth, $lock; 400 400 401 401 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); 402 402 if ($lock->isLocked() && !$lock->isMine()) { … … 406 406 // Break the cache because we are changing the list data. 407 407 SessionCache::breakCache($_SERVER['PHP_SELF']); 408 408 409 409 // If the userpass is left blank or with the filler **** characters, we don't want to update it. 410 410 if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) { … … 412 412 $auth->setPassword($frm['admin_id'], $frm['userpass']); 413 413 } 414 414 415 415 // Update record data. 416 416 DB::query(" … … 440 440 global $page; 441 441 global $so; 442 442 443 443 $where_clause = ''; 444 444 445 445 // Build search query if available. 446 446 if (getFormData('search_query', false)) { … … 460 460 // Count the total number of records so we can do something about the page numbers. 461 461 $qid = DB::query(" 462 SELECT COUNT(*) 463 FROM admin_tbl 462 SELECT COUNT(*) 463 FROM admin_tbl 464 464 $where_clause 465 465 "); 466 466 list($num_results) = mysql_fetch_row($qid); 467 467 468 468 // Set page numbers now we know (needed for next step). 469 469 $page->setTotalItems($num_results); 470 470 $page->calculate(); 471 471 472 472 // Final SQL, with sort and page limiters. 473 473 $sql = " 474 SELECT 475 admin_tbl.*, 474 SELECT 475 admin_tbl.*, 476 476 a1.username AS added_admin_username, 477 477 a2.username AS modified_admin_username … … 483 483 " . $page->getLimitSQL() . " 484 484 "; 485 485 486 486 // A unique key for this query, with the total_items in case db records 487 487 // were added since the last cache. This identifies a unique set of … … 494 494 Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 495 495 } 496 496 497 497 if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) { 498 498 // Get the cached results. … … 505 505 $list[] = $row; 506 506 } 507 507 508 508 if (isset($list) && !empty($list)) { 509 509 // Cache the results. -
trunk/services/css.php
r41 r42 1 1 <?php 2 2 /** 3 * css.php 3 * css.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 * -
trunk/services/lock.php
r41 r42 1 1 <?php 2 2 /** 3 * lock.php 3 * lock.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ -
trunk/services/login.php
r41 r42 1 1 <?php 2 2 /** 3 * login.php 3 * login.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 24 24 } else { 25 25 App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__); 26 App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', $auth->getVal('auth_name'), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);26 App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__); 27 27 } 28 28 } -
trunk/services/logout.php
r41 r42 1 1 <?php 2 2 /** 3 * logout.php 3 * logout.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ -
trunk/services/logs.php
r41 r42 1 1 <?php 2 2 /** 3 * logs.php 3 * logs.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 48 48 * MAIN 49 49 *****************************************************************************/ 50 50 51 51 // Allow realtime file stats. 52 clearstatcache(); 52 clearstatcache(); 53 53 54 54 // What action to take. … … 65 65 App::dieURL($_SERVER['PHP_SELF']); 66 66 break; 67 67 68 68 case 'clear' : 69 69 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); … … 76 76 App::dieURL($_SERVER['PHP_SELF']); 77 77 break; 78 78 79 79 case 'archive' : 80 80 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); … … 90 90 App::dieURL($_SERVER['PHP_SELF']); 91 91 break; 92 92 93 93 // case 'ouput' : 94 94 // $main_template = 'ouput'; 95 95 // break; 96 96 97 97 case 'download' : 98 98 header('Content-Type: application/octet-stream'); … … 101 101 die; 102 102 break; 103 103 104 104 default : 105 105 $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query')); … … 137 137 138 138 function deleteLog($log_file) 139 { 139 { 140 140 if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) { 141 141 App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 143 143 return false; 144 144 } 145 145 146 146 if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) { 147 147 App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 149 149 return false; 150 150 } 151 151 152 152 if (unlink(App::getParam('log_directory') . '/' . $log_file)) { 153 153 App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 162 162 163 163 function clearLog($log_file) 164 { 164 { 165 165 if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) { 166 166 App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 168 168 return false; 169 169 } 170 170 171 171 flock($fp, LOCK_EX); 172 172 $ftruncate_return = ftruncate($fp, 0); … … 185 185 186 186 function archiveLog($log_file) 187 { 187 { 188 188 $old_file_name = $log_file; 189 189 $new_file_name = $log_file . '__' . date('Y-m-d'); … … 198 198 return false; 199 199 } 200 200 201 201 App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__); 202 202 App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__); … … 205 205 206 206 function printLog($log_file) 207 { 207 { 208 208 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 209 209 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); … … 216 216 217 217 function &getLog($log_file, $search_query='') 218 { 218 { 219 219 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 220 220 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); … … 223 223 } 224 224 $log = file(App::getParam('log_directory') . '/' . $log_file); 225 225 226 226 if ('' != trim($search_query)) { 227 227 if (getFormData('search_grep')) { … … 237 237 { 238 238 global $valid_file_extensions; 239 239 240 240 // Get a list of all files in the log directory. 241 241 $dir_handle = opendir(App::getParam('log_directory')); -
trunk/services/password.php
r41 r42 1 1 <?php 2 2 /** 3 * password.php 3 * password.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 14 14 * CODE CONFIG 15 15 *****************************************************************************/ 16 16 17 17 // Titles and navigation header. 18 18 $nav->addPage(_("Change password")); … … 47 47 } 48 48 } 49 49 50 50 if (!$fv->anyErrors() && false === $auth->authenticate($auth->getVal('username'), $frm['oldpassword'])) { 51 51 $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication.")); -
trunk/services/templates/admin_list.ihtml
r41 r42 6 6 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span> 7 7 <br /> 8 8 9 9 <input type="text" class="small" 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.")); ?>" /> 10 10 <input type="submit" value="<?php echo _("Search"); ?>" /> -
trunk/services/templates/list_info.ihtml
r41 r42 4 4 <?php } ?> 5 5 <span class="nowrap commanditem commandtext"> 6 <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?> 6 <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?> 7 7 <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a> 8 8 <?php echo _("Per page"); ?>: <?php $page->printPerPageLinks() ?> -
trunk/services/templates/lock.ihtml
r41 r42 1 <?php 1 <?php 2 2 if (!is_a($lock, 'RecordLock')) { 3 3 return null; … … 9 9 10 10 <p><?php 11 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 12 $lock->getTitle(), 13 $lock->getEditor(), 11 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 12 $lock->getTitle(), 13 $lock->getEditor(), 14 14 date('i', $lock->getSecondsElapsed() + 60) 15 15 ); -
trunk/services/templates/versions_diff.ihtml
r41 r42 1 <div id="commandbox"> 1 <div id="commandbox"> 2 2 <?php if (!getFormData('current', false)) { ?> 3 3 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span> -
trunk/services/templates/versions_list.ihtml
r41 r42 9 9 <th class="padleft"><?php echo _("By"); ?></th> 10 10 </tr> 11 <?php 11 <?php 12 12 $first = true; 13 13 foreach ($versions as $v) { ?> … … 25 25 <td class="padleft nowrap"><?php echo $v['editor']; ?></td> 26 26 </tr> 27 <?php 27 <?php 28 28 $first = false; 29 } 29 } 30 30 ?> 31 31 </table> -
trunk/services/templates/versions_view.ihtml
r41 r42 1 <div id="commandbox"> 1 <div id="commandbox"> 2 2 <?php if (!getFormData('current', false)) { ?> 3 3 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span> … … 10 10 <table class="list" border="0" cellspacing="0" cellpadding="4"> 11 11 <?php 12 while ((list($k, $v_d) = each($data))) { 12 while ((list($k, $v_d) = each($data))) { 13 13 ?> 14 14 <tr> -
trunk/services/versions.php
r41 r42 1 1 <?php 2 2 /** 3 * versions.php 3 * versions.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 110 110 * TEMPLATE INITIALIZATION 111 111 *****************************************************************************/ 112 112 113 113 include 'header.ihtml'; 114 114 include 'codebase/services/templates/' . $main_template; -
trunk/tests/AppTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for App 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 124 124 // App::dieURL('/die/to/this/url.php'); 125 125 // } 126 // 126 // 127 127 // function test_dieboomerangurl() 128 128 // { … … 131 131 // $this->assertEquals($expected, $result); 132 132 // } 133 // 133 // 134 134 // function test_setboomerangurl() 135 135 // { … … 138 138 // $this->assertEquals($expected, $result); 139 139 // } 140 // 140 // 141 141 // function test_getboomerangurl() 142 142 // { … … 145 145 // $this->assertEquals($expected, $result); 146 146 // } 147 // 147 // 148 148 // function test_deleteboomerangurl() 149 149 // { … … 152 152 // $this->assertEquals($expected, $result); 153 153 // } 154 // 154 // 155 155 // function test_validboomerangurl() 156 156 // { … … 159 159 // $this->assertEquals($expected, $result); 160 160 // } 161 // 161 // 162 162 // function test_sslon() 163 163 // { … … 166 166 // $this->assertEquals($expected, $result); 167 167 // } 168 // 168 // 169 169 // function test_ssloff() 170 170 // { -
trunk/tests/Auth_FileTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for Auth_File 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 71 71 // $this->assertTrue($true); 72 72 // } 73 // 73 // 74 74 // function test_requireadminlogin() 75 75 // { … … 78 78 // $this->assertEquals($expected, $result); 79 79 // } 80 // 80 // 81 81 // function test__encrypt() 82 82 // { … … 85 85 // $this->assertEquals($expected, $result); 86 86 // } 87 // 87 // 88 88 // function test__salt() 89 89 // { -
trunk/tests/Auth_SQLTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for Auth_SQL 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 53 53 ) 54 54 "); 55 55 56 56 } 57 57 … … 212 212 // $this->assertEquals($expected, $result); 213 213 // } 214 // 214 // 215 215 // function test_requireaccessclearance() 216 216 // { -
trunk/tests/AuthorizeNetTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for AuthorizeNet 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 63 63 { 64 64 $result_code = $this->AuthorizeNet->process(); 65 65 66 66 $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?'); 67 67 $this->assertEquals('3', $result_code); … … 89 89 // $this->assertEquals($expected, $result); 90 90 // } 91 // 91 // 92 92 // function test__processresult() 93 93 // { -
trunk/tests/CSSTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for CSS 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ -
trunk/tests/DBSessionHandlerTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for DBSessionHandler 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ -
trunk/tests/EmailTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for Email 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-12-01 10 10 */ … … 37 37 // $this->assertEquals($expected, $result); 38 38 // } 39 // 39 // 40 40 // function testgetparam() 41 41 // { … … 44 44 // $this->assertEquals($expected, $result); 45 45 // } 46 // 46 // 47 47 // function testsettemplate() 48 48 // { … … 51 51 // $this->assertEquals($expected, $result); 52 52 // } 53 // 53 // 54 54 // function testsetstring() 55 55 // { … … 58 58 // $this->assertEquals($expected, $result); 59 59 // } 60 // 60 // 61 61 // function testreplace() 62 62 // { … … 65 65 // $this->assertEquals($expected, $result); 66 66 // } 67 // 67 // 68 68 // function testsend() 69 69 // { … … 76 76 { 77 77 $testpool = file('_email_test_addresses.txt'); 78 78 79 79 $gc = 0; 80 80 $bc = 0; -
trunk/tests/FormValidatorTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for FormValidator 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ -
trunk/tests/Google_APITest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for GoogleAPI 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/ImageThumbTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for ImageThumb 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/MCVETest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for MCVE 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/NavTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for Nav 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/NodeHeirarchyTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for NodeHeirarchy 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/PEditTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for PEdit 7 * 8 * T\he method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * T\he method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/PageNumbersTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for PageNumbers 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/PageSequenceTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for PageSequence 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/PayPalTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for PayPal 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 101 101 // $result = $this->PayPal->incomingipnrequest(); 102 102 // } 103 // 103 // 104 104 // function test_processipn() 105 105 // { 106 106 // $result = $this->PayPal->processipn(); 107 107 // } 108 // 108 // 109 109 // function test_verifiedipn() 110 110 // { -
trunk/tests/PrefsTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for Prefs 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/RecordLockTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for RecordLock 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ -
trunk/tests/RecordVersionTest.php
r41 r42 2 2 /** 3 3 * PHPUnit test case for RecordVersion 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 4 * 5 * The method skeletons below need to be filled in with 6 * real data so that the tests will run correctly. Replace 7 * all EXPECTED_VAL and PARAM strings with real data. 8 * 9 9 * Created with PHPUnit_Skeleton on 2005-08-09 10 10 */ … … 37 37 // Use fresh user table. 38 38 $this->Auth_SQL->initDB(true); 39 39 40 40 // Insert test data. 41 41 DB::query(" … … 56 56 ) 57 57 "); 58 58 59 59 $this->Auth_SQL->login('testuser', 'testpass'); 60 60 61 61 $this->RecordVersion =& RecordVersion::getInstance($this->Auth_SQL); 62 62 $this->RecordVersion->setParam(array('db_table' => 'test_version_tbl')); -
trunk/tests/ScriptTimerTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for ScriptTimer 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/SessionCacheTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for SessionCache 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/SortOrderTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for SortOrder 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/SpellCheckTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for SpellCheck 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/TemplateGlueTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for TemplateGlue 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/UploadTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for Upload 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/UtilitiesTest.php
r41 r42 5 5 /** 6 6 * PHPUnit test case for Utilities 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 7 * 8 * The method skeletons below need to be filled in with 9 * real data so that the tests will run correctly. Replace 10 * all EXPECTED_VAL and PARAM strings with real data. 11 * 12 12 * Created with PHPUnit_Skeleton on 2005-08-09 13 13 */ -
trunk/tests/_email_test_addresses.txt
r41 r42 4 4 "Bob Smith" asdf@domain.com 5 5 "Bob Smith"a sldkf &D*&F^*&^# @#*$ @#* asdf@domain.com 6 "white space" <asdf@domain.com> 7 whitespace@domain.com 6 "white space" <asdf@domain.com> 7 whitespace@domain.com 8 8 asdf@domain.com (hello donkey) 9 9 <asdf@domain.com> -
trunk/tests/_skel.php
r41 r42 39 39 // if (!preg_match('/^\./', $file) && is_file($dir . '/' . $file)) { 40 40 // echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n"; 41 // 41 // 42 42 // preg_match('/([^\.]+)\..*$/i', $file, $match); 43 43 // $classname = $match[1]; 44 // 44 // 45 45 // $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file); 46 // 46 // 47 47 // // Generate the test class. 48 48 // // Default settings will not include any parent class methods, but 49 49 // // will include private methods. 50 50 // $ps->createTestClass(); 51 // 51 // 52 52 // // Write the new test class to file. 53 53 // // By default, code to run the test will be included. 54 54 // $ps->writeTestClass(); 55 // 55 // 56 56 // } 57 57 // }
Note: See TracChangeset
for help on using the changeset viewer.