Problem With Update »  Show posts from    to     

Icy Phoenix


Old Support Topics - Problem With Update



DarthCarl [ Sat 08 Mar, 2008 19:22 ]
Post subject: Problem With Update
Hello!
I have a forum Icy Phoenix and just upgrade to version 1.2.0.27, following the instructions in the manual that the incorporá Icy Phoenix. But I have an error: the portal works perfectly, but to go to a forum is a mistake
The forum is this: http://forosdwp.ya.st
The forum is in Spanish, but just to click on Forum for the error
Perdon by poor syntax, it is because I don´t speak English


paramine-gx [ Sat 08 Mar, 2008 22:36 ]
Post subject: Re: Problem With Update
I got this text

Code: [Hide]
  1. Critical Error  
  2.  
  3. Error updating sessions table  
  4.  
  5. DEBUG MODE  
  6.  
  7. SQL Error : 1054 Unknown column 'session_topic' in 'field list'  
  8.  
  9. UPDATE icy_sessions SET session_time = 1205012036, session_page = 0, session_topic = '0' WHERE session_id = '6cc7d8455de2ac1fe6e5974f5f926816'  
  10.  
  11. Line : 431  
  12. File : sessions.php 


Has you tried to re-upload that file?.
and has you aplied all respectives CHMODS?...
Finally can you post that line (431)?


DarthCarl [ Sun 09 Mar, 2008 10:00 ]
Post subject: Re: Problem With Update
1.- Yes
2.- Yes
3.- The line 431 is:
if ( isset($userdata['user_id']) )


Zuker [ Sun 09 Mar, 2008 16:32 ]
Post subject: Re: Problem With Update
EDIT:
After checking... that column it isn't present on IP 1.2, it was on last versions.
Try to upload a fresh file from package.


DarthCarl [ Sun 09 Mar, 2008 16:41 ]
Post subject: Re: Problem With Update
I uploaded the Icy at least 7 times and still does not work. Desist. I have an error on my forum without updating: http://www.icyphoenix.com/viewtopic.php?f=2&t=3796


Zuker [ Sun 09 Mar, 2008 16:46 ]
Post subject: Re: Problem With Update
please upload here your sessions.php


DarthCarl [ Sun 09 Mar, 2008 16:50 ]
Post subject: Re: Problem With Update
I put this on / includes /, which is the sessions.php I found. If other warn me and I upload it

Code: [Hide]
  1. <?php  
  2. /***************************************************************************  
  3. * sessions.php  
  4. * -------------------  
  5. * begin : Saturday, Feb 13, 2001  
  6. * copyright : (C) 2001 The phpBB Group  
  7. * email : support@phpbb.com  
  8. *  
  9. * $Id: sessions.php,v 1.58.2.16 2005/10/30 15:17:14 acydburn Exp $  
  10. *  
  11. *  
  12. ***************************************************************************/  
  13.  
  14. /***************************************************************************  
  15. *  
  16. * This program is free software; you can redistribute it and/or modify  
  17. * it under the terms of the GNU General Public License as published by  
  18. * the Free Software Foundation; either version 2 of the License, or  
  19. * (at your option) any later version.  
  20. *  
  21. ***************************************************************************/  
  22.  
  23. //  
  24. // Adds/updates a new session to the database for the given userid.  
  25. // Returns the new session ID on success.  
  26. //  
  27. function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0, $admin = 0)  
  28. {  
  29. global $db, $board_config, $lang;  
  30. global $HTTP_COOKIE_VARS, $_GET, $SID;  
  31. global $user_agent;  
  32.  
  33. $cookiename = $board_config['cookie_name'];  
  34. $cookiepath = $board_config['cookie_path'];  
  35. $cookiedomain = $board_config['cookie_domain'];  
  36. $cookiesecure = $board_config['cookie_secure'];  
  37.  
  38. if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )  
  39. {  
  40. $session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';  
  41. $sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : array();  
  42. $sessionmethod = SESSION_METHOD_COOKIE;  
  43. }  
  44. else  
  45. {  
  46. $sessiondata = array();  
  47. $session_id = ( isset($_GET['sid']) ) ? $_GET['sid'] : '';  
  48. $sessionmethod = SESSION_METHOD_GET;  
  49. }  
  50.  
  51. //  
  52. if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))  
  53. {  
  54. $session_id = '';  
  55. }  
  56.  
  57. $page_id = (int) $page_id;  
  58.  
  59. $last_visit = 0;  
  60. $current_time = time();  
  61.  
  62. //  
  63. // Are auto-logins allowed?  
  64. // If allow_autologin is not set or is true then they are  
  65. // (same behaviour as old 2.0.x session code)  
  66. //  
  67. if (isset($board_config['allow_autologin']) && !$board_config['allow_autologin'])  
  68. {  
  69. $enable_autologin = $sessiondata['autologinid'] = false;  
  70. }  
  71.  
  72. //  
  73. // First off attempt to join with the autologin value if we have one  
  74. // If not, just use the user_id value  
  75. //  
  76. $userdata = array();  
  77.  
  78. if ($user_id != ANONYMOUS)  
  79. {  
  80. if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '' && $user_id)  
  81. {  
  82. $sql = 'SELECT u.*  
  83. FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k  
  84. WHERE u.user_id = ' . (int) $user_id . "  
  85. AND u.user_active = 1  
  86. AND k.user_id = u.user_id  
  87. AND k.key_id = '" . md5($sessiondata['autologinid']) . "'";  
  88. if (!($result = $db->sql_query($sql)))  
  89. {  
  90. message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);  
  91. }  
  92.  
  93. $userdata = $db->sql_fetchrow($result);  
  94. $db->sql_freeresult($result);  
  95.  
  96. $enable_autologin = $login = 1;  
  97. }  
  98. elseif (!$auto_create)  
  99. {  
  100. $sessiondata['autologinid'] = '';  
  101. $sessiondata['userid'] = $user_id;  
  102.  
  103. $sql = 'SELECT *  
  104. FROM ' . USERS_TABLE . '  
  105. WHERE user_id = ' . (int) $user_id . '  
  106. AND user_active = 1';  
  107. if (!($result = $db->sql_query($sql)))  
  108. {  
  109. message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);  
  110. }  
  111.  
  112. $userdata = $db->sql_fetchrow($result);  
  113. $db->sql_freeresult($result);  
  114.  
  115. $login = 1;  
  116. }  
  117. }  
  118.  
  119. //  
  120. // At this point either $userdata should be populated or  
  121. // one of the below is true  
  122. // * Key didn't match one in the DB  
  123. // * User does not exist  
  124. // * User is inactive  
  125. //  
  126. if (!sizeof($userdata) || !is_array($userdata) || !$userdata)  
  127. {  
  128. $sessiondata['autologinid'] = '';  
  129. $sessiondata['userid'] = $user_id = ANONYMOUS;  
  130. $enable_autologin = $login = 0;  
  131.  
  132. $sql = 'SELECT *  
  133. FROM ' . USERS_TABLE . '  
  134. WHERE user_id = ' . (int) $user_id;  
  135. if (!($result = $db->sql_query($sql)))  
  136. {  
  137. message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);  
  138. }  
  139.  
  140. $userdata = $db->sql_fetchrow($result);  
  141. $db->sql_freeresult($result);  
  142. }  
  143.  
  144. // Initial ban check against user id, IP and email address  
  145. preg_match('/(..)(..)(..)(..)/', $user_ip, $user_ip_parts);  
  146.  
  147. $sql = "SELECT ban_ip, ban_userid, ban_email, ban_email, ban_expire_time, ban_priv_reason, ban_pub_reason_mode, ban_pub_reason  
  148. FROM " . BANLIST_TABLE . "  
  149. WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')  
  150. OR ban_userid = $user_id";  
  151. if ( $user_id != ANONYMOUS )  
  152. {  
  153. $sql .= " OR ban_email LIKE '" . str_replace("'", "''", $userdata['user_email']) . "'  
  154. OR ban_email LIKE '" . substr(str_replace("'", "''", $userdata['user_email']), strpos(str_replace("'", "''", $userdata['user_email']), "@")) . "'";  
  155. }  
  156. if ( !($result = $db->sql_query($sql, false, 'ban_')) )  
  157. {  
  158. message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);  
  159. }  
  160.  
  161. if ( $ban_info = $db->sql_fetchrow($result) )  
  162. {  
  163. if ( ($ban_info['ban_userid'] == ANONYMOUS) && ($ban_info['ban_ip'] == '') && ($ban_info['ban_email'] == null) )  
  164. {  
  165. $sql = "DELETE FROM " . BANLIST_TABLE . " WHERE ban_userid = '" . ANONYMOUS . "'";  
  166. if (!$db->sql_query($sql))  
  167. {  
  168. message_die(GENERAL_MESSAGE, 'Unable to access the Banlist Table.');  
  169. }  
  170. }  
  171. else  
  172. {  
  173. if ( $ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email'] || ($ban_info['ban_expire_time'] >= time()) || ( $ban_info['ban_userid'] && (!$ban_info['ban_expire_time']) ) )  
  174. {  
  175. if ( ($ban_info['ban_pub_reason_mode'] == '0') || !isset ($ban_info['ban_pub_reason_mode']))  
  176. {  
  177. $reason = $lang['You_been_banned'];  
  178. }  
  179. elseif ($ban_info['ban_pub_reason_mode'] == '1')  
  180. {  
  181. $reason = str_replace ("n", '<br />', stripslashes ($ban_info['ban_priv_reason']));  
  182. }  
  183. elseif ($ban_info['ban_pub_reason_mode'] == '2')  
  184. {  
  185. $reason = str_replace ("n", '<br />', stripslashes ($ban_info['ban_pub_reason']));  
  186. }  
  187.  
  188. message_die(CRITICAL_MESSAGE, $reason);  
  189. }  
  190. }  
  191. }  
  192.  
  193. // Create or update the session  
  194. $sql_ip = ($user_id == ANONYMOUS) ? " AND session_ip = '$user_ip'" : '';  
  195. $sql = "UPDATE " . SESSIONS_TABLE . "  
  196. SET session_ip = '$user_ip', session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login, session_user_agent = '$user_agent', session_admin = $admin  
  197. WHERE session_id = '" . $session_id . "' $sql_ip  
  198. AND session_user_id = '$user_id'";  
  199. if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )  
  200. {  
  201. $session_id = md5(dss_rand());  
  202.  
  203. $sql = "INSERT INTO " . SESSIONS_TABLE . "  
  204. (session_id, session_user_id, session_start, session_time, session_ip, session_user_agent, session_page, session_logged_in, session_admin)  
  205. VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', '$user_agent', $page_id, $login, $admin)";  
  206. if ( !$db->sql_query($sql) )  
  207. {  
  208. message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);  
  209. }  
  210. }  
  211.  
  212. //if ( $user_id != ANONYMOUS )  
  213. //{  
  214. $last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;  
  215.  
  216. if (!$admin)  
  217. {  
  218. $sql = "UPDATE " . USERS_TABLE . "  
  219. SET user_session_time = $current_time, user_http_agents = '" . $user_agent . "', user_session_page = $page_id, user_lastvisit = $last_visit, user_lastlogon = " . time() . ", user_totallogon=user_totallogon+1  
  220. WHERE user_id = $user_id";  
  221. if ( !$db->sql_query($sql) )  
  222. {  
  223. message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);  
  224. }  
  225. // Start Advanced IP Tools Pack MOD  
  226. if ( $board_config['disable_logins'] == 0 )  
  227. {  
  228. $sql = "INSERT INTO " . LOGINS_TABLE . "  
  229. (login_id, login_userid, login_ip, login_user_agent, login_time)  
  230. VALUES (NULL, $user_id, '$user_ip', '$user_agent', $current_time)";  
  231. if ( !$db->sql_query($sql) )  
  232. {  
  233. message_die(CRITICAL_ERROR, 'Error: Seek Help', '', __LINE__, __FILE__, $sql);  
  234. }  
  235.  
  236. // Now get the results in groups based on how many topics per page parameter set in the admin panel  
  237. $sql = "SELECT * FROM " . LOGINS_TABLE . " WHERE login_userid = $user_id ORDER BY login_id ASC";  
  238.  
  239. if ( !$result = $db->sql_query($sql) )  
  240. {  
  241. message_die(GENERAL_ERROR, 'Error: Seek Help', '', __LINE__, __FILE__, $sql);  
  242. }  
  243.  
  244. $max_logins = $board_config['last_logins_n'];  
  245.  
  246. if ( $user_logins = $db->sql_numrows($result) )  
  247. {  
  248. if( $user_logins > $max_logins )  
  249. {  
  250. $login_rows = $db->sql_fetchrowset($result);  
  251.  
  252. for( $i = 0; $i < ($user_logins - $max_logins); $i++)  
  253. {  
  254. $sql = "DELETE FROM " . LOGINS_TABLE . " WHERE login_id = " . $login_rows[$i]['login_id'];  
  255. if ( !$db->sql_query($sql) )  
  256. {  
  257. message_die(CRITICAL_ERROR, 'Error: Seek Help', '', __LINE__, __FILE__, $sql);  
  258. }  
  259. }  
  260. }  
  261. }  
  262. else  
  263. {  
  264. message_die(GENERAL_ERROR, 'Error: Seek Help - User ID: ' . $user_id, '', __LINE__, __FILE__, $sql);  
  265. }  
  266. // End Advanced IP Tools Pack MOD  
  267. }  
  268. }  
  269.  
  270. $userdata['user_lastvisit'] = $last_visit;  
  271.  
  272. //  
  273. // Regenerate the auto-login key  
  274. //  
  275. if ($enable_autologin)  
  276. {  
  277. $auto_login_key = dss_rand() . dss_rand();  
  278.  
  279. if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '')  
  280. {  
  281. $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "  
  282. SET last_ip = '$user_ip', key_id = '" . md5($auto_login_key) . "', last_login = $current_time  
  283. WHERE key_id = '" . md5($sessiondata['autologinid']) . "'";  
  284. }  
  285. else  
  286. {  
  287. $sql = 'INSERT INTO ' . SESSIONS_KEYS_TABLE . "(key_id, user_id, last_ip, last_login)  
  288. VALUES ('" . md5($auto_login_key) . "', $user_id, '$user_ip', $current_time)";  
  289. }  
  290.  
  291. if ( !$db->sql_query($sql) )  
  292. {  
  293. message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);  
  294. }  
  295.  
  296. $sessiondata['autologinid'] = $auto_login_key;  
  297. unset($auto_login_key);  
  298. }  
  299. else  
  300. {  
  301. $sessiondata['autologinid'] = '';  
  302. }  
  303.  
  304. // $sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];  
  305. $sessiondata['userid'] = $user_id;  
  306. //}  
  307.  
  308. $userdata['session_id'] = $session_id;  
  309. $userdata['session_ip'] = $user_ip;  
  310. $userdata['session_user_id'] = $user_id;  
  311. $userdata['session_logged_in'] = $login;  
  312. $userdata['session_page'] = $page_id;  
  313. $userdata['session_start'] = $current_time;  
  314. $userdata['session_time'] = $current_time;  
  315. $userdata['session_admin'] = $admin;  
  316. $userdata['session_key'] = $sessiondata['autologinid'];  
  317. //<!-- BEGIN Unread Post Information to Database Mod -->  
  318. if ( !$board_config['board_disable'] && $userdata['session_logged_in'] && $board_config['upi2db_on'])  
  319. {  
  320. $userdata['upi2db_access'] = check_upi2db_on($userdata);  
  321. $userdata['always_read'] = select_always_read($userdata);  
  322. $userdata['auth_forum_id'] = auth_forum_read($userdata);  
  323. sync_database($userdata);  
  324. }  
  325. //<!-- END Unread Post Information to Database Mod -->  
  326.  
  327. setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);  
  328. setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);  
  329.  
  330. $SID = $user_id > 0 ? 'sid=' . $session_id : '';  
  331.  
  332. return $userdata;  
  333. }  
  334.  
  335. //  
  336. // Checks for a given user session, tidies session table and updates user  
  337. // sessions at each page refresh  
  338. //  
  339. function session_pagestart($user_ip, $thispage_id, $thistopic_id = PAGE_INDEX)  
  340. {  
  341. global $db, $lang, $board_config;  
  342. global $HTTP_COOKIE_VARS, $_GET, $SID;  
  343.  
  344. $cookiename = $board_config['cookie_name'];  
  345. $cookiepath = $board_config['cookie_path'];  
  346. $cookiedomain = $board_config['cookie_domain'];  
  347. $cookiesecure = $board_config['cookie_secure'];  
  348.  
  349. $current_time = time();  
  350. unset($userdata);  
  351.  
  352. if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )  
  353. {  
  354. $sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : array();  
  355. $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';  
  356. $sessionmethod = SESSION_METHOD_COOKIE;  
  357. }  
  358. else  
  359. {  
  360. $sessiondata = array();  
  361. $session_id = ( isset($_GET['sid']) ) ? $_GET['sid'] : '';  
  362. $sessionmethod = SESSION_METHOD_GET;  
  363. }  
  364.  
  365. //  
  366. if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))  
  367. {  
  368. $session_id = '';  
  369. }  
  370.  
  371. if ($thispage_id === false)  
  372. {  
  373. $thispage_id = 0;  
  374. $parse_session = false;  
  375. }  
  376. else  
  377. {  
  378. $thispage_id = (int) $thispage_id;  
  379. $parse_session = true;  
  380. }  
  381.  
  382. // Does a session exist?  
  383. if ( !empty($session_id) )  
  384. {  
  385. $expiry_time = $current_time - $board_config['session_length'] ;  
  386. //  
  387. // session_id exists so go ahead and attempt to grab all  
  388. // data in preparation  
  389. //  
  390. $sql = "SELECT u.*, s.*  
  391. FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u  
  392. WHERE s.session_id = '$session_id'  
  393. AND u.user_id = s.session_user_id AND session_time > $expiry_time";  
  394. if ( !($result = $db->sql_query($sql)) )  
  395. {  
  396. message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);  
  397. }  
  398.  
  399. $userdata = $db->sql_fetchrow($result);  
  400.  
  401. // Did the session exist in the DB?  
  402. if ( isset($userdata['user_id']) )  
  403. {  
  404. //  
  405. // Do not check IP assuming equivalence, if IPv4 we'll check only first 24  
  406. // bits ... I've been told (by vHiker) this should alleviate problems with  
  407. // load balanced et al proxies while retaining some reliance on IP security.  
  408. //  
  409. $ip_check_s = substr($userdata['session_ip'], 0, 6);  
  410. $ip_check_u = substr($user_ip, 0, 6);  
  411.  
  412. if ($ip_check_s == $ip_check_u)  
  413. {  
  414. $SID = $userdata['user_id'] > 0 ? (( ($sessionmethod == SESSION_METHOD_GET) || defined('IN_ADMIN')) ? 'sid=' . $session_id : '') : '';  
  415.  
  416. //  
  417. // Only update session DB a minute or so after last update  
  418. //  
  419. $session_page_tmp = ($userdata['user_id'] == ANONYMOUS) ? $userdata['user_session_page'] : $userdata['session_page'];  
  420. $session_topic_tmp = ($userdata['user_id'] == ANONYMOUS) ? $userdata['user_session_topic'] : $userdata['session_topic'];  
  421. if ( ((($current_time - $userdata['session_time']) > SESSION_REFRESH) || ( $session_page_tmp != $thispage_id ) || ( $session_topic_tmp != $thistopic_id)) && ($parse_session === true) )  
  422. {  
  423. // A little trick to reset session_admin on session re-usage  
  424. $update_admin = (!defined('IN_ADMIN') && $current_time - $userdata['session_time'] > ($board_config['session_length'] + SESSION_REFRESH)) ? ', session_admin = 0' : '';  
  425.  
  426. $sql = "UPDATE " . SESSIONS_TABLE . "  
  427. SET session_time = " . $current_time . ", session_page = " . $thispage_id . $update_admin . ", session_topic = '" . $thistopic_id . "'  
  428. WHERE session_id = '" . $userdata['session_id'] . "'";  
  429. if ( !$db->sql_query($sql) )  
  430. {  
  431. message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);  
  432. }  
  433.  
  434. if ( $userdata['user_id'] != ANONYMOUS )  
  435. {  
  436. $sql = "UPDATE " . USERS_TABLE . "  
  437. SET user_session_time = " . $current_time . ", user_session_page = " . $thispage_id . ", user_session_topic = '" . $thistopic_id . "', user_totalpages = user_totalpages + 1, user_totaltime = user_totaltime + ($current_time - " . $userdata['session_time'] . ")  
  438. WHERE user_id = " . $userdata['user_id'];  
  439. if ( !$db->sql_query($sql) )  
  440. {  
  441. message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);  
  442. }  
  443. }  
  444.  
  445. session_clean($userdata['session_id']);  
  446.  
  447. setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);  
  448. setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);  
  449. }  
  450. // Add the session_key to the userdata array if it is set  
  451. if ( isset($sessiondata['autologinid']) && $sessiondata['autologinid'] != '' )  
  452. {  
  453. $userdata['session_key'] = $sessiondata['autologinid'];  
  454. }  
  455. //<!-- BEGIN Unread Post Information to Database Mod -->  
  456. if ( !$board_config['board_disable'] && $userdata['session_logged_in'] && $board_config['upi2db_on'])  
  457. {  
  458. $userdata['upi2db_access'] = check_upi2db_on($userdata);  
  459. $userdata['always_read'] = select_always_read($userdata);  
  460. $userdata['auth_forum_id'] = auth_forum_read($userdata);  
  461. sync_database($userdata);  
  462. }  
  463. //<!-- END Unread Post Information to Database Mod -->  
  464.  
  465. return $userdata;  
  466. }  
  467. }  
  468. }  
  469. elseif(empty($sessiondata))  
  470. {  
  471. // try to login guest  
  472. $sql = "SELECT u.*, s.*  
  473. FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u  
  474. WHERE s.session_ip = '$user_ip'  
  475. AND s.session_user_id = " . ANONYMOUS . "  
  476. AND u.user_id = s.session_user_id  
  477. LIMIT 0, 1";  
  478. if ( !($result = $db->sql_query($sql)) )  
  479. {  
  480. message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);  
  481. }  
  482.  
  483. $userdata = $db->sql_fetchrow($result);  
  484.  
  485. if ( isset($userdata['user_id']) )  
  486. {  
  487. if ( ($current_time - $userdata['session_time']) > SESSION_REFRESH )  
  488. {  
  489. $sql = "UPDATE " . SESSIONS_TABLE . "  
  490. SET session_time = $current_time, session_start = $current_time, session_page = 0  
  491. WHERE session_id = '" . $userdata['session_id'] . "'";  
  492. if ( !$db->sql_query($sql) )  
  493. {  
  494. message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);  
  495. }  
  496. }  
  497. //<!-- BEGIN Unread Post Information to Database Mod -->  
  498. // $userdata['upi2db_access'] = check_upi2db_on($userdata);  
  499. //<!-- END Unread Post Information to Database Mod -->  
  500. return $userdata;  
  501. }  
  502. }  
  503. //  
  504. // If we reach here then no (valid) session exists. So we'll create a new one,  
  505. // using the cookie user_id if available to pull basic user prefs.  
  506. //  
  507. $user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;  
  508.  
  509. if ( !($userdata = session_begin($user_id, $user_ip, $thispage_id, true)) )  
  510. {  
  511. message_die(CRITICAL_ERROR, 'Error creating user session', '', __LINE__, __FILE__, $sql);  
  512. }  
  513.  
  514. return $userdata;  
  515.  
  516. }  
  517.  
  518. /**  
  519. * Terminates the specified session  
  520. * It will delete the entry in the sessions table for this session,  
  521. * remove the corresponding auto-login key and reset the cookies  
  522. */  
  523. function session_end($session_id, $user_id)  
  524. {  
  525. global $db, $lang, $board_config, $userdata;  
  526. global $HTTP_COOKIE_VARS, $_GET, $SID;  
  527.  
  528. $cookiename = $board_config['cookie_name'];  
  529. $cookiepath = $board_config['cookie_path'];  
  530. $cookiedomain = $board_config['cookie_domain'];  
  531. $cookiesecure = $board_config['cookie_secure'];  
  532.  
  533. $current_time = time();  
  534.  
  535. if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))  
  536. {  
  537. return;  
  538. }  
  539.  
  540. //  
  541. // Delete existing session  
  542. //  
  543. $sql = 'DELETE FROM ' . SESSIONS_TABLE . "  
  544. WHERE session_id = '$session_id'  
  545. AND session_user_id = $user_id";  
  546. if ( !$db->sql_query($sql) )  
  547. {  
  548. message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);  
  549. }  
  550.  
  551. //  
  552. // Remove this auto-login entry (if applicable)  
  553. //  
  554. if ( isset($userdata['session_key']) && $userdata['session_key'] != '' )  
  555. {  
  556. $autologin_key = md5($userdata['session_key']);  
  557. $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '  
  558. WHERE user_id = ' . (int) $user_id . "  
  559. AND key_id = '$autologin_key'";  
  560. if ( !$db->sql_query($sql) )  
  561. {  
  562. message_die(CRITICAL_ERROR, 'Error removing auto-login key', '', __LINE__, __FILE__, $sql);  
  563. }  
  564. }  
  565.  
  566. //  
  567. // We expect that message_die will be called after this function,  
  568. // but just in case it isn't, reset $userdata to the details for a guest  
  569. //  
  570. $sql = 'SELECT *  
  571. FROM ' . USERS_TABLE . '  
  572. WHERE user_id = ' . ANONYMOUS;  
  573. if ( !($result = $db->sql_query($sql)) )  
  574. {  
  575. message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);  
  576. }  
  577. if ( !($userdata = $db->sql_fetchrow($result)) )  
  578. {  
  579. message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);  
  580. }  
  581. $db->sql_freeresult($result);  
  582.  
  583.  
  584. setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);  
  585. setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);  
  586.  
  587. return true;  
  588. }  
  589.  
  590. /**  
  591. * Removes expired sessions and auto-login keys from the database  
  592. */  
  593. function session_clean($session_id)  
  594. {  
  595. global $board_config, $db;  
  596.  
  597. //  
  598. // Delete expired sessions  
  599. //  
  600. $sql = "DELETE FROM " . SESSIONS_TABLE . "  
  601. WHERE UNIX_TIMESTAMP() - session_time >= 172800  
  602. AND session_id <> '$session_id'";  
  603. if ( !$db->sql_query($sql) )  
  604. {  
  605. message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);  
  606. }  
  607.  
  608. //  
  609. // Delete expired auto-login keys  
  610. // If max_autologin_time is not set then keys will never be deleted  
  611. // (same behaviour as old 2.0.x session code)  
  612. //  
  613. if (!empty($board_config['max_autologin_time']) && $board_config['max_autologin_time'] > 0)  
  614. {  
  615. $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '  
  616. WHERE last_login < ' . (time() - (86400 * (int) $board_config['max_autologin_time']));  
  617. $db->sql_query($sql);  
  618. }  
  619.  
  620. return true;  
  621. }  
  622.  
  623. /**  
  624. * Reset all login keys for the specified user  
  625. * Called on password changes  
  626. */  
  627. function session_reset_keys($user_id, $user_ip)  
  628. {  
  629. global $db, $userdata, $board_config;  
  630.  
  631. $key_sql = ($user_id == $userdata['user_id'] && !empty($userdata['session_key'])) ? "AND key_id != '" . md5($userdata['session_key']) . "'" : '';  
  632.  
  633. $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '  
  634. WHERE user_id = ' . (int) $user_id . "  
  635. $key_sql";  
  636.  
  637. if ( !$db->sql_query($sql) )  
  638. {  
  639. message_die(CRITICAL_ERROR, 'Error removing auto-login keys', '', __LINE__, __FILE__, $sql);  
  640. }  
  641.  
  642. $where_sql = 'session_user_id = ' . (int) $user_id;  
  643. $where_sql .= ($user_id == $userdata['user_id']) ? " AND session_id <> '" . $userdata['session_id'] . "'" : '';  
  644. $sql = 'DELETE FROM ' . SESSIONS_TABLE . "  
  645. WHERE $where_sql";  
  646. if ( !$db->sql_query($sql) )  
  647. {  
  648. message_die(CRITICAL_ERROR, 'Error removing user session(s)', '', __LINE__, __FILE__, $sql);  
  649. }  
  650.  
  651. if ( !empty($key_sql) )  
  652. {  
  653. $auto_login_key = dss_rand() . dss_rand();  
  654.  
  655. $current_time = time();  
  656.  
  657. $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "  
  658. SET last_ip = '$user_ip', key_id = '" . md5($auto_login_key) . "', last_login = $current_time  
  659. WHERE key_id = '" . md5($userdata['session_key']) . "'";  
  660.  
  661. if ( !$db->sql_query($sql) )  
  662. {  
  663. message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);  
  664. }  
  665.  
  666. // And now rebuild the cookie  
  667. $sessiondata['userid'] = $user_id;  
  668. $sessiondata['autologinid'] = $auto_login_key;  
  669. $cookiename = $board_config['cookie_name'];  
  670. $cookiepath = $board_config['cookie_path'];  
  671. $cookiedomain = $board_config['cookie_domain'];  
  672. $cookiesecure = $board_config['cookie_secure'];  
  673.  
  674. setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);  
  675.  
  676. $userdata['session_key'] = $auto_login_key;  
  677. unset($sessiondata);  
  678. unset($auto_login_key);  
  679. }  
  680. }  
  681.  
  682. //  
  683. // Append $SID to a url. Borrowed from phplib and modified. This is an  
  684. // extra routine utilised by the session code above and acts as a wrapper  
  685. // around every single URL and form action. If you replace the session  
  686. // code you must include this routine, even if it's empty.  
  687. //  
  688. function append_sid($url, $non_html_amp = false, $char_conversion = false)  
  689. {  
  690. global $SID;  
  691.  
  692. if ( !empty($SID) && !preg_match('#sid=#', $url) )  
  693. {  
  694. if ($char_conversion == true)  
  695. {  
  696. $url .= ( ( strpos($url, '?') !== false ) ? '%26' : '?' ) . $SID;  
  697. }  
  698. else  
  699. {  
  700. $url .= ( ( strpos($url, '?') !== false ) ? ( ( $non_html_amp ) ? '&' : '&amp;' ) : '?' ) . $SID;  
  701. }  
  702. }  
  703.  
  704. return $url;  
  705. }  
  706.  
  707. ?>  
  708.  


Zuker [ Sun 09 Mar, 2008 16:54 ]
Post subject: Re: Problem With Update
that's a different file from the one included on the IP 1.2 Package... like i told you

download a clean package, unzip it and check


DarthCarl [ Sun 09 Mar, 2008 16:57 ]
Post subject: Re: Problem With Update
No, you misunderstood me. I no longer want to update it, I want to fix a mistake. That is the sessions.php of Icy 1.1.0.45


Zuker [ Sun 09 Mar, 2008 17:02 ]
Post subject: Re: Problem With Update
there it's no 1.1.0.45, are you talking about 1.1.0.15?


DarthCarl [ Sun 09 Mar, 2008 17:05 ]
Post subject: Re: Problem With Update
Yes, I confuse versions


Zuker [ Sun 09 Mar, 2008 17:15 ]
Post subject: Re: Problem With Update
Run this sql, but you may have lot's of errors since more than one field it's dropped when upgrading.
Why don't u wanna upgrade?

ALTER TABLE `phpbb_sessions` ADD `session_topic` int(11) NOT NULL default '0',


DarthCarl [ Sun 09 Mar, 2008 17:19 ]
Post subject: Re: Problem With Update
This is what he said:
MySQL said: Documentación
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


PS: I do not want to upgrade because I have tried many times and only got off the forum some time


Zuker [ Sun 09 Mar, 2008 17:25 ]
Post subject: Re: Problem With Update
run this fix


DarthCarl [ Sun 09 Mar, 2008 17:27 ]
Post subject: Re: Problem With Update
This is what comes out: http://forosdwp.webcindario.com/foros/fix.php


Zuker [ Sun 09 Mar, 2008 17:33 ]
Post subject: Re: Problem With Update
i'm checking that to many fields were dropped, check update_to_ip.php, find what was dropped and add it again...

it will be easier to upgrade


DarthCarl [ Sun 09 Mar, 2008 17:36 ]
Post subject: Re: Problem With Update
Ok, come back to prove. By the way, what is the code Update_to_ip.php?
I say this to see what went wrong


Zuker [ Sun 09 Mar, 2008 17:46 ]
Post subject: Re: Problem With Update
i'll add one field to make you understand what you have to do... check inside the install/schemas and find all the sql schemas for the version you are using

ALTER TABLE phpbb_sessions ADD session_topic int(11) DEFAULT '0' NOT NULL;


DarthCarl [ Sun 09 Mar, 2008 18:16 ]
Post subject: Re: Problem With Update
Appears this:
Critical Error

Error updating sessions table

DEBUG MODE

SQL Error : 1054 Unknown column 'user_session_topic' in 'field list'

UPDATE icy_users SET user_session_time = 1205082936, user_session_page = 19, user_session_topic = '48', user_totalpages = user_totalpages + 1, user_totaltime = user_totaltime + (1205082936 - 1205082931) WHERE user_id = 2

Line : 441
File : sessions.php


Zuker [ Sun 09 Mar, 2008 18:26 ]
Post subject: Re: Problem With Update
as i told you... there are more than one field that was dropped due to upgrade.

test this file, it should fix all your problems.


DarthCarl [ Sun 09 Mar, 2008 19:18 ]
Post subject: Re: Problem With Update
A million of thanks!!!!!!!!!! I have already arranged a personal website, thank you again
:D :D :D :D :D


Zuker [ Sun 09 Mar, 2008 19:45 ]
Post subject: Re: Problem With Update
you are welcome, anyway, you should think in a future upgrading to ip 1.2 :)


DarthCarl [ Sun 09 Mar, 2008 20:02 ]
Post subject: Re: Problem With Update
Ok, I thinking about what




Powered by Icy Phoenix