/** * Class process method wnich is used to execute this component. */ public function process() { $oArchiveImport = Phpfox::getLib('archive.import')->set(array('zip')); $bOverwrite = $this->request()->getInt('overwrite') ? true : false; if (isset($_FILES['import']) && ($aFile = $_FILES['import']) && !empty($aFile['name'])) { if (preg_match('/^phpfox-theme-(.*?)\\.zip$/i', $aFile['name'], $aMatches)) { if (($sLocationId = $oArchiveImport->process($aFile)) !== false) { $sFolderName = $aMatches[1]; if (preg_match('/^(.*)-(.*?)$/i', $aMatches[1])) { $aParts = explode('-', $aMatches[1]); $sFolderName = $aParts[0]; } if ($this->request()->get('overwrite') && Phpfox::getService('theme')->isTheme($sFolderName)) { $this->url()->send('admincp.theme.import', null, 'Theme successfully overwritten.'); } // $this->url()->send('admincp.theme.import', array('install' => $sFolderName, 'force' => $sLocationId)); if (Phpfox::getService('theme.process')->installThemeFromFolder($sFolderName, $sLocationId)) { $this->url()->send('admincp.theme.import', null, Phpfox::getPhrase('theme.theme_successfully_imported')); } } } else { Phpfox_Error::set(Phpfox::getPhrase('theme.not_a_valid_theme_to_import')); } } else { if ($sFolderName = $this->request()->get('install')) { if (Phpfox::getService('theme.process')->installThemeFromFolder($sFolderName)) { $this->url()->send('admincp.theme.import', null, Phpfox::getPhrase('theme.theme_successfully_imported')); } } } $this->template()->setTitle(Phpfox::getPhrase('theme.import_themes'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.import_themes'), null, true)->assign(array('aNewThemes' => Phpfox::getService('theme')->getNewThemes())); }
/** * Class process method wnich is used to execute this component. */ public function process() { if ($aVals = $this->request()->getArray('val')) { Phpfox::isUser(true); Phpfox::getUserParam('comment.can_post_comments', true); if (($iFlood = Phpfox::getUserParam('comment.comment_post_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('comment'), 'condition' => 'type_id = \'' . Phpfox::getLib('database')->escape($aVals['type']) . '\' AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('comment.posting_a_comment_a_little_too_soon_total_time', array('total_time' => Phpfox::getLib('spam')->getWaitTime()))); } } if (Phpfox::getLib('parse.format')->isEmpty($aVals['text'])) { Phpfox_Error::set(Phpfox::getPhrase('feed.add_some_text_to_your_comment')); } if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('comment.process')->add($aVals))) { $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), Phpfox::getPhrase('feed.successfully_added_your_comment')); } } if ($iLikeType = $this->request()->getInt('liketype')) { if (Phpfox::getService('feed.process')->like($this->request()->getInt('id'), $iLikeType)) { $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), $iLikeType == '1' ? Phpfox::getPhrase('feed.successfully_liked_this_feed') : Phpfox::getPhrase('feed.successfully_unliked_this_feed')); } } list($iFeedCount, $aFeeds) = Phpfox::getService('feed')->get(null, $this->request()->getInt('id'), 1); $iCommentCnt = 0; $aComments = array(); if (Phpfox::getParam('feed.allow_comments_on_feeds')) { list($iCommentCnt, $aComments) = Phpfox::getService('comment')->get('cmt.*', array("AND cmt.type_id = 'feed'", 'AND cmt.item_id = ' . (int) $aFeeds[0]['feed_id'], 'AND cmt.view_id = 0'), 'cmt.time_stamp ASC'); } if (!count($aFeeds)) { return Phpfox_Error::display(Phpfox::getPhrase('feed.not_a_valid_feed')); } $this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('iFeedId' => $aFeeds[0]['feed_id'], 'aFeeds' => $aFeeds, 'aComments' => $aComments)); }
/** * Class process method wnich is used to execute this component. */ public function process() { // assign the categories $this->template()->assign(array('aCategories' => Phpfox::getService('contact.contact')->getCategories())); // create the captcha check JS // they need to input some text always $aValidation = array('text' => Phpfox::getPhrase('contact.fill_in_some_text_for_your_message'), 'category_id' => Phpfox::getPhrase('contact.you_need_to_choose_a_category'), 'subject' => Phpfox::getPhrase('contact.provide_a_subject'), 'full_name' => Phpfox::getPhrase('contact.provide_your_full_name')); // do they need to complete a captcha challenge? if (Phpfox::isModule('captcha') && Phpfox::getParam('contact.contact_enable_captcha')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } // They always need to input their email address $aValidation['email'] = array('def' => 'email', 'title' => Phpfox::getPhrase('contact.provide_a_valid_email')); $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_contact_form', 'aParams' => $aValidation)); // check if we're getting a request: if ($aVals = $this->request()->getArray('val')) { // check the fields are valid if ($oValid->isValid($aVals)) { if (Phpfox::getService('contact.contact')->sendContactMessage($aVals)) { if (!empty($aVals['category_id']) && $aVals['category_id'] == 'phpfox_sales_ticket') { $this->url()->send('contact', array('sent' => 'true')); } else { $this->url()->send('contact', null, Phpfox::getPhrase('contact.your_message_was_successfully_sent')); } } else { $this->template()->assign(array('aContactErrors' => Phpfox_Error::set(Phpfox::getPhrase('error.site_email_not_set')))); } } } if (Phpfox::isUser()) { $this->template()->assign(array('sFullName' => Phpfox::getUserBy('full_name'), 'sEmail' => Phpfox::getUserBy('email'))); } $this->template()->setTitle(Phpfox::getPhrase('contact.contact_us'))->setBreadcrumb(Phpfox::getPhrase('contact.contact_us'))->assign(array('sCreateJs' => $oValid->createJs(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsSent' => $this->request()->get('sent')))->setFullSite(); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $oArchiveExport = Phpfox::getLib('archive.export')->set(array('zip')); $oArchiveImport = Phpfox::getLib('archive.import')->set(array('zip')); if (($sExportId = $this->request()->get('id')) && !empty($sExportId)) { if ($sData = Phpfox::getService('emoticon')->export($sExportId)) { $oArchiveExport->download('phpfox-emoticon-' . $sExportId, 'xml', $sData); } } if (isset($_FILES['import']) && ($aFile = $_FILES['import'])) { if (preg_match('/^phpfox-emoticon-(.*?)\\.xml$/i', $aFile['name'], $aMatches)) { if ($sXmlData = file_get_contents($aFile['tmp_name'])) { $aParams = Phpfox::getLib('xml.parser')->parse($sXmlData); if (($mReturn = Phpfox::getService('emoticon.process')->import($this->request()->getArray('val'), $aParams)) && is_array($mReturn)) { $this->url()->send('admincp.emoticon.view', array('id' => $mReturn['id']), Phpfox::getPhrase('emoticon.emoticon_package_successfully_created', array('success' => $mReturn['success'], 'failed' => $mReturn['failed']))); } } } else { Phpfox_Error::set(Phpfox::getPhrase('emoticon.not_a_valid_emoticon_package_to_import')); } } $this->template()->setTitle(Phpfox::getPhrase('emoticon.import_emoticons'))->setBreadcrumb(Phpfox::getPhrase('emoticon.emoticons'), $this->url()->makeUrl('admincp.emoticon.package'))->setBreadCrumb(Phpfox::getPhrase('emoticon.import_emoticons'), null, true); }
/** * Controller */ public function process() { $this->_setMenuName('admincp.user.cancellations.add'); // is user trying to edit or add an item? if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('user.cancellations.process')->add($aVals)) { if (isset($aVals['iDeleteId'])) { $sMessage = Phpfox::getPhrase('user.option_updated_successfully'); } else { $sMessage = Phpfox::getPhrase('user.option_added_successfully'); } $this->url()->send('admincp.user.cancellations.manage', null, $sMessage); } } // is user requesting an item for edit? if ($iId = $this->request()->getInt('id')) { $aDelete = Phpfox::getService('user.cancellations')->get($iId); if (empty($aDelete)) { Phpfox_Error::set(Phpfox::getPhrase('user.item_not_found')); } $aDelete = reset($aDelete); $this->template()->assign(array('aForms' => $aDelete)); } $this->template()->setTitle(Phpfox::getPhrase('user.add_cancellation_options'))->setBreadcrumb(Phpfox::getPhrase('user.add_cancellation_options'), $this->url()->makeUrl('admincp.user.cancellations.add'), true)->assign(array()); }
public function check() { $iCnt = 0; // Is the install dir. in place? if (file_exists(PHPFOX_DIR . 'install' . PHPFOX_DS . 'index.php')) { Phpfox_Error::set(Phpfox::getPhrase('admincp.install_dir_exists')); $iCnt++; } // Is main config writable? if (Phpfox::getLib('file')->isWritable(PHPFOX_DIR_SETTING . 'server.sett.php', true)) { $sFilePath = 'include' . PHPFOX_DS . 'setting' . PHPFOX_DS . 'server.sett.php'; Phpfox_Error::set(Phpfox::getPhrase('admincp.main_configuration_file_file_path_is_writable', array('file_path' => $sFilePath))); $iCnt++; } // Is the main file folder writable? if (Phpfox::getLib('file')->isWritable(PHPFOX_DIR_FILE, true)) { $sFilePath = str_replace(PHPFOX_DIR, '', PHPFOX_DIR_FILE); Phpfox_Error::set(Phpfox::getPhrase('admincp.main_file_folder_is_writable_file_path', array('file_path' => $sFilePath))); $iCnt++; } return ($iCnt ? false : true); }
/** * Process the controller * */ public function process() { if (Phpfox::isUser()) { $this->url()->send(''); } if ($sRequest = $this->request()->get('id')) { if ($aVals = $this->request()->getArray('val')) { if (!isset($aVals['newpassword']) || !isset($aVals['newpassword2']) || $aVals['newpassword'] != $aVals['newpassword2']) { Phpfox_Error::set(Phpfox::getPhrase('user.your_confirmed_password_does_not_match_your_new_password')); } else { if (Phpfox::getService('user.password')->updatePassword($sRequest, $aVals)) { $this->url()->send('user.password.verify', null, Phpfox::getPhrase('user.password_successfully_updated')); } } } if (Phpfox::getParam('user.shorter_password_reset_routine')) { if (Phpfox::getService('user.password')->isValidRequest($sRequest) == true) { $this->template()->assign(array('sRequest' => $sRequest)); } else { } } else { if (Phpfox::getService('user.password')->verifyRequest($sRequest)) { $this->url()->send('user.password.verify', null, Phpfox::getPhrase('user.new_password_successfully_sent_check_your_email_to_use_your_new_password')); } } } $this->template()->setTitle(Phpfox::getPhrase('user.password_request_verification'))->setBreadcrumb(Phpfox::getPhrase('user.password_request_verification')); }
/** * Adds a redirection rule * @param string $sRedirect Table table that stores the redirections * @param string $sOldTitle Previous title * @param string $sNewTitle New title * @param integer $iItemId Item id (blog_id, poll_id, etc) * @param string $sItemTable Database table that stores the main item * @param string $sItemField Field in $sItemTable that stores the title_url of the item * @return boolean Success */ public function addRedirect($sRedirectTable, $sOldTitle, $sNewTitle, $iItemId, $sItemTable, $sItemField) { if ($sOldTitle == $sNewTitle) { return Phpfox_Error::set('Titles are not different');;// this should never happen } // check if the new title is in use at sItemTable $iExisting = $this->database()->select('COUNT(' . $sItemField . ')') ->from($sItemTable) ->where($sItemField . ' = "' . $sNewTitle . '"') ->execute('getSlaveField'); if ($iExisting > 0) { return Phpfox_Error::set('This should not happen'); // this should never happen } // check for cyclic redirects $aRedirects = $this->database()->select('*') ->from($sRedirectTable) ->where('old_title = "' . $sNewTitle .'"') ->execute('getSlaveRows'); if (count($aRedirects) > 0) { return Phpfox_Error::set('This redirect would cause a loop'); } $this->database()->insert($sRedirectTable, array( 'old_title' => $sOldTitle, 'new_title' => $sNewTitle, 'item_id' => (int)$iItemId )); return true; }
public function connect($sHost, $sUser, $sPass, $sName, $sPort = false, $sPersistent = false) { // Connect to master db $this->_hMaster = $this->_connect($sHost, $sUser, $sPass); // Unable to connect to master if (!$this->_hMaster) { // Cannot connect to the database return Phpfox_Error::set('Cannot connect to the database: ' . $this->_sqlError()); } // Check if we have any slave servers if (Phpfox::getParam(array('db', 'slave'))) { // Get the slave array $aServers = Phpfox::getParam(array('db', 'slave_servers')); // Get a random slave to use if there is more then one slave $iSlave = count($aServers) > 1 ? rand(0, count($aServers) - 1) : 0; if (PHPFOX_DEBUG) { $this->sSlaveServer = $aServers[$iSlave][0]; } // Connect to slave $this->_hSlave = $this->_connect($aServers[$iSlave][0], $aServers[$iSlave][1], $aServers[$iSlave][2]); } // If unable to connect to a slave or if no slave is called lets copy the master if (!$this->_hSlave) { $this->_hSlave =& $this->_hMaster; } return true; }
public function process() { error_reporting(E_ALL); if ($aVals = $this->request()->get('val')) { if (!empty($aVals['sv_subfolder'])) { if (preg_match('/[^A-Za-z0-9-_.\\/]/', $aVals['sv_subfolder'])) { $invalid_character = 'The sub directory must only contain alphanumeric characters.'; return Phpfox_Error::set($invalid_character); } } if (Phpfox_Error::isPassed()) { //Save backup settings Phpfox::getService('backuprestore.settings')->saveBackupSettings($aVals); } } // Default time values if (!($setting = Phpfox::getService('backuprestore.settings')->getBackupSettings())) { Phpfox::getService('backuprestore.settings')->setDefaultSettings(); } //Time settings $hours = array(); $minutes = array(); for ($i = 0; $i <= 24; $i++) { $hours[$i] = $i; } for ($i = 0; $i <= 59; $i++) { $minutes[$i] = $i; } $this->template()->assign(array('timefreqs' => array('Each 6 hours', 'Daily', 'Every 3 days', 'Weakly', 'Monthly'), 'hours' => $hours, 'minutes' => $minutes, 'aForms' => Phpfox::getService('backuprestore.settings')->getBackupSettings())); $this->template()->setBreadcrumb(Phpfox::getPhrase('backuprestore.backup_settings'), $this->url()->makeUrl('admincp.backuprestore.setting'))->setHeader(array('btdbstyles.css' => 'module_backuprestore', 'scripts.js' => 'module_backuprestore')); }
public function add($aVals) { if (!isset($aVals['agree'])) { Phpfox_Error::set('Check our agreement in order to join our site.'); return false; } if (!filter_var($aVals['organization_email'], FILTER_VALIDATE_EMAIL)) { Phpfox_Error::set('Provide a valid email address.'); return false; } if (strlen($aVals['organization_password']) < 6) { Phpfox_Error::set('Not a valid password.'); return false; } $aInsert = array('view_id' => 0, 'type_id' => isset($aVals['type_id']) ? (int) $aVals['type_id'] : 2, 'app_id' => isset($aVals['app_id']) ? (int) $aVals['app_id'] : 0, 'category_id' => isset($aVals['category_id']) ? (int) $aVals['category_id'] : 2, 'user_id' => 0, 'title' => $this->preParse()->clean($aVals['organization_name']), 'founder' => $aVals['organization_founder'], 'mission_statement' => $aVals['organization_mission'], 'phone' => $aVals['organization_phone'], 'website' => $aVals['organization_website'], 'time_stamp' => PHPFOX_TIME); $iId = $this->database()->insert(Phpfox::getT('organization'), $aInsert); $aInsertText = array('organization_id' => $iId); if (isset($aVals['info'])) { $aInsertText['text'] = $this->preParse()->clean($aVals['info']); $aInsertText['text_parsed'] = $this->preParse()->prepare($aVals['info']); } $this->database()->insert(Phpfox::getT('organization_text'), $aInsertText); $sSalt = $this->_getSalt(); $iUserId = $this->database()->insert(Phpfox::getT('user'), array('profile_organization_id' => $iId, 'user_group_id' => NORMAL_USER_ID, 'view_id' => '7', 'full_name' => $this->preParse()->clean($aVals['organization_name']), 'joined' => PHPFOX_TIME, 'email' => $aVals['organization_email'], 'password' => Phpfox::getLib('hash')->setHash($aVals['organization_password'], $sSalt), 'password_salt' => $sSalt)); $this->database()->update(Phpfox::getT('user'), array('user_name' => 'profile-' . $iUserId), 'user_id=' . $iUserId); $this->database()->update(Phpfox::getT('organization'), array('user_id' => $iUserId), 'organization_id=' . $iId); $aExtras = array('user_id' => $iUserId); $this->database()->insert(Phpfox::getT('user_activity'), $aExtras); $this->database()->insert(Phpfox::getT('user_field'), $aExtras); $this->database()->insert(Phpfox::getT('user_space'), $aExtras); $this->database()->insert(Phpfox::getT('user_count'), $aExtras); Phpfox::getService('user.activity')->update(Phpfox::getUserId(), 'organization'); Phpfox::getService('like.process')->add('organization', $iId); return $iId; }
public function add($iBlockedUserId) { Phpfox::isUser(true); Phpfox::getUserParam('user.can_block_other_members', true); if ($iBlockedUserId == Phpfox::getUserId()) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_able_to_block_yourself')); } if (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iBlockedUserId)) { return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_blocked_this_user')); } $aUser = Phpfox::getService('user')->getUser($iBlockedUserId, 'u.user_id, u.user_group_id'); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others')) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user')); } $this->database()->insert($this->_sTable, array( 'user_id' => Phpfox::getUserId(), 'block_user_id' => (int) $iBlockedUserId, 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp() ) ); Phpfox::getService('friend.process')->deleteFromConnection(Phpfox::getUserId(), $iBlockedUserId); Phpfox::getService('friend.process')->deleteFromConnection($iBlockedUserId, Phpfox::getUserId()); return true; }
/** * Add thread * @param $iFourmId * @param $sTitle * @param $sText * @param $iSubscribed * @return bool|null */ public function addThread($iFourmId, $sTitle, $sText, $iSubscribed) { $aForum = Phpfox::getService('forum')->id($iFourmId)->getForum(); if (!isset($aForum['forum_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum')); } if ($aForum['is_closed']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed')); } $bPass = false; if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) { $bPass = true; } if ($bPass === false) { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread')); } $aVals = array('forum_id' => $iFourmId, 'title' => $sTitle, 'text' => $sText, 'is_subscribed' => $iSubscribed); if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } //add thread if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, false))) { //return thread return $this->getThreadById($iId, 1, 10, null); } return null; }
/** * Uploads the file to amazons server. * * @param string $sFile Full path to where the file is located. * @param string $sName Optional name of the file once it is uploaded. By default we just use the original file name. * @return bool We only return a bool false if we were not able to upload the item. */ public function put($sFile, $sName = null) { if (!Phpfox::getParam('core.amazon_bucket_created')) { $sBucketName = Phpfox::getParam('core.amazon_bucket'); if (empty($sBucketName)) { $this->_sBucket = md5(Phpfox::getParam('core.path')); } if (!$this->_oObject->putBucket($this->_sBucket, Phpfox::getParam('core.enable_amazon_expire_urls') ? S3::ACL_PRIVATE : S3::ACL_PUBLIC_READ)) { return Phpfox_Error::set('Unable to create Amazon bucket: ' . $sBucketName); } Phpfox::getLib('database')->update(Phpfox::getT('setting'), array('value_actual' => '1'), 'var_name = \'amazon_bucket_created\''); Phpfox::getLib('database')->update(Phpfox::getT('setting'), array('value_actual' => '' . $this->_sBucket . ''), 'var_name = \'amazon_bucket\''); Phpfox::getLib('cache')->remove(); } if (empty($sName)) { $sName = str_replace("\\", '/', str_replace(PHPFOX_DIR, '', $sFile)); } if ($this->_oObject->putObjectFile($sFile, $this->_sBucket, $sName, Phpfox::getParam('core.enable_amazon_expire_urls') ? S3::ACL_PRIVATE : S3::ACL_PUBLIC_READ)) { if (Phpfox::getParam('core.keep_files_in_server') == false) { $oSess = Phpfox::getLib('session'); $aFiles = $oSess->get('deleteFiles'); if (is_array($aFiles)) { $aFiles[] = $sFile; } else { $aFiles = array($sFile); } $oSess->set('deleteFiles', $aFiles); } return true; } return false; }
/** * Class process method wnich is used to execute this component. */ public function process() { if (isset($_POST['token']) && strlen($_POST['token']) == 40) { $aPost = array('token' => $_POST['token'], 'apiKey' => Phpfox::getParam('janrain.janrain_api_key'), 'format' => 'json', 'extended' => 'true'); $sResult = Phpfox::getLib('request')->send('https://rpxnow.com/api/v2/auth_info', $aPost); $aInfo = json_decode($sResult, true); if ($aInfo['stat'] == 'ok') { $aUserInfo = $aInfo['profile']; if ($aUser = Phpfox::getService('janrain')->getUser($aUserInfo)) { list($bIsLoggedIn, $aPostUserInfo) = Phpfox::getService('user.auth')->login($aUser['user_name'], null, false, 'user_name', true); if ($bIsLoggedIn) { $this->url()->send(Phpfox::getParam('user.redirect_after_login')); } } else { if (Phpfox::getService('janrain.process')->add($aUserInfo)) { $aUser = Phpfox::getService('janrain')->getUser($aUserInfo); if ($sPlugin = Phpfox_Plugin::get('janrain.component_controller_rpx_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } list($bIsLoggedIn, $aPostUserInfo) = Phpfox::getService('user.auth')->login($aUser['user_name'], null, false, 'user_name', true); if ($bIsLoggedIn) { $this->url()->send('user.setting', null, Phpfox::getPhrase('janrain.your_account_has_successfully_been_created_please_enter_your_account_details_below')); } } } } else { Phpfox_Error::set($aInfo['err']['msg']); } } else { Phpfox_Error::set('Authentication canceled.'); } }
public function export($sProductId, $sModuleId = null) { $aWhere = array(); $aWhere[] = "block.product_id = '" . $sProductId . "'"; if ($sModuleId !== null) { $aWhere[] = " AND block.module_id = '" . $sModuleId . "'"; } $aRows = $this->database()->select('block.*, product.title AS product_name, m.module_id AS module_name, bs.source_code, bs.source_parsed')->from($this->_sTable, 'block')->leftJoin(Phpfox::getT('block_source'), 'bs', 'bs.block_id = block.block_id')->leftJoin(Phpfox::getT('product'), 'product', 'product.product_id = block.product_id')->leftJoin(Phpfox::getT('module'), 'm', "m.module_id = block.module_id")->where($aWhere)->execute('getRows'); if (!isset($aRows[0]['product_name'])) { return Phpfox_Error::set(Phpfox::getPhrase('admincp.product_does_not_have_any_settings')); } if (!count($aRows)) { return false; } $oXmlBuilder = Phpfox::getLib('xml.builder'); $oXmlBuilder->addGroup('blocks'); foreach ($aRows as $aRow) { $oXmlBuilder->addGroup('block', array('type_id' => $aRow['type_id'], 'm_connection' => $aRow['m_connection'], 'module_id' => $aRow['module_name'], 'component' => $aRow['component'], 'location' => $aRow['location'], 'is_active' => $aRow['is_active'], 'ordering' => $aRow['ordering'], 'disallow_access' => $aRow['disallow_access'], 'can_move' => $aRow['can_move'])); $oXmlBuilder->addTag('title', $aRow['title']); $oXmlBuilder->addTag('source_code', empty($aRow['source_code']) ? '' : $aRow['source_code']); $oXmlBuilder->addTag('source_parsed', empty($aRow['source_parsed']) ? '' : $aRow['source_parsed']); $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); return true; }
/** * Controller */ public function process() { Phpfox::isUser(true); // http://www.phpfox.com/tracker/view/15093/ $bIsThickBox = $this->getParam('bIsThickBox'); $this->template()->assign(array('bIsThickBox' => $bIsThickBox)); if ($this->request()->getInt('purchase_id')) { if (!($aPackage = Phpfox::getService('subscribe.purchase')->getInvoice($this->request()->getInt('purchase_id'), true))) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.unable_to_find_the_purchase_you_are_looking_for')); } $iPurchaseId = $aPackage['purchase_id']; } else { if (!($aPackage = Phpfox::getService('subscribe')->getPackage($this->request()->getInt('id')))) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.unable_to_find_the_package_you_are_looking_for')); } if (Phpfox::getUserBy('user_group_id') == $aPackage['user_group_id']) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.attempting_to_upgrade_to_the_same_user_group_you_are_already_in')); } $aPackage['default_currency_id'] = isset($aPackage['default_currency_id']) ? $aPackage['default_currency_id'] : $aPackage['price'][0]['alternative_currency_id']; $aPackage['default_cost'] = isset($aPackage['default_cost']) ? $aPackage['default_cost'] : $aPackage['price'][0]['alternative_cost']; $iPurchaseId = Phpfox::getService('subscribe.purchase.process')->add(array('package_id' => $aPackage['package_id'], 'currency_id' => $aPackage['default_currency_id'], 'price' => $aPackage['default_cost'])); /* Make sure we mark it as free only if the default cost is free and its not a recurring charge */ if ($aPackage['default_cost'] == '0.00' && $aPackage['recurring_period'] == 0) { $this->template()->assign('bIsFree', true); $this->template()->assign('iPurchaseId', $iPurchaseId); Phpfox::getService('subscribe.purchase.process')->update($iPurchaseId, $aPackage['package_id'], 'completed', Phpfox::getUserId(), $aPackage['user_group_id'], $aPackage['fail_user_group']); return; } } /* Load the gateway only if its not free */ if (($aPackage['default_cost'] != '0.00' || $aPackage['recurring_period'] != 0) && $iPurchaseId) { $this->setParam('gateway_data', array('item_number' => 'subscribe|' . $iPurchaseId, 'currency_code' => $aPackage['default_currency_id'], 'amount' => $aPackage['default_cost'], 'item_name' => $aPackage['title'], 'return' => $this->url()->makeUrl('subscribe.complete'), 'recurring' => $aPackage['recurring_period'], 'recurring_cost' => isset($aPackage['default_recurring_cost']) ? $aPackage['default_recurring_cost'] : '', 'alternative_cost' => isset($aPackage['price'][0]) ? serialize($aPackage['price']) : '', 'alternative_recurring_cost' => isset($aPackage['recurring_price'][0]) ? serialize($aPackage['recurring_price']) : '')); } }
/** * Class process method wnich is used to execute this component. */ public function process() { $aValidExt = array('xml', 'zip', 'tar.gz'); $oArchiveExport = Phpfox::getLib('archive.export')->set($aValidExt); $oArchiveImport = Phpfox::getLib('archive.import')->set($aValidExt); // Run the export routine if ($iExportId = $this->request()->get('export')) { if ($sXml = Phpfox::getService('admincp.setting')->export($iExportId)) { $oArchiveExport->download($this->request()->get('file_extension'), 'phpfox_setting.xml', $sXml); } } // Run the import routine if ($aFile = $this->request()->get('import')) { if ($sXmlData = $oArchiveImport->process($aFile)) { $aParams = Phpfox::getLib('xml.parser')->parse($sXmlData); // Import the settings if ($iImported = Phpfox::getService('admincp.setting.process')->import($aParams, true)) { // Settings imported, mention how many settings were imported. $this->url()->send('admincp', array('setting', 'file'), Phpfox::getPhrase('admincp.setting_imported', array('total' => $iImported))); } else { if (is_numeric($iImported)) { // Nothing new to import Phpfox_Error::set(Phpfox::getPhrase('admincp.nothing_new_import')); } } } } // Assign needed vars to the template $this->template()->assign(array('aProducts' => Phpfox::getService('admincp.product')->get(), 'aArchives' => $oArchiveExport->getSupported(), 'sSupported' => $oArchiveImport->getSupported()))->setBreadCrumb(Phpfox::getPhrase('admincp.import_export_settings'))->setTitle(Phpfox::getPhrase('admincp.import_export_settings')); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_file_process')) ? eval($sPlugin) : false; }
public function process($aFile) { return Phpfox_Error::set('Unable to import data using the current routine. Use the manual method of importing data.'); if (!preg_match('/^(.*?)\.zip$/i', $aFile['name'])) { return Phpfox_Error::set('Not a valid ZIP package.'); } $sExt = 'zip'; $sLocation = PHPFOX_DIR_CACHE . md5(PHPFOX_TIME . uniqid() . $aFile['name']) . PHPFOX_DS; mkdir($sLocation); Phpfox::getLib('archive', $sExt)->extract($aFile['tmp_name'], $sLocation); $aFiles = Phpfox::getLib('file')->getAllFiles($sLocation); foreach ($aFiles as $sFile) { $sNewFile = str_replace($sLocation, '', $sFile); $aParts = explode(PHPFOX_DS, $sNewFile); unset($aParts[(count($aParts) - 1)]); $sDirPath = implode(PHPFOX_DS, $aParts); Phpfox::getLib('ftp')->mkdir(PHPFOX_DIR . $sDirPath, true); Phpfox::getLib('ftp')->put($sFile, PHPFOX_DIR . $sNewFile); } Phpfox::getLib('file')->delete_directory($sLocation); return true; }
/** * Hides blocks by issuing a callback * @param type $sBlockId * @param type $sTypeId * @return type */ public function hideBlock($sBlockId, $sTypeId, $sController) { $sBlockId = str_replace('clone_', '', $sBlockId); $sBlockId = str_replace('js_block_border_', '', $sBlockId); $aParts = explode('_', $sBlockId); if (!Phpfox::isModule($aParts[0])) { return Phpfox_Error::set(Phpfox::getPhrase('core.module_is_not_a_valid_module', array('module' => $aParts[0]))); } $sModule = $aParts[0]; unset($aParts[0]); $sTable = 'user_design_order'; if ($sController == 'core.index-member') { $sTable = 'user_dashboard'; } $iHasEntry = $this->database()->select('COUNT(*)')->from(Phpfox::getT($sTable))->where('user_id = ' . Phpfox::getUserId())->execute('getSlaveField'); if (!$iHasEntry) { $aBlocks = $this->database()->select('module_id, component, location, ordering')->from(Phpfox::getT('block'))->where('is_active = 1 && m_connection = "' . $sController . '" AND location IN (1,2,3)')->execute('getSlaveRows'); foreach ($aBlocks as $aBlock) { $this->database()->insert(Phpfox::getT($sTable), array('user_id' => Phpfox::getUserId(), 'cache_id' => 'js_block_border_' . $aBlock['module_id'] . '_' . $aBlock['component'], 'block_id' => $aBlock['location'], 'ordering' => $aBlock['ordering'], 'is_hidden' => 0)); } } else { $iCount = $this->database()->select('COUNT(*)')->from(Phpfox::getT($sTable))->where('user_id = ' . Phpfox::getUserId() . ' AND cache_id = \'js_block_border_' . $this->database()->escape($sBlockId) . '\'')->execute('getSlaveField'); if (!$iCount) { $this->database()->insert(Phpfox::getT($sTable), array('user_id' => Phpfox::getUserId(), 'cache_id' => 'js_block_border_' . $sBlockId, 'block_id' => null)); } } $this->database()->update(Phpfox::getT($sTable), array('is_hidden' => '1'), 'user_id = ' . Phpfox::getUserId() . ' AND cache_id = \'js_block_border_' . $this->database()->escape($sBlockId) . '\''); }
/** * Class process method wnich is used to execute this component. */ public function process() { Phpfox::getUserParam('language.can_manage_lang_packs', true); $bNoJsValidation = $this->getParam('bNoJsValidation'); $aModules = Phpfox::getService('admincp.module')->getModules(); $aLanguages = Phpfox::getService('language')->get(); if ($sPhrase = $this->getParam('sVar')) { $aParts = explode('.', $sPhrase); $sPhrase = $aParts[1]; } /* $aValidation = array( 'var_name' => array( 'def' => 'required', 'title' => Phpfox::getPhrase('language.select_varname') ) ); */ $aValidation = array(); $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_phrase_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if (empty($aVals['var_name']) && isset($aVals['text']['en'])) { $aVals['var_name'] = $aVals['text']['en']; } if (empty($aVals['var_name'])) { Phpfox_Error::set('Provide a var name.'); } // Check that all the fields are valid if ($oValid->isValid($aVals)) { // Check to make sure the phrase has not already been added if ($sIsPhrase = Phpfox::getService('language.phrase')->isPhrase($aVals)) { Phpfox_Error::set(Phpfox::getPhrase('language.phrase_already_created', array('phrase' => $sIsPhrase)) . ' - ' . Phpfox::getPhrase($sIsPhrase)); $sCachePhrase = $sIsPhrase; } else { $sVarName = Phpfox::getService('language.phrase.process')->prepare($aVals['var_name']); if (isset($aVals['module'])) { $aParts = explode('|', $aVals['module']); $sVarName = $aParts[1] . '.' . $sVarName; } $sCached = Phpfox::getPhrase('language.phrase_added', array('phrase' => $sVarName)); // Add the new phrase $sPhrase = Phpfox::getService('language.phrase.process')->add($aVals); // Verify if we have a return URL, if we do send them there instead if ($sReturn = $this->request()->get('return')) { $this->url()->forward($sReturn, $sCached); } else { Phpfox::getLib('session')->set('cache_new_phrase', $sVarName); // Phrase added lets send them back to the same page with a message that the phrase was added $this->url()->send('admincp.language.phrase.add', array('last-module' => $aParts[1]), $sCached); } } } } if (!isset($sCachePhrase) && ($sCachePhrase = Phpfox::getLib('session')->get('cache_new_phrase'))) { Phpfox::getLib('session')->remove('cache_new_phrase'); } // Assign needed vars to the template $this->template()->assign(array('aProducts' => Phpfox::getService('admincp.product')->get(), 'aModules' => $aModules, 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $bNoJsValidation ? 'return true;' : $oValid->getJsForm(), 'sReturn' => ($sReturn = $this->request()->get('return')) ? $sReturn : $this->getParam('sReturnUrl'), 'sVar' => $sPhrase, 'sCachePhrase' => isset($sCachePhrase) ? $sCachePhrase : '', 'sLastModuleId' => $this->request()->get('last-module')))->setBreadCrumb(Phpfox::getPhrase('language.add_phrase'))->setTitle(Phpfox::getPhrase('language.add_phrase')); ($sPlugin = Phpfox_Plugin::get('language.component_controller_admincp_phrase_add_process')) ? eval($sPlugin) : false; }
public function send($aVals) { Phpfox::isUser(true); $oFilter = Phpfox::getLib('parse.input'); if (!is_numeric($aVals['interaction']) || !is_numeric($aVals['user_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('interact.an_error_has_occured')); } if (!($iId = $this->database()->insert(Phpfox::getT('interactions_main'), array('sender_id' => Phpfox::getUserId(), 'recipient_id' => $aVals['user_id'], 'interaction_id' => $aVals['interaction'], 'message' => $aVals['text'] ? $oFilter->clean($aVals['text']) : '', 'time' => time(), 'is_reply' => $aVals['is_reply'], 'is_new' => 1)))) { return Phpfox_Error::set(Phpfox::getPhrase('interact.an_error_has_occured')); } if ($aVals['item_id'] != 0) { $this->database()->update(Phpfox::getT('interactions_main'), array('replied' => 1, 'is_new' => 0), 'id = ' . $aVals['item_id']); } if (Phpfox::isModule('notification')) { Phpfox::getService('notification.process')->add('interact', $iId, $aVals['user_id'], Phpfox::getUserId()); } if (Phpfox::isModule('feed') && Phpfox::getParam('interact.add_interact_to_feed')) { $iFeedId = Phpfox::getService('feed.process')->add('interact', $iId, '', Phpfox::getUserId()); if (Phpfox::getParam('interact.interact_friends_only')) { $this->database()->update(Phpfox::getT('feed'), array('privacy' => 1), 'feed_id = ' . $iFeedId); } } if (Phpfox::getParam('interact.send_email')) { $aInteractInfo = $this->database()->select('i.*, im.*, u.language_id')->from(Phpfox::getT('interactions_main'), 'im')->join(Phpfox::getT('interactions'), 'i', 'im.interaction_id = i.id')->join(Phpfox::getT('user'), 'u', 'im.recipient_id = u.user_id')->where('im.id = ' . $iId)->execute('getSlaveRow'); $sInteraction = strtolower(Phpfox::getPhrase('interact.action_' . Phpfox::getService('language.phrase.process')->prepare(htmlspecialchars_decode($aInteractInfo['name'], ENT_QUOTES)))); if ($aInteractInfo['message'] == '') { $sLink = Phpfox::getLib('url')->makeUrl('interact.inbox'); Phpfox::getLib('mail')->to($aVals['user_id'])->subject(array('interact.full_name_interacted_with_you_on_site_title', array('full_name' => Phpfox::getUserBy('full_name'), 'site_title' => Phpfox::getParam('core.site_title')), false, null, $aInteractInfo['language_id']))->message(array('interact.full_name_interacted_with_you', array('full_name' => Phpfox::getUserBy('full_name'), 'interaction' => $sInteraction, 'message' => $oFilter->clean(strip_tags(Phpfox::getLib('parse.bbcode')->cleanCode(str_replace(array('<', '>'), array('<', '>'), $aInteractInfo['message'])))), 'link' => $sLink)))->notification('interact.interact_received')->send(); } else { $sLink = Phpfox::getLib('url')->makeUrl('interact.inbox'); Phpfox::getLib('mail')->to($aVals['user_id'])->subject(array('interact.full_name_interacted_with_you_on_site_title', array('full_name' => Phpfox::getUserBy('full_name'), 'site_title' => Phpfox::getParam('core.site_title')), false, null, $aInteractInfo['language_id']))->message(array('interact.full_name_interacted_with_you_message', array('full_name' => Phpfox::getUserBy('full_name'), 'interaction' => $sInteraction, 'message' => $oFilter->clean(strip_tags(Phpfox::getLib('parse.bbcode')->cleanCode(str_replace(array('<', '>'), array('<', '>'), $aInteractInfo['message'])))), 'link' => $sLink)))->notification('interact.interact_received')->send(); } } return $iId; }
public function process() { $sAction = $this->request()->get('req4'); $sFlag = $this->request()->get('flag'); if ($sFlag == '') { if ($sAction == 'install') { $oInstaller = Phpfox::getService('blog.import'); if ($oInstaller->uninstall() && $oInstaller->install()) { $this->clearCache("file/cache"); $this->clearCache("file/gzip"); $this->url()->send('admincp.blog.installer.install' . '/flag_success1'); } else { Phpfox_Error::set('The module blog importer cannot installed, please try again'); } } elseif ($sAction == 'uninstall2') { if (Phpfox::getService('blog.import')->uninstall()) { $this->clearCache("file/cache"); $this->clearCache("file/gzip"); $this->url()->send('admincp.blog.installer.uninstall' . '/flag_success2'); } else { Phpfox_Error::set('The module blog importer cannot uninstalled, please try again'); } } elseif ($sAction == 'uninstall') { } else { $this->url()->send('subcribe'); } } elseif ($sFlag == 'success1') { $this->url()->send('admincp.blog.installer.install' . '/flag_success', null, 'Congratulation ! The module blog importer v3.02p2 has been installed successfully'); } elseif ($sFlag == 'success2') { $this->url()->send('admincp.blog.installer.uninstall' . '/flag_success', null, 'Uninstall blog importer v3.02p3 done !'); } $this->template()->assign(array('sAction' => $sAction, 'sFlag' => $sFlag))->setBreadCrumb(Phpfox::getPhrase('blog.blog'), $this->url()->makeUrl('admincp.blog')); }
public function __construct() { require_once 'module/backuprestore/Dropbox/API.php'; require_once 'module/backuprestore/Dropbox/OAuth/Consumer/ConsumerAbstract.class.php'; require_once 'module/backuprestore/Dropbox/OAuth/Consumer/Curl.class.php'; $this->btdbsett = PhpFox::getService('backuprestore.backuprestore'); if (!extension_loaded('curl')) { Phpfox_Error::set(Phpfox::getPhrase('testsearch.curl_not_loaded_message')); } $this->oauth = new Backuprestore_Dropbox_OAuth_Consumer_Curl($this->app_key, $this->app_secret); if ($dbarray = $this->btdbsett->getBTDBSettingByName('dropbox_tokens')) { $this->tokens = unserialize(array_shift($dbarray)); } //Convert array to stdClass for the new API if ($this->tokens && is_array($this->tokens['access'])) { $accessToken = new stdClass(); $accessToken->oauth_token = $this->tokens['access']["token"]; $accessToken->oauth_token_secret = $this->tokens['access']["token_secret"]; $this->tokens['access'] = $accessToken; $this->tokens['state'] = 'access'; } try { $this->init(); //If we are in the access state and are still not authorized then unlink and re init if ($this->tokens['state'] == 'access' && !$this->is_authorized()) { throw new Exception(); } } catch (Exception $e) { $this->unlink_account(); $this->init(); } }
/** * Class process method which is used to execute this component. */ public function process() { $this->template()->setTitle(Phpfox::getPhrase('user.email_verification'))->setBreadcrumb(Phpfox::getPhrase('user.email_verification'))->assign(array('iVerifyUserId' => Phpfox::getLib('session')->get('cache_user_id'))); $sHash = $this->request()->get('link', ''); if ($sHash == '') { } elseif (Phpfox::getService('user.verify.process')->verify($sHash)) { if ($sPlugin = Phpfox_Plugin::get('user.component_verify_process_redirection')) { eval($sPlugin); } $sRedirect = Phpfox::getParam('user.redirect_after_signup'); if (!empty($sRedirect)) { Phpfox::getLib('session')->set('redirect', str_replace('.', '/', $sRedirect)); } if (Phpfox::isMobile()) { $this->url()->send('mobile.user.login', null, Phpfox::getPhrase('user.your_email_has_been_verified_please_log_in_with_the_information_you_provided_during_sign_up')); } // send to the log in and say everything is ok Phpfox::getLib('session')->set('verified_do_redirect', '1'); $this->url()->send('user.login', null, Phpfox::getPhrase('user.your_email_has_been_verified_please_log_in_with_the_information_you_provided_during_sign_up')); } else { //send to the log in and say there was an error Phpfox_Error::set(Phpfox::getPhrase('user.invalid_verification_link')); $iTime = Phpfox::getParam('user.verify_email_timeout'); if ($iTime < 60) { $sTime = Phpfox::getPhrase('user.time_minutes', array('time' => $iTime)); } elseif ($iTime < 60 * 60 * 24) { $sTime = $iTime == 60 ? Phpfox::getPhrase('user.time_hour', array('time' => round($iTime / 60))) : Phpfox::getPhrase('user.time_hours', array('time' => round($iTime / 60))); } else { $sTime = Phpfox::getPhrase('user.time_days', array('time' => $sTime)); } Phpfox::getService('user.verify.process')->sendMail(Phpfox::getLib('session')->get('cache_user_id')); $this->template()->assign(array('sTime' => $sTime)); } }
public function add($aObject) { if (!$this->database()->tableExists($aObject['object_table'])) { Phpfox_Error::set('Table ' . $aObject['object_table'] . ' does not exist in the database.'); return false; } if (!isset($aObject['object_plugin_create'])) { $aObject['object_plugin_create'] = ''; } if (!isset($aObject['object_plugin_delete'])) { $aObject['object_plugin_delete'] = ''; } if ($aObject['object_static_target']) { $aObject['object_column_target_type'] = ''; } $iObjectId = $this->database()->insert($this->_sTable, array('object_name' => $this->preParse()->clean($aObject['object_name']), 'object_table' => $this->preParse()->clean($aObject['object_table']), 'object_column_id' => $this->preParse()->clean($aObject['object_column_id']), 'object_column_user_id' => $this->preParse()->clean($aObject['object_column_user_id']), 'object_column_timestamp' => $this->preParse()->clean($aObject['object_column_timestamp']), 'object_column_title' => $this->preParse()->clean($aObject['object_column_title']), 'object_table_text' => $this->preParse()->clean($aObject['object_table_text']), 'object_column_text' => $this->preParse()->clean($aObject['object_column_text']), 'object_image_location' => $this->preParse()->clean($aObject['object_image_location']), 'object_column_image_path' => $this->preParse()->clean($aObject['object_column_image_path']), 'object_plugin_create' => $this->preParse()->clean($aObject['object_plugin_create']), 'object_plugin_create_id_var_name' => $this->preParse()->clean($aObject['object_plugin_create_id_var_name']), 'object_plugin_delete' => $this->preParse()->clean($aObject['object_plugin_delete']), 'object_plugin_delete_id_var_name' => $this->preParse()->clean($aObject['object_plugin_delete_id_var_name']), 'object_target_handle' => $this->preParse()->clean($aObject['object_target_handle']), 'object_column_target_type' => $this->preParse()->clean($aObject['object_column_target_type']), 'object_static_target' => $this->preParse()->clean($aObject['object_static_target']), 'object_column_target_id' => $this->preParse()->clean($aObject['object_column_target_id']), 'object_url_link' => $this->preParse()->clean($aObject['object_url_link']))); if (strlen($aObject['object_plugin_create']) && $aObject['object_plugin_create_id_var_name']) { $sEval = 'Phpfox::getService(\'sysop\')->runCreatePlugin(' . (int) $iObjectId . ', ' . $this->preParse()->clean($aObject['object_plugin_create_id_var_name']) . ');'; $aCustomHook = array('module_id' => 'sysop', 'product_id' => 'AdminTools', 'call_name' => $aObject['object_plugin_create'], 'title' => 'AdminTools, System Operator, Create Object, ' . $this->preParse()->clean($aObject['object_name']), 'php_code' => $sEval, 'is_active' => 1); Phpfox::getService('admincp.plugin.process')->add($aCustomHook); } if (strlen($aObject['object_plugin_delete']) && $aObject['object_plugin_create_id_var_name']) { $sEval = 'Phpfox::getService(\'sysop\')->runDeletePlugin(' . (int) $iObjectId . ', ' . $this->preParse()->clean($aObject['object_plugin_delete_id_var_name']) . ');'; $aCustomHook = array('module_id' => 'sysop', 'product_id' => 'AdminTools', 'call_name' => $aObject['object_plugin_delete'], 'title' => 'AdminTools, System Operator, Delete Object, ' . $this->preParse()->clean($aObject['object_name']), 'php_code' => $sEval, 'is_active' => 1); Phpfox::getService('admincp.plugin.process')->add($aCustomHook); } Phpfox::getLib('cache')->remove(); return $iObjectId; }
public function share() { $aPost = $this->get('val'); if ($aPost['post_type'] == '2') { if (!isset($aPost['friends']) || isset($aPost['friends']) && !count($aPost['friends'])) { Phpfox_Error::set('Select a friend to share this with.'); } else { $iCnt = 0; foreach ($aPost['friends'] as $iFriendId) { $aVals = array('user_status' => $aPost['post_content'], 'parent_user_id' => $iFriendId, 'parent_feed_id' => $aPost['parent_feed_id'], 'parent_module_id' => $aPost['parent_module_id']); if (Phpfox::getService('user.privacy')->hasAccess($iFriendId, 'feed.share_on_wall') && Phpfox::getUserParam('profile.can_post_comment_on_profile')) { $iCnt++; Phpfox::getService('feed.process')->addComment($aVals); } } $sMessage = '<div class="message">' . str_replace("'", "\\'", Phpfox::getPhrase('feed.successfully_shared_this_item_on_your_friends_wall')) . '</div>'; if (!$iCnt) { $sMessage = '<div class="error_message">' . str_replace("'", "\\'", Phpfox::getPhrase('user.unable_to_share_this_post_due_to_privacy_settings')) . '</div>'; } $this->call('$(\'#\' + tb_get_active()).find(\'.js_box_content:first\').html(\'' . $sMessage . '\');'); if ($iCnt) { $this->call('setTimeout(\'tb_remove();\', 2000);'); } } return; } $aVals = array('user_status' => $aPost['post_content'], 'privacy' => '0', 'privacy_comment' => '0', 'parent_feed_id' => $aPost['parent_feed_id'], 'parent_module_id' => $aPost['parent_module_id']); if ($iId = Phpfox::getService('user.process')->updateStatus($aVals)) { $this->call('$(\'#\' + tb_get_active()).find(\'.js_box_content:first\').html(\'<div class="message">' . str_replace("'", "\\'", Phpfox::getPhrase('feed.successfully_shared_this_item')) . '</div>\'); setTimeout(\'tb_remove();\', 2000);'); } }
public function add($aVals, $iUpdateId = null) { $aForm = array('currency_id' => array('message' => Phpfox::getPhrase('admincp.provide_a_3_character_currency_id'), 'type' => 'string:required'), 'symbol' => array('message' => Phpfox::getPhrase('admincp.provide_a_symbol'), 'type' => 'string:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('admincp.provide_a_phrase_for_your_currency'), 'type' => 'phrase:required'), 'is_active' => array('message' => Phpfox::getPhrase('admincp.select_if_this_currency_is_active_or_not'), 'type' => 'int:required')); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aVals['symbol'] = $this->preParse()->clean($aVals['symbol']); if ($iUpdateId !== null) { if ($iUpdateId != $aVals['currency_id']) { $iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\'')->execute('getField'); if ($iCheck) { return Phpfox_Error::set(Phpfox::getPhrase('admincp.this_currency_is_already_in_use')); } } $aPhrases = $aVals['phrase_var']; unset($aVals['phrase_var']); $this->database()->update($this->_sTable, $aVals, 'currency_id = \'' . $this->database()->escape($iUpdateId) . '\''); foreach ($aPhrases as $sPhrase => $aPhrase) { $aLanguage = array_keys($aPhrase); $aText = array_values($aPhrase); Phpfox::getService('language.phrase.process')->updateVarName($aLanguage[0], $sPhrase, $aText[0]); } } else { $iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\'')->execute('getField'); if ($iCheck) { return Phpfox_Error::set(Phpfox::getPhrase('admincp.this_currency_is_already_in_use')); } $this->database()->insert($this->_sTable, $aVals); $sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'custom_currency_' . $aVals['currency_id'], 'product_id' => 'phpfox', 'module' => 'core|core', 'text' => $aVals['phrase_var'])); $this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\''); } $this->cache()->remove('currency'); return true; }
public function add($aRating) { Phpfox::isUser(true); if (!is_array($aRating)) { return Phpfox_Error::set(Phpfox::getPhrase('rate.not_a_valid_post')); } $sModule = $aRating['type']; $sExtra = ''; if (strpos($aRating['type'], '_')) { $aParts = explode('_', $aRating['type']); $sModule = $aParts[0]; $sExtra = ucfirst($aParts[1]); } $aCallback = Phpfox::callback($sModule . '.getRatingData' . $sExtra, $aRating['item_id']); $aRow = $this->database()->select($aCallback['field'] . ', user_id')->from(Phpfox::getT(isset($aCallback['check_table']) ? $aCallback['check_table'] : $aCallback['table']))->where($aCallback['field'] . ' = ' . (int) $aRating['item_id'])->execute('getSlaveRow'); if (!isset($aRow[$aCallback['field']])) { return Phpfox_Error::set(Phpfox::getPhrase('rate.not_a_valid_item_to_rate')); } if ($aRow['user_id'] == Phpfox::getUserId()) { return Phpfox_Error::set(Phpfox::getPhrase('rate.sorry_you_are_not_able_to_rate_your_own_item')); } $iIsRated = $this->database()->select('COUNT(*)')->from(Phpfox::getT($aCallback['table_rating']))->where('item_id = ' . (int) $aRating['item_id'] . ' AND user_id = ' . Phpfox::getUserId())->execute('getSlaveField'); if (!$iIsRated) { $aParts = explode('|', $aRating['star']); $iId = $this->database()->insert(Phpfox::getT($aCallback['table_rating']), array('item_id' => $aRating['item_id'], 'user_id' => Phpfox::getUserId(), 'rating' => (int) $aParts[0], 'time_stamp' => PHPFOX_TIME)); $aAverage = $this->database()->select('COUNT(*) AS count, AVG(rating) AS average_rating')->from(Phpfox::getT($aCallback['table_rating']))->where('item_id = ' . (int) $aRating['item_id'])->execute('getRow'); $this->database()->update(Phpfox::getT($aCallback['table']), array('total_score' => round($aAverage['average_rating']), 'total_rating' => $aAverage['count']), $aCallback['field'] . ' = ' . (int) $aRating['item_id']); return $iId; } return Phpfox_Error::set(Phpfox::getPhrase('rate.you_have_already_voted_on_this_item')); }
/** * Controller */ public function process() { if (!Phpfox::getParam('comment.allow_rss_feed_on_comments')) { return Phpfox_Error::set(Phpfox::getPhrase('comment.rss_feeds_are_disabled_for_comments')); } $aRss = Phpfox::getService('comment')->getForRss($this->request()->get('type'), $this->request()->getInt('item')); Phpfox::getService('rss')->output($aRss); }