/** * Main class entry point * * @access public * @param object ipsRegistry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Set up stuff //----------------------------------------- $this->form_code = 'module=settings&section=settings'; $this->form_code_js = 'module=settings§ion=settings'; //------------------------------- // Grab, init and load settings //------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings'); $settings = new $classToLoad($this->registry); $settings->makeRegistryShortcuts($this->registry); ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_tools'), 'core'); $settings->html = $this->registry->output->loadTemplate('cp_skin_settings', 'core'); $settings->form_code = $settings->html->form_code = 'module=settings&section=settings'; $settings->form_code_js = $settings->html->form_code_js = 'module=settings§ion=settings'; $this->request['conf_title_keyword'] = 'calendar'; $settings->return_after_save = $this->settings['base_url'] . $this->form_code; $settings->_viewSettings(); //----------------------------------------- // Pass to CP output hander //----------------------------------------- $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper(); $this->registry->getClass('output')->sendOutput(); }
/** * Get topics from a forum * * @return @e void [Outputs to screen] */ protected function _getTopics() { //----------------------------------------- // Reset input //----------------------------------------- $_GET['showforum'] = intval($_GET['f']); ipsRegistry::$request['showforum'] = intval(ipsRegistry::$request['f']); if ($_GET['showforum'] < 1) { $this->returnJsonArray(array('error' => 'incorrect_f')); } //----------------------------------------- // Get the forum controller //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/forums/forums.php', 'public_forums_forums_forums'); $forums = new $classToLoad(); $forums->makeRegistryShortcuts($this->registry); $forums->initForums(); $forums->buildPermissions(); $data = $forums->renderForum(); $html = ''; if (is_array($data['topic_data']) && count($data['topic_data'])) { foreach ($data['topic_data'] as $idx => $tdata) { $html .= $this->registry->output->getTemplate('forum')->topic($tdata, $data['other_data']['forum_data'], $data['other_data'], 1); } } $this->returnJsonArray(array('topics' => $html, 'pages' => $data['other_data']['forum_data']['SHOW_PAGES'], 'hasMore' => $data['other_data']['hasMore']), true); }
/** * Serve the iCalendar feed (valid for both download as .ics and webcal:// protocol) * * @return @e void */ public function downloadIcalFeed() { //----------------------------------------- // Get main view class //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php', 'public_calendar_calendar_view'); $calendar = new $classToLoad($this->registry); $calendar->makeRegistryShortcuts($this->registry); $calendar->initCalendar(); //----------------------------------------- // Load (all) events //----------------------------------------- $calendar->calendarGetEventsSQL(gmstrftime('%m'), gmstrftime('%Y'), array('timenow' => '1', 'timethen' => '2000000000', 'cal_id' => $this->calendar['cal_id'], 'honor_permissions' => true, 'no_date_convert' => true)); $events = $calendar->calendarGetAllEvents(); //----------------------------------------- // Load iCalendar class //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('calendar') . "/sources/icalendar.php", 'app_calendar_classes_icalendarOutput', 'calendar'); $iCalendar = new $classToLoad($this->registry, $this->calendar['cal_id']); //----------------------------------------- // Send data to iCalendar class and get output //----------------------------------------- foreach ($events as $event) { $event = $calendar->calendarMakeEventHTML($event, true); $iCalendar->addEvent($event); } $feed = $iCalendar->buildICalendarFeed(); //----------------------------------------- // Output //----------------------------------------- @header("Content-type: text/calendar; charset=" . IPS_DOC_CHAR_SET); @header("Content-Disposition: inline; filename=calendarEvents.ics"); print $feed; exit; }
/** * Shows board index popular tags * */ public function tags() { $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'sources/classes/tags/cloud.php', 'classes_tags_cloud'); $cloud = new $classToLoad(); $cloud->setSkinGroup('boards'); $cloud->setSkinTemplate('hookTagCloud'); return $cloud->render($cloud->getCloudData(array('limit' => 50))); }
/** * Main class entry point * * @param object ipsRegistry reference */ public function doExecute(ipsRegistry $registry) { /* Require the right driver file */ $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/sql/' . strtolower(ipsRegistry::dbFunctions()->getDriverType()) . '.php', 'admin_core_sql_toolbox_module'); /*noLibHook*/ $dbdriver = new $classToLoad(); $dbdriver->makeRegistryShortcuts($registry); $dbdriver->doExecute($registry); }
/** * Run this task * * @return @e void */ public function runTask() { $this->registry->getClass('class_localization')->loadLanguageFile(array('public_chat'), 'ipchat'); $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('ipchat') . '/modules_admin/logs/logs.php', 'admin_ipchat_logs_logs'); $_logs = new $classToLoad(); $_logs->makeRegistryShortcuts($this->registry); $_message = $_logs->refreshLogs(true); /* Log task action */ $this->class->appendTaskLog($this->task, $_message); /* Unlock Task: DO NOT MODIFY! */ $this->class->unlockTask($this->task); }
/** * Retrieve posters in a given topic * * @return @e void [Outputs to screen] */ protected function _whoPosted() { ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_stats'), 'forums'); $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/extras/stats.php', 'public_forums_extras_stats'); $stats = new $classToLoad($this->registry); $stats->makeRegistryShortcuts($this->registry); $output = $stats->whoPosted(true); if (!$output) { $this->returnJsonError($this->lang->words['ajax_nohtml_return']); } else { $this->returnHtml($output); } }
/** * Run this task * * @return @e void */ public function runTask() { //----------------------------------------- // Load Bulk Mailer thing //----------------------------------------- define('IN_ACP', 1); require_once IPSLib::getAppDir('members') . '/sources/classes/bulkMailFilter.php'; $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('members') . '/modules_admin/bulkmail/bulkmail.php', 'admin_members_bulkmail_bulkmail'); $bulkmail = new $classToLoad(); $bulkmail->makeRegistryShortcuts($this->registry); $bulkmail->mailSendProcess(); //----------------------------------------- // Unlock Task: DO NOT MODIFY! //----------------------------------------- $this->class->unlockTask($this->task); }
/** * Main class entry point * * @param object ipsRegistry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Init //----------------------------------------- require_once IPSLib::getAppDir('members') . '/sources/classes/bulkMailFilter.php'; $this->html = $this->registry->output->loadTemplate('cp_skin_bulkmail'); ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_bulkmail')); $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('bulkmail_send'); $controllerClass = IPSLib::loadActionOverloader(IPSLib::getAppDir('members') . '/modules_admin/bulkmail/bulkmail.php', 'admin_members_bulkmail_bulkmail'); $controller = new $controllerClass($registry); $controller->makeRegistryShortcuts($registry); //----------------------------------------- // Load Mail //----------------------------------------- $id = intval($this->request['id']); $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $id)); if (!$mail['mail_id']) { $this->returnHTML(''); } if (!$mail['mail_subject'] and !$mail['mail_content']) { $this->returnHTML(''); } $opts = unserialize(stripslashes($mail['mail_opts'])); $mail['mail_html_on'] = $opts['mail_html_on']; //----------------------------------------- // Get Members //----------------------------------------- /* Start with a basic query */ $queryData = array('select' => 'm.member_id, m.members_display_name, m.email', 'from' => array('members' => 'm'), 'order' => 'm.members_display_name', 'limit' => array(10000 * ($this->request['page'] - 1), 10000)); /* Add in filters */ $_queryData = $controller->_buildMembersQuery($opts['filters']); $queryData['add_join'] = $_queryData['add_join']; $queryData['where'] = implode(' AND ', $_queryData['where']); /* Count */ $this->DB->build($queryData); $this->DB->execute(); while ($row = $this->DB->fetch()) { $members[] = $row; } //----------------------------------------- // Display //----------------------------------------- $this->returnHTML($this->html->mss_recipients($this->request['page'], $this->request['countmembers'], $members)); }
public function getOutput() { /* Make sure the calednar is installed and enabled */ if (!IPSLib::appIsInstalled('calendar')) { return ''; } /* Load language */ $this->registry->class_localization->loadLanguageFile(array('public_calendar'), 'calendar'); /* Load calendar library */ $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php', 'public_calendar_calendar_view'); $cal = new $classToLoad(); $cal->makeRegistryShortcuts($this->registry); if (!$cal->initCalendar(true)) { return ''; } /* Return calendar */ return "<div id='hook_calendar' class='calendar_wrap'>" . $cal->getMiniCalendar(date('n'), date('Y')) . '</div><br />'; }
/** * Run this task * * @return @e void */ public function runTask() { $this->registry->getClass('class_localization')->loadLanguageFile(array('public_global'), 'core'); //----------------------------------------- // Deactivate expired announcements //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/forums/announcements.php', 'public_forums_forums_announcements'); $announcements = new $classToLoad(); $announcements->makeRegistryShortcuts($this->registry); $announcements->announceRetireExpired(); //----------------------------------------- // Log to log table - modify but dont delete //----------------------------------------- $this->class->appendTaskLog($this->task, $this->lang->words['task_announcements']); //----------------------------------------- // Unlock Task: DO NOT MODIFY! //----------------------------------------- $this->class->unlockTask($this->task); }
/** * Grab the RSS document content and return it * * @return string RSS document */ public function returnRSSDocument() { //----------------------------------------- // INIT //----------------------------------------- $rss_export_id = intval(ipsRegistry::$request['id']); $rss_data = array(); $to_print = ''; $this->expires = time(); //----------------------------------------- // Get RSS export //----------------------------------------- $rss_data = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'rss_export', 'where' => 'rss_export_id=' . $rss_export_id)); //----------------------------------------- // Got one? //----------------------------------------- if ($rss_data['rss_export_id'] and $rss_data['rss_export_enabled']) { //----------------------------------------- // Correct expires time //----------------------------------------- $this->expires += $rss_data['rss_export_cache_time'] * 60; //----------------------------------------- // Need to recache? //----------------------------------------- $time_check = time() - $rss_data['rss_export_cache_time'] * 60; if (!$rss_data['rss_export_cache_content'] or $time_check > $rss_data['rss_export_cache_last']) { //----------------------------------------- // Yes //----------------------------------------- define('IN_ACP', 1); ipsRegistry::getAppClass('forums'); $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_admin/rss/export.php', 'admin_forums_rss_export'); $rss_export = new $classToLoad(); $rss_export->makeRegistryShortcuts(ipsRegistry::instance()); return $rss_export->rssExportRebuildCache($rss_data['rss_export_id'], 0); } else { //----------------------------------------- // No //----------------------------------------- return $rss_data['rss_export_cache_content']; } } }
public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Set up some shortcuts for our urls //----------------------------------------- $this->form_code = 'module=syncacp&section=settings'; $this->form_code_js = 'module=syncacp§ion=settings'; //------------------------------- // Grab the settings controller, instantiate and set up shortcuts //------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings'); $settings = new $classToLoad(); $settings->makeRegistryShortcuts($this->registry); //------------------------------- // Load language file that will be needed //------------------------------- ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_tools'), 'core'); //------------------------------- // Load the skin file the settings file will need and pass shortcuts //------------------------------- $settings->html = $this->registry->output->loadTemplate('cp_skin_settings', 'core'); $settings->form_code = $settings->html->form_code = 'module=settings&section=settings'; $settings->form_code_js = $settings->html->form_code_js = 'module=settings§ion=settings'; //------------------------------- // Here we specify the setting group key //------------------------------- $this->request['conf_title_keyword'] = 'syncapp'; //------------------------------- // Here we specify where to send the admin after submitting the form //------------------------------- $settings->return_after_save = $this->settings['base_url'] . $this->form_code; //------------------------------- // View the settings configuration page //------------------------------- $settings->_viewSettings(); //----------------------------------------- // And finally, output //----------------------------------------- $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper(); $this->registry->getClass('output')->sendOutput(); }
/** * Class entry point * * @param object Registry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { /* Get ignore user quick call file */ $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('members') . '/modules_public/profile/ignore.php', 'public_members_profile_ignore'); $library = new $classToLoad($registry); $library->makeRegistryShortcuts($registry); switch ($this->request['do']) { default: case 'add': $result = $library->ignoreMember($this->request['memberID'], 'topics'); break; case 'remove': $result = $library->stopIgnoringMember($this->request['memberID'], 'topics'); break; case 'addPM': $result = $library->ignoreMember($this->request['memberID'], 'messages'); break; case 'removePM': $result = $library->stopIgnoringMember($this->request['memberID'], 'messages'); break; } $this->returnJsonArray($result); }
/** * Class entry point * * @param object ipsRegistry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // INIT //----------------------------------------- $topic_id = intval($this->request['tid']); ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_stats'), 'forums'); //----------------------------------------- // Check.. //----------------------------------------- if (!$topic_id) { $this->returnJsonError($this->lang->words['notopic_attach']); } //----------------------------------------- // get topic.. //----------------------------------------- $topic = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topic_id)); if (!$topic['topic_hasattach']) { $this->returnJsonError($this->lang->words['topic_noattach']); } //----------------------------------------- // Check forum.. //----------------------------------------- if ($this->registry->getClass('class_forums')->forumsCheckAccess($topic['forum_id'], 0, 'forum', $topic, true) === false) { $this->returnJsonError($this->lang->words['topic_noperms']); } $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/forums/attach.php', 'public_forums_forums_attach'); $attach = new $classToLoad($this->registry); $attach->makeRegistryShortcuts($this->registry); $attachHTML = $attach->getAttachments($topic); if (!$attachHTML) { $this->returnJsonError($this->lang->words['ajax_nohtml_return']); } else { $this->returnHtml($attachHTML); } }
/** * Execute plugin * * @param array $permissions Moderator permissions * @return @e string */ public function executePlugin($permissions) { //----------------------------------------- // Check permissions //----------------------------------------- if (!$this->canView($permissions)) { return ''; } //----------------------------------------- // Get forum class //----------------------------------------- if (!$this->registry->isClassLoaded('topics')) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums'); $this->registry->setClass('topics', new $classToLoad($this->registry)); } //----------------------------------------- // Get forum class //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/forums/forums.php', 'public_forums_forums_forums'); $this->forums = new $classToLoad($this->registry); $this->forums->makeRegistryShortcuts($this->registry); $st = intval($this->request['st']); $_filters = $this->_getFilters(); $_filters = array_merge($_filters, array('topicType' => array('sdelete', 'pdelete', 'oktoremove'), 'getCount' => true, 'sortField' => 'tid', 'sortOrder' => 'desc', 'limit' => 10, 'offset' => $st)); $this->registry->getClass('topics')->setPermissionData(); $topics = $this->registry->getClass('topics')->getTopics($_filters); $total = $this->registry->getClass('topics')->getTopicsCount(); $final = array(); //----------------------------------------- // Format data //----------------------------------------- if (count($topics)) { foreach ($topics as $tid => $topic) { /* Have to preserve original forum id for linked topics */ if ($topic['state'] == 'link') { $_originalForum = $topic['forum_id']; } $topic = $this->_checkPermissions($topic); $topic = $this->forums->renderEntry($topic); $topic['forum'] = $this->registry->class_forums->getForumById($topic['forum_id']); if ($topic['state'] == 'link') { $topic['_toForum'] = $this->registry->class_forums->getForumById($_originalForum); } $final[$tid] = $topic; } } $other_data = array(); if (is_array($topics) and count($topics)) { $other_data = IPSDeleteLog::fetchEntries(array_keys($topics), 'topic', false); } //----------------------------------------- // Page links //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => $total, 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&module=modcp&fromapp=forums&tab=deletedtopics")); return $this->registry->output->getTemplate('modcp')->deletedTopics($final, $other_data, $pages); }
/** * Delete a forum * * @return @e void Outputs to screen */ public function doDelete() { //----------------------------------------- // Auth check... //----------------------------------------- $this->registry->adminFunctions->checkSecurityKey(); //----------------------------------------- // Continue //----------------------------------------- $this->request['f'] = intval($this->request['f']); $this->request['new_parent_id'] = intval($this->request['new_parent_id']); $forum = $this->registry->class_forums->forum_by_id[$this->request['f']]; if (!$forum['id']) { $this->registry->output->showError($this->lang->words['for_noid_source'], 11313); } if (!$this->request['new_parent_id']) { $this->request['new_parent_id'] = -1; } else { if ($this->request['new_parent_id'] == $this->request['f']) { $this->registry->output->global_message = $this->lang->words['for_child_no_parent']; $this->deleteForm(); return; } } //----------------------------------------- // Would deleting this category orphan the only // remaining forums? //----------------------------------------- if ($forum['parent_id'] == -1) { $otherParent = 0; foreach ($this->registry->class_forums->forum_by_id as $id => $data) { if ($data['parent_id'] == -1) { $otherParent = $id; break; } } if (!$otherParent) { $this->registry->output->showError($this->lang->words['nodelete_last_cat'], 11364); } } //----------------------------------------- // Get library //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums'); $modfunc = new $classToLoad($this->registry); /* Load tagging stuff */ if (!$this->registry->isClassLoaded('tags')) { require_once IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php'; /*noLibHook*/ $this->registry->setClass('tags', classes_tags_bootstrap::run('forums', 'topics')); } //----------------------------------------- // Move stuff //----------------------------------------- if (isset($this->request['MOVE_ID'])) { $this->request['MOVE_ID'] = intval($this->request['MOVE_ID']); if (!$this->request['MOVE_ID']) { $this->registry->output->global_error = $this->lang->words['forum_delete_none_selected']; $this->deleteForm(); return; } if ($this->request['MOVE_ID'] == $this->request['f']) { $this->registry->output->global_error = $this->lang->words['for_wherewhatwhy']; $this->deleteForm(); return; } //----------------------------------------- // Move topics... //----------------------------------------- $this->DB->update('topics', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']); //----------------------------------------- // Move polls... //----------------------------------------- $this->DB->update('polls', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']); //----------------------------------------- // Move voters... //----------------------------------------- $this->DB->update('voters', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']); /* Move tags */ $this->registry->tags->moveTagsByParentId($this->request['f'], $this->request['MOVE_ID']); $modfunc->forumRecount($this->request['MOVE_ID']); } //----------------------------------------- // Delete the forum //----------------------------------------- $this->DB->delete('forums', "id=" . $this->request['f']); $this->DB->delete('permission_index', "app='forums' AND perm_type='forum' AND perm_type_id=" . $this->request['f']); //----------------------------------------- // Remove moderators from this forum //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => "forum_id LIKE '%,{$this->request['f']},%'")); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $forums = explode(',', IPSText::cleanPermString($r['forum_id'])); $newForums = array(); foreach ($forums as $aForumId) { if ($aForumId != $this->request['f']) { $newForums[] = $aForumId; } } if (!count($newForums)) { $this->DB->delete('moderators', "mid=" . $r['mid']); } else { $this->DB->update('moderators', array('forum_id' => ',' . implode(',', $newForums) . ','), 'mid=' . $r['mid']); } } //----------------------------------------- // Delete forum subscriptions //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $_like = classes_like::bootstrap('forums', 'forums'); $_like->remove($this->request['f']); //----------------------------------------- // Update children //----------------------------------------- $this->DB->update('forums', array('parent_id' => $this->request['new_parent_id']), "parent_id=" . $this->request['f']); //----------------------------------------- // Rebuild moderator cache //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_admin/forums/moderator.php', 'admin_forums_forums_moderator'); $moderator = new $classToLoad(); $moderator->makeRegistryShortcuts($this->registry); $moderator->rebuildModeratorCache(); $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['for_removedlog'], $forum['name'])); $this->registry->output->global_message = $this->lang->words['for_removed']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code); }
/** * Retreive the command * * @access public * @param object ipsRegistry reference * @return object */ public function getCommand(ipsRegistry $registry) { $_NOW = IPSDebug::getMemoryDebugFlag(); $module = ipsRegistry::$current_module; $section = ipsRegistry::$current_section; $filepath = IPSLib::getAppDir(IPS_APP_COMPONENT) . '/' . self::$modules_dir . '/' . $module . '/'; /* Bug Fix #21009 */ if (!ipsRegistry::$applications[IPS_APP_COMPONENT]['app_enabled']) { throw new Exception("The specified application has been disabled"); } if (!IN_ACP and !IPSLib::moduleIsEnabled($module, IPS_APP_COMPONENT) and $module != 'ajax') { throw new Exception("The specified module has been disabled"); } /* Got a section? */ if (!$section) { if (is_file($filepath . 'defaultSection.php')) { $DEFAULT_SECTION = ''; include $filepath . 'defaultSection.php'; /*noLibHook*/ if ($DEFAULT_SECTION) { $section = $DEFAULT_SECTION; ipsRegistry::$current_section = $section; } } } $_classname = self::$class_dir . '_' . IPS_APP_COMPONENT . '_' . $module . '_'; /* Rarely used, let's leave file_exists which is faster for non-existent files */ if (file_exists($filepath . 'manualResolver.php')) { $classname = IPSLib::loadActionOverloader($filepath . 'manualResolver.php', $_classname . 'manualResolver'); } else { if (is_file($filepath . $section . '.php')) { $classname = IPSLib::loadActionOverloader($filepath . $section . '.php', $_classname . $section); } } IPSDebug::setMemoryDebugFlag("Controller getCommand executed"); if (class_exists($classname)) { $cmd_class = new ReflectionClass($classname); if ($cmd_class->isSubClassOf(self::$base_cmd)) { return $cmd_class->newInstance(); } else { throw new Exception("{$section} in {$module} does not exist!"); } } else { throw new Exception("{$classname} does not exist!"); } # Fudge it to return just the default object return clone self::$default_cmd; }
/** * Edit */ public function edit() { $exploded = explode('_', $this->request['service']); if (!IPSLib::appIsInstalled($exploded[1]) or !is_file(IPSLib::getAppDir($exploded[1]) . '/extensions/enhancements/' . $exploded[2] . '.php')) { $this->registry->output->showError($this->lang->words['err_no_enhancement'], 111800); } $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($exploded[1]) . '/extensions/enhancements/' . $exploded[2] . '.php', $this->request['service']); $class = new $classToLoad($this->registry); if (method_exists($class, 'check')) { $class->check(); } if (isset($class->settings) and !empty($class->settings)) { $settingsClass = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings'); $settingsClass = new $settingsClass(); $settingsClass->makeRegistryShortcuts($this->registry); $settingsClass->html = $this->registry->output->loadTemplate('cp_skin_settings'); $html = ''; $imploded = implode(', ', array_map(create_function('$v', 'return "\'{$v}\'";'), $class->settings)); $settings = array(); $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN( {$imploded} )", 'order' => 'conf_position')); $e = $this->DB->execute(); while ($row = $this->DB->fetch($e)) { $html .= $settingsClass->_processSettingEntry($row); } $this->registry->output->html .= $this->html->communityEnhancementsSettings($class, $html); } else { $this->registry->output->html .= $class->editSettings(); } }
/** * Sort out bbcode and permissions * * @return @e void */ public function permsAndBbcode() { /* INIT */ $options = IPSSetUp::getSavedData('custom_options'); $rootAdmins = $options['core'][30001]['rootAdmins']; /* First off, import default BBCode */ $apps = array(); $bbcodeOld = array(); $bbcodeNew = array(); /* Load apps */ $this->DB->build(array('select' => '*', 'from' => 'core_applications')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $apps[$row['app_directory']] = $row; } /* Load old codes */ $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode_old')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $bbcodeOld[$row['bbcode_tag']] = $row; } /* Add 'em */ foreach ($apps as $dir => $data) { if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml')) { //----------------------------------------- // Continue //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode'); $bbcode = new $classToLoad(); $bbcode->makeRegistryShortcuts($this->registry); $bbcode->bbcodeImportDo(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml')); } if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml')) { //----------------------------------------- // Continue //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media'); $bbcode = new $classToLoad(); $bbcode->makeRegistryShortcuts($this->registry); $bbcode->doMediaImport(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml')); } } /* Load current code */ $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $bbcodeCurrent[$row['bbcode_tag']] = $row; //----------------------------------------- // Need to take into account aliases too! //----------------------------------------- if ($row['bbcode_aliases']) { $aliases = explode(',', $row['bbcode_aliases']); if (count($aliases)) { foreach ($aliases as $alias) { $bbcodeCurrent[$alias] = $row; } } } } if (count($bbcodeOld)) { foreach ($bbcodeOld as $tag => $row) { if (!$bbcodeCurrent[$row['bbcode_tag']]) { $bbcodeNew[$row['bbcode_tag']] = $row; } } } $this->registry->output->addMessage("BB-коды обновлены...."); /* Now see if there's anything we need to move back over */ if (count($bbcodeNew)) { foreach ($bbcodeNew as $tag => $data) { $bbarray = array('bbcode_title' => $data['bbcode_title'], 'bbcode_desc' => $data['bbcode_desc'], 'bbcode_tag' => $data['bbcode_tag'], 'bbcode_replace' => IPSText::safeslashes($data['bbcode_replace']), 'bbcode_useoption' => $data['bbcode_useoption'], 'bbcode_example' => $data['bbcode_example'], 'bbcode_switch_option' => $data['bbcode_switch_option'], 'bbcode_menu_option_text' => $data['bbcode_menu_option_text'], 'bbcode_menu_content_text' => $data['bbcode_menu_content_text'], 'bbcode_groups' => 'all', 'bbcode_sections' => 'all', 'bbcode_php_plugin' => '', 'bbcode_parse' => 2, 'bbcode_no_parsing' => 0, 'bbcode_optional_option' => 0, 'bbcode_aliases' => '', 'bbcode_image' => ''); $this->DB->insert('custom_bbcode', $bbarray); } } /* OK, now onto permissions... */ /* Insert basic perms for profiles and help */ $this->DB->insert('permission_index', array('app' => 'members', 'perm_type' => 'profile_view', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); $this->DB->insert('permission_index', array('app' => 'core', 'perm_type' => 'help', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); /* And now calendars */ $this->DB->build(array('select' => '*', 'from' => 'cal_calendars')); $o = $this->DB->execute(); while ($row = $this->DB->fetch($o)) { if (strstr($row['cal_permissions'], 'a:')) { $_perms = unserialize(stripslashes($row['cal_permissions'])); if (is_array($_perms)) { $_view = $_perms['perm_read'] ? ',' . implode(',', explode(',', $_perms['perm_read'])) . ',' : ''; $_start = $_perms['perm_post'] ? ',' . implode(',', explode(',', $_perms['perm_post'])) . ',' : ''; $_nomod = $_perms['perm_nomod'] ? ',' . implode(',', explode(',', $_perms['perm_nomod'])) . ',' : ''; $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_start), 'perm_3' => str_replace(',*,', '*', $_nomod), 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); } else { $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); } } else { $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); } } /* And now forums */ $this->DB->build(array('select' => '*', 'from' => 'forums')); $o = $this->DB->execute(); while ($row = $this->DB->fetch($o)) { /* Do we need to tidy up the title? */ if (strstr($row['name'], '&')) { $row['name'] = preg_replace("#& #", "& ", $row['name']); $this->DB->update('forums', array('name' => $row['name']), 'id=' . $row['id']); } if (strstr($row['permission_array'], 'a:')) { $_perms = unserialize(stripslashes($row['permission_array'])); if (is_array($_perms)) { $_view = $_perms['show_perms'] ? ',' . implode(',', explode(',', $_perms['show_perms'])) . ',' : ''; $_read = $_perms['read_perms'] ? ',' . implode(',', explode(',', $_perms['read_perms'])) . ',' : ''; $_reply = $_perms['reply_perms'] ? ',' . implode(',', explode(',', $_perms['reply_perms'])) . ',' : ''; $_start = $_perms['start_perms'] ? ',' . implode(',', explode(',', $_perms['start_perms'])) . ',' : ''; $_upload = $_perms['upload_perms'] ? ',' . implode(',', explode(',', $_perms['upload_perms'])) . ',' : ''; $_download = $_perms['download_perms'] ? ',' . implode(',', explode(',', $_perms['download_perms'])) . ',' : ''; $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_read), 'perm_3' => str_replace(',*,', '*', $_reply), 'perm_4' => str_replace(',*,', '*', $_start), 'perm_5' => str_replace(',*,', '*', $_upload), 'perm_6' => str_replace(',*,', '*', $_download), 'perm_7' => '')); } else { $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core'); } } else { $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => '')); IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core'); } } $this->registry->output->addMessage("Права доступа обновлены...."); /* Fix up forum moderators */ $this->DB->build(array('select' => '*', 'from' => 'moderators')); $o = $this->DB->execute(); while ($r = $this->DB->fetch($o)) { $this->DB->update('moderators', array('forum_id' => ',' . IPSText::cleanPermString($r['forum_id']) . ','), 'mid=' . $r['mid']); } $this->registry->output->addMessage("Модераторы форумов обновлены...."); /* Root admin reset? */ if ($rootAdmins) { /* Find all admin groups */ $this->DB->build(array('select' => '*', 'from' => 'groups', 'where' => 'g_id != ' . $this->settings['admin_group'] . ' AND g_access_cp=1')); $o = $this->DB->execute(); while ($row = $this->DB->fetch($o)) { /* Insert blank perm row */ $this->DB->insert('admin_permission_rows', array('row_id' => $row['g_id'], 'row_id_type' => 'group', 'row_perm_cache' => serialize(array()), 'row_updated' => time())); } $this->registry->output->addMessage("Удалены вторичные группы администраторов...."); } /* Report center reset */ $canReport = array(); $canView = array(); $this->DB->build(array('select' => 'g_id, g_view_board, g_access_cp, g_is_supmod', 'from' => 'groups')); $o = $this->DB->execute(); while ($r = $this->DB->fetch($o)) { if ($r['g_access_cp'] or $r['g_is_supmod']) { $canView[] = $r['g_id']; } if ($r['g_view_board'] and $r['g_id'] != $this->settings['guest_group']) { $canReport[] = $r['g_id']; } } $this->DB->update('rc_classes', array('group_can_report' => ',' . implode(',', $canReport) . ',', 'mod_group_perm' => ',' . implode(',', $canView) . ',')); /* Next Page */ $this->request['workact'] = 'skinlang'; }
/** * View details about an application * * @return @e void [Outputs to screen] */ protected function applicationViewDetails() { $id = intval($this->request['app_id']); if (!$id) { $this->registry->output->showError($this->lang->words['a_noid'], 11110.1); } $appData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_applications', 'where' => 'app_id=' . $id)); if (!$appData['app_id']) { $this->registry->output->showError($this->lang->words['a_nodetails'], 11111.1); } /* Format dates */ $lastUpdate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='{$appData['app_directory']}'", 'order' => 'upgrade_version_id DESC', 'limit' => array(1))); $appData['_installed'] = $this->registry->getClass('class_localization')->getDate($appData['app_added'], 'DATE'); $appData['_updated'] = $lastUpdate['upgrade_date'] > $appData['app_added'] ? $this->registry->getClass('class_localization')->getDate($lastUpdate['upgrade_date'], 'DATE') : '--'; /* Get the setup class */ require_once IPS_ROOT_PATH . "setup/sources/base/setup.php"; /*noLibHook*/ /* Version numbers */ $_a = in_array($appData['app_directory'], array('forums', 'members')) ? 'core' : $appData['app_directory']; $numbers = IPSSetUp::fetchAppVersionNumbers($_a); $appData['_human_version'] = $numbers['latest'][1]; $appData['_long_version'] = $numbers['latest'][0]; $appData['_human_current'] = $numbers['current'][1]; $appData['_long_current'] = $numbers['current'][0]; /* Got updates? */ if ($appData['app_update_check']) { /* Get hooks file for update check */ $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/applications/hooks.php', 'admin_core_applications_hooks'); $hooksClass = new $classToLoad(); $hooksClass->makeRegistryShortcuts($this->registry); $appData['app_update_available'] = $hooksClass->_updateAvailable($appData['app_update_check'], $appData['app_long_version']); } else { $appData['app_update_available'] = array(0); } /* Get related hooks */ $hooks = array(); $this->DB->build(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_requirements LIKE \'%:"' . $this->DB->addSlashes($appData['app_directory']) . '";a:%\'', 'order' => 'hook_id ASC')); $outer = $this->DB->execute(); /* Got results? */ if ($this->DB->getTotalRows($outer)) { /* Get hooks file for update check */ $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/applications/hooks.php', 'admin_core_applications_hooks'); $hooksClass = new $classToLoad(); $hooksClass->makeRegistryShortcuts($this->registry); /* Loop */ while ($rh = $this->DB->fetch($outer)) { /* Check requirements */ if ($rh['hook_enabled']) { $rh['_require_errors'] = $hooksClass->checkHookRequirements($rh); } $hooks[] = $rh; } } /* Upgrade history */ $upgradeHistory = array(); $this->DB->build(array('select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='" . $this->DB->addSlashes($appData['app_directory']) . "'", 'order' => 'upgrade_version_id DESC')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $upgradeHistory[] = $r; } /* Output */ $this->registry->output->html .= $this->html->application_details($appData, $upgradeHistory, $hooks); }
/** * Execute the plugin and return the HTML to show on the page. * Can be called from ACP or front end, so the plugin needs to setup any appropriate lang files, skin files, etc. * * @access public * @param array Block data * @return string Block HTML to display or cache */ public function executePlugin($block) { if (!IPSLib::appIsInstalled('calendar') or !is_file(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php')) { return ''; } $config = unserialize($block['block_config']); ipsRegistry::$request['cal_id'] = $config['custom']['calendar']; //----------------------------------------- // Grab calendar class //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php', "public_calendar_calendar_view"); $calendar = new $classToLoad($this->registry); $calendar->makeRegistryShortcuts($this->registry); if (!$calendar->initCalendar(true, false)) { return ''; } //----------------------------------------- // What now? //----------------------------------------- $a = explode(',', gmdate('Y,n,j,G,i,s', time() + ipsRegistry::getClass('class_localization')->getTimeOffset())); $now_date = array('year' => $a[0], 'mon' => $a[1], 'mday' => $a[2], 'hours' => $a[3], 'minutes' => $a[4], 'seconds' => $a[5]); $content = $calendar->getMiniCalendar($now_date['mon'], $now_date['year']); $pluginConfig = $this->returnPluginInfo(); $templateBit = $pluginConfig['templateBit'] . '_' . $block['block_id']; ob_start(); $_return = $this->registry->getClass('output')->getTemplate('ccs')->{$templateBit}($content); ob_end_clean(); return $_return; }
/** * Rebuild upcoming events cache * * @return @e void */ public function rebuildCalendarEventsCache() { //----------------------------------------- // Ensure calendar is installed //----------------------------------------- if (!$this->DB->checkForTable('cal_calendars')) { return; } if (!IPSLib::appIsInstalled('calendar')) { $this->cache->setCache('calendar_events', array(), array('array' => 1)); $this->cache->setCache('birthdays', array(), array('array' => 1)); return; } //----------------------------------------- // Init //----------------------------------------- $this->settings['calendar_limit'] = (intval($this->settings['calendar_limit']) < 2 ? 1 : intval($this->settings['calendar_limit'])) + 1; $birthdays = array(); $events = array(); $calendars = $this->cache->getCache('calendars'); $seenids = array(); //-------------------------------------------- // Set time stuff //-------------------------------------------- $startTime = gmmktime(0, 0, 0, gmstrftime('%m'), 1); $endTime = gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') + $this->settings['calendar_limit']); $nowTime = gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') - 1); list($month, $day, $year) = explode('-', gmstrftime('%m-%d-%Y')); list($last_month, $last_day, $last_year) = explode('-', gmstrftime('%m-%d-%Y', $nowTime)); list($next_month, $next_day, $next_year) = explode('-', gmstrftime('%m-%d-%Y', gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') + 1))); //-------------------------------------------- // Get classes //-------------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php', 'public_calendar_calendar_view'); $calendar = new $classToLoad($this->registry); $calendar->makeRegistryShortcuts($this->registry); if (!$calendar->initCalendar(true, true)) { $this->cache->setCache('calendar_events', array(), array('array' => 1)); $this->cache->setCache('birthdays', array(), array('array' => 1)); return; } //-------------------------------------------- // Load the events //-------------------------------------------- $calendar->calendarGetEventsSQL($month, $year, array('timenow' => $startTime, 'timethen' => $endTime, 'minimal' => true, 'no_date_convert' => true)); //-------------------------------------------- // Loop through events and cache //-------------------------------------------- for ($i = 0; $i <= $this->settings['calendar_limit']; $i++) { list($_month, $_day, $_year) = explode('-', gmstrftime('%m-%d-%Y', $nowTime)); $eventcache = $calendar->calendarGetDayEvents($_month, $_day, $_year); foreach ($eventcache as $event) { if ($event['event_approved'] and !in_array($event['event_id'], $seenids)) { if (!$event['event_recurring'] or $calendar->checkRecurring($event, $_month, $_day, $_year)) { unset($event['event_content'], $event['event_smilies']); $event['perm_view'] = $calendars[$event['event_calendar_id']]['perm_view']; $events[$event['event_id']] = $event; } $seenids[$event['event_id']] = $event['event_id']; } } $nowTime += 86400; } //----------------------------------------- // Grab birthdays //----------------------------------------- $append_string = ""; if (!gmdate("L")) { if ($month == 2 and $day > 26) { $append_string = " OR ( bday_month=2 AND bday_day=29 )"; } } $_days = array(); $this->DB->build(array('select' => 'member_id, members_seo_name, members_display_name, member_group_id, bday_day, bday_month, bday_year', 'from' => 'members', 'where' => "member_banned=0 AND ( !" . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ")\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND ( ( bday_day={$last_day} AND bday_month={$last_month} )\r\n\t\t\t\t\t\t\t\t\t\t\t\tOR ( bday_day={$day} AND bday_month={$month} )\r\n\t\t\t\t\t\t\t\t\t\t\t\tOR ( bday_day={$next_day} AND bday_month={$next_month} ) {$append_string} )")); $this->DB->execute(); while ($r = $this->DB->fetch()) { /* Only allow 6 per day, then the "upcoming birthdays" can display 5 and know there are more to display */ $_days[$r['bday_month'] . '.' . $r['bday_day']]++; if ($_days[$r['bday_month'] . '.' . $r['bday_day']] > 6) { continue; } $birthdays[$r['member_id']] = $r; } //-------------------------------------------- // Update calendar array //-------------------------------------------- $this->cache->setCache('calendar_events', $events, array('array' => 1)); $this->cache->setCache('birthdays', $birthdays, array('array' => 1)); }
/** * Rebuild a cache * * @access public * @param string Cache key * @param string Application * @return @e void */ public static function rebuildCache($key, $app = '') { /* INIT */ $app = IPSText::alphanumericalClean($app); $_caches = array(); if ($app) { if ($app == 'global') { $_caches = ipsRegistry::_fetchCoreVariables('cache'); } else { /* isset there is needed to prevent issues on applications installation */ if (isset(ipsRegistry::$applications[$app]) && !IPSLib::appIsInstalled($app)) { return; } $_caches = ipsRegistry::_fetchAppCoreVariables($app, 'cache'); } } else { /* Get all caches from all apps */ $_caches = ipsRegistry::_fetchCoreVariables('cache'); foreach (ipsRegistry::$applications as $appDir => $appData) { $CACHE = ipsRegistry::_fetchAppCoreVariables($appDir, 'cache'); if (is_array($CACHE)) { $_caches = array_merge($_caches, $CACHE); } } } /* Rebuild the cache, if found */ if (isset($_caches[$key])) { $file_to_check = $_caches[$key]['recache_file']; if ($file_to_check and is_file($file_to_check)) { $_func = $_caches[$key]['recache_function']; /* Hackish way to check for action overloader */ if (strpos($file_to_check, '/modules_') !== FALSE) { $_class = IPSLib::loadActionOverloader($file_to_check, $_caches[$key]['recache_class']); } elseif ($app) { $_class = IPSLib::loadLibrary($file_to_check, $_caches[$key]['recache_class'], $app == 'global' ? 'core' : $app); } /* Fallback */ if (!$_class) { $_class = $_caches[$key]['recache_class']; } $recache = new $_class(ipsRegistry::instance()); if (method_exists($recache, 'makeRegistryShortcuts')) { $recache->makeRegistryShortcuts(ipsRegistry::instance()); } $recache->{$_func}(); } } }
/** * Execute plugin * * @param array $permissions Moderator permissions * @return @e string */ public function executePlugin($permissions) { //----------------------------------------- // Check permissions //----------------------------------------- if (!$this->canView($permissions)) { return ''; } //----------------------------------------- // Functions class //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('calendar') . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar'); $this->functions = new $classToLoad($this->registry); $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . "/modules_public/calendar/view.php", 'public_calendar_calendar_view'); $this->view = new $classToLoad($this->registry); $this->view->makeRegistryShortcuts($this->registry); $this->view->initCalendar(); /* Add some CSS.. */ $this->registry->output->addToDocumentHead('importcss', "{$this->settings['css_base_url']}style_css/{$this->registry->output->skin['_csscacheid']}/ipb_calendar.css"); //----------------------------------------- // Get 10 events //----------------------------------------- $calendars = $this->functions->getCalendars(); $events = array(); $total = array('events' => 0); if (count($calendars)) { $_calIds = array_keys($calendars); $st = intval($this->request['st']); $total = $this->DB->buildAndFetch(array('select' => 'count(*) as events', 'from' => 'cal_events', 'where' => "event_calendar_id IN(" . implode(',', $_calIds) . ') AND event_approved=0')); //----------------------------------------- // Page links //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => $total['events'], 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&module=modcp&fromapp=calendar&tab=unapprovedevents")); /* Got events to load? */ if ($total['events']) { $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.event_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left')); if ($this->settings['reputation_enabled']) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache'); $this->registry->setClass('repCache', new $classToLoad()); $_joins[] = $this->registry->getClass('repCache')->getTotalRatingJoin('event_id', 'e.event_id', 'calendar'); $_joins[] = $this->registry->getClass('repCache')->getUserHasRatedJoin('event_id', 'e.event_id', 'calendar'); } $this->DB->build(array('select' => 'e.*', 'from' => array('cal_events' => 'e'), 'order' => 'e.event_start_date ASC', 'limit' => array($st, 10), 'where' => "e.event_calendar_id IN(" . implode(',', $_calIds) . ') AND e.event_approved=0', 'add_join' => $_joins)); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $events[] = $this->view->calendarMakeEventHTML(IPSMember::buildDisplayData($r), true); } } } return $this->registry->output->getTemplate('calendar')->modEventsWrapper($events, $pages); }
/** * Rebuild a cache using defined $CACHE settings in it's extensions file * * @param string Cache key * @param string Application * @return @e void */ public static function rebuildCache($key, $app = '') { if (defined('IPS_NO_CACHE_REBUILD')) { return true; } /* INIT */ $app = IPSText::alphanumericalClean($app); $_caches = array(); if ($app) { if ($app == 'global') { $_caches = ipsRegistry::_fetchCoreVariables('cache'); } else { /* isset there is needed to prevent issues on applications installation */ if (isset(ipsRegistry::$applications[$app]) && !IPSLib::appIsInstalled($app)) { return; } $_caches = ipsRegistry::_fetchAppCoreVariables($app, 'cache'); } } else { /* Get all caches from all apps */ $_caches = ipsRegistry::_fetchCoreVariables('cache'); foreach (ipsRegistry::$applications as $appDir => $appData) { $CACHE = ipsRegistry::_fetchAppCoreVariables($appDir, 'cache'); if (is_array($CACHE)) { $_caches = array_merge($_caches, $CACHE); /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/automatic-cache-reloads-do-not-take-application-directories-into-account-r41762 */ if (isset($CACHE[$key])) { $app = $appDir; } } } } /* Rebuild the cache, if found */ if (isset($_caches[$key])) { $file_to_check = $_caches[$key]['recache_file']; if ($file_to_check and is_file($file_to_check)) { $_func = $_caches[$key]['recache_function']; /* Hackish way to check for action overloader */ if (strpos($file_to_check, '/modules_') !== FALSE) { $_class = IPSLib::loadActionOverloader($file_to_check, $_caches[$key]['recache_class']); } elseif ($app) { $_class = IPSLib::loadLibrary($file_to_check, $_caches[$key]['recache_class'], $app == 'global' ? 'core' : $app); } /* Fallback */ if (!$_class) { $_class = $_caches[$key]['recache_class']; } $recache = new $_class(ipsRegistry::instance()); if (method_exists($recache, 'makeRegistryShortcuts')) { $recache->makeRegistryShortcuts(ipsRegistry::instance()); } $recache->{$_func}(); } } }
/** * Language Import * * @return @e void */ public function languages() { /* INIT */ $vars = $this->getVars(); $output = array(); $errors = array(); /* Load the language file */ $this->registry->class_localization->loadLanguageFile(array('admin_system')); /* Get the language stuff */ $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages'); $lang = new $classToLoad(); $lang->makeRegistryShortcuts($this->registry); /* Loop through the xml directory and look for lang packs */ $_PATH = $this->app_full_path . '/xml/'; try { foreach (new DirectoryIterator($_PATH) as $f) { if (preg_match("#(.+?)_language_pack.xml#", $f->getFileName())) { $this->request['file_location'] = $_PATH . $f->getFileName(); $lang->imprtFromXML(true, true, true, $vars['app_directory'], false, 1); } } } catch (Exception $e) { } $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['redir__nolanguages']; /* Clear main msg */ $this->registry->output->global_message = ''; /* Show redirect... */ $this->showRedirectScreen($vars['app_directory'], $output, $errors, $this->getNextURL('tasks', $vars)); }
/** * Check DB * * @return void */ public function install_checkdb() { //----------------------------------------- // INIT //----------------------------------------- ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_system'), 'core'); ipsRegistry::$settings['base_url'] = ipsRegistry::$settings['board_url']; ipsRegistry::$settings['public_url'] = ipsRegistry::$settings['board_url'] . '/index.php?'; ipsRegistry::$settings['public_dir'] = ipsRegistry::$settings['board_url'] . '/' . PUBLIC_DIRECTORY . '/'; ipsRegistry::$settings['base_acp_url'] = ipsRegistry::$settings['base_url'] . '/' . CP_DIRECTORY; ipsRegistry::$settings['skin_acp_url'] = ipsRegistry::$settings['base_url'] . '/' . CP_DIRECTORY . "/skin_cp"; ipsRegistry::$settings['skin_app_url'] = ipsRegistry::$settings['skin_acp_url']; ipsRegistry::$settings['js_main_url'] = ipsRegistry::$settings['base_url'] . '/' . CP_DIRECTORY . '/js/'; ipsRegistry::$settings['js_app_url'] = ipsRegistry::$settings['base_url'] . '/' . CP_DIRECTORY . '/' . IPSLib::getAppFolder($_app) . '/' . $_app . '/js/'; ipsRegistry::$settings['base_url'] = ipsRegistry::$settings['base_url'] . '/' . CP_DIRECTORY . '/upgrade/index.php?'; ipsRegistry::$settings['_base_url'] = ipsRegistry::$settings['base_url']; $_class = IPSLib::loadActionOverloader(IPS_ROOT_PATH . '/applications/core/modules_admin/diagnostics/diagnostics.php', 'admin_core_diagnostics_diagnostics'); $_check = new $_class(ipsRegistry::instance()); if (method_exists($_check, 'makeRegistryShortcuts')) { $_check->makeRegistryShortcuts(ipsRegistry::instance()); } $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/skin_cp/cp_skin_diagnostics.php', 'cp_skin_diagnostics', 'core'); $_check->html = new $classToLoad(ipsRegistry::instance()); $_check->form_code = $_check->html->form_code = 'app=upgrade&s=' . $this->request['s']; $_check->form_code_js = $_check->html->form_code_js = 'app=upgrade&s=' . $this->request['s']; $_check->_dbCheck(); if (strpos($this->registry->output->html, "<!--NOERRORSFOUND-->") !== false) { $this->_finishStep(array("Проверка БД закончена - Проблем не обнаружено"), "Обновление: Проверка БД", 'upgrade&do=modules'); return; } $this->registry->output->html = str_replace("module=diagnostics", '', $this->registry->output->html); $this->registry->output->html = str_replace("section=diagnostics", 'section=upgrade', $this->registry->output->html); $this->registry->output->html = str_replace("do=dbchecker", 'do=checkdb', $this->registry->output->html); $this->registry->output->addContent($this->registry->output->template()->db_checker_css() . $this->registry->output->html); $this->registry->output->setTitle("Upgrade: Database Checker"); $this->registry->output->setNextAction('upgrade&do=modules'); $this->registry->output->setInstallStep($this->_stepCount, $this->_totalSteps); $this->registry->output->sendOutput(); //----------------------------------------- // Next... //----------------------------------------- //$output[] = "Database Check Complete"; //$this->_finishStep( $output, "Upgrade: DB Check", 'upgrade&do=modules' ); }
/** * Show the configuration page * * @return @e void [Outputs to screen] */ protected function _chatConfig() { //----------------------------------------- // Load libby-do-dah //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings'); $settings = new $classToLoad(); $settings->makeRegistryShortcuts($this->registry); $settings->html = $this->registry->output->loadTemplate('cp_skin_settings', 'core'); ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_tools'), 'core'); $settings->form_code = $settings->html->form_code = 'module=settings&section=settings'; $settings->form_code_js = $settings->html->form_code_js = 'module=settings§ion=settings'; //----------------------------------------- // Did we reset the component? //----------------------------------------- if (!$this->settings['ipschat_account_key'] and !$this->settings['ipb_reg_number']) { $this->_chatSplash(); } $this->request['conf_title_keyword'] = 'ipschat'; $settings->return_after_save = $this->settings['base_url'] . $this->form_code . '&do=chatsettings'; $settings->_viewSettings(); }
/** * Uninstall a hook * * @return @e void [Outputs to screen] */ protected function _uninstallHook() { /* Init vars */ $hook_id = intval($this->request['id']); $hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id)); $extra_data = unserialize($hook['hook_extra_data']); if (!$hook['hook_id']) { $this->registry->output->global_message = $this->lang->words['h_hasbeenun']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=hooks_overview'); } /* Got any custom file to initialize? */ $_customFile = ''; $customClass = null; if ($extra_data['display']['custom']) { $_customFile = IPS_HOOKS_PATH . 'install_' . $extra_data['display']['custom']; if (is_file($_customFile)) { require_once $_customFile; /*noLibHook*/ $classname = str_replace('.php', '', $extra_data['display']['custom']); if (class_exists($classname)) { $customClass = new $classname($this->registry); if (method_exists($customClass, 'pre_uninstall')) { $customClass->pre_uninstall(); } } } } /* Get associated files */ $this->DB->build(array('select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook_id)); $this->DB->execute(); while ($r = $this->DB->fetch()) { @unlink(IPS_HOOKS_PATH . $r['hook_file_stored']); } /* Delete hook file entries */ $this->DB->delete('core_hooks_files', "hook_hook_id={$hook_id}"); //----------------------------------------- // Settings or setting groups? //----------------------------------------- if (count($extra_data['settingGroups'])) { $this->DB->delete('core_sys_settings_titles', "conf_title_keyword IN('" . implode("','", $extra_data['settingGroups']) . "')"); } if (count($extra_data['settings'])) { $this->DB->delete('core_sys_conf_settings', "conf_key IN('" . implode("','", $extra_data['settings']) . "')"); } $this->cache->rebuildCache('settings', 'global'); //----------------------------------------- // Language strings/files //----------------------------------------- if (count($extra_data['language'])) { foreach ($extra_data['language'] as $file => $bit) { $this->DB->delete('core_sys_lang_words', "word_pack='{$file}' AND word_key IN('" . implode("','", $bit) . "')"); } $langPacks = array(); $this->DB->build(array('select' => 'lang_id', 'from' => 'core_sys_lang')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $langPacks[] = $r['lang_id']; } $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages'); $langLib = new $classToLoad(); $langLib->makeRegistryShortcuts($this->registry); foreach ($langPacks as $langId) { $langLib->cacheToDisk($langId); } } //----------------------------------------- // Modules //----------------------------------------- if (count($extra_data['modules'])) { foreach ($extra_data['modules'] as $module) { list($_side, $_app, $_module) = explode('-', $module); $_is_admin = $_side == 'admin' ? 1 : 0; $this->DB->delete('core_sys_module', "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}"); } $this->cache->rebuildCache('module_cache', 'global'); $this->cache->rebuildCache('app_menu_cache', 'global'); } //----------------------------------------- // Help files //----------------------------------------- if (count($extra_data['help'])) { $this->DB->delete('faq', "title IN('" . implode("','", $extra_data['help']) . "')"); } //----------------------------------------- // Skin templates //----------------------------------------- if (count($extra_data['templates'])) { foreach ($extra_data['templates'] as $group => $bits) { $this->DB->delete('skin_templates', "template_group='{$group}' AND template_name IN('" . implode("','", $bits) . "')"); } require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ $skinCaching = new skinCaching($this->registry); $skinCaching->rebuildPHPTemplates(0); } //----------------------------------------- // CSS //----------------------------------------- if (count($extra_data['css'])) { $this->DB->delete('skin_css', "css_group IN('" . implode("','", $extra_data['css']) . "')"); if (!$skinCaching) { require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ $skinCaching = new skinCaching($this->registry); } $skinCaching->rebuildCSSCache(0); } //----------------------------------------- // Tasks //----------------------------------------- if (count($extra_data['tasks'])) { $this->DB->delete('task_manager', "task_key IN('" . implode("','", $extra_data['tasks']) . "')"); } //----------------------------------------- // Database changes //----------------------------------------- if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) { foreach ($extra_data['database']['create'] as $create_query) { $this->DB->return_die = true; $this->DB->dropTable($create_query['name']); $this->DB->return_die = false; } } if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) { foreach ($extra_data['database']['alter'] as $alter_query) { $this->DB->return_die = true; if ($alter_query['altertype'] == 'add') { if ($this->DB->checkForField($alter_query['field'], $alter_query['table'])) { $this->DB->dropField($alter_query['table'], $alter_query['field']); } } else { if ($alter_query['altertype'] == 'change') { if ($this->DB->checkForField($alter_query['newfield'], $alter_query['table'])) { $this->DB->changeField($alter_query['table'], $alter_query['newfield'], $alter_query['field'], $alter_query['fieldtype'], $alter_query['default']); } } } $this->DB->return_die = false; } } if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) { foreach ($extra_data['database']['update'] as $update_query) { $this->DB->return_die = true; $this->DB->update($update_query['table'], array($update_query['field'] => $update_query['oldvalue']), $update_query['where']); $this->DB->return_die = false; } } if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) { foreach ($extra_data['database']['insert'] as $insert_query) { if ($insert_query['fordelete']) { $this->DB->return_die = true; $this->DB->delete($insert_query['table'], $insert_query['fordelete']); $this->DB->return_die = false; } } } //----------------------------------------- // Custom install/uninstall script? //----------------------------------------- if ($_customFile) { if (is_object($customClass) && method_exists($customClass, 'uninstall')) { $customClass->uninstall(); } @unlink($_customFile); } /* Delete main hook entry */ $this->DB->delete('core_hooks', "hook_id={$hook_id}"); $this->rebuildHooksCache(); /* Done */ $this->registry->output->global_message = $this->lang->words['h_hasbeenun']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=hooks_overview'); }