Changeset 906
- Timestamp:
- 09/23/07 03:51:17 (14 months ago)
- Location:
- trunk/htdocs/system
- Files:
-
- 6 modified
-
admin/dashboard.php (modified) (1 diff)
-
admin/logs.php (modified) (1 diff)
-
classes/adminhandler.php (modified) (1 diff)
-
classes/eventlog.php (modified) (2 diffs)
-
classes/logentry.php (modified) (5 diffs)
-
classes/utils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htdocs/system/admin/dashboard.php
r868 r906 81 81 <h3><?php _e( 'Site Statistics' ); ?></h3> 82 82 <table id="site-stats" width="100%" cellspacing="0"> 83 <tr><td><?php _e( 'Total Posts' ); ?></td><td><?php echo Posts::count_total( Post::status( 'a ll' ) ); ?></td></tr>83 <tr><td><?php _e( 'Total Posts' ); ?></td><td><?php echo Posts::count_total( Post::status( 'any' ) ); ?></td></tr> 84 84 <tr><td><?php _e( 'Number of Your Posts' ); ?></td><td><?php echo Posts::count_by_author( User::identify()->id, Post::status( 'all' ) ); ?></td></tr> 85 85 <tr><td><?php _e( 'Number of Comments' ); ?></td><td><?php echo Comments::count_total(); ?></td></tr> -
trunk/htdocs/system/admin/logs.php
r867 r906 8 8 </div> 9 9 <div class="dashboard-block c3" id="log-activity"> 10 <form method="post" action="<?php URL::out('admin', 'page=logs'); ?>" class="buttonform"> 11 <p>Search log entries: 12 <input type="textbox" size="50" name='search' value="<?php echo $search; ?>"> <input type="submit" name="do_search" value="<?php _e('Search'); ?>"> 13 <?php printf( _t('Limit: %s'), Utils::html_select('limit', $limits, $limit)); ?> 14 <?php printf( _t('Page: %s'), Utils::html_select('index', $pages, $index)); ?> 15 <a href="<?php URL::out('admin', 'page=logs'); ?>">Reset</a> 16 </p> 10 17 <table id="log-activity-table" width="100%" cellspacing="0"> 11 18 <thead> 12 19 <tr> 20 <th></th> 13 21 <th align="left">Date</th> 14 22 <th align="left">User</th> 15 23 <th align="left">Type</th> 24 <th align="center">Severity</th> 16 25 <th align="left">Message</th> 17 <th align="center">Severity</th>18 26 </tr> 19 27 </thead> 20 <?php foreach( eventlog::get( array( 'nolimit' => true ) ) as $log ){ ?>21 28 <tr> 29 <td></td> 30 <td><?php echo Utils::html_select('date', $dates, $date); ?></td> 31 <td><?php echo Utils::html_select('user', $users, $user); ?></td> 32 <td><?php echo Utils::html_select('type', $types, $type); ?></td> 33 <td><?php echo Utils::html_select('severity', $severities, $severity); ?></td> 34 <td align="right"><input type="submit" name="filter" value="<?php _e('Filter'); ?>"></td> 35 </tr> 36 <?php foreach( $logs as $log ){ ?> 37 <tr> 38 <td align="center"><input type="checkbox" name="log_ids[]" value="<?php echo $log->id; ?>"></td> 22 39 <td><?php echo $log->timestamp; ?></td> 23 40 <td><?php if ( $log->user_id ) { $user= User::get_by_id( $log->user_id ); echo $user->username; } ?></td> 24 41 <td><?php echo $log->type; ?></td> 42 <td><?php echo $log->severity; ?></td> 25 43 <td><p><?php echo $log->message; ?></p></td> 26 <td><?php echo $log->severity; ?></td>27 44 </tr> 28 45 <?php } ?> 46 <tr><td colspan="6"> 47 <input type="hidden" name="nonce" value="<?php echo $wsse['nonce']; ?>"> 48 <input type="hidden" name="timestamp" value="<?php echo $wsse['timestamp']; ?>"> 49 <input type="hidden" name="PasswordDigest" value="<?php echo $wsse['digest']; ?>"> 50 <input type="submit" name="do_delete" value="<?php _e('Delete'); ?>"> 29 51 </table> 30 52 </div> -
trunk/htdocs/system/classes/adminhandler.php
r900 r906 542 542 } 543 543 544 public function get_logs() 545 { 546 $this->post_logs(); 547 } 548 549 public function post_logs() 550 { 551 $locals= array( 552 'do_update' => false, 553 'log_ids' => null, 554 'nonce' => '', 555 'timestamp' => '', 556 'PasswordDigest' => '', 557 'change' => '', 558 'limit' => 20, 559 'user' => 0, 560 'date' => 'any', 561 'type' => 'any', 562 'severity' => 'any', 563 'search' => '', 564 'do_search' => false, 565 'index' => 1, 566 ); 567 foreach ( $locals as $varname => $default ) { 568 $$varname= isset($this->handler_vars[$varname]) ? $this->handler_vars[$varname] : $default; 569 $this->theme->{$varname}= $$varname; 570 } 571 $this->theme->severities= LogEntry::list_severities(); 572 $types= array( 0 => 'Any'); 573 $this->theme->types= array_merge( $types, LogEntry::list_types() ); 574 575 // set up the users 576 $users_temp= DB::get_results( 'SELECT username, user_id FROM ' . DB::table('users') . ' JOIN ' . DB::table('log') . ' ON ' . DB::table('users') . '.id=' . DB::table('log') . '.user_id GROUP BY user_id ORDER BY username ASC'); 577 array_unshift( $users_temp, new QueryRecord(array('username' => 'All', 'user_id' => 0))); 578 foreach ($users_temp as $user) { 579 $users[$user->user_id]= $user->username; 580 } 581 $this->theme->users= $users; 582 583 // set up dates. 584 $dates= DB::get_column("SELECT DATE_FORMAT(timestamp, '%Y-%m') FROM " . DB::table('log') . ' ORDER BY timestamp DESC'); 585 array_unshift( $dates, 'Any'); 586 $dates= array_combine( $dates, $dates ); 587 $this->theme->dates= $dates; 588 589 // set up the limit select box 590 $limits= array( 5, 10, 20, 50, 100 ); 591 $limits= array_combine( $limits, $limits ); 592 $this->theme->limits= $limits; 593 594 // prepare the WSSE tokens 595 $this->theme->wsse= Utils::WSSE(); 596 597 $arguments= array( 598 'type' => $type, 599 'severity' => LogEntry::severity($severity), 600 'limit' => $limit, 601 'offset' => ( $index - 1) * $limit, 602 ); 603 if ( 'any' != strtolower($date) ) { 604 list($arguments['year'], $arguments['month'])= explode( '-', $date ); 605 } 606 if ( '' != $search ) { 607 $arguments['criteria']= $search; 608 } 609 $this->theme->logs= EventLog::get( $arguments ); 610 611 // get the page count 612 $arguments['count']= 'id'; 613 unset($arguments['limit']); 614 unset($arguments['offset']); 615 $totalpages= EventLog::get( $arguments ); 616 $pagecount= ceil( $totalpages / $limit ); 617 618 // put the page numbers into an array 619 $pages= array(); 620 for ( $z= 1; $z <= $pagecount; $z++ ) { 621 $pages[$z]= $z; 622 } 623 $this->theme->pagecount= $pagecount; 624 $this->theme->pages= $pages; 625 626 $this->display( 'logs' ); 627 } 628 544 629 /** 545 630 * Assembles the main menu for the admin area. -
trunk/htdocs/system/classes/eventlog.php
r820 r906 54 54 DB::query( 'DELETE FROM ' . DB::Table('log_types') . ' WHERE module = ? AND type = ?', array( self::get_module($module), $type ) ); 55 55 } 56 56 57 57 /** 58 58 * Write an entry to the event log. … … 162 162 $params[]= $paramset['user_id']; 163 163 } 164 if ( isset( $paramset['severity'] ) ) {165 $where[]= "severity = ?";166 $params[]= $paramset['severity'];164 if ( isset( $paramset['severity'] ) && ( 'any' != LogEntry::severity_name($paramset['severity']) ) ) { 165 $where[]= "severity_id= ?"; 166 $params[]= LogEntry::severity($paramset['severity']); 167 167 } 168 168 if ( isset( $paramset['type_id'] ) ) { 169 169 $where[]= "type_id= ?"; 170 170 $params[]= $paramset['type_id']; 171 } 172 173 /* do searching */ 174 if ( isset( $paramset['criteria'] ) ) { 175 preg_match_all( '/(?<=")(\\w[^"]*)(?=")|(\\w+)/', $paramset['criteria'], $matches ); 176 foreach ( $matches[0] as $word ) { 177 $where[] .= "(message LIKE CONCAT('%',?,'%'))"; 178 $params[] = $word; 179 } 171 180 } 172 181 -
trunk/htdocs/system/classes/logentry.php
r830 r906 17 17 */ 18 18 private static $severities= array( 19 'any', 19 20 'none', // should not be used 20 21 'debug', 'info', 'notice', 'warning', 'err', 'crit', 'alert', 'emerg', … … 70 71 71 72 /** 72 * Returns an associative array of posttypes73 * Returns an associative array of LogEntry types 73 74 * 74 75 * @param bool whether to force a refresh of the cached values … … 85 86 } 86 87 return self::$types; 87 } 88 } 89 90 /** 91 * Return an array of Severities 92 * @return array An array of severity ID => name pairs 93 **/ 94 public static function list_severities() 95 { 96 foreach ( self::$severities as $id => $name ) { 97 if ( 'none' == $name ) { 98 continue; 99 } 100 $results[$id]= $name; 101 } 102 return $results; 103 } 104 105 /** 106 * Returns an array of LogEntry modules 107 * @param bool Whether to refresh the cached values 108 * @return array An array of LogEntry module id => name pairs 109 **/ 110 public static function list_modules( $refresh= false ) 111 { 112 $types= self::list_logentry_types( $refresh ); 113 foreach ($types as $module => $types) { 114 $modules[]= $module; 115 } 116 } 117 118 /** 119 * Returns an array of LogEntry types 120 * @param bool Whether to refresh the cached values 121 * @return array An array of LogEntry id => name pairs 122 **/ 123 public static function list_types( $refresh= false ) 124 { 125 $types= array(); 126 $matrix= self::list_logentry_types( $refresh ); 127 foreach ($matrix as $module => $module_types) { 128 $types= array_merge($types, $module_types); 129 } 130 return array_flip($types); 131 } 88 132 89 133 /** … … 102 146 103 147 /** 104 * Get the string representation of t ehseverity numeric value.148 * Get the string representation of the severity numeric value. 105 149 * 106 150 * @param integer $severity The severity index. … … 251 295 252 296 /** 253 * Overrides QueryRecord __ get to implement custom object properties297 * Overrides QueryRecord __set to implement custom object properties 254 298 * 255 299 * @param string Name of property to return -
trunk/htdocs/system/classes/utils.php
r905 r906 690 690 } 691 691 // if the string is less than the length specified, bail out 692 if ( strlen($str) <= $len ) {692 if ( iconv_strlen($str) <= $len ) { 693 693 return $str; 694 694 } … … 699 699 $len = round(($len-3)/2); 700 700 // and place an ellipse in between the pieces 701 return substr($str, 0, $len) . '...' . substr($str, -$len);701 return iconv_substr($str, 0, $len) . '...' . substr($str, -$len); 702 702 } else { 703 703 // no, the ellipse goes at the end 704 704 $len= $len-3; 705 return substr($str, 0, $len ) . '...';705 return iconv_substr($str, 0, $len ) . '...'; 706 706 } 707 707 }
