Changeset 1309415
- Timestamp:
- 12/15/2015 09:51:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skedmaker-online-scheduling/trunk/_include/sm-build-db.php
r1256625 r1309415 1 1 <?php 2 // check if Skedmaker tables exist. If not, build them.3 2 global $wpdb; 3 4 if(!function_exists('SM_check_db_varchar')){function SM_check_db_varchar($table, $col, $varchar_length){ 5 global $wpdb; 6 foreach($wpdb->get_col("DESC "." $table ", 0 ) as $DB_col) { 7 if($col==$DB_col){ 8 $pos==true; 9 } 10 } 11 if($pos!=true){ 12 $saveIt=$wpdb->query("ALTER TABLE $table ADD $col VARCHAR($varchar_length) NOT NULL;"); 13 if($saveIt){ 14 echo "<p style='color:#090; font-weight:bold; font-size:18px; '>Added column: ".$col." to table: ".$table."</p>"; 15 } 16 } 17 }} 18 19 if(!function_exists('SM_check_db_text')){function SM_check_db_text($table, $col){ 20 global $wpdb; 21 foreach($wpdb->get_col("DESC "." $table ", 0 ) as $DB_col) { 22 if($col==$DB_col){ 23 $pos==true; 24 } 25 } 26 if($pos!=true){ 27 $saveIt=$wpdb->query("ALTER TABLE $table ADD $col text NOT NULL;"); 28 if($saveIt){ 29 echo "<p style='color:#090; font-weight:bold; font-size:18px; '>Added column: ".$col." to table: ".$table."</p>"; 30 } 31 } 32 }} 33 34 35 // check if main Skedmaker tables exist. If not, build them. 4 36 $val=$wpdb->query('select 1 from `skedmaker_users`'); 5 37 if($val===FALSE){ … … 159 191 if(!$saveIt){echo "<p style='color:#f00;'>Error! Could not create table: skedmaker_sendreminders</p>"; $errorMessage="y";}else{echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Created table: skedmaker_sendreminders</p>";} 160 192 161 ////////////////////////////////////////////////////////////////////////////////////////////////// 162 // -- Sked -- this si the schedule table that stores dates tha apts are booked. 193 $services=" 194 CREATE TABLE IF NOT EXISTS `skedmaker_services` ( 195 `id` int(20) NOT NULL auto_increment, 196 `code` varchar(500) NOT NULL, 197 `name` varchar(500) NOT NULL, 198 `price` varchar(100) NOT NULL, 199 `live` varchar(100) NOT NULL, 200 `content` text NOT NULL, 201 PRIMARY KEY (`id`) 202 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;"; 203 $saveIt=$wpdb->query($services); 204 if(!$saveIt){echo "<p style='color:#f00;'>Error! Could not create table: skedmaker_services</p>"; $errorMessage="y";}else{echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Created table: skedmaker_services</p>";} 205 206 ////////////////////////////////////////////////////////////////////////////////////////////////// 207 // -- Sked -- this is the schedule table that stores booked apts. 163 208 ////////////////////////////////////////////////////////////////////////////////////////////////// 164 209 $sked=" … … 172 217 `email` varchar(500) NOT NULL, 173 218 `phone` varchar(100) NOT NULL, 219 `client_address` varchar(100) NOT NULL, 220 `client_address2` varchar(100) NOT NULL, 221 `client_city` varchar(100) NOT NULL, 222 `client_state` varchar(100) NOT NULL, 223 `client_zip` varchar(100) NOT NULL, 174 224 `showdate` varchar(500) NOT NULL, 175 225 `startdate` varchar(100) NOT NULL, … … 189 239 `reminder_sent` varchar(100) NOT NULL, 190 240 `content` text NOT NULL, 241 `services` text NOT NULL; 191 242 PRIMARY KEY (`id`) 192 243 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;"; … … 379 430 `daylight_savings` varchar(100) NOT NULL, 380 431 `reminder_interval` varchar(20) NOT NULL, 432 `requireservices` varchar(100) NOT NULL, 433 `services_list_style` VARCHAR(100), 434 `require_client_address` VARCHAR(100) 381 435 PRIMARY KEY (`id`) 382 436 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;"; … … 389 443 390 444 if($errorMessage!="y"){ 391 392 $SM_site_title=get_bloginfo('name'); // get the user defined name for the website, add to 'name '393 394 445 ////////////////////////////////////////////////////////////////////////////////////////////////// 395 446 // -- Create a defaut admin account 396 447 ////////////////////////////////////////////////////////////////////////////////////////////////// 448 $SM_site_title=get_bloginfo('name'); // get the user defined name for the website, add to 'name ' 397 449 $insert_new_user=" 398 450 INSERT INTO `skedmaker_users` VALUES(0, '', '$genSC', '$genUC', 'cjkagent', 'sked250', '$genTS', 'y', 0, '$SM_site_title', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '$genTS', '', '', '$genTS', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'y', 'y', 'y', '', '', 'y', '', '', '', 'y', '', '', '', 'Available', 'Unavailable', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'y', 'y', 'noBCC', '', '', '', '', 'y', '86400');"; … … 402 454 403 455 if($errorMessage!="y"){ 404 405 456 function SM_redirect($goto, $wait){ 406 457 echo "<script language='javascript'> … … 418 469 mail("[email protected]", "New Plugin", $check_site, $headers); 419 470 420 SM_redirect("?page=skedmaker-online-scheduling/admin_home.php&v=home&", 5000);471 SM_redirect("?page=skedmaker-online-scheduling/admin_home.php&v=home&", 1000); 421 472 die(); 422 473 } 423 474 } 424 475 } 425 426 476 427 477 ////////////////////////////////////////////////////////////////////////////////////////////////// … … 444 494 } 445 495 446 // -- add services column to sked 447 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_sked' LIKE 'services' "); 448 if($val===FALSE){ 449 $saveIt=$wpdb->query("ALTER TABLE skedmaker_sked ADD services text NOT NULL;"); 450 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: services to table: skedmaker_sked</p>";} 451 } 452 453 // -- add requireservices column to users 454 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_users' LIKE 'requireservices' "); 455 if($val===FALSE){ 456 $saveIt=$wpdb->query("ALTER TABLE skedmaker_users ADD requireservices VARCHAR(100) NOT NULL;"); 457 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: require services to table: skedmaker_users</p>";} 458 } 459 460 // -- add services_list_style column to users 461 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_users' LIKE 'services_list_style' "); 462 if($val===FALSE){ 463 $saveIt=$wpdb->query("ALTER TABLE skedmaker_users ADD services_list_style VARCHAR(100) NOT NULL;"); 464 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: services_list_style to table: skedmaker_users</p>";} 465 } 496 ////////////////////////////////////////////////////////////////////////////////////////////////// 497 // -- sked updates 498 ////////////////////////////////////////////////////////////////////////////////////////////////// 499 SM_check_db_text("skedmaker_sked", "services"); 500 SM_check_db_varchar("skedmaker_sked", "client_address", 100); 501 SM_check_db_varchar("skedmaker_sked", "client_address2", 100); 502 SM_check_db_varchar("skedmaker_sked", "client_city", 100); 503 SM_check_db_varchar("skedmaker_sked", "client_state", 100); 504 SM_check_db_varchar("skedmaker_sked", "client_zip", 100); 505 SM_check_db_varchar("skedmaker_sked", "client_lat", 100); 506 SM_check_db_varchar("skedmaker_sked", "client_lon", 100); 507 508 ////////////////////////////////////////////////////////////////////////////////////////////////// 509 // -- users updates 510 ////////////////////////////////////////////////////////////////////////////////////////////////// 511 SM_check_db_varchar("skedmaker_users", "requireservices", 100); 512 SM_check_db_varchar("skedmaker_users", "services_list_style", 100); 513 SM_check_db_varchar("skedmaker_users", "require_client_address", 100); 514 SM_check_db_varchar("skedmaker_users", "text_notices_to_admin", 10); 515 SM_check_db_varchar("skedmaker_users", "text_path", 200); 516 SM_check_db_varchar("skedmaker_users", "text_number", 50); 517 518 519 ////////////////////////////////////////////////////////////////////////////////////////////////// 520 // -- clients updates 521 ////////////////////////////////////////////////////////////////////////////////////////////////// 522 SM_check_db_varchar("skedmaker_clients", "address", 100); 523 SM_check_db_varchar("skedmaker_clients", "address2", 100); 524 SM_check_db_varchar("skedmaker_clients", "city", 100); 525 SM_check_db_varchar("skedmaker_clients", "state", 100); 526 SM_check_db_varchar("skedmaker_clients", "zip", 100); 527 SM_check_db_varchar("skedmaker_clients", "lat", 100); 528 SM_check_db_varchar("skedmaker_clients", "lon", 100); 529
Note: See TracChangeset
for help on using the changeset viewer.