- Timestamp:
- Apr 27, 2017 4:43:35 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/init_codebase_tables.cli.php
r573 r601 146 146 // Lock! 147 147 require_once CODEBASE_PATH . '/lib/Lock.inc.php'; 148 require_once CODEBASE_PATH . '/lib/Auth_SQL.inc.php'; 148 149 $lock =& Lock::getInstance(new Auth_SQL('codebase')); 149 150 $lock->setParam(array('create_table' => true)); … … 162 163 // Version! 163 164 require_once CODEBASE_PATH . '/lib/Version.inc.php'; 165 require_once CODEBASE_PATH . '/lib/Auth_SQL.inc.php'; 164 166 $version = Version::getInstance(new Auth_SQL('codebase')); 165 167 $version->setParam(array('create_table' => true)); -
trunk/bin/module_maker/list_template.cli.php
r533 r601 119 119 $listrows[] = "<\x3fphp echo mb_strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(mb_substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>"; 120 120 } else if (preg_match('/.*(begin|start).*date.*/i', $field)) { 121 $listrows[] = "<\x3fphp echo '0000-00-00'== \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";121 $listrows[] = "<\x3fphp echo \$db->getParam('zero_date') == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; 122 122 } else if (preg_match('/.*(end|expire).*date.*/i', $field)) { 123 123 $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; -
trunk/bin/module_maker/skel/public.php
r468 r601 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 60 60 WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' 61 61 AND publish = 'true' 62 __///__AND (publish_date <= CURDATE() OR publish_date = ' 0000-00-00')63 __///__AND (expire_date > CURDATE() OR expire_date = ' 0000-00-00')62 __///__AND (publish_date <= CURDATE() OR publish_date = '" . $db->escapeString($db->getParam('zero_date')) . "') 63 __///__AND (expire_date > CURDATE() OR expire_date = '" . $db->escapeString($db->getParam('zero_date')) . "') 64 64 "); 65 65 if (!$item = mysql_fetch_assoc($qid)) { -
trunk/lib/ACL.inc.php
r534 r601 162 162 163 163 // acl_tbl 164 $db->query( "164 $db->query(sprintf(" 165 165 CREATE TABLE IF NOT EXISTS acl_tbl ( 166 166 aro_id SMALLINT UNSIGNED NOT NULL DEFAULT '0', … … 168 168 axo_id SMALLINT UNSIGNED NOT NULL DEFAULT '0', 169 169 access ENUM('allow', 'deny') DEFAULT NULL, 170 added_datetime DATETIME NOT NULL DEFAULT ' 0000-00-0000:00:00',170 added_datetime DATETIME NOT NULL DEFAULT '%s 00:00:00', 171 171 UNIQUE KEY (aro_id, aco_id, axo_id), 172 172 KEY (access) 173 173 ) ENGINE=MyISAM 174 " );174 ", $db->getParam('zero_date'))); 175 175 if (!$db->columnExists('acl_tbl', array( 176 176 'aro_id', … … 192 192 // aro_tbl, aco_tbl, axo_tbl 193 193 foreach (array('aro', 'aco', 'axo') as $a_o) { 194 $db->query( "195 CREATE TABLE IF NOT EXISTS {$a_o}_tbl (196 {$a_o}_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,197 name VARCHAR( " . $this->getParam('name_max_length') . ") NOT NULL DEFAULT '',194 $db->query(sprintf(" 195 CREATE TABLE IF NOT EXISTS %1\$s_tbl ( 196 %1\$s_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 197 name VARCHAR(%2\$s) NOT NULL DEFAULT '', 198 198 lft MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', 199 199 rgt MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', 200 added_datetime DATETIME NOT NULL DEFAULT ' 0000-00-0000:00:00',200 added_datetime DATETIME NOT NULL DEFAULT '%3\$s 00:00:00', 201 201 UNIQUE KEY name (name(15)), 202 202 KEY transversal (lft, rgt) 203 203 ) ENGINE=MyISAM; 204 " );204 ", $a_o, $this->getParam('name_max_length'), $db->getParam('zero_date'))); 205 205 206 206 if (!$db->columnExists("{$a_o}_tbl", array( -
trunk/lib/Auth_SQL.inc.php
r593 r601 175 175 176 176 // The minimal columns for a table compatible with the Auth_SQL class. 177 $db->query("CREATE TABLE IF NOT EXISTS " . $db->escapeString($this->getParam('db_table')) . " ( 178 " . $this->getParam('db_primary_key') . " MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 179 " . $this->getParam('db_username_column') . " varchar(255) NOT NULL default '', 180 userpass VARCHAR(255) NOT NULL DEFAULT '', 181 userpass_hashtype TINYINT UNSIGNED NOT NULL DEFAULT '0', 182 first_name VARCHAR(50) NOT NULL DEFAULT '', 183 last_name VARCHAR(50) NOT NULL DEFAULT '', 184 email VARCHAR(255) NOT NULL DEFAULT '', 185 login_abuse_exempt ENUM('true') DEFAULT NULL, 186 blocked ENUM('true') DEFAULT NULL, 187 blocked_reason VARCHAR(255) NOT NULL DEFAULT '', 188 abuse_warning_level TINYINT NOT NULL DEFAULT '0', 189 seconds_online INT NOT NULL DEFAULT '0', 190 last_login_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', 191 last_access_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', 192 last_login_ip VARCHAR(45) NOT NULL DEFAULT '0.0.0.0', 193 added_by_user_id SMALLINT DEFAULT NULL, 194 modified_by_user_id SMALLINT DEFAULT NULL, 195 added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', 196 modified_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', 197 KEY " . $this->getParam('db_username_column') . " (" . $this->getParam('db_username_column') . "), 198 KEY userpass (userpass), 199 KEY email (email), 200 KEY last_login_datetime (last_login_datetime), 201 KEY last_access_datetime (last_access_datetime) 202 )"); 177 $db->query(sprintf( 178 "CREATE TABLE IF NOT EXISTS %1\$s ( 179 %2\$s MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 180 %3\$s varchar(255) NOT NULL default '', 181 userpass VARCHAR(255) NOT NULL DEFAULT '', 182 userpass_hashtype TINYINT UNSIGNED NOT NULL DEFAULT '0', 183 first_name VARCHAR(50) NOT NULL DEFAULT '', 184 last_name VARCHAR(50) NOT NULL DEFAULT '', 185 email VARCHAR(255) NOT NULL DEFAULT '', 186 login_abuse_exempt ENUM('true') DEFAULT NULL, 187 blocked ENUM('true') DEFAULT NULL, 188 blocked_reason VARCHAR(255) NOT NULL DEFAULT '', 189 abuse_warning_level TINYINT NOT NULL DEFAULT '0', 190 seconds_online INT NOT NULL DEFAULT '0', 191 last_login_datetime DATETIME NOT NULL DEFAULT '%4\$s 00:00:00', 192 last_access_datetime DATETIME NOT NULL DEFAULT '%4\$s 00:00:00', 193 last_login_ip VARCHAR(45) NOT NULL DEFAULT '0.0.0.0', 194 added_by_user_id SMALLINT DEFAULT NULL, 195 modified_by_user_id SMALLINT DEFAULT NULL, 196 added_datetime DATETIME NOT NULL DEFAULT '%4\$s 00:00:00', 197 modified_datetime DATETIME NOT NULL DEFAULT '%4\$s 00:00:00', 198 KEY %5\$s (%5\$s), 199 KEY userpass (userpass), 200 KEY email (email), 201 KEY last_login_datetime (last_login_datetime), 202 KEY last_access_datetime (last_access_datetime) 203 )", 204 $db->escapeString($this->getParam('db_table')), 205 $this->getParam('db_primary_key'), 206 $this->getParam('db_username_column'), 207 $db->getParam('zero_date'), 208 $this->getParam('db_username_column') 209 )); 203 210 204 211 if (!$db->columnExists($this->getParam('db_table'), array( … … 232 239 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_INFO, __FILE__, __LINE__); 233 240 } 234 $db->query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_login_table') . " ( 235 " . $this->getParam('db_primary_key') . " MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', 236 login_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', 237 remote_ip_binary CHAR(32) NOT NULL DEFAULT '', 238 KEY " . $this->getParam('db_primary_key') . " (" . $this->getParam('db_primary_key') . "), 239 KEY login_datetime (login_datetime), 240 KEY remote_ip_binary (remote_ip_binary) 241 )"); 241 $db->query(sprintf( 242 "CREATE TABLE IF NOT EXISTS %1\$s ( 243 %2\$s MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', 244 login_datetime DATETIME NOT NULL DEFAULT '%3\$s 00:00:00', 245 remote_ip_binary CHAR(32) NOT NULL DEFAULT '', 246 KEY %4\$s (%4\$s), 247 KEY login_datetime (login_datetime), 248 KEY remote_ip_binary (remote_ip_binary) 249 )", 250 $this->getParam('db_login_table'), 251 $this->getParam('db_primary_key'), 252 $db->getParam('zero_date'), 253 $this->getParam('db_primary_key') 254 )); 242 255 243 256 if (!$db->columnExists($this->getParam('db_login_table'), array( … … 327 340 328 341 // FIX ME: Should we check if the session is active? 329 $db->query(" 330 UPDATE " . $this->_params['db_table'] . " SET 331 seconds_online = seconds_online + ABS(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)), 332 last_login_datetime = '0000-00-00 00:00:00' 333 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "' 334 "); 342 $db->query(sprintf( 343 "UPDATE %s SET 344 seconds_online = seconds_online + ABS(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)), 345 last_login_datetime = '%s 00:00:00' 346 WHERE %s = '%s' 347 ", 348 $this->_params['db_table'], 349 $db->getParam('zero_date'), 350 $this->_params['db_primary_key'], 351 $this->get('user_id') 352 )); 335 353 } 336 354 $_SESSION['_auth_sql'][$this->_ns] = array( -
trunk/lib/DB.inc.php
r575 r601 65 65 // Script stops on db error. TRUE recommended for production sites. 66 66 'db_die_on_failure' => true, 67 68 // Special date settings. These will dynamically changes depending on MySQL version or settings. 69 'zero_date' => '0000-00-00', 70 'infinity_date' => '9999-12-31', 67 71 ); 68 72 … … 78 82 79 83 /** 84 * Constructor. 85 */ 86 public function __construct() 87 { 88 // Initialize default parameters. 89 $this->_params = array_merge($this->_params, $this->_param_defaults); 90 } 91 92 /** 80 93 * This method enforces the singleton pattern for this class. 81 94 * … … 181 194 } else { 182 195 $app->logMsg(sprintf('%s is not a known character_set.', $app->getParam('character_set')), LOG_ERR, __FILE__, __LINE__); 196 } 197 198 // Update config for this version of MySQL. 199 if (version_compare(mysql_get_server_info(), '5.7.4', '>=')) { 200 $this->setParam(array('zero_date' => '1000-01-01')); 183 201 } 184 202 -
trunk/lib/Lock.inc.php
r592 r601 117 117 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_INFO, __FILE__, __LINE__); 118 118 } 119 $db->query( "CREATE TABLE IF NOT EXISTS " . $db->escapeString($this->getParam('db_table')) . "(119 $db->query(sprintf("CREATE TABLE IF NOT EXISTS %s ( 120 120 lock_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 121 121 record_table varchar(255) NOT NULL default '', … … 124 124 title varchar(255) NOT NULL default '', 125 125 set_by_admin_id smallint(11) NOT NULL default '0', 126 lock_datetime datetime NOT NULL default ' 0000-00-0000:00:00',126 lock_datetime datetime NOT NULL default '%s 00:00:00', 127 127 KEY record_table (record_table), 128 128 KEY record_key (record_key), 129 129 KEY record_val (record_val) 130 )" );130 )", $db->escapeString($this->getParam('db_table')), $db->getParam('zero_date'))); 131 131 132 132 if (!$db->columnExists($this->getParam('db_table'), array( -
trunk/lib/Utilities.inc.php
r600 r601 939 939 $db =& DB::getInstance(); 940 940 941 if ($db->isConnected() && version_compare(mysql_get_server_info(), '5.7.4', '>=')) {941 if ($db->isConnected() && mb_strpos($db->getParam('zero_date'), '-') !== false) { 942 942 // Mysql version >= 5.7.4 stopped allowing a "zero" date of 0000-00-00. 943 943 // https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_zero_date 944 $zero_y = '1000'; 945 $zero_m = '01'; 946 $zero_d = '01'; 944 $zero_date_parts = explode('-', $db->getParam('zero_date')); 945 $zero_y = $zero_date_parts[0]; 946 $zero_m = $zero_date_parts[1]; 947 $zero_d = $zero_date_parts[2]; 947 948 } else { 948 949 $zero_y = '0000'; -
trunk/lib/Validator.inc.php
r597 r601 429 429 { 430 430 $app =& App::getInstance(); 431 if (empty($val) || '0000-00-00 00:00:00' == $val || '0000-00-00' == $val || '00:00:00' == $val) { 431 432 if (empty($val) || '0000-00-00 00:00:00' == $val || '1000-01-01 00:00:00' == $val || '0000-00-00' == $val || '1000-01-01' == $val || '00:00:00' == $val) { 432 433 return true; 433 434 } -
trunk/lib/Version.inc.php
r550 r601 123 123 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_INFO, __FILE__, __LINE__); 124 124 } 125 $db->query( "CREATE TABLE IF NOT EXISTS " . $db->escapeString($this->getParam('db_table')) . "(125 $db->query(sprintf("CREATE TABLE IF NOT EXISTS %s ( 126 126 version_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 127 127 record_table VARCHAR(255) NOT NULL DEFAULT '', … … 133 133 version_notes VARCHAR(255) NOT NULL DEFAULT '', 134 134 saved_by_user_id SMALLINT(11) NOT NULL DEFAULT '0', 135 version_datetime DATETIME NOT NULL DEFAULT ' 0000-00-0000:00:00',135 version_datetime DATETIME NOT NULL DEFAULT '%s 00:00:00', 136 136 KEY record_table (record_table), 137 137 KEY record_key (record_key), 138 138 KEY record_val (record_val) 139 )" );139 )", $db->escapeString($this->getParam('db_table')), $db->getParam('zero_date'))); 140 140 141 141 if (!$db->columnExists($this->getParam('db_table'), array( -
trunk/services/admins.php
r535 r601 258 258 'email' => '', 259 259 'seconds_online' => '0', 260 'last_login_datetime' => ' 0000-00-00 00:00:00',261 'last_access_datetime' => ' 0000-00-00 00:00:00',260 'last_login_datetime' => '', 261 'last_access_datetime' => '', 262 262 'last_login_ip' => '0.0.0.0', 263 263 'added_by_user_id' => '', 264 264 'modified_by_user_id' => '', 265 'added_datetime' => ' 0000-00-00 00:00:00',266 'modified_datetime' => ' 0000-00-00 00:00:00',265 'added_datetime' => '', 266 'modified_datetime' => '', 267 267 'new_op' => 'insert', 268 268 'submit_buttons' => array( … … 315 315 'email' => '', 316 316 'seconds_online' => '0', 317 'last_login_datetime' => ' 0000-00-00 00:00:00',318 'last_access_datetime' => ' 0000-00-00 00:00:00',317 'last_login_datetime' => '', 318 'last_access_datetime' => '', 319 319 'last_login_ip' => '0.0.0.0', 320 320 'added_by_user_id' => '', 321 321 'modified_by_user_id' => '', 322 'added_datetime' => ' 0000-00-00 00:00:00',323 'modified_datetime' => ' 0000-00-00 00:00:00',322 'added_datetime' => '', 323 'modified_datetime' => '', 324 324 'new_op' => 'update', 325 325 'old_username' => $frm['username'],
Note: See TracChangeset
for help on using the changeset viewer.