/** * Controller */ public function process() { if ($iId = $this->request()->getInt('delete')) { if (Phpfox::getService('ad.process')->deleteInvoice($iId)) { $this->url()->send('admincp.ad.invoice', null, Phpfox::getPhrase('ad.invoice_successfully_deleted')); } } $iPage = $this->request()->getInt('page'); $aPages = array(5, 10, 15, 20); $aDisplays = array(); foreach ($aPages as $iPageCnt) { $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt)); } $aSorts = array('time_stamp' => Phpfox::getPhrase('ad.recently_added')); $aFilters = array('status' => array('type' => 'select', 'options' => array('1' => Phpfox::getPhrase('ad.paid'), '2' => Phpfox::getPhrase('ad.pending_payment'), '3' => Phpfox::getPhrase('ad.cancelled')), 'add_any' => true), 'display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '10'), 'sort' => array('type' => 'select', 'options' => $aSorts, 'default' => 'ad_id'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC')); $oSearch = Phpfox_Search::instance()->set(array('type' => 'invoices', 'filters' => $aFilters, 'search' => 'search')); $sStatus = $oSearch->get('status'); switch ($sStatus) { case '1': $oSearch->setCondition('ai.status = \'completed\''); break; case '2': $oSearch->setCondition('(ai.status = \'pending\' OR ' . Phpfox_Database::instance()->isNull('ai.status') . ')'); break; case '3': $oSearch->setCondition('ai.status = \'cancel\''); break; default: break; } $iLimit = $oSearch->getDisplay(); list($iCnt, $aInvoices) = Ad_Service_Ad::instance()->getInvoices($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $iLimit); $this->template()->setTitle(Phpfox::getPhrase('ad.ad_invoices'))->setBreadcrumb(Phpfox::getPhrase('ad.invoices'))->assign(array('aInvoices' => $aInvoices)); }
/** * Controller */ public function process() { if ($this->request()->get('update')) { $aModules = Phpfox::massCallback('getSqlTitleField'); $aParseTables = array(); if (is_array($aModules) && count($aModules)) { foreach ($aModules as $aModule) { if (isset($aModule['table'])) { $aModule = array($aModule); } foreach ($aModule as $aInfo) { $aParseTables[] = $aInfo; } } } $oDb = Phpfox_Database::instance(); foreach ($aParseTables as $aParseTable) { if (isset($aParseTable['has_index'])) { $aIndexes = Phpfox::getLib('database.support')->getIndexes(Phpfox::getT($aParseTable['table']), null, $oDb, true); foreach ($aIndexes as $aIndex) { if ($aIndex['Column_name'] == $aParseTable['has_index']) { $oDb->query('ALTER TABLE ' . Phpfox::getT($aParseTable['table']) . ' DROP INDEX ' . $aIndex['Key_name']); } } } Phpfox_Database::instance()->query('ALTER TABLE ' . Phpfox::getT($aParseTable['table']) . ' CHANGE ' . $aParseTable['field'] . ' ' . $aParseTable['field'] . ' text'); } $this->url()->send('admincp.sql.title', null, Phpfox::getPhrase('admincp.database_tables_updated')); } $this->template()->setTitle(Phpfox::getPhrase('admincp.alter_title_fields'))->setBreadcrumb(Phpfox::getPhrase('admincp.alter_title_fields'))->assign(array()); }
/** * Controller */ public function process() { $aCond = array(); $iPage = $this->request()->getInt('page'); $iPageSize = 10; $bIsSentbox = $this->request()->get('req2') == 'sent' ? true : false; $bIsSearch = false; if ($bIsSentbox) { $aCond[] = 'm.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 0'; } else { $aCond[] = 'm.viewer_folder_id = 0 AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0'; } if (($sSearch = $this->request()->get('search')) || $this->request()->get('search-query')) { if ($this->request()->get('search-query')) { $sSearch = Phpfox::getLib('session')->get('mfsearch'); } $bIsSearch = true; $aCond[] = "AND (m.subject LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR m.preview LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%')"; $this->url()->setParam('search-query', 'true'); Phpfox::getLib('session')->set('mfsearch', $sSearch); } if ($bIsSearch == false) { Phpfox::getLib('session')->remove('mfsearch'); } list($iCnt, $aMessages, $aInputs) = Mail_Service_Mail::instance()->get($aCond, 'm.time_updated DESC', $iPage, $iPageSize, $bIsSentbox); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('bMobileInboxIsActive' => true, 'aMessages' => $aMessages, 'bIsSearch' => $bIsSearch, 'bIsSentbox' => $bIsSentbox, 'aMobileSubMenus' => array($this->url()->makeUrl('mail') => Phpfox::getPhrase('mail.mobile_messages'), $this->url()->makeUrl('mail', 'sent') => Phpfox::getPhrase('mail.sent'), $this->url()->makeUrl('mail', 'compose') => Phpfox::getPhrase('mail.compose')), 'sActiveMobileSubMenu' => $this->url()->makeUrl('mail', $this->request()->get('req2') == '' ? null : $this->request()->get('req2')))); }
/** * Controller */ public function process() { if ($aTables = $this->request()->getArray('tables')) { if ($this->request()->get('optimize')) { foreach ($aTables as $sTable) { Phpfox_Database::instance()->optimizeTable($sTable); } $this->url()->send('admincp.sql', null, Phpfox::getPhrase('admincp.table_s_successfully_optimized')); } elseif ($this->request()->get('repair')) { foreach ($aTables as $sTable) { Phpfox_Database::instance()->repairTable($sTable); } $this->url()->send('admincp.sql', null, Phpfox::getPhrase('admincp.table_s_successfully_repaired')); } } $aItems = Phpfox_Database::instance()->getTableStatus(); $iSize = 0; $iOverhead = 0; foreach ($aItems as $iKey => $aItem) { $iSize += $aItem['Data_length']; $iOverhead += $aItem['Data_free']; $aItems[$iKey]['Name'] = $aItems[$iKey]['Name']; } $this->template()->setTitle(Phpfox::getPhrase('admincp.sql_maintenance_title'))->setBreadcrumb(Phpfox::getPhrase('admincp.sql_maintenance_title'), $this->url()->makeUrl('admincp.sql'))->assign(array('aItems' => $aItems, 'iSize' => $iSize, 'iOverhead' => $iOverhead, 'iCnt' => count($aItems))); }
/** * Loads and initiates the SQL driver that we need to use. * */ public function __construct() { if (!self::$_oObject) { $sDriver = 'phpfox.database.driver.mysqli'; self::$_oObject = Phpfox::getLib($sDriver); self::$_oObject->connect(Phpfox::getParam(array('db', 'host')), Phpfox::getParam(array('db', 'user')), Phpfox::getParam(array('db', 'pass')), Phpfox::getParam(array('db', 'name'))); } }
/** * Controller */ public function process() { list($aGroups, $aModules, $aProductGroups) = Phpfox::getService('admincp.setting.group')->get(); $aCond = array(); $aUrl = array(); $sSettingTitle = ''; if ($sSettingId = $this->request()->get('setting-id')) { $aCond[] = " AND setting.setting_id = " . (int) $sSettingId; $aUrl = array('setting', 'edit', 'setting-id' => $sSettingId); } if ($sGroupId = $this->request()->get('group-id')) { $aCond[] = " AND setting.group_id = '" . Phpfox_Database::instance()->escape($sGroupId) . "' AND setting.is_hidden = 0 "; $aUrl = array('setting', 'edit', 'group-id' => $sGroupId); foreach ($aGroups as $aGroup) { if ($aGroup['group_id'] == $sGroupId) { $sSettingTitle = $aGroup['var_name']; break; } } } if ($iModuleId = $this->request()->get('module-id')) { $aCond[] = " AND setting.module_id = '" . Phpfox_Database::instance()->escape($iModuleId) . "' AND setting.is_hidden = 0 "; $aUrl = array('setting', 'edit', 'module-id' => $iModuleId); foreach ($aModules as $aModule) { if ($aModule['module_id'] == $iModuleId) { $sSettingTitle = $aModule['module_id']; break; } } } if ($sProductId = $this->request()->get('product-id')) { $aCond[] = " AND setting.product_id = '" . Phpfox_Database::instance()->escape($sProductId) . "' AND setting.is_hidden = 0 "; $aUrl = array('setting', 'edit', 'product-id' => $sProductId); foreach ($aProductGroups as $aProduct) { if ($aProduct['product_id'] == $sProductId) { $sSettingTitle = $aProduct['var_name']; break; } } } $aSettings = Phpfox::getService('admincp.setting')->get($aCond); if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('admincp.setting.process')->update($aVals)) { // $this->url()->send('admincp', $aUrl, Phpfox::getPhrase('admincp.updated')); return ['updated' => true]; } } $sWatermarkImage = Phpfox::getParam('core.url_watermark') . sprintf(Phpfox::getParam('core.watermark_image'), '') . '?v=' . uniqid(); if (!file_exists(Phpfox::getParam('core.dir_watermark') . sprintf(Phpfox::getParam('core.watermark_image'), '')) && Phpfox::getParam('core.allow_cdn')) { $sWatermarkImage = Phpfox::getLib('cdn')->getUrl(str_replace(PHPFOX_DIR, '', $sWatermarkImage)); } if (Phpfox::isModule($sSettingTitle)) { $sSettingTitle = Phpfox_Locale::instance()->translate($sSettingTitle, 'module'); } $this->template()->setSectionTitle($sSettingTitle); $this->template()->setBreadCrumb(Phpfox::getPhrase('admincp.manage_settings'), $this->url()->makeUrl('admincp.setting'))->setBreadCrumb(Phpfox::getPhraseT($sSettingTitle, 'module'), null, true)->setTitle(Phpfox::getPhrase('admincp.manage_settings'))->assign(array('aGroups' => $aGroups, 'aModules' => $aModules, 'aProductGroups' => $aProductGroups, 'aSettings' => $aSettings, 'sSettingTitle' => $sSettingTitle, 'sWatermarkImage' => $sWatermarkImage)); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_edit_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $bCanBackup = Phpfox_Database::instance()->canBackup(); $sDefaultPath = PHPFOX_DIR_FILE . 'log' . PHPFOX_DS; if (($sPath = $this->request()->get('path')) && $bCanBackup) { if ($sBackupPath = Phpfox_Database::instance()->backup($sPath)) { $this->url()->send('admincp.sql.backup', null, Phpfox::getPhrase('admincp.sql_backup_successfully_created_and_can_be_downloaded_here_path', array('path' => $sBackupPath))); } } $this->template()->setTitle(Phpfox::getPhrase('admincp.sql_maintenance_title'))->setBreadcrumb(Phpfox::getPhrase('admincp.sql_maintenance_title'), $this->url()->makeUrl('admincp.sql'))->setBreadcrumb(Phpfox::getPhrase('admincp.backup'), null, true)->assign(array('bCanBackup' => $bCanBackup, 'sDefaultPath' => $sDefaultPath)); }
/** * Controller */ public function process() { $iPage = $this->getParam('page', 0); $iPageSize = 9; $oDb = Phpfox_Database::instance(); $aConditions = array(); if ($sFind = $this->getParam('find')) { $aConditions[] = 'AND (u.user_name LIKE \'%' . $oDb->escape($sFind) . '%\' OR u.full_name LIKE \'%' . $oDb->escape($sFind) . '%\' OR u.email LIKE \'%' . $oDb->escape($sFind) . '%\')'; } list($iCnt, $aUsers) = Phpfox::getService('user.browse')->conditions($aConditions)->page($iPage)->limit($iPageSize)->sort('u.last_login DESC')->get(); Phpfox_Pager::instance()->set(array('ajax' => 'user.browseAjax', 'page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('aUsers' => $aUsers, 'sPrivacyInputName' => $this->getParam('input'), 'bIsAjaxSearch' => $this->getParam('is_search', false))); }
/** * Controller */ public function process() { if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getLib('phpfox.api')->send('clientVerification', $aVals)) { if (Phpfox::getLib('phpfox.api')->send('brandingRemoval', array('domain' => Phpfox::getParam('core.path')))) { Phpfox_Database::instance()->update(Phpfox::getT('setting'), array('value_actual' => '1'), "var_name = 'branding'"); Phpfox::getLib('cache')->remove(); $this->url()->send('admincp', null, Phpfox::getPhrase('admincp.phpfox_branding_removal_successfully_installed')); } else { Phpfox_Error::set('We are unable to find a branding removal assigned to this license.'); } } } $this->template()->setTitle(Phpfox::getPhrase('admincp.phpfox_branding_removal'))->setBreadcrumb(Phpfox::getPhrase('admincp.phpfox_branding_removal'))->assign(array()); }
/** * Checks to see if the content being passed is considered as SPAM. * * @return bool TRUE if it is spam, FALSE if it isn't spam. */ public function isSpam() { if (empty($this->_aParams['content'])) { Phpfox_Error::set(Phpfox::getPhrase('core.content_is_empty')); return true; } $this->_aParams['content'] = md5(str_replace(array("\n", "\r", "\t", " ", "\\o", "\\xOB"), '', $this->_aParams['content'])); $sCount = $this->_oDb->select('COUNT(*)')->from(Phpfox::getT($this->_aParams['table']))->where('user_id = ' . Phpfox::getUserId() . ' AND item_hash = \'' . $this->_oDb->escape($this->_aParams['content']) . '\' AND time_stamp >= \'' . (PHPFOX_TIME - $this->_aParams['time'] * 60) . '\'')->limit($this->_aParams['total'])->order('time_stamp DESC')->execute('getSlaveField'); if ((int) $sCount > 0) { Phpfox_Database::instance()->updateCounter('user', 'total_spam', 'user_id', Phpfox::getUserId()); Phpfox_Error::set(Phpfox::getPhrase('core.the_content_of_this_item_is_identical_to_something_you_have_added_before_please_try_again')); return true; } $this->_oDb->insert(Phpfox::getT($this->_aParams['table']), array('user_id' => Phpfox::getUserId(), 'item_hash' => $this->_aParams['content'], 'time_stamp' => PHPFOX_TIME)); return false; }
/** * Controller */ public function process() { Phpfox::getUserParam('user.can_add_user_group_setting', true); $aGroups = Phpfox::getService('user.group')->get('user_group.is_special = 1'); $aForms = array(); if (($iSetting = $this->request()->getInt('id')) && ($aForms = Phpfox::getService('user.group.setting')->getSetting($iSetting)) && isset($aForms['setting_id'])) { foreach ($aGroups as $iKey => $aGroup) { if ($aGroup['user_group_id'] == '1') { $aGroups[$iKey]['value'] = $aForms['default_admin']; } elseif ($aGroup['user_group_id'] == '3') { $aGroups[$iKey]['value'] = $aForms['default_guest']; } elseif ($aGroup['user_group_id'] == '4') { $aGroups[$iKey]['value'] = $aForms['default_staff']; } else { $aGroups[$iKey]['value'] = $aForms['default_user']; } } } if (!$this->request()->getInt('id')) { $this->url()->send('admincp'); } $aValidation = array('name' => Phpfox::getPhrase('user.select_varname')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { // Check that all the fields are valid if ($oValid->isValid($aVals)) { if (isset($aForms['setting_id'])) { if (Phpfox::getService('user.group.setting.process')->updateSetting(array_merge($aVals, array('setting_id' => $aForms['setting_id'])))) { $this->url()->send('admincp', array('user', 'group', 'add', 'id' => $this->request()->getInt('gid'), '#setting' . $aForms['setting_id']), Phpfox::getPhrase('user.setting_successfully_updated')); } } else { if (Phpfox::getService('user.group.setting.process')->addSetting($aVals)) { $this->url()->send('admincp', array('user', 'group', 'setting'), Phpfox::getPhrase('user.setting_successfully_added')); } } } } if ($sCacheSetting = Phpfox::getLib('session')->get('cache_new_user_setting')) { Phpfox::getLib('session')->remove('cache_new_user_setting'); } if (isset($aForms['name'])) { Phpfox_Database::instance()->select('language_phrase.text, ')->leftJoin(Phpfox::getT('language_phrase'), 'language_phrase', "language_phrase.language_id = l.language_id AND language_phrase.var_name = 'user_setting_{$aForms['name']}'"); } $aLanguages = Phpfox::getService('language')->get(); $this->template()->setBreadcrumb(Phpfox::getPhrase('user.user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.manage_user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.add_user_group_setting'), null, true)->setTitle(Phpfox::getPhrase('user.add_user_group_setting'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aTypes' => array('boolean', 'integer', 'string', 'array'), 'aUserGroups' => $aGroups, 'sCacheSetting' => $sCacheSetting, 'aForms' => $aForms, 'iGroupId' => $this->request()->getInt('gid'))); ($sPlugin = Phpfox_Plugin::get('user.component_controller_admincp_group_setting_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $iId = (int) $this->getParam('iItemId'); $sType = $this->getParam('sType'); $aRows = $this->getParam('attachments', null); $bIsAttachmentEdit = (bool) $this->getParam('attachment_edit', false); $bIsAttachmentNoHeader = (bool) $this->getParam('attachment_no_header', false); if ($bIsAttachmentEdit) { list($iCnt, $aRows) = Phpfox::getService('attachment')->get('attachment.attachment_id IN(' . rtrim($this->getParam('sIds'), ',') . ')', 'attachment.time_stamp ASC', 0, 500, false); } else { if (!is_array($aRows)) { list($iCnt, $aRows) = Phpfox::getService('attachment')->get("attachment.item_id = {$iId} AND attachment.view_id = 0 AND attachment.category_id = '" . Phpfox_Database::instance()->escape($sType) . "' " . ($bIsAttachmentNoHeader ? '' : 'AND attachment.is_inline = 0'), 'attachment.attachment_id DESC', '', '', false); } } $this->template()->assign(array('aAttachments' => $aRows, 'sUrlPath' => Phpfox::getParam('core.url_attachment'), 'sUsage' => Phpfox::getUserBy('space_attachment'), 'bIsAttachmentNoHeader' => $bIsAttachmentNoHeader, 'bIsAttachmentEdit' => $bIsAttachmentEdit)); ($sPlugin = Phpfox_Plugin::get('attachment.component_block_list_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $sCategoryId = PHPFOX_IS_AJAX ? $this->request()->get('category_id') : $this->getParam('sCategoryId'); $sCached = $this->getParam('sAttachments'); $iUserId = Phpfox::getUserId(); $aRows1 = array(); $aRows2 = array(); if ($sCategoryId == 'page') { if (Phpfox::getUserParam('page.can_manage_custom_pages')) { $iUserId = false; } } if ($iItemId = $this->getParam('iItemId')) { list($iCnt, $aRows1) = Phpfox::getService('attachment')->get(array("AND attachment.item_id = " . (int) $iItemId . " AND attachment.category_id = '" . Phpfox_Database::instance()->escape($sCategoryId) . "'" . ($iUserId !== false ? " AND attachment.user_id = " . $iUserId . "" : "") . "")); } if (!empty($sCached)) { $sCacheQuery = ''; $aParts = explode(',', $sCached); foreach ($aParts as $iPart) { $iPart = trim($iPart); if (!is_numeric($iPart)) { continue; } $sCacheQuery .= $iPart . ','; } $sCachedQuery = rtrim($sCacheQuery, ','); if (!empty($sCachedQuery)) { list($iCnt, $aRows2) = Phpfox::getService('attachment')->get(array("AND attachment.attachment_id IN(" . $sCachedQuery . ") AND attachment.category_id = '" . Phpfox_Database::instance()->escape($sCategoryId) . "'" . ($iUserId !== false ? " AND attachment.user_id = " . $iUserId . "" : "") . "")); } } $aRows = array_merge($aRows1, $aRows2); if (isset($aRows)) { $sAttachments = ''; foreach ($aRows as $aRow) { $sAttachments .= $aRow['attachment_id'] . ','; } } if (!empty($sAttachments)) { $this->template()->assign(array('sAttachments' => rtrim($sAttachments, ','))); } if ($this->getParam('bFixToken')) { $this->template()->assign(array('bFixToken' => true)); } $this->template()->assign(array('sCategoryId' => $sCategoryId, 'sAttachmentInput' => $this->request()->get('input'), 'sCustomAttachment' => $this->request()->get('attachment_custom'))); }
/** * Controller */ public function process() { Phpfox::getUserParam('admincp.can_clear_site_cache', true); if ($this->request()->get('unlock')) { Phpfox::getLib('cache')->unlock(); $this->url()->send('admincp.maintain.cache', null, Phpfox::getPhrase('admincp.cache_system_unlocked')); } if ($this->request()->get('all')) { Phpfox_Database::instance()->update(Phpfox::getT('setting'), array('value_actual' => (int) Phpfox::getParam('core.css_edit_id') + 1), 'var_name = \'css_edit_id\''); Phpfox::getLib('cache')->remove(); Phpfox::getLib('template.cache')->remove(); Phpfox::getLib('cache')->removeStatic(); $aParams = array('maintain', 'cache', 'clear' => 'done'); if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_maintain_1')) { eval($sPlugin); } // $this->url()->send('admincp', $aParams, Phpfox::getPhrase('admincp.cached_cleared')); return ['content' => Phpfox::getPhrase('admincp.cached_cleared')]; } if ($aIds = $this->request()->getArray('id')) { foreach ($aIds as $sKey => $aItems) { foreach ($aItems as $sId) { Phpfox::getLib('cache')->remove($sId, 'path'); } } $this->url()->send('admincp', array('maintain', 'cache'), Phpfox::getPhrase('admincp.cached_cleared')); } $iPage = $this->request()->getInt('page'); $aPages = array(20, 30, 40, 50); $aDisplays = array(); foreach ($aPages as $iPageCnt) { $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt)); } $aSorts = array('time_stamp' => Phpfox::getPhrase('admincp.timestamp'), 'file_name' => Phpfox::getPhrase('admincp.cache_name'), 'data_size' => Phpfox::getPhrase('admincp.data_size')); $aFilters = array('search' => array('type' => 'input:text', 'search' => "AND file_name LIKE '%[VALUE]%'"), 'display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '20'), 'sort' => array('type' => 'select', 'options' => $aSorts, 'default' => 'time_stamp'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC')); $oSearch = Phpfox_Search::instance()->set(array('type' => 'cache', 'filters' => $aFilters, 'search' => 'search')); $iLimit = $oSearch->getDisplay(); list($iCnt, $aCaches) = Phpfox::getLib('cache')->getCachedFiles($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $iLimit); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iLimit, 'count' => $oSearch->getSearchTotal($iCnt))); if ($this->request()->get('clear')) { $aCaches = array(); $iCnt = 0; } $this->template()->setTitle('Cache Manager')->setSectionTitle('Cache Manager')->setActionMenu(['Clear Cache' => ['url' => $this->url()->makeUrl('admincp.maintain.cache', ['all' => true]), 'class' => 'popup']])->assign(array('iCacheCnt' => $iCnt, 'aCaches' => $aCaches, 'aStats' => Phpfox::getLib('cache')->getStats(), 'bCacheLocked' => file_exists(PHPFOX_DIR_CACHE . 'cache.lock') ? true : false, 'sUnlockCache' => $this->url()->makeUrl('admincp.maintain.cache', array('unlock' => 'true')))); }
/** * Controller */ public function process() { if ($sVar = $this->request()->get('var')) { if (preg_match('/(.*)\\.(.*)/i', $sVar, $aMatches) && isset($aMatches[2])) { $sVar = $aMatches[2]; $aResults = Phpfox::getService('admincp.setting')->search("setting.module_id = '" . Phpfox_Database::instance()->escape($aMatches[1]) . "' AND setting.var_name = '" . Phpfox_Database::instance()->escape($sVar) . "'"); } else { $aResults = Phpfox::getService('admincp.setting')->search("setting.var_name = '" . Phpfox_Database::instance()->escape($sVar) . "'"); } if (isset($aResults[0]['var_name'])) { $iId = $aResults[0]['module_id']; $sUrl = $this->url()->makeUrl('admincp.setting.edit') . 'module-id_' . $iId . '/#' . $aResults[0]['var_name']; $this->url()->send($sUrl); } else { $this->template()->assign(array('sMessage' => Phpfox::getPhrase('admincp.your_search_did_not_return_any_results'))); } } }
/** * Controller */ public function process() { $aModules = Phpfox::massCallback('reparserList'); foreach ($aModules as $iKey => $aModule) { if (!isset($aModule['name'])) { unset($aModules[$iKey]); $iCnt = 0; foreach ($aModule as $iModuleKey => $aCacheModule) { $iCnt++; $aModules = array_merge($aModules, array('custom' . $iCnt => $aCacheModule)); } } } foreach ($aModules as $iKey => $aModule) { if (!isset($aModule['name'])) { foreach ($aModule as $iSubKey => $aSub) { $aModules[$iKey . '_' . $iSubKey] = $aSub; } unset($aModules[$iKey]); } if (is_array($aModule['table'])) { $aModule['table'] = $aModule['table'][0]; } $aModules[$iKey]['total_record'] = Phpfox_Database::instance()->select('COUNT(*)')->from(Phpfox::getT($aModule['table']))->execute('getSlaveField'); if ($aModules[$iKey]['total_record'] == 0) { unset($aModules[$iKey]); } } $iPage = $this->request()->get('page'); $iLimit = 200; if (($sModule = $this->request()->get('module')) && isset($aModules[$sModule])) { $iCnt = Phpfox::getService('admincp.maintain')->reParseText($aModules[$sModule], $iPage, $iLimit); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iLimit, 'count' => $iCnt)); $iTotalPages = (int) Phpfox_Pager::instance()->getTotalPages(); $iCurrentPage = (int) Phpfox_Pager::instance()->getCurrentPage(); $iPage = (int) Phpfox_Pager::instance()->getNextPage(); if ($iTotalPages === $iCurrentPage || $iTotalPages === 0) { $this->url()->send('admincp.maintain.reparser', null, Phpfox::getPhrase('admincp.parsing_completed')); } else { $this->template()->assign(array('bInProcess' => true, 'iCurrentPage' => $iCurrentPage, 'iTotalPages' => $iTotalPages))->setHeader(array('<meta http-equiv="refresh" content="2;url=' . Phpfox_Url::instance()->makeUrl('admincp.maintain.reparser', array('module' => $sModule, 'page' => $iPage)) . '" />')); } } $this->template()->setTitle(Phpfox::getPhrase('admincp.text_reparser'))->setSectionTitle('Content Re-Parser')->assign(array('aReparserLists' => $aModules)); }
public function get() { $oFile = Phpfox_File::instance(); $bSlaveEnabled = Phpfox::getParam(array('db', 'slave')); $sDriver = Phpfox::getParam(array('db', 'driver')); $aStats = array(Phpfox::getPhrase('admincp.phpfox_version') => PhpFox::getVersion() . '<i>(build ' . Phpfox::getBuild() . ')</i>', Phpfox::getPhrase('admincp.php_version') => '<a href="' . Phpfox_Url::instance()->makeUrl('admincp.core.phpinfo') . '">' . PHP_VERSION . '</a>', Phpfox::getPhrase('admincp.php_sapi') => php_sapi_name(), Phpfox::getPhrase('admincp.php_safe_mode') => PHPFOX_SAFE_MODE ? Phpfox::getPhrase('admincp.true') : Phpfox::getPhrase('admincp.false'), Phpfox::getPhrase('admincp.php_open_basedir') => PHPFOX_OPEN_BASE_DIR ? Phpfox::getPhrase('admincp.true') : Phpfox::getPhrase('admincp.false'), Phpfox::getPhrase('admincp.php_disabled_functions') => @ini_get('disable_functions') ? str_replace(",", ", ", @ini_get('disable_functions')) : Phpfox::getPhrase('admincp.none'), Phpfox::getPhrase('admincp.php_loaded_extensions') => implode(' ', get_loaded_extensions()), Phpfox::getPhrase('admincp.operating_system') => PHP_OS, Phpfox::getPhrase('admincp.server_time_stamp') => date('F j, Y, g:i a', PHPFOX_TIME) . ' (GMT)', Phpfox::getPhrase('admincp.gzip') => Phpfox::getParam('core.use_gzip') ? Phpfox::getPhrase('admincp.enabled') : Phpfox::getPhrase('admincp.disabled'), Phpfox::getPhrase('admincp.sql_driver_version') => $sDriver == 'DATABASE_DRIVER' ? Phpfox::getPhrase('admincp.n_a') : Phpfox_Database::instance()->getServerInfo(), Phpfox::getPhrase('admincp.sql_slave_enabled') => $bSlaveEnabled ? Phpfox::getPhrase('admincp.yes') : Phpfox::getPhrase('admincp.no'), Phpfox::getPhrase('admincp.sql_total_slaves') => $bSlaveEnabled ? count(Phpfox::getParam(array('db', 'slave_servers'))) : Phpfox::getPhrase('admincp.n_a'), Phpfox::getPhrase('admincp.sql_slave_server') => $bSlaveEnabled ? Phpfox_Database::instance()->sSlaveServer : Phpfox::getPhrase('admincp.n_a'), Phpfox::getPhrase('admincp.memory_limit') => $oFile->filesize($this->_getUsableMemory()) . ' (' . @ini_get('memory_limit') . ')', Phpfox::getPhrase('admincp.load_balancing_enabled') => Phpfox::getParam(array('balancer', 'enabled')) ? Phpfox::getPhrase('admincp.yes') : Phpfox::getPhrase('admincp.no')); if (strpos(strtolower(PHP_OS), 'win') === 0 || PHPFOX_SAFE_MODE || PHPFOX_OPEN_BASE_DIR) { } else { if (function_exists('shell_exec')) { $sMemory = @shell_exec("free -m"); $aMemory = explode("\n", str_replace("\r", "", $sMemory)); if (is_array($aMemory)) { $aMemory = array_slice($aMemory, 1, 1); if (isset($aMemory[0])) { $aMemory = preg_split("#\\s+#", $aMemory[0]); $aStats[Phpfox::getPhrase('admincp.total_server_memory')] = isset($aMemory[1]) ? $aMemory[1] . ' MB' : '--'; $aStats[Phpfox::getPhrase('admincp.available_server_memory')] = isset($aMemory[3]) ? $aMemory[3] . ' MB' : '--'; } } } else { if (stristr(PHP_OS, "win") === false) { $sMemory = file_get_contents('/proc/meminfo'); $aMemoryStats = explode("n", $sMemory); // escape the "new line" $aMem = null; foreach ($aMemoryStats as $iKey => $sMemoryStat) { $aMemoryStats[$iKey] = preg_replace('/s+/', ' ', $sMemoryStat); if (preg_match('/[0-9]+/', $sMemoryStat, $aMem)) { $aMemoryStats[$iKey] = $aMem[0] / 1024; } } $aStats[Phpfox::getPhrase('admincp.total_server_memory')] = (int) $aMemoryStats[0] . ' MB'; $aStats[Phpfox::getPhrase('admincp.available_server_memory')] = (int) $aMemoryStats[1] . ' MB'; } } } if (!PHPFOX_OPEN_BASE_DIR && ($sLoad = Phpfox::getService('core.load')->get()) !== null) { $aStats[Phpfox::getPhrase('admincp.current_server_load')] = $sLoad; } return $aStats; }
/** * Import XML data. * * @param array $aVals ARRAY of XML data. * @param bool $bMissingOnly TRUE to import only missing data. * @return bool Always returns TRUE. */ public function import($aVals, $bMissingOnly = false) { $aCache = array(); if ($bMissingOnly) { $aRows = Phpfox_Database::instance()->select('version_id')->from(Phpfox::getT('version'))->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[$aRow['version_id']] = $aRow['version_id']; } } $aSql = array(); foreach ($aVals['version'] as $aVal) { if ($bMissingOnly && isset($aCache[$aVal['version_id']])) { continue; } $aSql[] = array($aVal['version_id'], $aVal['ordering']); } if ($aSql) { Phpfox_Database::instance()->multiInsert(Phpfox::getT('version'), array('version_id', 'ordering'), $aSql); } return true; }
/** * Class constructor is used to build the current URL and all the custom rewrite rules. * */ public function __construct() { if (!defined('PHPFOX_INSTALLER')) { $oCache = Phpfox::getLib('cache'); $iCacheId = $oCache->set('rewrite'); $iReverseCacheId = $oCache->set('rewrite_reverse'); if (!($this->aRewrite = $oCache->get($iCacheId)) || !($this->aReverseRewrite = $oCache->get($iReverseCacheId))) { $aRows = Phpfox_Database::instance()->select('r.url, r.replacement')->from(Phpfox::getT('rewrite'), 'r')->execute('getRows'); foreach ($aRows as $aRow) { $aParts = explode('/', $aRow['url']); /*$this->aRewrite[rtrim($aRow['replacement'], '/')] = array( 'module' => $aParts[0], 'component' => ((isset($aParts[1]) && !empty($aParts[1])) ? $aParts[1] : 'index'));*/ $this->aRewrite[$aRow['url']] = $aRow['replacement']; $this->aReverseRewrite[rtrim($aRow['replacement'], '/')] = $aRow['url']; } $oCache->save($iCacheId, $this->aRewrite); $oCache->save($iReverseCacheId, $this->aReverseRewrite); } } $this->_setParams(); }
/** * Controller */ public function process() { Phpfox::isUser(true); if (!Phpfox::getUserParam('user.can_delete_own_account')) { Phpfox_Url::instance()->send(''); } if (Phpfox::isModule('friend')) { list($iCnt, $aShowFriends) = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . Phpfox::getUserId() . ' AND ' . Phpfox_Database::instance()->isNotNull('user_image'), 'RAND()', 0, 3); $this->template()->assign(array('aFriends' => $aShowFriends, 'aReasons' => Phpfox::getService('user')->getReasons())); } // is not confirming if ($this->request()->get('req3') == 'confirm') { if ($aVals = $this->request()->getArray('val')) { // user inputted password, no turning back now... if (User_Service_Cancellations_Process::instance()->cancelAccount($aVals)) { // redirect is in the cancelAccoutn because of the logout } else { // an error occured (??) } } } $this->template()->setTitle(Phpfox::getPhrase('user.cancel_account'))->setBreadcrumb(Phpfox::getPhrase('user.cancel_account')); }
public function __construct() { $this->db = \Phpfox_Database::instance(); $this->request = \Phpfox_Request::instance(); if ($this->request->segment(1) == 'api') { \Core\Route\Controller::$isApi = true; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { throw new \Exception('Missing authentication key and pass.'); } foreach ((new App())->all() as $App) { if ($App->auth->id == $_SERVER['PHP_AUTH_USER']) { $this->active = $App; break; } } if (!$this->active) { throw new \Exception('Unable to find this app.'); } if ($_SERVER['PHP_AUTH_PW'] != $App->auth->key) { throw new \Exception('Authentication failed. Key is not valid: ' . $App->auth->key); } } }
/** * Controller */ public function process() { Phpfox::isUser(true); $iPageSize = 10; $iPage = $this->request()->getInt('page'); $bIsSearch = false; $aCond = array(); $aCond[] = 'AND friend.user_id = ' . Phpfox::getUserId(); if (($sSearch = $this->request()->get('search')) || $this->request()->get('search-query')) { if ($this->request()->get('search-query')) { $sSearch = Phpfox::getLib('session')->get('mfsearch'); } $bIsSearch = true; $aCond[] = "AND (u.full_name LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR u.email LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR u.user_name LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%')"; $this->url()->setParam('search-query', 'true'); Phpfox::getLib('session')->set('mfsearch', $sSearch); } if ($bIsSearch == false) { Phpfox::getLib('session')->remove('mfsearch'); } list($iCnt, $aFriends) = Friend_Service_Friend::instance()->get($aCond, 'u.full_name ASC', $iPage, $iPageSize); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('aFriends' => $aFriends, 'bMobileFriendIsActive' => true, 'bIsSearch' => $bIsSearch, 'bIsFriendSelect' => $this->request()->get('req2') == 'select' ? true : false)); }
/** * Controller */ public function process() { Phpfox::getUserParam('event.can_access_event', true); $aParentModule = $this->getParam('aParentModule'); if ($aParentModule === null && $this->request()->getInt('req2') > 0) { return Phpfox_Module::instance()->setController('event.view'); } if (($sLegacyTitle = $this->request()->get('req2')) && !empty($sLegacyTitle)) { if ($this->request()->get('req3') != '') { $sLegacyTitle = $this->request()->get('req3'); } $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('category_id', 'name'), 'table' => 'event_category', 'redirect' => 'event.category', 'title' => $sLegacyTitle, 'search' => 'name_url')); } if (($iRedirectId = $this->request()->getInt('redirect')) && ($aEvent = Event_Service_Event::instance()->getEvent($iRedirectId, true)) && $aEvent['module_id'] != 'event' && Phpfox::hasCallback($aEvent['module_id'], 'getEventRedirect')) { if ($sForward = Phpfox::callback($aEvent['module_id'] . '.getEventRedirect', $aEvent['event_id'])) { Phpfox::getService('notification.process')->delete('event_invite', $aEvent['event_id'], Phpfox::getUserId()); $this->url()->forward($sForward); } } if ($iDeleteId = $this->request()->getInt('delete')) { if ($mDeleteReturn = Event_Service_Process::instance()->delete($iDeleteId)) { if (is_bool($mDeleteReturn)) { $this->url()->send('event', null, Phpfox::getPhrase('event.event_successfully_deleted')); } else { $this->url()->forward($mDeleteReturn, Phpfox::getPhrase('event.event_successfully_deleted')); } } } if (($iRedirectId = $this->request()->getInt('redirect')) && ($aEvent = Event_Service_Event::instance()->getEvent($iRedirectId, true))) { Phpfox::getService('notification.process')->delete('event_invite', $aEvent['event_id'], Phpfox::getUserId()); $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title']); } $bIsUserProfile = false; if (defined('PHPFOX_IS_AJAX_CONTROLLER')) { $bIsUserProfile = true; $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id')); $this->setParam('aUser', $aUser); } if (defined('PHPFOX_IS_USER_PROFILE')) { $bIsUserProfile = true; $aUser = $this->getParam('aUser'); } $oServiceEventBrowse = Phpfox::getService('event.browse'); $sCategory = null; $sView = $this->request()->get('view', false); $aCallback = $this->getParam('aCallback', false); $this->search()->set(array('type' => 'event', 'field' => 'm.event_id', 'search_tool' => array('default_when' => 'upcoming', 'when_field' => 'start_time', 'when_upcoming' => true, 'table_alias' => 'm', 'search' => array('action' => $aParentModule === null ? $bIsUserProfile === true ? $this->url()->makeUrl($aUser['user_name'], array('event', 'view' => $this->request()->get('view'))) : $this->url()->makeUrl('event', array('view' => $this->request()->get('view'))) : $aParentModule['url'] . 'event/view_' . $this->request()->get('view') . '/', 'default_value' => Phpfox::getPhrase('event.search_events'), 'name' => 'search', 'field' => 'm.title'), 'sort' => array('latest' => array('m.start_time', Phpfox::getPhrase('event.latest'), 'ASC'), 'most-liked' => array('m.total_like', Phpfox::getPhrase('event.most_liked')), 'most-talked' => array('m.total_comment', Phpfox::getPhrase('event.most_discussed'))), 'show' => array(12, 15, 18, 21)))); $aBrowseParams = array('module_id' => 'event', 'alias' => 'm', 'field' => 'event_id', 'table' => Phpfox::getT('event'), 'hide_view' => array('pending', 'my')); switch ($sView) { case 'pending': if (Phpfox::getUserParam('event.can_approve_events')) { $this->search()->setCondition('AND m.view_id = 1'); } break; case 'my': Phpfox::isUser(true); $this->search()->setCondition('AND m.user_id = ' . Phpfox::getUserId()); break; default: if ($bIsUserProfile) { $this->search()->setCondition('AND m.view_id ' . ($aUser['user_id'] == Phpfox::getUserId() ? 'IN(0,2)' : '= 0') . ' AND m.module_id = "event" AND m.privacy IN(' . (Phpfox::getParam('core.section_privacy_item_browsing') ? '%PRIVACY%' : Phpfox::getService('core')->getForBrowse($aUser)) . ') AND m.user_id = ' . (int) $aUser['user_id']); } elseif ($aParentModule !== null) { $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%) AND m.module_id = \'' . Phpfox_Database::instance()->escape($aParentModule['module_id']) . '\' AND m.item_id = ' . (int) $aParentModule['item_id'] . ''); } else { switch ($sView) { case 'attending': $oServiceEventBrowse->attending(1); break; case 'may-attend': $oServiceEventBrowse->attending(2); break; case 'not-attending': $oServiceEventBrowse->attending(3); break; case 'invites': $oServiceEventBrowse->attending(0); break; } if ($sView == 'attending') { $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%)'); } else { $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%) AND m.item_id = ' . ($aCallback !== false ? (int) $aCallback['item'] : 0) . ''); } if ($this->request()->getInt('user') && ($aUserSearch = Phpfox::getService('user')->getUser($this->request()->getInt('user')))) { $this->search()->setCondition('AND m.user_id = ' . (int) $aUserSearch['user_id']); $this->template()->setBreadcrumb($aUserSearch['full_name'] . '\'s Events', $this->url()->makeUrl('event', array('user' => $aUserSearch['user_id'])), true); } } break; } if ($this->request()->getInt('sponsor') == 1) { $this->search()->setCondition('AND m.is_sponsor != 1'); Phpfox::addMessage(Phpfox::getPhrase('event.sponsor_help')); } if ($this->request()->get('req2') == 'category') { $sCategory = $this->request()->getInt('req3'); $this->search()->setCondition('AND mcd.category_id = ' . (int) $sCategory); } if ($sView == 'featured') { $this->search()->setCondition('AND m.is_featured = 1'); } $this->setParam('sCategory', $sCategory); $oServiceEventBrowse->callback($aCallback)->category($sCategory); $this->search()->browse()->params($aBrowseParams)->execute(); $aFilterMenu = array(); $bSetFilterMenu = !defined('PHPFOX_IS_USER_PROFILE') && !defined('PHPFOX_IS_PAGES_VIEW'); if ($sPlugin = Phpfox_Plugin::get('event.component_controller_index_set_filter_menu_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } if ($bSetFilterMenu) { $aFilterMenu = array(Phpfox::getPhrase('event.all_events') => '', Phpfox::getPhrase('event.my_events') => 'my'); if (Phpfox::isModule('friend') && !Phpfox::getParam('core.friends_only_community')) { $aFilterMenu[Phpfox::getPhrase('event.friends_events')] = 'friend'; } list($iTotalFeatured, $aFeatured) = Event_Service_Event::instance()->getFeatured(); if ($iTotalFeatured) { $aFilterMenu[Phpfox::getPhrase('event.featured_events') . '<span class="pending">' . $iTotalFeatured . '</span>'] = 'featured'; } if (Phpfox::getUserParam('event.can_approve_events')) { $iPendingTotal = Event_Service_Event::instance()->getPendingTotal(); if ($iPendingTotal) { $aFilterMenu[Phpfox::getPhrase('event.pending_events') . '<span class="pending">' . $iPendingTotal . '</span>'] = 'pending'; } } $aFilterMenu[] = true; $aFilterMenu[Phpfox::getPhrase('event.events_i_m_attending')] = 'attending'; $aFilterMenu[Phpfox::getPhrase('event.events_i_may_attend')] = 'may-attend'; $aFilterMenu[Phpfox::getPhrase('event.events_i_m_not_attending')] = 'not-attending'; $aFilterMenu[Phpfox::getPhrase('event.event_invites')] = 'invites'; $this->template()->buildSectionMenu('event', $aFilterMenu); } $this->template()->setTitle($bIsUserProfile ? Phpfox::getPhrase('event.full_name_s_events', array('full_name' => $aUser['full_name'])) : Phpfox::getPhrase('event.events'))->setBreadcrumb(Phpfox::getPhrase('event.events'), $aCallback !== false ? $this->url()->makeUrl($aCallback['url_home'][0], array_merge($aCallback['url_home'][1], array('event'))) : ($bIsUserProfile ? $this->url()->makeUrl($aUser['user_name'], 'event') : $this->url()->makeUrl('event')))->setHeader('cache', array('country.js' => 'module_core', 'browse.css' => 'module_event', 'feed.js' => 'module_feed'))->assign(array('aEvents' => $this->search()->browse()->getRows(), 'sView' => $sView, 'aCallback' => $aCallback, 'sParentLink' => $aCallback !== false ? $aCallback['url_home'][0] . '.' . implode('.', $aCallback['url_home'][1]) . '.event' : 'event', 'sApproveLink' => $this->url()->makeUrl('event', array('view' => 'pending')))); if ($sCategory !== null) { $aCategories = Phpfox::getService('event.category')->getParentBreadcrumb($sCategory); $iCnt = 0; foreach ($aCategories as $aCategory) { $iCnt++; $this->template()->setTitle($aCategory[0]); if ($aCallback !== false) { $sHomeUrl = '/' . Phpfox_Url::instance()->doRewrite($aCallback['url_home'][0]) . '/' . implode('/', $aCallback['url_home'][1]) . '/' . Phpfox_Url::instance()->doRewrite('event') . '/'; $aCategory[1] = preg_replace('/^http:\\/\\/(.*?)\\/' . Phpfox_Url::instance()->doRewrite('event') . '\\/(.*?)$/i', 'http://\\1' . $sHomeUrl . '\\2', $aCategory[1]); } $this->template()->setBreadcrumb($aCategory[0], $aCategory[1], empty($sView) ? true : false); } } if ($aCallback !== false) { $this->template()->rebuildMenu('event.index', $aCallback['url_home']); } Phpfox_Pager::instance()->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount())); $this->setParam('global_moderation', array('name' => 'event', 'ajax' => 'event.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('event.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('event.approve'), 'action' => 'approve')))); }
/** * Gets the newer polls available * @param integer $iLimit How many polls to fetch * @return array */ public function getNew($iLimit = 3) { ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getnew_start')) ? eval($sPlugin) : false; return $this->database()->select('p.poll_id, p.time_stamp, p.question, p.question_url, ' . Phpfox::getUserField())->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where('' . Phpfox_Database::instance()->isNull('p.module_id') . ' AND p.view_id = 0 AND p.privacy = 1')->limit($iLimit)->order('p.time_stamp DESC')->execute('getSlaveRows'); ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getnew_end')) ? eval($sPlugin) : false; }
public function _hashSearch() { if (Phpfox_Request::instance()->get('req1') != 'hashtag' && Phpfox_Request::instance()->get('hashtagsearch') == '') { return; } $sRequest = isset($_GET[PHPFOX_GET_METHOD]) ? $_GET[PHPFOX_GET_METHOD] : ''; $sReq2 = ''; if (!empty($sRequest)) { $aParts = explode('/', trim($sRequest, '/')); $iCnt = 0; // http://www.phpfox.com/tracker/view/15000/ // We have to count the "mobile" part as a req1 // add one to the count $iCntTotal = Phpfox::isMobile() ? 3 : 2; foreach ($aParts as $sPart) { $iCnt++; if ($iCnt === $iCntTotal) { $sReq2 = $sPart; break; } } } $sTag = Phpfox_Request::instance()->get('hashtagsearch') ? Phpfox_Request::instance()->get('hashtagsearch') : $sReq2; $sTag = \Phpfox_Parse_Output::instance()->parse($sTag); //https://github.com/moxi9/phpfox/issues/595 $sTag = urldecode($sTag); if (empty($sTag)) { return; } $sTag = Phpfox::getLib('parse.input')->clean($sTag, 255); $sTag = mb_convert_case($sTag, MB_CASE_LOWER, "UTF-8"); $this->database()->join(Phpfox::getT('tag'), 'hashtag', 'hashtag.item_id = feed.item_id AND hashtag.category_id = feed.type_id AND (tag_text = \'' . Phpfox_Database::instance()->escape($sTag) . '\' OR tag_url = \'' . Phpfox_Database::instance()->escape($sTag) . '\')'); }
/** * @see User_Service_Auth::getUserId() * @return int */ public static function getUserId() { //static $bChecked = false; if (isset($_REQUEST['custom_pages_post_as_page']) && (int) $_REQUEST['custom_pages_post_as_page'] > 0) { //$bChecked = true; $aPage = Phpfox_Database::instance()->getRow(' SELECT p.page_id, p.user_id AS owner_user_id, u.user_id FROM ' . Phpfox::getT('pages') . ' AS p JOIN ' . Phpfox::getT('user') . ' AS u ON(u.profile_page_id = p.page_id) WHERE p.page_id = ' . (int) $_REQUEST['custom_pages_post_as_page'] . ' '); $iActualUserId = Phpfox::getService('user.auth')->getUserId(); if (!defined('PHPFOX_POSTING_AS_PAGE')) { define('PHPFOX_POSTING_AS_PAGE', true); } if (isset($aPage['page_id'])) { $bPass = false; if ($aPage['owner_user_id'] == $iActualUserId) { $bPass = true; } if (!$bPass) { $aAdmin = Phpfox_Database::instance()->getRow(' SELECT page_id FROM ' . Phpfox::getT('pages_admin') . ' WHERE page_id = ' . (int) $aPage['page_id'] . ' AND user_id = ' . (int) $iActualUserId . ' '); if (isset($aAdmin['page_id'])) { $bPass = true; } } if ($bPass) { return $aPage['user_id']; } } } if ($sPlugin = Phpfox_Plugin::get('library_phpfox_phpfox_getuserid__1')) { eval($sPlugin); } if (defined('PHPFOX_APP_USER_ID')) { return PHPFOX_APP_USER_ID; } return Phpfox::getService('user.auth')->getUserId(); }
/** * Get all the drag/drop information from a specific table for a specific user. * */ private function _getItemCacheData() { if ($this->_aCachedItemData === null) { $this->_aCachedItemData = array(); $this->_aCachedItemDataBlock = array(); $this->_aItemDataCache = array(); $aDesigns = Phpfox_Database::instance()->select('cache_id, block_id, ordering, is_hidden')->from(Phpfox::getT($this->_aCacheBlockData['table']))->where($this->_aCacheBlockData['field'] . ' = ' . (int) $this->_aCacheBlockData['item_id'])->order('ordering ASC')->execute('getSlaveRows'); if (count($aDesigns)) { $iCnt = 0; foreach ($aDesigns as $aDesign) { $iCnt++; $this->_aCachedItemData[$aDesign['cache_id']] = $iCnt; $this->_aCachedItemDataBlock[$aDesign['cache_id']] = $aDesign['block_id']; $this->_aItemDataCache[$aDesign['cache_id']] = $aDesign; } } } }
public function __construct() { if (self::$_object === null) { self::$_object = \Phpfox_Database::instance(); } }
/** * Controller */ public function process() { // Set page vars $oComment = Phpfox::getService('comment'); $sType = $this->getParam('sType'); $iItemId = $this->getParam('iItemId'); $iPage = $this->request()->get('page'); $iOriginalCnt = $this->getParam('iTotal', 0); $iViewId = $this->getParam('iViewId', 0); $iPageSize = Phpfox::getParam('comment.comment_page_limit'); $aRows = array(); $bCanPostOnItem = Phpfox::getUserParam(Phpfox::callback($sType . '.getAjaxCommentVar')); if ($sType == 'group' && !Phpfox::getService('group')->hasAccess($iItemId, 'can_use_comments')) { $bCanPostOnItem = false; } if ($sType == 'group' && !Phpfox::getService('group')->hasAccess($iItemId, 'can_use_comments', true)) { $bCanPostOnItem = false; } if (PHPFOX_IS_AJAX) { $aRequests = $this->request()->getRequests(); foreach ($aRequests as $sKey => $sValue) { if (!preg_match("/req[0-9]/", $sKey)) { continue; } $this->url()->setParam($sKey, $sValue); } } if (!$iOriginalCnt) { $iCnt = 0; } if ($iOriginalCnt || Phpfox::getUserParam('comment.can_moderate_comments')) { if (Phpfox::getUserParam('comment.can_moderate_comments')) { $aSql = array(Phpfox::getParam('comment.comment_is_threaded') ? 'AND cmt.parent_id = 0' : '', "AND cmt.type_id = '" . Phpfox_Database::instance()->escape($sType) . "'", 'AND cmt.item_id = ' . (int) $iItemId); } else { $aSql = array(Phpfox::getParam('comment.comment_is_threaded') ? 'AND cmt.parent_id = 0' : '', "AND cmt.type_id = '" . Phpfox_Database::instance()->escape($sType) . "'", 'AND cmt.item_id = ' . (int) $iItemId, 'AND cmt.view_id = ' . (int) $iViewId); } if ($iCommentId = $this->request()->getInt('comment')) { if (count($aSql) && count($aSql) > 2) { unset($aSql[0]); } $aSql[] = 'AND cmt.comment_id = ' . $iCommentId; } // Get the comments for this page list($iCnt, $this->_aComments) = $oComment->get('cmt.*', $aSql, 'cmt.time_stamp DESC', $iPage, $iPageSize, Phpfox::getParam('comment.comment_is_threaded') || Phpfox::getUserParam('comment.can_moderate_comments') ? null : $iOriginalCnt); } // Threaded mode? if (Phpfox::getParam('comment.comment_is_threaded')) { if (count($this->_aComments)) { foreach ($this->_aComments as $iKey => $aComment) { unset($this->_aComments[$iKey]); $this->_aComments[$aComment['comment_id']] = $aComment; } $sComments = ''; foreach ($this->_aComments as $aComment) { if ($aComment['child_total']) { $sComments .= $aComment['comment_id'] . ','; } } $sComments = rtrim($sComments, ','); if (!empty($sComments)) { list($iChildCnt, $this->_aChildComments) = $oComment->get('cmt.*', array('cmt.parent_id IN(' . $sComments . ') AND cmt.view_id = ' . (int) $iViewId), 'cmt.time_stamp DESC'); foreach ($this->_aChildComments as $aChildComment) { $this->_aComments[$aChildComment['parent_id']]['childrens'][] = $aChildComment; } unset($this->_aChildComments); } } // Set the pager Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'ajax' => 'comment.browse', 'aParams' => array('sType' => $sType, 'iItemId' => $iItemId, 'iTotal' => $iCnt))); $this->template()->assign(array('bCanPostOnItem' => $bCanPostOnItem, 'sType' => $sType, 'iTotalComments' => $iOriginalCnt === null ? $iCnt : $iOriginalCnt, 'aRows' => $this->_aComments, 'sLoginLink' => $this->url()->makeUrl('user.login'), 'sSignupLink' => $this->url()->makeUrl('user.register'))); // Display the comments $sBlockViewTemplate = 'comment.block.view'; ($sPlugin = Phpfox_Plugin::get('comment.component_block_view_process_template_load')) ? eval($sPlugin) : false; $this->template()->getTemplate('comment.block.view-top'); if (count($this->_aComments)) { $this->_displayComment($this->_aComments); } else { $this->template()->getTemplate($sBlockViewTemplate); } $this->template()->getTemplate('comment.block.view-bottom'); ($sPlugin = Phpfox_Plugin::get('comment.component_block_view_process')) ? eval($sPlugin) : false; return false; } else { // Set the pager Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'ajax' => 'comment.browse', 'aParams' => array('sType' => $sType, 'iItemId' => $iItemId, 'iTotal' => $iCnt))); // Assign template vars $this->template()->assign(array('aRows' => $this->_aComments, 'sLoginLink' => $this->url()->makeUrl('user.login'), 'sSignupLink' => $this->url()->makeUrl('user.register'), 'bCanPostOnItem' => $bCanPostOnItem, 'iTotalComments' => $iOriginalCnt === null ? $iCnt : $iOriginalCnt)); ($sPlugin = Phpfox_Plugin::get('comment.component_block_view_process')) ? eval($sPlugin) : false; } }
/** * Preparing a URL title. Will be used to replace a title "this is a TITLE" to * "this-is-a-title". * * Example: * <code> * Phpfox::getLib('parse.input')->prepareTitle('photo', $aVals['title'], 'name_url', Phpfox::getUserId(), Phpfox::getT('photo_album')); * </code> * * @param string $sModule Module ID. * @param string $sTitle Title to parse and fix. * @param string $sField Database field to check if such titles already exist. * @param int $iUserId User ID to check * @param string $sTable Name of the database table. * @param mixed $mCondition Database WHERE condition. * @param boolean $bCleanOnly Return true if you want to return the clean title without running the existing title check. * @param array $bCache FALSE will force a new check, while default TRUE will cache previous checks. * @return string New fixed title. */ public function prepareTitle($sModule, $sTitle, $sField, $iUserId = null, $sTable, $mCondition = null, $bCleanOnly = false, $bCache = true) { static $aTitle = array(); static $iCacheCount = 0; if (defined('PHPFOX_INSTALLER')) { $bCache = false; } if ($bCache && isset($aTitle[$sTitle])) { return $aTitle[$sTitle]; } $sNewTitle = $this->cleanTitle($sTitle); if ($bCleanOnly) { return $sNewTitle; } if (!defined('PHPFOX_INSTALLER')) { $sNewTitle = substr($sNewTitle, 0, Phpfox::getParam('core.crop_seo_url')); } $oDb = Phpfox_Database::instance(); $aOlds = $oDb->select($sField . ' AS title_url')->from($sTable)->where($mCondition === null ? $sField . ' LIKE \'%' . $oDb->escape($sNewTitle) . '%\'' : $mCondition)->execute('getRows'); $iTotal = 0; $aNumbers = array(); $aIntNumbers = array(); foreach ($aOlds as $aOld) { if (preg_match("/(.*)-([0-9]+)/i", $aOld['title_url'], $aMatches)) { $aIntNumbers[] = $aMatches[2]; } if ($aOld['title_url'] === $sNewTitle) { $aNumbers[] = $sNewTitle; } } // Is this a valid module? if (Phpfox::isModule($sModule)) { // Open the modules controller directory $hDir = opendir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS); while ($sFile = readdir($hDir)) { if ($sFile == '.' || $sFile == '..' || $sFile == '.svn') { continue; } // Put the directory name within an array if (is_dir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $sFile) && $sNewTitle === $sFile) { $aNumbers[] = $sFile; } // Put the file name within an array if (preg_match("/(.*?)\\.class\\.php/i", $sFile, $aMatches) && $sNewTitle === $aMatches[1]) { $aNumbers[] = $aMatches[1]; } } } if (count($aIntNumbers)) { $iTotal = max($aIntNumbers) + 1; } else { if (count($aNumbers)) { arsort($aNumbers); $iTotal = count($aNumbers) + 1; } } if (!$bCache && isset($aTitle[$sTitle])) { $iCacheCount++; return $aTitle[$sTitle] . '-' . $iCacheCount; } // Do we have any titles that match and if we do add a new count after it. $aTitle[$sTitle] = $sNewTitle . ($iTotal > 0 ? '-' . $iTotal : ''); return $aTitle[$sTitle]; }