示例#1
0
 /**
  * Save a bbcode [add|edit]
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 protected function _bbcodeSave($type = 'add')
 {
     if ($type == 'edit') {
         if (!$this->request['id']) {
             $this->registry->output->global_message = $this->lang->words['no_bbcode_found_edit'];
             $this->_bbcodeForm($type);
             return;
         }
         $bbcode = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_id=' . intval($this->request['id'])));
         if (!$bbcode['bbcode_id']) {
             $this->registry->output->showError($this->lang->words['no_bbcode_found_edit'], 111162);
         }
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id'] && $duplicate['bbcode_id'] != $this->request['id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 if ($row['bbcode_id'] == $this->request['id']) {
                     continue;
                 }
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     } else {
         $bbcode = array();
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Fix BR tags
     //-----------------------------------------
     $this->request['bbcode_aliases'] = str_replace(array(' ', "\n"), '', IPSText::br2nl($this->request['bbcode_aliases']));
     //-----------------------------------------
     // check...
     //-----------------------------------------
     if (!$this->request['bbcode_title'] or !$this->request['bbcode_tag'] or !$this->request['bbcode_replace'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['complete_form'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!$this->request['bbcode_single_tag'] and !strstr($this->request['bbcode_replace'], '{content}') and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_content'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!strstr($this->request['bbcode_replace'], '{option}') and $this->request['bbcode_useoption'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_option'];
         $this->_bbcodeForm($type);
         return;
     }
     if (preg_match("/[^a-zA-Z0-9_]/", $this->request['bbcode_tag'])) {
         $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
         $this->_bbcodeForm($type);
         return;
     }
     $_aliases = explode(",", $this->request['bbcode_aliases']);
     foreach ($_aliases as $_alias) {
         if (preg_match("/[^a-zA-Z0-9_]/", $_alias)) {
             $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
             $this->_bbcodeForm($type);
             return;
         }
     }
     $array = array('bbcode_title' => $this->request['bbcode_title'], 'bbcode_desc' => IPSText::safeslashes($_POST['bbcode_desc']), 'bbcode_tag' => preg_replace("/[^a-zA-Z0-9_]/", "", $this->request['bbcode_tag']), 'bbcode_replace' => IPSText::safeslashes($_POST['bbcode_replace']), 'bbcode_example' => IPSText::safeslashes($_POST['bbcode_example']), 'bbcode_useoption' => $this->request['bbcode_useoption'], 'bbcode_switch_option' => intval($this->request['bbcode_switch_option']), 'bbcode_menu_option_text' => trim($this->request['bbcode_menu_option_text']), 'bbcode_menu_content_text' => trim($this->request['bbcode_menu_content_text']), 'bbcode_single_tag' => intval($this->request['bbcode_single_tag']), 'bbcode_groups' => is_array($this->request['bbcode_groups']) ? implode(',', $this->request['bbcode_groups']) : '', 'bbcode_sections' => is_array($this->request['bbcode_sections']) ? implode(',', $this->request['bbcode_sections']) : '', 'bbcode_php_plugin' => trim($this->request['bbcode_php_plugin']), 'bbcode_no_parsing' => intval($this->request['bbcode_no_parsing']), 'bbcode_optional_option' => intval($this->request['bbcode_optional_option']), 'bbcode_aliases' => $this->request['bbcode_aliases'], 'bbcode_image' => $this->request['bbcode_image'], 'bbcode_app' => $this->request['bbcode_app'], 'bbcode_protected' => intval($this->request['bbcode_protected']), 'bbcode_custom_regex' => str_replace("\", '\\', IPSText::stripslashes($_POST['bbcode_custom_regex'])));
     if ($type == 'add') {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}'"));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         $this->DB->insert('custom_bbcode', $array);
         $this->registry->output->global_message = $this->lang->words['new_bbcode'];
     } else {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}' AND bbcode_id<>" . intval($this->request['id'])));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         if ($this->request['drop_cache']) {
             IPSContentCache::truncate();
         }
         $this->DB->update('custom_bbcode', $array, 'bbcode_id=' . intval($this->request['id']));
         $this->registry->output->global_message = $this->lang->words['edited_bbcode'];
     }
     $this->bbcodeRebuildCache();
     $this->_bbcodeStart();
 }
示例#2
0
 /**
  * View an individual cache store contents
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _contentCache()
 {
     $type = $this->request['type'];
     $method = $this->request['method'];
     /* What are we doing? */
     if ($method == 'all') {
         $removed = IPSContentCache::truncate($type);
     } else {
         $removed = IPSContentCache::prune($type);
     }
     $this->registry->output->global_message = sprintf($this->lang->words['cc_processed'], $removed);
     $this->cacheOverview();
 }
示例#3
0
 public function recacheAndLog($action, $message = null)
 {
     if ($action) {
         // log our message
         $this->logMessage($action, $message);
         // recache our stuff.
         switch ($action) {
             case 'attachments':
                 $this->cache->rebuildCache('attachtypes', 'forums');
                 break;
             case 'attachments_type':
                 break;
             case 'announcements':
                 break;
             case 'custom_bbcode':
                 break;
             case 'emoticons':
                 break;
             case 'forums':
                 break;
             case 'forum_perms':
                 break;
             case 'groups':
                 break;
             case 'ignored_users':
                 break;
             case 'members':
                 break;
             case 'moderators':
                 break;
             case 'posts':
                 IPSContentCache::truncate($type);
                 break;
             case 'polls':
                 break;
             case 'pms':
                 break;
             case 'profile_friends':
                 break;
             case 'profile_comments':
                 break;
             case 'pfields':
                 break;
             case 'tags':
                 break;
             case 'topics':
                 IPSContentCache::truncate($type);
                 break;
             case 'topic_ratings':
                 break;
             case 'reputation_index':
                 break;
             case 'ranks':
                 break;
             case 'warn_logs':
                 break;
             case 'finalize':
                 // recache all
                 break;
             default:
                 break;
         }
     }
 }
示例#4
0
 /**
  * Edit Settings
  */
 public function editSettings()
 {
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     $skinFunctions = new skinCaching(ipsRegistry::instance());
     if (ipsRegistry::$request['recache']) {
         $skinFunctions->flushipscdn();
         ipsRegistry::getClass('output')->redirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements&amp;do=edit&amp;service=enhancements_core_ipscdn", ipsRegistry::getClass('class_localization')->words['cdn_recached']);
     }
     if (ipsRegistry::$request['disable']) {
         IPSLib::updateSettings(array('ips_cdn' => FALSE, 'ipb_img_url' => '', 'ipb_css_url' => '', 'ipb_js_url' => '', 'upload_url' => ''));
         if (IPSLib::appIsInstalled('gallery')) {
             $this_script = str_replace('\\', '/', getenv('SCRIPT_FILENAME'));
             $url = ipsRegistry::$settings['_original_base_url'];
             if ($this_script) {
                 $this_script = str_replace('/' . CP_DIRECTORY . '/index.php', '', $this_script);
                 if (substr(ipsRegistry::$settings['gallery_images_path'], 0, strlen($this_script)) === $this_script) {
                     $url = str_replace('\\', '/', str_replace($this_script, $url, ipsRegistry::$settings['gallery_images_path']));
                 }
             } else {
                 $url .= '/uploads';
             }
             IPSLib::updateSettings(array('gallery_images_path' => $url));
         }
         IPSContentCache::truncate('post');
         IPSContentCache::truncate('sig');
         /* Set skin sets to recache */
         $skinFunctions->flagSetForRecache();
         ipsRegistry::getClass('output')->redirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements", ipsRegistry::getClass('class_localization')->words['cdn_disabled']);
         return;
     }
     if (!ipsRegistry::$settings['ipb_reg_number']) {
         ipsRegistry::getClass('output')->showError(sprintf(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_nokey'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools&section=licensekey', 'admin')));
     }
     $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement');
     $file = new $classToLoad();
     $return = NULL;
     if ($json = @json_decode($ping, TRUE)) {
         if ($json['ENABLED'] and $json['BYTES'] > 0) {
             if (!ipsRegistry::$settings['ips_cdn'] and !ipsRegistry::$request['enable']) {
                 return $this->html->cdnInactive($json);
             } else {
                 $settings = array('ips_cdn' => TRUE, 'ipb_img_url' => $json['URL'], 'ipb_css_url' => rtrim($json['URL'], '/') . '/', 'ipb_js_url' => rtrim($json['URL'], '/') . '/', 'upload_url' => $json['URL'] . '/uploads');
                 if (IPSLib::appIsInstalled('downloads')) {
                     if (substr(ipsRegistry::$settings['idm_localsspath'], 0, 11) === '{root_path}') {
                         $settings['idm_screenshot_url'] = str_replace('{root_path}', $json['URL'], ipsRegistry::$settings['idm_localsspath']);
                     }
                 }
                 if (IPSLib::appIsInstalled('gallery')) {
                     $this_script = str_replace('\\', '/', getenv('SCRIPT_FILENAME'));
                     if ($this_script) {
                         $this_script = str_replace('/' . CP_DIRECTORY . '/index.php', '', $this_script);
                         if (substr(ipsRegistry::$settings['gallery_images_path'], 0, strlen($this_script)) === $this_script) {
                             $settings['gallery_images_url'] = str_replace('\\', '/', str_replace($this_script, $json['URL'], ipsRegistry::$settings['gallery_images_path']));
                         }
                     }
                 }
                 $_settings = array();
                 foreach ($settings as $k => $v) {
                     if (ipsRegistry::$settings[$k] != $v) {
                         $_settings[$k] = $v;
                     }
                 }
                 if (!empty($_settings)) {
                     IPSLib::updateSettings($settings);
                 }
                 /* Set skin sets to recache */
                 $skinFunctions->flagSetForRecache();
             }
         } else {
             $licenseData = ipsRegistry::cache()->getCache('licenseData');
             if ($licenseData['key']['url'] != ipsRegistry::$settings['board_url']) {
                 ipsRegistry::getClass('output')->showError(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_url']);
             }
             /* Set skin sets to recache */
             $skinFunctions->flagSetForRecache();
             return $this->html->cdnNotEnabled($json);
         }
     } else {
         ipsRegistry::getClass('output')->showError(sprintf(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_key'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools&section=licensekey', 'admin')));
     }
     return $this->html->cdnOverview($json);
 }