Baseball Posted December 22, 2009 Share Posted December 22, 2009 require_once "ipbsdk/ipbsdk_class.inc.php"; $SDK =& new IPBSDK(); global $ibforums; And the ipbsdk_class file is over 10k lines of code.. im lost on what the $SDK =& new IPBSDK(); does and global $ibforums; So when I put this in a test.php i can echo {$ibforums->member["id"]} and it will give me the session id of whoever is logged in but were do i find all this information from? Is it all in the big 10k line ipbdsk_class.php file? if so very confusing. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/ Share on other sites More sharing options...
Baseball Posted December 22, 2009 Author Share Posted December 22, 2009 And why is my session class so freaking long? class session { var $ip_address = 0; var $user_agent = ""; var $time_now = 0; var $session_id = 0; var $session_dead_id = 0; var $session_user_id = 0; var $session_user_pass = ""; var $last_click = 0; var $location = ""; var $member = array(); // No need for a constructor function authorise() { global $DB, $INFO, $ibforums, $std, $_SERVER; //------------------------------------------------- // Before we go any lets check the load settings.. //------------------------------------------------- if ($ibforums->vars['load_limit'] > 0) { //-- mod_sec_update_131 begin if (true) { if (file_exists('/proc/loadavg')) { if ($fh = @fopen( '/proc/loadavg', 'r' )) { $data = @fread( $fh, 6 ); @fclose( $fh ); $load_avg = explode( " ", $data ); $ibforums->server_load = trim($load_avg[0]); } } // no /proc/loadavg or no permission to read it if (!$ibforums->server_load && $serverstats = @exec("uptime")) { if (preg_match( "/average.*?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $serverstats, $load )) $ibforums->server_load = $load[1]; } // are we on a windows with load average installed? if (!$ibforums->server_load && $serverstats = @exec("getloadavg")) { if (preg_match( "/average.*?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $serverstats, $load )) $ibforums->server_load = $load[1]; } if ($ibforums->server_load > $ibforums->vars['load_limit']) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'server_too_busy', 'INIT' => 1 ) ); } } else //-- mod_sec_update_131 end if ( file_exists('/proc/loadavg') ) { if ( $fh = @fopen( '/proc/loadavg', 'r' ) ) { $data = @fread( $fh, 6 ); @fclose( $fh ); $load_avg = explode( " ", $data ); $ibforums->server_load = trim($load_avg[0]); if ($ibforums->server_load > $ibforums->vars['load_limit']) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'server_too_busy', 'INIT' => 1 ) ); } } } else { if ( $serverstats = @exec("uptime") ) { preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $serverstats, $load ); $ibforums->server_load = $load[1]; } } } //-------------------------------------------- // Are they banned? //-------------------------------------------- if ($ibforums->vars['ban_ip']) { $ips = explode( "|", $ibforums->vars['ban_ip'] ); foreach ($ips as $ip) { $ip = preg_replace( "/\*/", '.*' , preg_quote($ip, "/") ); if ( preg_match( "/^$ip/", $ibforums->input['IP_ADDRESS'] ) ) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'you_are_banned', 'INIT' => 1 ) ); } } } //-------------------------------------------- $this->member = array( 'id' => 0, 'password' => "", 'name' => "", 'mgroup' => $INFO['guest_group'] ); //-------------------------------------------- // no new headers if we're simply viewing an attachment.. //-------------------------------------------- //-- mod_sec_update_131 begin if ($ibforums->vars['guests_attach']) //-- mod_sec_update_131 end if ( $ibforums->input['act'] == 'Attach' ) { return $this->member; } $_SERVER['HTTP_USER_AGENT'] = $std->clean_value($_SERVER['HTTP_USER_AGENT']); $this->ip_address = $ibforums->input['IP_ADDRESS']; //-- mod_sec_update_131 begin $this->ip_address = $ibforums->input['IP_ADDRESS'] ? $ibforums->input['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR']; //-- mod_sec_update_131 end $this->user_agent = substr($_SERVER['HTTP_USER_AGENT'],0,50); $this->time_now = time(); //------------------------------------------------- // Manage bots? (tee-hee) //------------------------------------------------- if ( $ibforums->vars['spider_sense'] == 1 ) { $remap_agents = array( 'googlebot' => 'google', 'slurp@inktomi' => 'inktomi', 'ask jeeves' => 'jeeves', 'lycos' => 'lycos', 'whatuseek' => 'wuseek', 'ia_archiver' => 'Archive_org', ); if ( preg_match( '/(googlebot|slurp@inktomi|ask jeeves|lycos|whatuseek|ia_archiver)/i', $_SERVER['HTTP_USER_AGENT'], $match ) ) { $DB->query("SELECT * from ibf_groups WHERE g_id=".$ibforums->vars['spider_group']); $group = $DB->fetch_row(); foreach ($group as $k => $v) { $this->member[ $k ] = $v; } $this->member['restrict_post'] = 1; $this->member['g_use_search'] = 0; $this->member['g_email_friend'] = 0; $this->member['g_edit_profile'] = 0; $this->member['g_use_pm'] = 0; $this->member['g_is_supmod'] = 0; $this->member['g_access_cp'] = 0; $this->member['g_access_offline'] = 0; $this->member['g_avoid_flood'] = 0; $this->member['id'] = 0; $ibforums->perm_id = $this->member['g_perm_id']; $ibforums->perm_id_array = explode( ",", $ibforums->perm_id ); $ibforums->session_type = 'cookie'; $ibforums->is_bot = 1; $this->session_id = ""; if ( ! $agent = $remap_agents[ $match[1] ] ) { $agent = 'google'; } if ( $ibforums->vars['spider_visit'] ) { $dba = $DB->compile_db_insert_string( array ( 'bot' => $agent, 'query_string' => str_replace( "'", "", $_SERVER['QUERY_STRING']), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'entry_date' => time(), ) ); $DB->query("INSERT INTO ibf_spider_logs ({$dba['FIELD_NAMES']}) VALUES({$dba['FIELD_VALUES']})"); } if ( $ibforums->vars['spider_active'] ) { $DB->query("DELETE FROM ibf_sessions WHERE id='".$agent."_session'"); $this->create_bot_session($agent); } return $this->member; } } //------------------------------------------------- // Continue! //------------------------------------------------- $cookie = array(); $cookie['session_id'] = $std->my_getcookie('session_id'); $cookie['member_id'] = $std->my_getcookie('member_id'); $cookie['pass_hash'] = $std->my_getcookie('pass_hash'); if ( $cookie['session_id'] ) { $this->get_session($cookie['session_id']); $ibforums->session_type = 'cookie'; } elseif ( $ibforums->input['s'] ) { $this->get_session($ibforums->input['s']); $ibforums->session_type = 'url'; } else { $this->session_id = 0; } //------------------------------------------------- // Finalise the incoming data.. //------------------------------------------------- $ibforums->input['Privacy'] = $std->select_var( array( 1 => $ibforums->input['Privacy'], 2 => $std->my_getcookie('anonlogin') ) ); //-- mod_sec_update_131 begin $ibforums->input['Privacy'] = max(0, intval($ibforums->input['Privacy'])); //-- mod_sec_update_131 end //------------------------------------------------- // Do we have a valid session ID? //------------------------------------------------- if ( $this->session_id ) { // We've checked the IP addy and browser, so we can assume that this is // a valid session. if ( ($this->session_user_id != 0) and ( ! empty($this->session_user_id) ) ) { // It's a member session, so load the member. $this->load_member($this->session_user_id); // Did we get a member? if ( (! $this->member['id']) or ($this->member['id'] == 0) ) { $this->unload_member(); $this->update_guest_session(); } else { $this->update_member_session(); } } else { $this->update_guest_session(); } } else { // We didn't have a session, or the session didn't validate // Do we have cookies stored? if ($cookie['member_id'] != "" and $cookie['pass_hash'] != "") { $this->load_member($cookie['member_id']); if ( (! $this->member['id']) or ($this->member['id'] == 0) ) { $this->unload_member(); $this->create_guest_session(); } else { if ($this->member['password'] == $cookie['pass_hash']) { $this->create_member_session(); } else { $this->unload_member(); $this->create_guest_session(); } } } else { $this->create_guest_session(); } } //------------------------------------------------- // Set up a guest if we get here and we don't have a member ID //------------------------------------------------- if (! $this->member['id']) { $this->member = $std->set_up_guest(); $DB->query("SELECT * from ibf_groups WHERE g_id='".$INFO['guest_group']."'"); $group = $DB->fetch_row(); foreach ($group as $k => $v) { $this->member[ $k ] = $v; } } //------------------------------------------------ // Synchronise the last visit and activity times if // we have some in the member profile //------------------------------------------------- if ($this->member['id']) { if ( ! $ibforums->input['last_activity'] ) { if ($this->member['last_activity']) { $ibforums->input['last_activity'] = $this->member['last_activity']; } else { $ibforums->input['last_activity'] = $this->time_now; } } //------------ if ( ! $ibforums->input['last_visit'] ) { if ($this->member['last_visit']) { $ibforums->input['last_visit'] = $this->member['last_visit']; } else { $ibforums->input['last_visit'] = $this->time_now; } } //------------------------------------------------- // If there hasn't been a cookie update in 2 hours, // we assume that they've gone and come back //------------------------------------------------- if (!$this->member['last_visit']) { // No last visit set, do so now! $DB->query("UPDATE ibf_members SET last_visit='".$this->time_now."', last_activity='".$this->time_now."' WHERE id=".$this->member['id']); } else if ( (time() - $ibforums->input['last_activity']) > 300 ) { // If the last click was longer than 5 mins ago and this is a member // Update their profile. $DB->query("UPDATE ibf_members SET last_activity='".$this->time_now."' WHERE id=".$this->member['id']); } //------------------------------------------------- // Check ban status //------------------------------------------------- if ( $this->member['temp_ban'] ) { $ban_arr = $std->hdl_ban_line( $this->member['temp_ban'] ); if ( time() >= $ban_arr['date_end'] ) { // Update this member's profile $DB->query("UPDATE ibf_members SET temp_ban='' WHERE id=".intval($this->member['id']) ); } else { $ibforums->member = $this->member; // Set time right $std->Error( array( 'LEVEL' => 1, 'MSG' => 'account_susp', 'INIT' => 1, 'EXTRA' => $std->get_date($ban_arr['date_end'],'LONG') ) ); } } } //------------------------------------------------- // Set a session ID cookie //------------------------------------------------- $std->my_setcookie("session_id", $this->session_id, -1); $ibforums->perm_id = ( $this->member['org_perm_id'] ) ? $this->member['org_perm_id'] : $this->member['g_perm_id']; $ibforums->perm_id_array = explode( ",", $ibforums->perm_id ); return $this->member; } Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982012 Share on other sites More sharing options...
trq Posted December 22, 2009 Share Posted December 22, 2009 $SDK =& new IPBSDK(); Creates a new reference to the IPBSDK object and stores it within $SDK. As for why the files are so big? Thats something you need to take up within whoever wrote the code. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982019 Share on other sites More sharing options...
Baseball Posted December 22, 2009 Author Share Posted December 22, 2009 $SDK =& new IPBSDK(); Creates a new reference to the IPBSDK object and stores it within $SDK. As for why the files are so big? Thats something you need to take up within whoever wrote the code. The guy who wrote is called Matt Mecham, he's creator of IPB .. he wrote this specific code in 2002.. there's no way he'll remember or anyway he will have time to contact me for help that's why I post here bro. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982022 Share on other sites More sharing options...
trq Posted December 22, 2009 Share Posted December 22, 2009 What kind of question is 'why is my session class so freaking long?' Because it is? Sometimes programs require allot of code. There's no simple answer. I can tell you its terribly written and very out of date, but does that help you? Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982025 Share on other sites More sharing options...
Baseball Posted December 22, 2009 Author Share Posted December 22, 2009 What kind of question is 'why is my session class so freaking long?' Because it is? Sometimes programs require allot of code. There's no simple answer. I can tell you its terribly written and very out of date, but does that help you? Yeah actually it does, lol. Cause im not gonna use it now, lol how it outwritten cause he makes var in beggining huh? Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982094 Share on other sites More sharing options...
trq Posted December 22, 2009 Share Posted December 22, 2009 var is just old code, nothing wrong with it. The use of globals within classes however wreaks of poor design. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982098 Share on other sites More sharing options...
Baseball Posted December 22, 2009 Author Share Posted December 22, 2009 var is just old code, nothing wrong with it. The use of globals within classes however wreaks of poor design. But he is the person who made ipb ... .. So who are you to tell this , you havn't gone out and made a professional forum software like invision power board have you? Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982099 Share on other sites More sharing options...
trq Posted December 22, 2009 Share Posted December 22, 2009 var is just old code, nothing wrong with it. The use of globals within classes however wreaks of poor design. But he is the person who made ipb ... .. So who are you to tell this , you havn't gone out and made a professional forum software like invision power board have you? No, I haven't but I have written plenty of software in my time. Just because something is widely used does not make it good code / design. In fact allot of these forums are very poorly coded. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982103 Share on other sites More sharing options...
Baseball Posted December 22, 2009 Author Share Posted December 22, 2009 var is just old code, nothing wrong with it. The use of globals within classes however wreaks of poor design. But he is the person who made ipb ... .. So who are you to tell this , you havn't gone out and made a professional forum software like invision power board have you? No, I haven't but I have written plenty of software in my time. Just because something is widely used does not make it good code / design. In fact allot of these forums are very poorly coded. I think Vbulletin is the worst one of them all, Honestly I think any forum software is blusterd with extra code and custom or rewritten software is the best way to be. Link to comment https://forums.phpfreaks.com/topic/185966-what-does-sdk-new-ipbsdk-mean/#findComment-982115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.