upgrade120-20.php
来自「日程 BosDates v4.5 Copyright ?2004-2005 B」· PHP 代码 · 共 697 行 · 第 1/3 页
PHP
697 行
//Update categories $oldCatInfo = array(); $result = query("SELECT category_id,category_ad_types,category_price_sale,category_price_want,category_price_job,category_price_service,category_price_notice,category_optional_1,category_optional_2,category_optional_3,category_optional_4,category_optional_5 FROM {$class_prefix}categories",$class_link); while(list($catID,$adTypes,$oldSale,$oldWanted,$oldJob,$oldService,$oldNotice,$oldOptional1,$oldOptional2,$oldOptional3,$oldOptional4,$oldOptional5) = mysql_fetch_row($result)) { $oldCatInfo[$catID]['adtype'] = $adTypes; $oldCatInfo[$catID]['sale'] = $oldSale; $oldCatInfo[$catID]['wanted'] = $oldWanted; $oldCatInfo[$catID]['notice'] = $oldNotice; $oldCatInfo[$catID]['service'] = $oldService; $oldCatInfo[$catID]['job'] = $oldJob; $oldCatInfo[$catID]['opt1'] = $oldOptional1; $oldCatInfo[$catID]['opt2'] = $oldOptional2; $oldCatInfo[$catID]['opt3'] = $oldOptional3; $oldCatInfo[$catID]['opt4'] = $oldOptional4; $oldCatInfo[$catID]['opt5'] = $oldOptional5; } $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_subs` INT( 5 ) NOT NULL ,ADD `category_listings` INT( 5 ) NOT NULL ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` CHANGE `category_ad_types` `category_ad_types` VARCHAR( 255 ) NOT NULL",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_ad_prices` VARCHAR( 255 ) NOT NULL AFTER `category_ad_types` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` DROP `category_price_sale` ,DROP `category_price_want` ,DROP `category_price_job` ,DROP `category_price_service` ,DROP `category_price_notice` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_optional_1_def` VARCHAR( 255 ) NOT NULL AFTER `category_optional_1` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_optional_2_def` VARCHAR( 255 ) NOT NULL AFTER `category_optional_2` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_optional_3_def` VARCHAR( 255 ) NOT NULL AFTER `category_optional_3` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_optional_4_def` VARCHAR( 255 ) NOT NULL AFTER `category_optional_4` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `category_optional_5_def` VARCHAR( 255 ) NOT NULL AFTER `category_optional_5` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}categories` ADD `banner_top` VARCHAR( 5 ) NOT NULL ,ADD `banner_bottom` VARCHAR( 5 ) NOT NULL ;",$class_link); $result = query("SELECT category_id FROM {$class_prefix}categories",$class_link); while(list($catID) = mysql_fetch_row($result)) { $catTypes = ""; $catPrices = ""; $newOpt1Def = ""; $newOpt2Def = ""; $newOpt3Def = ""; $newOpt4Def = ""; $newOpt5Def = ""; if(($oldCatInfo[$catID]['adtype'] & 1) != 0) { $catTypes .= "1,"; $catPrices .= "{$oldCatInfo[$catID]['sale']},"; } if(($oldCatInfo[$catID]['adtype'] & 2) != 0) { $catTypes .= "2,"; $catPrices .= "{$oldCatInfo[$catID]['wanted']},"; } if(($oldCatInfo[$catID]['adtype'] & 4) != 0) { $catTypes .= "4,"; $catPrices .= "{$oldCatInfo[$catID]['job']},"; } if(($oldCatInfo[$catID]['adtype'] & 8) != 0) { $catTypes .= "8,"; $catPrices .= "{$oldCatInfo[$catID]['service']},"; } if(($oldCatInfo[$catID]['adtype'] & 16) != 0) { $catTypes .= "16,"; $catPrices .= "{$oldCatInfo[$catID]['notice']},"; } if(trim($oldCatInfo[$catID]['opt1']) != "") { $newOpt1Def = "1|"; } if(trim($oldCatInfo[$catID]['opt2']) != "") { $newOpt2Def = "1|"; } if(trim($oldCatInfo[$catID]['opt3']) != "") { $newOpt3Def = "1|"; } if(trim($oldCatInfo[$catID]['opt4']) != "") { $newOpt4Def = "1|"; } if(trim($oldCatInfo[$catID]['opt5']) != "") { $newOpt5Def = "1|"; } $result2 = query("UPDATE {$class_prefix}categories SET category_ad_types='$catTypes',category_ad_prices='$catPrices',category_optional_1_def='$newOpt1Def',category_optional_2_def='$newOpt2Def',category_optional_3_def='$newOpt3Def',category_optional_4_def='$newOpt4Def',category_optional_5_def='$newOpt5Def' WHERE category_id=$catID",$class_link); } updateCounts(); //Update ads table $result = query("ALTER TABLE `{$class_prefix}ads` CHANGE `ad_type` `ad_type` TINYINT( 3 ) DEFAULT '0' NOT NULL",$class_link); $result = query("ALTER TABLE `{$class_prefix}ads` ADD `ad_type_optional1` VARCHAR( 255 ) NOT NULL AFTER `ad_optional_5` ,ADD `ad_type_optional2` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional1` ,ADD `ad_type_optional3` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional2` ,ADD `ad_type_optional4` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional3` ,ADD `ad_type_optional5` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional4` ,ADD `ad_type_optional6` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional5` ,ADD `ad_type_optional7` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional6` ,ADD `ad_type_optional8` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional7` ,ADD `ad_type_optional9` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional8` ,ADD `ad_type_optional10` VARCHAR( 255 ) NOT NULL AFTER `ad_type_optional9` ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}ads` ADD `ad_city` VARCHAR( 255 ) NOT NULL ,ADD `ad_state` VARCHAR( 255 ) NOT NULL ,ADD `ad_postal` VARCHAR( 255 ) NOT NULL ,ADD `ad_country` VARCHAR( 255 ) NOT NULL ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}ads` CHANGE `ad_user_id` `ad_user_id` INT( 5 ) DEFAULT '0' NOT NULL",$class_link); $result = query("ALTER TABLE `{$class_prefix}ads` ADD `ad_fee` FLOAT( 6, 2 ) NOT NULL ;",$class_link); $result = query("ALTER TABLE `{$class_prefix}ads` CHANGE `ad_price` `ad_price` VARCHAR( 255 ) DEFAULT '0.00' NOT NULL",$class_link); $newDate = date("Y-m-d",strtotime("+3650 days")); $result = query("UPDATE {$class_prefix}ads SET ad_date_end='$newDate' WHERE ad_date_end='0000-00-00'",$class_link); //Update coupons table $result = query("ALTER TABLE `{$class_prefix}coupons` ADD `coupon_restrict` TINYINT( 1 ) DEFAULT '0' NOT NULL ;",$class_link); //Update the users, switching over to the BosDev UUS //Grab who owns which ad $adOwner = array(); $newAdOwner = array(); $result = query("SELECT ad_id,ad_user_id FROM {$class_prefix}ads",$class_link); while(list($adID,$adUserID) = mysql_fetch_row($result)) { $adOwner[$adID] = $adUserID; } //Create BosDev UUS if needed $result = query("CREATE TABLE IF NOT EXISTS bosdevUUS (id int(5) NOT NULL auto_increment,username varchar(255) NOT NULL,password varchar(255) NOT NULL,email varchar(255) NOT NULL, status TINYINT( 1 ) DEFAULT '0' NOT NULL, last_login DATE NOT NULL, bd1 varchar(255) NOT NULL,bd2 varchar(255) NOT NULL,bd3 varchar(255) NOT NULL,bd4 varchar(255) NOT NULL,bd5 varchar(255) NOT NULL,bc1 tinyint(255) DEFAULT '0' NOT NULL,bc2 varchar(255) DEFAULT '0' NOT NULL,bc3 varchar(255) NOT NULL,bc4 varchar(255) NOT NULL,bc5 varchar(255) NOT NULL,bdir1 varchar(255) NOT NULL,bdir2 varchar(255) NOT NULL,bdir3 varchar(255) NOT NULL,bdir4 varchar(255) NOT NULL,bdir5 varchar(255) NOT NULL,bm1 tinyint(255) DEFAULT '0' NOT NULL,bm2 varchar(255) NOT NULL,bm3 varchar(255) NOT NULL,bm4 varchar(255) NOT NULL,bm5 varchar(255) NOT NULL,bn1 tinyint(255) DEFAULT '0' NOT NULL,bn2 varchar(255) NOT NULL,bn3 varchar(255) NOT NULL,bn4 varchar(255) NOT NULL,bn5 varchar(255) NOT NULL,PRIMARY KEY (id));",$uus_link); //Get all of the current users, and put them into the UUS $result = query("SELECT user_id,user_name,user_pass,user_email,user_admin FROM {$class_prefix}users",$class_link); while(list($userID,$userName,$userPass,$userEmail,$userAdmin) = mysql_fetch_row($result)) { if($userAdmin == "1") { $adminFlag = "2"; } else { $adminFlag = "0"; } //Check the UUS for this username or email $userName = protect($userName); $userEmail = protect($userEmail); $result2 = query("SELECT id FROM bosdevUUS WHERE username='$userName' OR email='$userEmail'",$uus_link); if($id != "") { //User exists, do not add an entry $newAdOwner[$userID] = $id; $result2 = query("UPDATE bosdevUUS SET bc1='$adminFlag' WHERE id=$userID",$uus_link); } else { //Insert the user $result2 = query("INSERT INTO bosdevUUS (id,username,password,email,bc1,bc2,status) VALUES ($userID,'$userName','$userPass','$userEmail','$adminFlag','0','1')",$uus_link); } } //Update any ads with their new user while(list($key,$newUsr) = each($newAdOwner)) { reset($adOwner); while(list($ad,$oldUsr) = each($adOwner)) { $result = query("UPDATE {$class_prefix}ads SET ad_user_id=$newUsr WHERE ad_id=$ad",$class_link); } } echo<<<ENDPRINT <table width="600" border="0" cellspacing="1" cellpadding="3"> <form method="post" action="upgrade120-20.php"> <input type="hidden" name="step" value="8"> <tr> <td class="headtd">Updating database structure</td> </tr> <tr> <td> The upgrade script has now reconfigured your database settings.<br> <br> <input type="submit" value="Proceed"><br> <br> <b>Note: The next step takes a while depending upon how many images you have in your classifieds, please be patient and do not try to refresh the screen.</b> </td> </tr> </form> </table>ENDPRINT; break; case "8": //Copy images include("connect.php"); $errorFound = 0; if(!is_dir("{$insPath}images/ads")) { if ($handle = opendir("{$insPath}images/listings")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "index.htm" && !strstr($file,"_thumb") && !strstr($file,"_small")) { $pos = strpos($file,"."); $name = substr($file,0,$pos); $ext = substr($file,$pos); copy("{$insPath}images/listings/$file","{$insPath}images/listings/{$name}_small{$ext}"); } } } else { $errorFound = 1; $msg = "Could not open the /images/listings/ directory. Please make sure that you have renamed your existing /images/ads/ directory to /images/listings/<br>"; } } else { $errorFound = 1; $msg = "Please rename your existing /images/ads/ directory to /images/listings/ to proceed.<br>"; }echo<<<ENDPRINT <table width="600" border="0" cellspacing="1" cellpadding="3"> <form method="post" action="upgrade120-20.php" onReset="javascript:window.location.reload();"> <input type="hidden" name="step" value="9"> <tr> <td class="headtd">Copying images</td> </tr> <tr> <td> This version now stores the original image the user posts. To "fake" this for the current images, they have been copied.<br> <br> <b>$msg</b>ENDPRINT; if($errorFound == 1) { $button = "<input type=\"reset\" value=\"Retry\">"; } else { $button = "<input type=\"submit\" value=\"Proceed\">"; } echo<<<ENDPRINT $button </td> </tr> </form> </table>ENDPRINT; break; case "9": echo<<<ENDPRINT <table width="600" border="0" cellspacing="1" cellpadding="3"> <tr> <td class="headtd">Upgrade complete</td> </tr> <tr> <td> Congratulations, your BosClassifieds has now been upgraded.<br> <br> Please make sure that you remove or rename the install.php script, and all of the upgradeX.php scripts to prevent a visitor from accidentally running the scripts and damaging your installation.<br> <br> You may now run <a href="index.php">index.php</a> to begin using your classified ads.<br> <br> If you have questions about the classified ads system, please see our support forums at http://www.bosdev.com/support for assistance.<br> <br> To read or reference a manual for BosClassifieds, please visit http://www.bosdev.com/bosclassifieds/manual/.<br> <br> </td> </tr> </table>ENDPRINT; break; default: echo<<<ENDPRINT <table width="600" border="0" cellspacing="1" cellpadding="3"> <form method="post" action="upgrade120-20.php"> <input type="hidden" name="step" value="1"> <tr> <td> Welcome to the BosClassifieds 1.20 to BosClassifieds 2.0 upgrade script.<br> <br> <b>If you are doing an initial installation, please run install.php instead. This script should only be used when upgrading version 1.20 to version 2.0. To upgrade from versions earlier than 1.20, please contact BosDev for directions.</b><br> <br> <span style="font-weight:bold; color:#FF0000;">As with any upgrade operation, it is strongly suggested to back up all files and the database before proceeding. While we do our best to ensure that no lose of data will occur, we cannot gaurantee it.</span><br> <br> One very important thing you must do, is rename your current /images/ads/ directory to /images/listings/. This is being done to prevent specifically Norton Utilities from blocking your visitors from seeing the ads.<br> <br> As version 2.0 is a complete rewrite, you will need to reset all of your CSS coloration, and your HTML content areas to your liking. Versions prior to v2.0 allowed for 4 HTML content areas, in v2.0 this has been reduced to 2 areas while maintaining the same/better functionality. For these reasons, you will need to reset the appearance aspects of your classifieds.<br> <br> To proceed with updating the database, click Proceed below.<br> <br> <input type="submit" value="Proceed"> </td> </tr> </form> </table>ENDPRINT; break; }echo<<<ENDPRINT <br> <div id="copyright" align="center"> Powered by BosClassifieds<br>Copyright 2002-2005. All Rights Reserved </div> <br> <br> </div> </body></html>ENDPRINT;?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?