コード例 #1
0
ファイル: core.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Get a cookie.
  * Abstract layer allows us to do some checking, etc
  *
  * @param	string		Cookie name
  * @return	mixed
  * @since	2.0
  */
 public static function get($name)
 {
     /* Check internal data first */
     if (isset(self::$_cookiesSet[$name])) {
         return self::$_cookiesSet[$name];
     } else {
         if (isset($_COOKIE[ipsRegistry::$settings['cookie_id'] . $name])) {
             $_value = $_COOKIE[ipsRegistry::$settings['cookie_id'] . $name];
             $_couldBeJson = stripslashes(urldecode($_value));
             $_test = json_decode($_couldBeJson, true);
             if (is_array($_test)) {
                 return IPSLib::parseIncomingRecursively($_test);
             } else {
                 return IPSText::parseCleanValue(urldecode($_value));
             }
         } else {
             return FALSE;
         }
     }
 }
コード例 #2
0
 /**
  * INIT furls
  * Performs set up and figures out any incoming links
  *
  * @return	@e void
  */
 protected static function _fUrlInit()
 {
     /**
      * Fix request uri
      */
     self::_fixRequestUri();
     if (ipsRegistry::$settings['use_friendly_urls']) {
         /* Grab and store accessing URL */
         self::$_uri = preg_replace("/s=(&|\$)/", '', str_replace('/?', '/' . IPS_PUBLIC_SCRIPT . '?', $_SERVER['REQUEST_URI']));
         $_urlBits = array();
         /* Grab FURL data... */
         if (!IN_DEV and is_file(FURL_CACHE_PATH)) {
             $templates = array();
             include FURL_CACHE_PATH;
             /*noLibHook*/
             self::$_seoTemplates = $templates;
         } else {
             /* Attempt to write it */
             self::$_seoTemplates = IPSLib::buildFurlTemplates();
             try {
                 IPSLib::cacheFurlTemplates();
             } catch (Exception $e) {
             }
         }
         if (is_array(self::$_seoTemplates) and count(self::$_seoTemplates)) {
             $uri = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI');
             /* Bug 21295 - remove known URL from test URI */
             $_t = !empty(ipsRegistry::$settings['board_url']) ? @parse_url(ipsRegistry::$settings['board_url']) : @parse_url(ipsRegistry::$settings['base_url']);
             $_toTest = ($_t['path'] and $_t['path'] != '/') ? preg_replace("#^{$_t['path']}#", '', $uri) : str_replace($_t['scheme'] . '://' . $_t['host'], '', $uri);
             $_404Check = $_toTest;
             //We want to retain any /index.php for this test later in this block of code
             $_toTest = str_ireplace(array('//' . IPS_PUBLIC_SCRIPT . '?', '/' . IPS_PUBLIC_SCRIPT . '?', '/' . IPS_PUBLIC_SCRIPT), '', $_toTest);
             $_gotMatch = false;
             foreach (self::$_seoTemplates as $key => $data) {
                 if (empty($data['in']['regex'])) {
                     continue;
                 }
                 /* Clean up regex */
                 $data['in']['regex'] = str_replace('#{__varBlock__}', preg_quote(self::$_seoTemplates['__data__']['varBlock'], '#'), $data['in']['regex']);
                 if (preg_match($data['in']['regex'], $_toTest, $matches)) {
                     $_gotMatch = true;
                     /* Handling pages as a special thing? */
                     if ($data['isPagesMode']) {
                         if (strstr($_toTest, self::$_seoTemplates['__data__']['varPage'])) {
                             preg_match('#(' . preg_quote(self::$_seoTemplates['__data__']['varPage'], '#') . '(\\d+?))(?:$|' . preg_quote(self::$_seoTemplates['__data__']['varBlock'], '#') . ')#', $_toTest, $pageMatches);
                             if ($pageMatches[1]) {
                                 $k = 'page';
                                 $_GET[$k] = intval($pageMatches[2]);
                                 $_POST[$k] = intval($pageMatches[2]);
                                 $_REQUEST[$k] = intval($pageMatches[2]);
                                 $_urlBits[$k] = intval($pageMatches[2]);
                                 ipsRegistry::$request[$k] = intval($pageMatches[2]);
                                 $_toTest = str_replace($pageMatches[1], '', $_toTest);
                             }
                         } else {
                             /* Redirect all < 3.4 links to the new sexy awesome format if need be */
                             if (self::$_seoTemplates['__data__']['varBlock'] != '/page__' && $uri && strstr($uri, '/page__')) {
                                 preg_match('#(.*)(page__.*)$#', $uri, $matches);
                                 $url = $matches[1];
                                 $query = $matches[2];
                                 $newQuery = '?';
                                 $data = explode('__', substr($query, 6));
                                 for ($i = 0, $j = count($data); $i < $j; $i++) {
                                     $newQuery .= ($i % 2 == 0 ? '&' : '=') . $data[$i];
                                 }
                                 /* Class output not created here */
                                 header("HTTP/1.1 301 Moved Permanently");
                                 header("Location: " . $_t['scheme'] . '://' . $_t['host'] . $url . $newQuery);
                                 exit;
                             }
                         }
                     }
                     if (is_array($data['in']['matches'])) {
                         foreach ($data['in']['matches'] as $_replace) {
                             $k = IPSText::parseCleanKey($_replace[0]);
                             if (strpos($_replace[1], '$') !== false) {
                                 $v = IPSText::parseCleanValue($matches[intval(str_replace('$', '', $_replace[1]))]);
                             } else {
                                 $v = IPSText::parseCleanValue($_replace[1]);
                             }
                             $_GET[$k] = $v;
                             $_POST[$k] = $v;
                             $_REQUEST[$k] = $v;
                             $_urlBits[$k] = $v;
                             ipsRegistry::$request[$k] = $v;
                         }
                     }
                     if (strpos($_toTest, self::$_seoTemplates['__data__']['varBlock']) !== false) {
                         /* Changed how the input variables are parsed based on feedback in bug report 24907
                            @link http://community.invisionpower.com/tracker/issue-24907-member-list-pagination-not-work-with-checkbox
                            Input variables now preserve array depth properly as a result */
                         $_parse = substr($_toTest, strpos($_toTest, self::$_seoTemplates['__data__']['varBlock']) + strlen(self::$_seoTemplates['__data__']['varBlock']));
                         $_data = explode(self::$_seoTemplates['__data__']['varSep'], $_parse);
                         $_query = '';
                         foreach ($_data as $line) {
                             list($k, $v) = explode(self::$_seoTemplates['__data__']['varJoin'], $line);
                             $_query .= $k . '=' . $v . '&';
                         }
                         $_data = array();
                         parse_str($_query, $_data);
                         $_data = IPSLib::parseIncomingRecursively($_data);
                         foreach ($_data as $k => $v) {
                             $_GET[$k] = $v;
                             $_POST[$k] = $v;
                             $_REQUEST[$k] = $v;
                             $_urlBits[$k] = $v;
                             ipsRegistry::$request[$k] = $v;
                         }
                     }
                     break;
                 }
             }
             /* Check against the original request for 404 error */
             $_404checkPass = false;
             if (!strstr($_404Check, '&') and !strstr($_404Check, '=') and (strstr($_404Check, IPS_PUBLIC_SCRIPT . '?/') or !strstr($_404Check, '.php'))) {
                 $_404checkPass = true;
             }
             if (strstr($_404Check, '/' . IPS_PUBLIC_SCRIPT)) {
                 if (preg_match("#(.+?)/" . preg_quote(IPS_PUBLIC_SCRIPT) . "#", $_404Check, $matches) and !is_file(DOC_IPS_ROOT_PATH . preg_replace('/(.+?)\\?.+/', '$1', $_404Check))) {
                     $_404checkPass = true;
                 }
             }
             /* Got a match? */
             if (!defined('CCS_GATEWAY_CALLED') and !defined('IPS_ENFORCE_ACCESS') and !defined('LOFIVERSION_CALLED') and IPS_IS_MOBILE_APP === false and IPS_DEFAULT_PUBLIC_APP == 'forums' and $_gotMatch === false and $_toTest and $_toTest != '/' and $_toTest != '/?' and $_404checkPass) {
                 self::$_noFurlMatch = true;
             }
             //-----------------------------------------
             // If using query string furl, extract any
             // secondary query string.
             // Ex: http://localhost/index.php?/path/file.html?key=value
             // Will pull the key=value properly
             //-----------------------------------------
             $_qmCount = substr_count($_toTest, '?');
             /* We don't want to check for secondary query strings in the ACP */
             if (!IN_ACP && $_qmCount > 1) {
                 $_secondQueryString = substr($_toTest, strrpos($_toTest, '?') + 1);
                 $_secondParams = explode('&', $_secondQueryString);
                 if (count($_secondParams)) {
                     foreach ($_secondParams as $_param) {
                         list($k, $v) = explode('=', $_param);
                         $k = IPSText::parseCleanKey($k);
                         $v = IPSText::parseCleanValue($v);
                         $_GET[$k] = $v;
                         $_REQUEST[$k] = $v;
                         $_urlBits[$k] = $v;
                         ipsRegistry::$request[$k] = $v;
                     }
                 }
             }
             /* Process URL bits for extra ? in them */
             /* We don't want to check for secondary query strings in the ACP */
             if (!IN_ACP && is_array($_GET) and count($_GET)) {
                 foreach ($_GET as $k => $v) {
                     /* Nexus sends &url=.... as a parameter, which can have a ? in it, but we don't want to strip that out of the parameter or consider those values part of the input */
                     if ($k == 'url') {
                         continue;
                     }
                     if (!is_array($v) and strstr($v, '?')) {
                         list($rvalue, $more) = explode('?', $v);
                         if ($rvalue and $more) {
                             //$k	= IPSText::parseCleanKey( $_k );
                             //$v	= IPSText::parseCleanValue( $_v );
                             /* Reset key with correct value */
                             $_v = IPSText::parseCleanValue($rvalue);
                             $_GET[$k] = $_v;
                             $_REQUEST[$k] = $_v;
                             $_urlBits[$k] = $_v;
                             ipsRegistry::$request[$k] = $_v;
                             /* Now add in the other value */
                             if (strstr($more, '=')) {
                                 list($_k, $_v) = explode('=', $more);
                                 if ($_k and $_v) {
                                     $_GET[$_k] = $_v;
                                     $_REQUEST[$_k] = $_v;
                                     $_urlBits[$_k] = $_v;
                                     ipsRegistry::$request[$_k] = $_v;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /* Reformat basic URL */
         if (is_array($_urlBits)) {
             ipsRegistry::$settings['query_string_real'] = trim(http_build_query($_urlBits), '&');
         }
     }
 }
コード例 #3
0
 /**
  * Initiate the registry
  *
  * @access	public
  * @return	@e void
  */
 public static function init()
 {
     if (self::$initiated === TRUE) {
         return FALSE;
     }
     self::$initiated = TRUE;
     /* Log current upgrade step */
     self::logUpgradeStep();
     /* Load static classes */
     require IPS_ROOT_PATH . "sources/base/core.php";
     /*noLibHook*/
     require IPS_ROOT_PATH . "sources/base/ipsMember.php";
     /*noLibHook*/
     require_once IPS_ROOT_PATH . "setup/sources/base/setup.php";
     /*noLibHook*/
     /* Load conf global and set up DB */
     if (IPS_IS_UPGRADER) {
         if (!is_file(DOC_IPS_ROOT_PATH . "conf_global.php")) {
             print "Cannot locate: " . DOC_IPS_ROOT_PATH . "conf_global.php";
             exit;
         }
         self::loadConfGlobal();
         /* Got settings? */
         if (!ipsRegistry::$settings['sql_driver']) {
             print "Settings not loaded from: " . DOC_IPS_ROOT_PATH . "conf_global.php - did you mean to install?";
             exit;
         }
         self::setDBHandle();
     } else {
         /* Ensure char set is defined */
         if (!defined('IPS_DOC_CHAR_SET')) {
             define('IPS_DOC_CHAR_SET', strtoupper(IPSSetUp::charSet));
         }
         if (!defined('IPS_CACHE_PATH')) {
             define('IPS_CACHE_PATH', DOC_IPS_ROOT_PATH);
         }
         require IPS_ROOT_PATH . "setup/sources/base/install.php";
         /*noLibHook*/
     }
     /* Input set up... */
     if (is_array($_POST) and count($_POST)) {
         foreach ($_POST as $key => $value) {
             # Skip post arrays
             if (!is_array($value)) {
                 $_POST[$key] = IPSText::stripslashes($value);
             }
         }
     }
     //-----------------------------------------
     // Clean globals, first.
     //-----------------------------------------
     IPSLib::cleanGlobals($_GET);
     IPSLib::cleanGlobals($_POST);
     IPSLib::cleanGlobals($_COOKIE);
     IPSLib::cleanGlobals($_REQUEST);
     # GET first
     $input = IPSLib::parseIncomingRecursively($_GET, array());
     # Then overwrite with POST
     self::$request = IPSLib::parseIncomingRecursively($_POST, $input);
     # Assign request method
     self::$request['request_method'] = strtolower(my_getenv('REQUEST_METHOD'));
     self::_setUpAppData();
     /* Make sure it's a string */
     if (is_array(self::$request['section'])) {
         self::$request['section'] = '';
     }
     /* Get caches */
     self::$handles['caches'] = ips_CacheRegistry::instance();
     if (IPS_IS_UPGRADER) {
         /* Make sure all is well before we proceed */
         self::instance()->setUpSettings();
         /* Build module and application caches */
         self::instance()->checkCaches();
         /* Load 'legacy' systems */
         $file = '';
         if (IPSSetUp::is300plus() === TRUE) {
             $file = '3xx.php';
         } else {
             if (IPSSetUp::is200plus() === TRUE) {
                 $file = '2xx.php';
             } else {
                 $file = '1xx.php';
             }
         }
         require_once IPS_ROOT_PATH . 'setup/sources/legacy/' . $file;
         /*noLibHook*/
         self::instance()->setClass('legacy', new upgradeLegacy(self::instance()));
     }
     /* Set up member */
     self::$handles['member'] = ips_MemberRegistry::instance();
     # Thaw saved data
     IPSSetUp::thawSavedData();
     /* Gather other classes */
     require_once IPS_ROOT_PATH . 'setup/sources/classes/output/output.php';
     /*noLibHook*/
     self::instance()->setClass('output', new output(self::instance(), TRUE));
     # Fetch global config
     if (self::readGlobalConfig() === FALSE) {
         self::getClass('output')->addError("Could not load config.xml");
     }
     if (IPS_IS_UPGRADER) {
         /* Check session status */
         $validationStatus = self::member()->sessionClass()->getStatus();
         $validationMessage = self::member()->sessionClass()->getMessage();
         if (self::$request['section'] and self::$request['section'] != 'index' and !$validationStatus) {
             /* Force log in */
             self::getClass('output')->setTitle("Upgrader: Error");
             self::getClass('output')->setNextAction('');
             self::getClass('output')->addContent(self::getClass('output')->template()->page_error($validationMessage));
             self::getClass('output')->sendOutput();
             exit;
         }
     } else {
         # Installer locked?
         if (is_file(DOC_IPS_ROOT_PATH . 'cache/installer_lock.php')) {
             self::getClass('output')->setTitle("Installer: Error");
             self::getClass('output')->setNextAction('');
             self::getClass('output')->addContent(self::getClass('output')->template()->page_locked());
             self::getClass('output')->sendOutput();
             exit;
         }
     }
 }