/**
  * Returns whether or not the license key is valid.
  * @param string $licenseKey
  * @param string $localKey
  * @return boolean
  */
 public static function VerifyLicense($licenseKey, $localKey = null)
 {
     $dataRegistry = new XenForo_Model_DataRegistry();
     if (XenForo_Application::getOptions()->simpleFormsLicenseKey == $licenseKey) {
         $localKey = $dataRegistry->get('lpsf_localkey');
     }
     if ($licenseKey != '') {
         $licenseCheck = self::_checkLicense($licenseKey, $localKey);
         if (array_key_exists('status', $licenseCheck) && $licenseCheck['status'] == 'Active') {
             if (array_key_exists('localkey', $licenseCheck) && $localKey != $licenseCheck['localkey']) {
                 $dataRegistry->set('lpsf_localkey', $licenseCheck['localkey']);
             }
             return true;
         }
     }
     return false;
 }
Example #2
0
 public static function getNodeOptions($selectedForum, $includeRoot = false)
 {
     $nodeModel = XenForo_Model_DataRegistry::create('XenForo_Model_Node');
     $options = array();
     foreach ($nodeModel->getAllNodes() as $nodeId => $node) {
         $node['depth'] += $includeRoot && $nodeId ? 1 : 0;
         $options[$nodeId] = array('value' => $nodeId, 'label' => $node['title'], 'selected' => in_array($nodeId, $selectedForum), 'depth' => $node['depth'], 'node_type_id' => $node['node_type_id']);
     }
     return $options;
 }
Example #3
0
 public static function Uninstall()
 {
     $db = XenForo_Application::get('db');
     // delete content types
     $db->delete('xf_content_type_field', "content_type = 'form'");
     $db->delete('xf_content_type', "content_type = 'form'");
     // drop tables
     $db->query("DROP TABLE IF EXISTS `lpsf_response_field`");
     $db->query("DROP TABLE IF EXISTS `lpsf_response`");
     $db->query("DROP TABLE IF EXISTS `lpsf_field`");
     $db->query("DROP TABLE IF EXISTS `lpsf_form_destination`");
     $db->query("DROP TABLE IF EXISTS `lpsf_form_destination_option`");
     $db->query("DROP TABLE IF EXISTS `lpsf_form`");
     $db->query("DROP TABLE IF EXISTS `lpsf_destination_option`");
     $db->query("DROP TABLE IF EXISTS `lpsf_destination`");
     $db->query("DROP TABLE IF EXISTS `lpsf_forum_form`");
     $db->query("DROP TABLE IF EXISTS `lpsf_page`");
     // delete permissions
     $db->delete('xf_permission_cache_content', "content_type = 'form'");
     $db->delete('xf_permission_entry_content', "content_type = 'form'");
     // remove the local key
     $dataRegistry = new XenForo_Model_DataRegistry();
     $dataRegistry->delete('lpsf_localkey');
 }
 public function deleteMulti($itemNamePattern)
 {
     $cache = $this->_getCache(true);
     if (empty($cache)) {
         if (empty(self::$loggedMissingRedis)) {
             self::$loggedMissingRedis = true;
             XenForo_Error::logException(new Exception("No Cache setup"));
         }
         return;
     }
     $credis = $this->getCredis($cache);
     if (empty($credis)) {
         if (empty(self::$loggedMissingRedis)) {
             self::$loggedMissingRedis = true;
             XenForo_Error::logException(new Exception("Redis Cache is not setup"));
         }
         return;
     }
     $prefix = Cm_Cache_Backend_Redis::PREFIX_KEY . $cache->getOption('cache_id_prefix');
     $pattern = $prefix . $itemNamePattern;
     // indicate to the redis instance would like to process X items at a time.
     $count = 1000;
     // find indexes matching the pattern
     $cursor = null;
     $keys = array();
     while (true) {
         $next_keys = $credis->scan($cursor, $pattern, $count);
         // scan can return an empty array
         if ($next_keys) {
             $keys += $next_keys;
         }
         if (empty($cursor) || $next_keys === false) {
             break;
         }
     }
     if ($keys) {
         // delete them, use pipelining
         $credis->pipeline()->multi();
         foreach ($keys as $key) {
             $credis->del($key);
         }
         $credis->exec();
     }
 }
Example #5
0
 /**
  * Pre-loads globally required data for the system.
  */
 public function preLoadData()
 {
     $required = array_merge(array('options', 'languages', 'contentTypes', 'codeEventListeners', 'deferredRun', 'simpleCache', 'addOns', 'defaultStyleProperties', 'routeFiltersIn', 'routeFiltersOut'), $this->_dataPreLoadFromRegistry);
     $dr = new XenForo_Model_DataRegistry();
     // this is a slight hack to prevent the class from being cached
     $data = $dr->getMulti($required);
     if (XenForo_Application::get('config')->enableListeners) {
         if (!is_array($data['codeEventListeners'])) {
             $data['codeEventListeners'] = XenForo_Model::create('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
         }
         XenForo_CodeEvent::setListeners($data['codeEventListeners']);
     }
     if (!is_array($data['options'])) {
         $data['options'] = XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
     }
     $options = new XenForo_Options($data['options']);
     XenForo_Application::setDefaultsFromOptions($options);
     XenForo_Application::set('options', $options);
     if (!is_array($data['languages'])) {
         $data['languages'] = XenForo_Model::create('XenForo_Model_Language')->rebuildLanguageCache();
     }
     XenForo_Application::set('languages', $data['languages']);
     if (!is_array($data['defaultStyleProperties'])) {
         $data['defaultStyleProperties'] = XenForo_Model::create('XenForo_Model_StyleProperty')->rebuildPropertyCacheInStyleAndChildren(0, true);
     }
     XenForo_Application::set('defaultStyleProperties', $data['defaultStyleProperties']);
     if (!is_array($data['contentTypes'])) {
         $data['contentTypes'] = XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache();
     }
     XenForo_Application::set('contentTypes', $data['contentTypes']);
     if (!is_int($data['deferredRun'])) {
         $data['deferredRun'] = XenForo_Model::create('XenForo_Model_Deferred')->updateNextDeferredTime();
     }
     XenForo_Application::set('deferredRun', $data['deferredRun']);
     if (!is_array($data['addOns'])) {
         $data['addOns'] = XenForo_Model::create('XenForo_Model_AddOn')->rebuildActiveAddOnCache();
     }
     XenForo_Application::set('addOns', $data['addOns']);
     if (!is_array($data['simpleCache'])) {
         $data['simpleCache'] = array();
         XenForo_Model::create('XenForo_Model_DataRegistry')->set('simpleCache', $data['simpleCache']);
     }
     XenForo_Application::set('simpleCache', $data['simpleCache']);
     if (!is_array($data['routeFiltersIn']) || !is_array($data['routeFiltersOut'])) {
         $filterCache = XenForo_Model::create('XenForo_Model_RouteFilter')->rebuildRouteFilterCache();
         $data['routeFiltersIn'] = $filterCache['in'];
         $data['routeFiltersOut'] = $filterCache['out'];
     }
     XenForo_Application::set('routeFiltersIn', $data['routeFiltersIn']);
     XenForo_Application::set('routeFiltersOut', $data['routeFiltersOut']);
     XenForo_Link::setRouteFiltersOut($data['routeFiltersOut']);
     $this->_handleCustomPreloadedData($data);
     XenForo_CodeEvent::fire('init_dependencies', array($this, $data));
 }