| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/forum/forum_update.php,v $ 14 | $Revision: 1.15 $ 15 | $Date: 2006/01/09 09:55:14 $ 16 | $Author: sweetas $ 17 +----------------------------------------------------------------------------+ 18 */ 19 if (!defined('e107_INIT')) { exit; } 20 21 require_once(e_PLUGIN.'forum/forum_class.php'); 22 global $ns; 23 $forum = new e107forum; 24 25 $timestart = microtime(); 26 $ttab = MPREFIX.'forum_t'; 27 28 29 if($sql->db_Select("plugin", "plugin_version", "plugin_name = 'Forum'")) 30 { 31 $row = $sql->db_Fetch(); 32 $forum_version = $row['plugin_version']; 33 } 34 35 36 $forum_subs = FALSE; 37 $fields = mysql_list_fields($mySQLdefaultdb, MPREFIX."forum"); 38 $columns = mysql_num_fields($fields); 39 for ($i = 0; $i < $columns; $i++) 40 { 41 if("forum_sub" == mysql_field_name($fields, $i)) 42 { 43 $forum_subs = TRUE; 44 } 45 } 46 47 $text = ""; 48 if(!$forum_subs) 49 { 50 $text .= forum_stage1(); 51 $text .= forum_stage2(); 52 $text .= forum_stage3(); 53 $text .= forum_stage4(); 54 $text .= forum_stage5(); 55 $text .= forum_stage6(); 56 } 57 58 if($forum_version < 1.2) 59 { 60 $text .= mods_to_userclass(); 61 } 62 $text .= set_forum_version(); 63 64 $timeend = microtime(); 65 $diff = number_format(((substr($timeend, 0, 9)) + (substr($timeend, -10)) - (substr($timestart, 0, 9)) - (substr($timestart, -10))), 4); 66 $text .= "<br />script generation took $diff s"; 67 68 if ($pref['developer']) { 69 $ns->tablerender('forum upgrade',$text); 70 } 71 72 function forum_stage1() 73 { 74 global $sql; 75 $ttab = MPREFIX.'forum_t'; 76 $sql->db_Select_gen("ALTER TABLE #forum_t ADD thread_edit_datestamp int(10) unsigned NOT NULL default '0'"); 77 $sql->db_Select_gen("ALTER TABLE #forum_t ADD thread_lastuser varchar(30) NOT NULL default ''"); 78 $sql->db_Select_gen("ALTER TABLE #forum_t ADD thread_total_replies int(10) unsigned NOT NULL default '0'"); 79 $sql->db_Select_gen("ALTER TABLE #forum ADD forum_postclass TINYINT( 3 ) UNSIGNED DEFAULT '0' NOT NULL ;"); 80 $sql->db_Select_gen("ALTER TABLE #forum ADD `forum_sub` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL AFTER `forum_parent` ;"); 81 return "Updated table structure <br />"; 82 } 83 84 function forum_stage2() 85 { 86 global $sql; 87 $ttab = MPREFIX.'forum_t'; 88 // $numrows = $sql->db_Update('forum_t', "thread_anon = SUBSTRING(thread_user,3) WHERE thread_user LIKE '0.%'"); 89 $numrows = $sql->db_Update('forum_t', "thread_user = CAT('0.', thread_anon) WHERE thread_user = '0'"); 90 return $ret."Updated anonymous post info ... $numrows rows updated<br />"; 91 } 92 93 function forum_stage3() 94 { 95 global $sql; 96 $sql->db_Select_gen("ALTER TABLE #forum_t CHANGE thread_user thread_user varchar(250) NOT NULL default ''"); 97 $sql->db_Select_gen("ALTER TABLE #forum_t DROP thread_anon"); 98 return "Updated thread_user & forum_anon field<br />"; 99 } 100 101 function forum_stage4() 102 { 103 global $sql, $forum; 104 $sql->db_Select_gen("SELECT thread_parent AS id, COUNT(*) AS amount FROM #forum_t WHERE thread_parent !=0 GROUP BY thread_parent"); 105 $threadArray = $sql->db_getList('ALL', FALSE, 0); 106 foreach($threadArray as $threads) 107 { 108 extract($threads); 109 $sql->db_Update("forum_t", "thread_total_replies=$amount WHERE thread_id=$id"); 110 } 111 112 $ret = "Updated thread reply info...".count($threadArray). " threads updated.<br />"; 113 $forum = new e107forum; 114 $forum->forum_update_counts('all'); 115 return $ret."Updated forum thread count info. <br />"; 116 } 117 118 function forum_stage5() 119 { 120 global $sql, $forum; 121 $sql->db_Select_gen("ALTER TABLE #forum CHANGE forum_lastpost forum_lastpost_user varchar(200) NOT NULL default ''"); 122 $sql->db_Select_gen("ALTER TABLE #forum ADD forum_lastpost_info varchar(40) NOT NULL default '' AFTER forum_lastpost_user"); 123 set_time_limit(180); 124 $forum->update_lastpost('forum', 'all', TRUE); 125 return "Updated lastpost info <br />"; 126 } 127 128 function forum_stage6() 129 { 130 global $sql; 131 global $PLUGINS_DIRECTORY; 132 if(!$sql->db_Count('plugin','(*)',"WHERE plugin_name = 'Forum'")) 133 { 134 $sql->db_Insert('plugin',"0,'Forum','1.1','forum',1"); 135 return "Forum entry added to plugin table, set as installed.<br />"; 136 } 137 else 138 { 139 $sql->db_Update('plugin',"plugin_installflag = 1 WHERE plugin_name='Forum'"); 140 } 141 $sql->db_Update('links',"link_url='{$PLUGINS_DIRECTORY}forum/forum.php' WHERE link_name='Forum'"); 142 143 } 144 145 function mods_to_userclass() 146 { 147 global $sql; 148 require_once(e_HANDLER."userclass_class.php"); 149 $_uc = new e_userclass; 150 if($sql->db_Select("forum", "forum_id, forum_moderators","forum_parent != 0")) 151 { 152 $fList = $sql->db_getList(); 153 foreach($fList as $row) 154 { 155 if(!is_numeric($row['forum_moderators'])) 156 { 157 $newclass = $_uc->class_create($row['forum_moderators'], "FORUM_MODS_"); 158 $sql->db_Update("forum", "forum_moderators = '{$newclass}' WHERE forum_id = '{$row['forum_id']}'"); 159 } 160 } 161 } 162 return "Forum moderators converted to userclasses <br />"; 163 } 164 165 function set_forum_version() 166 { 167 global $sql; 168 $new_version = "1.2"; 169 $sql->db_Update('plugin',"plugin_version = '{$new_version}' WHERE plugin_name='Forum'"); 170 return "Forum Version updated to version: $new_version <br />"; 171 } 172 173 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |