/**
  * Fetch an RSS feed's encoding, if possible
  *
  * @access	protected
  * @return	void
  */
 protected function _fetchEncoding()
 {
     $url = $this->request['url'];
     if (!$url) {
         $this->returnJsonError($this->lang->words['ajax__no_url']);
     }
     require_once IPS_KERNEL_PATH . '/classFileManagement.php';
     $fileManagement = new classFileManagement();
     $xmlDocument = $fileManagement->getFileContents($url);
     if (!$xmlDocument) {
         $this->returnJsonError($this->lang->words['ajax__no_doc']);
     }
     if (preg_match("#encoding=['\"](.+?)[\"']#i", $xmlDocument, $matches)) {
         $this->returnJsonArray(array('encoding' => $matches[1]));
     } else {
         $this->returnJsonError($this->lang->words['ajax__no_charset']);
     }
 }
示例#2
0
 /**
  * Check License Key
  *
  * @access	public
  * @return	bool
  */
 private function check()
 {
     $this->request['lkey'] = trim($this->request['lkey']);
     // License key is optional
     if (!$this->request['lkey']) {
         return true;
     }
     $url = IPSSetup::getSavedData('install_url');
     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
     /*noLibHook*/
     $query = new classFileManagement();
     $response = $query->getFileContents("http://license.invisionpower.com/?a=check&key={$this->request['lkey']}&url={$url}");
     $response = json_decode($response, true);
     if ($response['result'] != 'ok') {
         return "Your license key could not be activated. Please check your key and try again. If the problem persists, please contact technical support.";
     } else {
         IPSSetup::setSavedData('lkey', $this->request['lkey']);
         return TRUE;
     }
 }
示例#3
0
 /**
  * Check License Key
  *
  * @access	public
  * @return	bool
  */
 private function check($init = FALSE)
 {
     $this->request['lkey'] = $init ? ipsRegistry::$settings['ipb_reg_number'] : trim($this->request['lkey']);
     if (!$this->request['lkey'] and !$init) {
         return true;
     }
     $url = ipsRegistry::$settings['board_url'] ? ipsRegistry::$settings['board_url'] : ipsRegistry::$settings['base_url'];
     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
     /*noLibHook*/
     $query = new classFileManagement();
     $response = $query->getFileContents("http://license.invisionpower.com/?a=check&key={$this->request['lkey']}&url={$url}");
     $response = json_decode($response, true);
     if ($response['result'] != 'ok') {
         if ($this->request['ignoreError']) {
             return TRUE;
         } else {
             return "License key check failed. Click next to continue anyway.";
         }
     } else {
         IPSLib::updateSettings(array('ipb_reg_number' => $this->request['lkey']));
         return TRUE;
     }
 }
 /**
  * Fetches the JSON from the remote server and writes it
  */
 public function buildLocalJsonCache()
 {
     /* Now fetch JSON data from the server and write it */
     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
     /*noLibHook*/
     $files = new classFileManagement();
     $json = $files->getFileContents($this->getJsonUrl());
     if ($json) {
         $cacheFile = IPS_CACHE_PATH . 'cache/skinGenJsonCache.js';
         if (file_exists($cacheFile)) {
             @unlink($cacheFile);
         }
         file_put_contents($cacheFile, $json);
         @chmod($cacheFile, 0777);
     } else {
         throw new Exception("JSON_NOT_RETURNED");
     }
     return true;
 }
 /**
  * Sends a query to the IPS Spam Service
  *
  * @access	public
  * @param	string		$email		Email address to check/report
  * @param	string		[$ip]		IP Address to check report, ipsRegistry::member()->ip_address will be used if the address is not specified
  * @param	string		[$type]		Either register or markspam, register is default
  * @return	string
  */
 public static function querySpamService($email, $ip = '', $type = 'register', $test = 0)
 {
     /* Get the response */
     $key = ipsRegistry::$settings['spam_service_api_key'];
     $domain = ipsRegistry::$settings['board_url'];
     $ip = ip2long($ip) ? $ip : ipsRegistry::member()->ip_address;
     $response = false;
     $testConn = $test ? '&debug_mode=1' : '';
     /* Get the file managemnet class */
     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
     $query = new classFileManagement();
     $query->use_sockets = 1;
     $query->timeout = ipsRegistry::$settings['spam_service_timeout'];
     /* Query the service */
     $response = $query->getFileContents("http://ips-spam-service.com/api/index.php?key={$key}&domain={$domain}&type={$type}&email={$email}&ip={$ip}{$testConn}");
     if (!$response) {
         return 'timeout';
     }
     $response = explode("\n", $response);
     $responseCode = $response[0];
     $responseMsg = $response[1];
     if ($test) {
         return $responseMsg;
     }
     /* Log Request */
     if ($type == 'register') {
         ipsRegistry::DB()->insert('spam_service_log', array('log_date' => time(), 'log_code' => $responseCode, 'log_msg' => $responseMsg, 'email_address' => $email, 'ip_address' => $ip));
     }
     return intval($responseCode);
 }
示例#6
0
 /**
  * Make call to IPS to get API keys
  *
  * @return	array
  */
 private function _makeApiCall()
 {
     $subId = NULL;
     if (ipsRegistry::$settings['ipb_reg_number']) {
         $exploded = explode('-', ipsRegistry::$settings['ipb_reg_number']);
         if (isset($exploded[3])) {
             $subId = $exploded[3];
         }
     }
     if ($subId === NULL) {
         $subId = ipsRegistry::$settings['board_url'];
         if (strlen($subId) > 32) {
             $subId = str_replace(array('http://', 'https://'), '', $subId);
         }
         if (strlen($subId) > 32) {
             $subId = md5($subId);
         }
     }
     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
     $cfm = new classFileManagement();
     $return = $cfm->getFileContents("http://license.invisionpower.com/viglink/?subId=" . urlencode($subId));
     if ($return and $json = @json_decode($return, TRUE) and $json['SUCCESS'] == TRUE) {
         return $json;
     } else {
         ipsRegistry::getClass('output')->showError(ipsRegistry::getClass('class_localization')->words['enhancements_viglink_error']);
     }
 }
 /**
  * Check if there is an update for a hook
  *
  * @access	private
  * @param	string 		URL to check
  * @param	string		Long version number
  * @return	bool
  */
 private function _updateAvailable($url, $version)
 {
     if (!$version) {
         return false;
     }
     require_once IPS_KERNEL_PATH . '/classFileManagement.php';
     $checker = new classFileManagement();
     $checker->use_sockets = $this->settings['enable_sockets'];
     //-----------------------------------------
     // This is a low timeout to prevent page from taking too long
     //-----------------------------------------
     $checker->timeout = 5;
     $return = $checker->getFileContents(str_replace('php&', 'php?', $url . '&version=' . $version));
     return $return == 1 ? true : false;
 }
 /**
  * Extract: Parse RSS document from URL
  *
  * @param	string		URI
  * @return	@e boolean
  */
 public function parseFeedFromUrl($feed_location)
 {
     //-----------------------------------------
     // Load file management class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . '/classFileManagement.php';
     /*noLibHook*/
     $this->classFileManagement = new classFileManagement();
     $this->classFileManagement->use_sockets = $this->use_sockets;
     $this->classFileManagement->auth_req = $this->auth_req;
     $this->classFileManagement->auth_user = $this->auth_user;
     $this->classFileManagement->auth_pass = $this->auth_pass;
     $this->classFileManagement->userAgent = $this->userAgent;
     //-------------------------------
     // Reset arrays
     //-------------------------------
     $this->rss_items = array();
     $this->rss_channels = array();
     //-------------------------------
     // Get data
     //-------------------------------
     $data = $this->classFileManagement->getFileContents($feed_location);
     if (count($this->classFileManagement->errors)) {
         $this->errors = $this->classFileManagement->errors;
         return FALSE;
     }
     $_foundIn = '';
     if (preg_match("#encoding=[\"'](\\S+?)[\"']#si", $data, $matches)) {
         $this->orig_doc_type = strtoupper($matches[1]);
         $_foundIn = 'encoding';
     }
     if (!$this->orig_doc_type and preg_match("#charset=(\\S+?)#si", $data, $matches)) {
         $this->orig_doc_type = strtoupper($matches[1]);
         $_foundIn = 'charset';
     }
     //-----------------------------------------
     // If feed charset isn't supportd by XML lib,
     // convert to UTF-8
     // Edit - ALWAYS use utf-8.  A wide html entity (‘) is
     // valid in iso-8859-1 output because it is an entity, however
     // the XML library tries to convert all entities to their appropriate
     // character which corrupts it.
     // @link	http://community.invisionpower.com/tracker/issue-33588-rss-import-character-issue
     // @link	http://us.php.net/manual/en/function.xml-set-character-data-handler.php#35065
     //-----------------------------------------
     $supported_encodings = array("UTF-8");
     $charset = ($this->orig_doc_type and in_array($this->orig_doc_type, $supported_encodings)) ? $this->orig_doc_type : "UTF-8";
     if ($this->convert_charset and $data) {
         if ($charset != $this->orig_doc_type) {
             $data = IPSText::convertCharsets($data, $this->orig_doc_type, $charset);
             # Replace any char-set= data
             if ($_foundIn == 'encoding') {
                 $data = preg_replace("#encoding=[\"'](\\S+?)[\"']#si", "encoding=\"" . $charset . "\"", $data);
             } else {
                 $data = preg_replace("#charset=(\\S+?)#si", "charset=" . $charset, $data);
             }
         }
     }
     /* Parse */
     $this->_parse($data, $charset);
     return TRUE;
 }
示例#9
0
 /**
  * Constructor :: Authorizes the session
  *
  * @param	boolean		$noAutoParsingSessions		No auto parsing of sessions - set as true when using API-like methods
  * @return	@e mixed	Void normally, but can print error message
  */
 public function __construct($noAutoParsingSessions = false)
 {
     /* Make object */
     $this->registry = ipsRegistry::instance();
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     $this->_member = self::instance();
     $this->_memberData =& self::instance()->fetchMemberData();
     /* Delete immediately */
     $this->_deleteNow = true;
     /**
      * If the sso.php file is present in this folder, we'll load it.
      * This file can be used to easily integrate single-sign on in
      * situations where you need to check session data
      */
     if (is_file(IPS_ROOT_PATH . '/sources/classes/session/sso.php')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/session/sso.php', 'ssoSessionExtension');
         if (class_exists($classToLoad)) {
             $this->sso = new $classToLoad($this->registry);
         }
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cookie = array();
     $this->_userAgent = substr($this->_member->user_agent, 0, 200);
     //-----------------------------------------
     // Fix up app / section / module
     //-----------------------------------------
     $this->current_appcomponent = IPS_APP_COMPONENT;
     $this->current_module = IPSText::alphanumericalClean($this->request['module']);
     $this->current_section = IPSText::alphanumericalClean($this->request['section']);
     $this->settings['session_expiration'] = $this->settings['session_expiration'] ? $this->settings['session_expiration'] : 3600;
     //-----------------------------------------
     // Return as guest if running a task
     //-----------------------------------------
     if (IPS_IS_TASK) {
         self::$data_store = IPSMember::setUpGuest();
         self::$data_store['last_activity'] = time();
         self::$data_store['last_visit'] = time();
         return true;
     }
     /* Not auto parsing sessions? */
     if ($noAutoParsingSessions === true) {
         return true;
     }
     //-----------------------------------------
     // no new headers if we're simply viewing an attachment..
     //-----------------------------------------
     if ($this->request['section'] == 'attach') {
         $this->settings['no_print_header'] = 1;
     }
     //-----------------------------------------
     // no new headers if we're updating chat
     //-----------------------------------------
     if (IPS_IS_AJAX && ($this->request['section'] != 'login' && $this->request['section'] != 'skin') or $this->request['section'] == 'attach' or $this->request['section'] == 'captcha') {
         $this->settings['no_print_header'] = 1;
         $this->do_update = 0;
     }
     //-----------------------------------------
     // IPS Connect
     //-----------------------------------------
     $ipsConnectEnabled = FALSE;
     foreach ($this->caches['login_methods'] as $k => $data) {
         if ($data['login_folder_name'] == 'ipsconnect' and $data['login_enabled']) {
             $ipsConnectEnabled = TRUE;
             $ipsConnectSettings = unserialize($data['login_custom_config']);
         }
     }
     //-----------------------------------------
     // Continue!
     //-----------------------------------------
     $cookie['session_id'] = IPSCookie::get('session_id');
     $cookie['member_id'] = IPSCookie::get('member_id');
     $cookie['pass_hash'] = IPSCookie::get('pass_hash');
     if ($cookie['session_id'] && empty($this->request['_nsc'])) {
         $this->getSession($cookie['session_id']);
         $this->session_type = 'cookie';
     } elseif (!empty($this->request['s'])) {
         $this->getSession($this->request['s']);
         $this->session_type = 'url';
     } else {
         $this->session_id = 0;
         $this->session_type = 'url';
     }
     //-----------------------------------------
     // Do we have a valid session ID?
     //-----------------------------------------
     if ($this->session_id) {
         $haveMember = FALSE;
         $forceNoMember = FALSE;
         /* Check we're not specifically logged out of IPS Connect */
         if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) and !$_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
             $forceNoMember = TRUE;
         }
         /* Check Local */
         if (!empty($this->session_user_id) and !$forceNoMember) {
             self::setMember($this->session_user_id);
             if (self::$data_store['member_id'] and self::$data_store['member_id'] != 0) {
                 $haveMember = TRUE;
             }
         }
         /* Check IPS Connect */
         if (!$haveMember and !$forceNoMember) {
             if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])])) {
                 if ($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
                     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
                     $cfm = new classFileManagement();
                     $return = $cfm->getFileContents($ipsConnectSettings['master_url'] . '?' . http_build_query(array('act' => 'cookies', 'data' => json_encode($_COOKIE))));
                     if ($return = @json_decode($return, TRUE)) {
                         if ($return['connect_status'] == 'SUCCESS') {
                             $this->_handleIpsConnect($return);
                             $haveMember = TRUE;
                         }
                     }
                 }
             }
         }
         /* Handle */
         if ($haveMember) {
             $this->_updateMemberSession();
             /**
              * If we have an SSO object, run it for the update member call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                 $this->sso->checkSSOForMember('update');
             }
         } else {
             $this->_updateGuestSession();
             /**
              * If we have an SSO object, run it for the update guest session call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('update');
             }
         }
     } else {
         //-----------------------------------------
         // We didn't have a session, or the session didn't validate
         // Do we have cookies stored?
         //-----------------------------------------
         $haveMember = FALSE;
         if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])])) {
             if ($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
                 require_once IPS_KERNEL_PATH . 'classFileManagement.php';
                 $cfm = new classFileManagement();
                 $return = $cfm->getFileContents($ipsConnectSettings['master_url'] . '?' . http_build_query(array('act' => 'cookies', 'data' => json_encode($_COOKIE))));
                 if ($return = @json_decode($return, TRUE)) {
                     if ($return['connect_status'] == 'SUCCESS') {
                         $this->_handleIpsConnect($return);
                         $haveMember = TRUE;
                     }
                 }
             }
         } elseif ($cookie['member_id'] != "" and $cookie['pass_hash'] != "") {
             self::setMember($cookie['member_id']);
             if (self::$data_store['member_id'] and self::$data_store['member_login_key'] == $cookie['pass_hash'] and (!$this->settings['login_key_expire'] or time() <= self::$data_store['member_login_key_expire'])) {
                 $haveMember = TRUE;
             }
         }
         //-----------------------------------------
         // Handle
         //-----------------------------------------
         if ($haveMember) {
             $this->_createMemberSession();
             /**
              * If we have an SSO object, run it for the create member call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                 $this->sso->checkSSOForMember('create');
             }
         } else {
             self::setMember(0);
             $this->_createGuestSession();
             /**
              * If we have an SSO object, run it for the create guest call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('create');
             }
         }
     }
     //-----------------------------------------
     // Knock out Google Web Accelerator
     //-----------------------------------------
     if (ipsRegistry::$settings['disable_prefetching']) {
         if (my_getenv('HTTP_X_MOZ') and strstr(strtolower(my_getenv('HTTP_X_MOZ')), 'prefetch') and self::$data_store['member_id']) {
             if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) {
                 @header('HTTP/1.0 403 Forbidden');
             } else {
                 @header('HTTP/1.1 403 Forbidden');
             }
             @header("Cache-Control: no-cache, must-revalidate, max-age=0");
             @header("Expires: 0");
             @header("Pragma: no-cache");
             print "Prefetching or precaching is not allowed. If you have Google Accelerator enabled, please disable";
             exit;
         }
     }
     //-----------------------------------------
     // Still no member id and not a bot?
     //-----------------------------------------
     if (empty(self::$data_store['member_id']) and !$this->_member->is_not_human) {
         self::setMember(0);
         self::$data_store['last_activity'] = time();
         $this->request['last_visit'] = time();
     }
     //-----------------------------------------
     // Set a session ID cookie
     //-----------------------------------------
     $this->_member->session_type = $this->session_type;
     $this->_member->session_id = $this->session_id;
     IPSCookie::set("session_id", $this->session_id, -1);
 }
示例#10
0
 /**
  * Flush IPS CDN Cache
  */
 public function flushipscdn()
 {
     if (ipsRegistry::$settings['ips_cdn']) {
         require_once IPS_KERNEL_PATH . 'classFileManagement.php';
         $cfm = new classFileManagement();
         $cfm->timeout = 1;
         $cfm->getFileContents("http://license.invisionpower.com/?a=cdnflush&key=" . ipsRegistry::$settings['ipb_reg_number'] . "&version=" . IPB_LONG_VERSION);
     }
 }