[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 /* 3 http://blog.markplace.net 4 5 Bad Behavior - LifeType Plugin 6 Copyright (C) 2006 Mark Wu http://blog.markplace.net 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 // This file is the entry point for Bad Behavior in LifeType. 24 25 if (!defined('PLOG_CLASS_PATH')) die('No cheating!'); 26 27 // Timer start 28 $bb2_mtime = explode(" ", microtime()); 29 $bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0]; 30 31 define('BB2_CWD', PLOG_CLASS_PATH . "plugins/badbehavior/" ); 32 define('BB2_EMERGENCY_EMAIL', "admin@yourblog.com" ); 33 define('BB2_DEFAULT_LOG_TABLE', "bad_behavior" ); 34 35 // Bad Behavior callback functions. 36 37 // Return current time in the format preferred by your database. 38 function bb2_db_date() { 39 return gmdate('Y-m-d H:i:s'); 40 } 41 42 // Return affected rows from most recent query. 43 function bb2_db_affected_rows() { 44 lt_include( PLOG_CLASS_PATH."class/database/db.class.php" ); 45 $db =& Db::getDb(); 46 47 return $db->Affected_Rows(); 48 } 49 50 // Escape a string for database usage 51 function bb2_db_escape($string) { 52 lt_include( PLOG_CLASS_PATH."class/database/db.class.php" ); 53 54 return Db::qstr($string); 55 } 56 57 // Return the number of rows in a particular query. 58 function bb2_db_num_rows($result) { 59 return $result->RecordCount(); 60 } 61 62 // Run a query and return the results, if any. 63 // Should return FALSE if an error occurred. 64 function bb2_db_query($query) { 65 lt_include( PLOG_CLASS_PATH."class/database/db.class.php" ); 66 $db =& Db::getDb(); 67 68 $result = $db->Execute( $query ); 69 70 if (!$result) 71 return FALSE; 72 73 return $result; 74 } 75 76 // Return all rows in a particular query. 77 // Should contain an array of all rows generated by calling mysql_fetch_assoc() 78 // or equivalent and appending the result of each call to an array. 79 function bb2_db_rows($result) { 80 $rows = array(); 81 while( $row = $result->FetchRow()) { 82 $rows[] = $row; 83 } 84 85 return $rows; 86 } 87 88 // Return emergency contact email address. 89 function bb2_email() { 90 return BB2_EMERGENCY_EMAIL; 91 } 92 93 // retrieve settings from lifetype config 94 function bb2_read_settings() { 95 lt_include( PLOG_CLASS_PATH."class/database/db.class.php" ); 96 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 97 $config =& Config::getConfig(); 98 $prefix = Db::getPrefix(); 99 $logTable = $config->getValue( 'bb2_log_table', BB2_DEFAULT_LOG_TABLE ); 100 $displayStats = $config->getValue( 'bb2_display_stats', true ); 101 $strict = $config->getValue( 'bb2_strict', false ); 102 $verbose = $config->getValue( 'bb2_verbose', false ); 103 $isInstalled = $config->getValue( 'bb2_installed', false ); 104 105 return array('log_table' => $prefix . $logTable, 106 'display_stats' => $displayStats, 107 'strict' => $strict, 108 'verbose' => $verbose, 109 'is_installed' => $isInstalled ); 110 } 111 112 // write settings to lifetype config 113 function bb2_write_settings($settings) { 114 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 115 $config =& Config::getConfig(); 116 $config->setValue( 'bb2_log_table', BB2_DEFAULT_LOG_TABLE ); 117 $config->setValue( 'bb2_display_stats', $settings['display_stats'] ); 118 $config->setValue( 'bb2_strict', $settings['strict'] ); 119 $config->setValue( 'bb2_verbose', $settings['verbose'] ); 120 $config->setValue( 'bb2_installed', $settings['is_installed'] ); 121 $config->save(); 122 } 123 124 // installation 125 function bb2_install() { 126 $settings = bb2_read_settings(); 127 if( $settings['is_installed'] == false ) 128 { 129 bb2_db_query(bb2_table_structure($settings['log_table'])); 130 $settings['is_installed'] = true; 131 bb2_write_settings( $settings ); 132 } 133 } 134 135 // Return the top-level relative path of wherever we are (for cookies) 136 function bb2_relative_path() { 137 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 138 $config =& Config::getConfig(); 139 140 $url = parse_url( $config->getValue( 'base_url' ) ); 141 if( empty($url['path']) ) 142 return '/'; 143 else { 144 if( substr( $url['path'], -1, 1 ) == '/' ) 145 return $url['path']; 146 else 147 return $url['path'] . '/'; 148 } 149 } 150 151 // Load Bad Behavior Core 152 lt_include(BB2_CWD . "bad-behavior/core.inc.php"); 153 bb2_install(); 154 $settings = bb2_read_settings(); 155 bb2_start($settings); 156 157 // Time Stop 158 $bb2_mtime = explode(" ", microtime()); 159 $bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0]; 160 $bb2_timer_total = $bb2_timer_stop - $bb2_timer_start; 161 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |