/** * Changes a user's email addres, checks if user is allowed and if he should be made verify their email address * afterwards and if it should be logged out immediately after changing it. * @param <type> $aUser * @param <type> $sMail * @return <type> */ public function changeEmail($aUser, $sMail) { // check if user has enough permissions and the mails dont match if they have to verify the new email upon signup it if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_change_email')) { Phpfox::getService('user.validate')->email($sMail); if (!Phpfox_Error::isPassed()) { return false; } // check that the new email is not in use. $sEmail = Phpfox::getLib('parse.input')->prepare($sMail); $inUse = $this->database()->select('email')->where('email = \'' . $sEmail . '\'')->from(Phpfox::getT('user'))->execute('getSlaveField'); if ($inUse != '') { return 'Email address already in use'; } //die(d(Phpfox::getParam('user.verify_email_at_signup'), true)); // set the status to need to be verified only if they are required at signup if (Phpfox::getParam('user.verify_email_at_signup')) { $mUser = array('user_id' => $aUser['user_id'], 'email' => Phpfox::getLib('parse.input')->prepare($sMail), 'password' => $aUser['password']); $this->database()->update(Phpfox::getT('user'), array('status_id' => 1), 'user_id = ' . (int) $aUser['user_id']); $this->sendMail($mUser); } else { // just change the email $this->database()->update(Phpfox::getT('user'), array('email' => Phpfox::getLib('parse.input')->prepare($sMail)), 'user_id = ' . (int) $aUser['user_id']); } //Phpfox::getParam('user.logout_after_change_email_if_verify') && Phpfox::getParam('user.verify_email_at_signup') // check if they should be logged out immediately after changing it. Only then should their status_id be changed if (Phpfox::getParam('user.verify_email_at_signup') && Phpfox::getParam('user.logout_after_change_email_if_verify') == true) { Phpfox::getService('user.auth')->logout(); } return true; } return false; }
/** * 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)); }
/** * Adds a new cancellation option to be shown when a user wants to delete their account * Looks like its working when adding, @todo Purefan: test it works for editing as well. * @param array $aVals * @param int $iUpdateId Optional param to tell if we're editing * @return boolean */ public function add($aVals) { $aForm = array('product_id' => array('message' => Phpfox::getPhrase('user.select_a_product'), 'type' => 'product_id:required'), 'module_id' => array('message' => Phpfox::getPhrase('user.select_a_module'), 'type' => 'module_id:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('user.you_need_to_add_a_message_to_show'), 'type' => 'phrase:required'), 'is_active' => array('message' => Phpfox::getPhrase('user.select_if_the_cancellation_option_is_active_or_not'), 'type' => 'int:required')); $iUpdateId = isset($aVals['iDeleteId']) ? (int) $aVals['iDeleteId'] : null; if ($iUpdateId !== null) { unset($aForm['product_id'], $aForm['module_id']); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['phrase_var']; unset($aVals['phrase_var']); $this->database()->update($this->_sTable, $aVals, 'delete_id = ' . $iUpdateId); // Updates the language phrases for every language 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 { $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['phrase_var']; $aVals['phrase_var'] = ''; $iId = $this->database()->insert($this->_sTable, $aVals); $sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'user_cancellation_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aPhrases)); $this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'delete_id = ' . $iId); } $this->cache()->remove('user_cancellations'); return true; }
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 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')); }
/** * 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; }
/** * Adds a new job to send the newsletter, first there is no cron jobs/tabs so this function's return * directs the flow of the script (refresh) to process the batches. * Sets the errors using Phpfox_Error::set * @param <type> $aVals * @return Int Next round to process | false on error. */ public function add($aVals, $iUser) { // Check validations using the new method $aForm = array('subject' => array('message' => Phpfox::getPhrase('newsletter.add_a_subject'), 'type' => 'string:required'), 'total' => array('message' => Phpfox::getPhrase('newsletter.how_many_users_to_contact_per_round'), 'type' => 'int:required'), 'text' => array('message' => Phpfox::getPhrase('newsletter.you_need_to_write_a_message_to_send'), 'type' => 'string:required')); $aVals['type_id'] = 2; // Internal newsletters are deprecated since 3.3.0 beta 1 $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } // Phpfox::getService('ban')->checkAutomaticBan($aVals['subject'] . ' ' . $aVals['text'] . ' ' . $aVals['txtPlain']); $iActive = $this->database()->select('COUNT(newsletter_id)')->from($this->_sTable)->where('state = 1')->execute('getSlaveField'); // insert the values in the database $aInsert = array('subject' => $this->preParse()->clean($aVals['subject']), 'round' => 0, 'state' => $iActive > 0 ? 0 : 1, 'age_from' => (int) $aVals['age_from'], 'age_to' => (int) $aVals['age_to'], 'type_id' => (int) $aVals['type_id'], 'country_iso' => $this->preParse()->clean($aVals['country_iso']), 'gender' => (int) $aVals['gender'], 'user_group_id' => '', 'total' => (int) $aVals['total'], 'user_id' => (int) $iUser, 'time_stamp' => Phpfox::getTime(), 'archive' => isset($aVals['archive']) ? (int) $aVals['archive'] : 2, 'privacy' => isset($aVals['privacy']) ? (int) $aVals['privacy'] : 2); if (isset($aVals['is_user_group']) && $aVals['is_user_group'] == 2) { $aGroups = array(); $aUserGroups = Phpfox::getService('user.group')->get(); if (isset($aVals['user_group'])) { foreach ($aUserGroups as $aUserGroup) { if (in_array($aUserGroup['user_group_id'], $aVals['user_group'])) { $aGroups[] = $aUserGroup['user_group_id']; } } } $aInsert['user_group_id'] = count($aGroups) ? serialize($aGroups) : null; } // ** when we implement the cron job this is the place to set the state differently $iId = $this->database()->insert($this->_sTable, $aInsert); $this->database()->insert(Phpfox::getT('newsletter_text'), array('newsletter_id' => $iId, 'text_plain' => $this->preParse()->clean($aVals['txtPlain']), 'text_html' => $aVals['text'])); // store that we are processing a job $aInsert['newsletter_id'] = $iId; $aInsert['round'] = 0; return $aInsert; }
/** * Controller * This controller handles invalid user group by 2 means: * 1. getInt('id',0) => if no user group is given its explicitly redirected * 2. getActivityPoints may return a Phpfox_Error */ public function process() { $iGroupId = $this->request()->getInt('id', 0); $aPoints = Phpfox::getService('user.group.setting')->getActivityPoints($iGroupId); if ($aVals = $this->request()->getArray('val')) { $oService = Phpfox::getService('user.group.setting.process'); $aUpdate = array(); foreach ($aVals['module'] as $iSetting => $iValue) { foreach ($aPoints as $iKey => $aPoint) { if ($aPoint['setting_id'] == $iSetting && $iValue != $aPoint['value_actual']) { $aUpdate['value_actual'][$iSetting] = $iValue; /* Update the array to show the change in the template without calling DB again */ $aPoints[$iKey]['value_actual'] = $iValue; } } } if (!empty($aUpdate)) { $oService->update($aVals['igroup'], $aUpdate); } $iGroupId = $aVals['igroup']; } else { if ($iGroupId == 0) { $this->url()->send('admincp.user.group', null, Phpfox::getPhrase('user.invalid_user_group')); } } $sUserGroup = Phpfox::getService('user.group')->getGroup($iGroupId); if (!Phpfox_Error::isPassed()) { $aError = array_unique(Phpfox_Error::get()); $sMessage = implode(', ', $aError); $this->url()->send('admincp.user.group', null, $sMessage); } $this->template()->setBreadcrumb('Manage Activity Points', $this->url()->makeUrl('current'), true)->setTitle('Manage Activity Points')->assign(array('aPoints' => $aPoints, 'aUserGroup' => $sUserGroup))->setHeader(array('activitypoints.css' => 'module_user')); }
public function addSlide($aVals, $iEditId = null) { $aForm = array('slide_title' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_title_fill')), 'slide_description' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_description_fill')), 'slide_position' => array('type' => 'string'), 'button_label' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_button_label_fill')), 'button_color' => array('type' => 'string'), 'button_text_color' => array('type' => 'string'), 'button_link' => array('type' => 'string'), 'is_active' => array('type' => 'int')); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aVals['slide_title'] = $this->preParse()->clean($aVals['slide_title']); $aVals['slide_description'] = $this->preParse()->clean($aVals['slide_description']); if ($iEditId === null) { $aVals['slide_url'] = Phpfox::getLib('parse.input')->cleanFileName(uniqid()); if (!($aVals['slide_url'] = $this->_uploadImage($aVals['slide_url']))) { return false; } $this->database()->insert($this->_sTable, $aVals); } else { if (!empty($_FILES['slide_url']['name'])) { $aVals['slide_url'] = Phpfox::getLib('parse.input')->cleanFileName(uniqid()); $aOld = $this->getSlideForEdit($iEditId); if (file_exists(Phpfox::getParam('bootstraptheme.bootstraptheme_dir_image') . $aOld['slide_url'])) { Phpfox::getLib('file')->unlink(Phpfox::getParam('bootstraptheme.bootstraptheme_dir_image') . $aOld['slide_url']); } if (!($aVals['slide_url'] = $this->_uploadImage($aVals['slide_url']))) { return false; } } $this->database()->update($this->_sTable, $aVals, 'slide_id = ' . (int) $iEditId); } $this->cache()->remove('bootstraptheme', 'substr'); return true; }
public function add($aVals, $iUpdateId = null) { $aForm = array('product_id' => array('message' => Phpfox::getPhrase('admincp.select_a_product'), 'type' => 'product_id:required'), 'module_id' => array('message' => Phpfox::getPhrase('admincp.select_a_module'), 'type' => 'module_id:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('admincp.at_least_one_title_for_the_stat_is_required'), 'type' => 'phrase:required'), 'stat_link' => array('message' => Phpfox::getPhrase('admincp.link_for_the_stat_is_required'), 'type' => 'string:required'), 'stat_image' => array('message' => Phpfox::getPhrase('admincp.image_for_the_stat_is_required'), 'type' => 'string'), 'php_code' => array('message' => Phpfox::getPhrase('admincp.php_code_for_the_stat_is_required'), 'type' => 'php_code:required'), 'is_active' => array('message' => Phpfox::getPhrase('admincp.select_if_the_stat_is_active_or_not'), 'type' => 'int:required')); if ($iUpdateId !== null) { unset($aForm['product_id'], $aForm['module_id']); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['phrase_var']; unset($aVals['phrase_var']); $this->database()->update($this->_sTable, $aVals, 'stat_id = ' . $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 { $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['phrase_var']; unset($aVals['phrase_var']); $iId = $this->database()->insert($this->_sTable, $aVals); $sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'stat_title_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aPhrases)); $this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'stat_id = ' . $iId); } $this->cache()->remove('stat', 'substr'); return true; }
public function add($aVals, $iEditId = null) { $aForm = array('type_id' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.select_what_type_of_a_site_this_is')), 'title' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.provide_a_name_for_the_site')), 'url' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.provide_a_url_for_the_site')), 'is_active' => array('type' => 'int:required')); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } Phpfox::getService('ban')->checkAutomaticBan($aVals['title']); $aVals['title'] = $this->preParse()->clean($aVals['title']); if ($iEditId === null) { $iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('title = \'' . $this->database()->escape($aVals['title']) . '\'')->execute('getField'); if ($iCheck) { return Phpfox_Error::set(Phpfox::getPhrase('share.this_site_already_exists')); } $aVals['icon'] = Phpfox::getLib('parse.input')->cleanFileName($aVals['title']); if (!($aVals['icon'] = $this->_uploadImage($aVals['icon']))) { return false; } $this->database()->insert($this->_sTable, $aVals); } else { if (!empty($_FILES['icon']['name'])) { $aVals['icon'] = Phpfox::getLib('parse.input')->cleanFileName($aVals['title']); $aOld = Phpfox::getService('share')->getForEdit($iEditId); if (file_exists(Phpfox::getParam('share.dir_image') . $aOld['icon'])) { Phpfox::getLib('file')->unlink(Phpfox::getParam('share.dir_image') . $aOld['icon']); } if (!($aVals['icon'] = $this->_uploadImage($aVals['icon']))) { return false; } } $this->database()->update($this->_sTable, $aVals, 'site_id = ' . (int) $iEditId); } $this->cache()->remove('share', 'substr'); return true; }
/** * This function is only called from the ajax function im.add * @param type $aVals * @return type */ public function addText($aVals) { Phpfox::isUser(true); $aValid = array('parent_id' => array('type' => 'int:required'), 'text' => array('type' => 'string:required')); if (isset($aVals['text']) && Phpfox::getLib('parse.format')->isEmpty($aVals['text']) && $aVals['text'] != '0') { return false; } $aVals = $this->validator()->allowZero()->process($aValid, $aVals); // Cant use validator because "0" is considered empty //$aVals['text'] = Phpfox::getLib('parse.input')->clean($aVals['text']); if (!Phpfox_Error::isPassed()) { return false; } $aChat = Phpfox::getService('im')->getChat($aVals['parent_id']); if (!isset($aChat['im_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('im.not_a_valid_chat_room')); } if (!$aChat['is_logged_in']) { return Phpfox_Error::set(Phpfox::getPhrase('im.unable_to_send_this_user_an_offline_message')); } Phpfox::getService('ban')->checkAutomaticBan($aVals['text']); $aVals['user_id'] = Phpfox::getUserId(); $aVals['time_stamp'] = PHPFOX_TIME; $aVals['text'] = $this->preParse()->clean($aVals['text']); //if ($sPlugin = Phpfox_Plugin::get('im.service_process_addtext_pre_insert')){eval($sPlugin);} $iId = $this->database()->insert(Phpfox::getT('im_text'), $aVals); if ($sPlugin = Phpfox_Plugin::get('im.service_process_addtext_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } //$this->database()->update($this->_sTable, array('is_active' => '1', 'last_update' => PHPFOX_TIME), 'parent_id = ' . $aVals['parent_id'] . ''); /* Check if the other user has this chat conversation open */ $aOpen = $this->database()->select('is_active, is_new')->from($this->_sTable)->where('parent_id = ' . (int) $aVals['parent_id'])->execute('getSlaveRow'); $aUpdate = array(); if ($aOpen['is_new'] = 0) { //$aUpdate = array('is_new' => $iId); } if ($aOpen['is_active'] != 2) { $aUpdate['is_active'] = '1'; } if (!empty($aUpdate)) { //$this->database()->update($this->_sTable, $aUpdate, 'parent_id = ' . $aVals['parent_id'] . ' AND owner_user_id = ' . Phpfox::getUserId()); } if (Phpfox::getService('im')->canAddAlert($aChat['user_id'], $aChat['parent_id'])) { $this->addAlert($aChat['user_id'], $aChat['parent_id']); } // http://www.phpfox.com/tracker/view/15335/ $sCacheId = $this->cache()->set('chat_rooms_user_' . $aChat['owner_user_id']); if ($aChatData = $this->cache()->get($sCacheId)) { $aChatData['room_id'][$aChat['parent_id']] = Phpfox::getUserId(); } else { $aChatData = array('room_id' => array($aChat['parent_id'] => Phpfox::getUserId())); } $sCacheId = $this->cache()->set('chat_rooms_user_' . $aChat['owner_user_id']); $this->cache()->save($sCacheId, $aChatData); return true; }
public function upgrade() { $this->error(false); Phpfox::getBlock('subscribe.upgrade', array('bIsThickBox' => true)); // http://www.phpfox.com/tracker/view/15093/ if (!Phpfox_Error::isPassed()) { echo '<div class="error_message">' . implode('<br />', Phpfox_Error::get()) . '</div>'; } }
public function export($aVals) { if (empty($aVals['title'])) { Phpfox_Error::set('Provide a package name.'); } if (empty($aVals['url'])) { Phpfox_Error::set('Provide a URL.'); } if (empty($aVals['apps'])) { Phpfox_Error::set('Select apps to export.'); } if (Phpfox_Error::isPassed()) { $aVals['title'] = strtolower($aVals['title']); $aVals['title'] = preg_replace('/[^a-zA-Z0-9]+/', '', $aVals['title']); $aVals['title'] = substr($aVals['title'], 0, 20); define('PHPFOX_XML_SKIP_STAMP', true); $oXmlBuilder = Phpfox::getLib('xml.builder'); $oXmlBuilder->addGroup('phpfoxapps'); $oXmlBuilder->addGroup('appsinfo'); $oXmlBuilder->addTag('url', $aVals['url']); $oXmlBuilder->closeGroup(); $oXmlBuilder->addGroup('apps'); $aApps = $this->getAllApps($aVals['apps']); foreach ($aApps as $aApp) { $oXmlBuilder->addGroup('app'); $oXmlBuilder->addTag('app_title', $aApp['app_title']); $oXmlBuilder->addTag('app_description', $aApp['app_description']); $oXmlBuilder->addTag('app_url', $aApp['app_url']); $oXmlBuilder->addTag('image_url', $aApp['image_url']); $oXmlBuilder->addTag('time_stamp', $aApp['time_stamp']); if (!empty($aApp['image_path'])) { $oXmlBuilder->addGroup('images'); $aSizes = array('', 50, 200, 'square'); foreach ($aSizes as $mSize) { $sImage = sprintf($aApp['image_path'], empty($mSize) ? '' : '_' . $mSize); $sContent = file_get_contents(PHPFOX_DIR . 'file' . PHPFOX_DS . 'pic' . PHPFOX_DS . 'app' . PHPFOX_DS . $sImage); $aExts = preg_split('/[\\/\\.]/', $sImage); $iCnt = count($aExts) - 1; $sExt = strtolower($aExts[$iCnt]); $oXmlBuilder->addTag('data', base64_encode($sContent), array('id' => md5($sContent), 'size' => empty($mSize) ? '' : '_' . $mSize, 'ext' => $sExt)); } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); $oXmlBuilder->closeGroup(); $sNewHomeFolder = PHPFOX_DIR_CACHE . md5(uniqid() . Phpfox::getUserId()); Phpfox::getLib('file')->write($sNewHomeFolder, $oXmlBuilder->output()); Phpfox::getLib('file')->forceDownload($sNewHomeFolder, 'phpfox-' . $aVals['title'] . '.apps'); } return false; }
public function add($aVals, $iUpdateId = null) { $aForms = array('title' => array('message' => Phpfox::getPhrase('subscribe.provide_a_message_for_the_package'), 'type' => array('string:required')), 'description' => array('message' => Phpfox::getPhrase('subscribe.provide_a_description_for_the_package'), 'type' => 'string:required'), 'user_group_id' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_success'), 'type' => 'int:required'), 'fail_user_group' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_cancellation'), 'type' => 'int:required'), 'is_registration' => array('message' => Phpfox::getPhrase('subscribe.provide_if_the_package_should_be_added_to_the_registration_form'), 'type' => 'int:required'), 'is_active' => array('message' => Phpfox::getPhrase('subscribe.select_if_the_package_is_active_or_not'), 'type' => 'int:required'), 'cost' => array('message' => Phpfox::getPhrase('subscribe.provide_a_price_for_the_package'), 'type' => 'currency:required'), 'show_price' => array('type' => 'int:required'), 'background_color' => array('type' => 'string')); $bIsRecurring = false; if (isset($aVals['is_recurring']) && $aVals['is_recurring']) { $aForms['recurring_cost'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_cost'), 'type' => 'currency:required'); $aForms['recurring_period'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_period'), 'type' => 'int:required'); $bIsRecurring = true; } if ($iUpdateId !== null) { if (isset($aVals['is_recurring']) && !$aVals['is_recurring']) { $aCacheForm = $aVals; } } $aVals = $this->validator()->process($aForms, $aVals); if (!Phpfox_Error::isPassed()) { return false; } if ($iUpdateId !== null) { if (isset($aCacheForm['is_recurring']) && !$aCacheForm['is_recurring']) { $aVals['recurring_period'] = 0; $aVals['recurring_cost'] = null; } } $aVals['cost'] = serialize($aVals['cost']); if ($bIsRecurring) { $aVals['recurring_cost'] = serialize($aVals['recurring_cost']); } if (!empty($_FILES['image']['name'])) { $aImage = Phpfox_File::instance()->load('image', array('jpg', 'gif', 'png')); if ($aImage === false) { return false; } } $aVals['title'] = $this->preParse()->convert($aVals['title']); $aVals['description'] = $this->preParse()->convert($aVals['description']); $aVals['background_color'] = Phpfox::getLib('parse.input')->clean($aVals['background_color']); if ($iUpdateId !== null) { $iId = $iUpdateId; $this->database()->update($this->_sTable, $aVals, 'package_id = ' . (int) $iUpdateId); } else { $iLastOrderId = $this->database()->select('ordering')->from($this->_sTable)->order('ordering DESC')->execute('getSlaveField'); $aVals['ordering'] = $iLastOrderId + 1; $iId = $this->database()->insert($this->_sTable, $aVals); } if (!empty($_FILES['image']['name']) && ($sFileName = Phpfox_File::instance()->upload('image', Phpfox::getParam('subscribe.dir_image'), $iId))) { $this->database()->update($this->_sTable, array('image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')), 'package_id = ' . (int) $iId); Phpfox_Image::instance()->createThumbnail(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, '_120'), 120, 120); unlink(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, '')); } return $iId; }
public function update($sId, $aVals) { $aForm = array('title' => array('message' => Phpfox::getPhrase('api.provide_a_name'), 'type' => 'string:required', 'convert' => true), 'description' => array('message' => Phpfox::getPhrase('api.provide_a_description'), 'type' => 'string', 'convert' => true), 'is_active' => array('message' => Phpfox::getPhrase('api.select_if_the_gateway_is_active_or_not'), 'type' => 'int:required'), 'is_test' => array('message' => Phpfox::getPhrase('api.select_if_the_gateway_is_in_test_mode'), 'type' => 'int:required'), 'setting' => array('type' => 'array')); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } if (isset($aVals['setting'])) { $aVals['setting'] = empty($aVals['setting']) ? null : serialize($aVals['setting']); } $this->database()->update($this->_sTable, $aVals, 'gateway_id = \'' . $this->database()->escape($sId) . '\''); return true; }
public function loadProfileBlock() { die('sdsdg'); exit; $sProfileUrl = str_replace('profile_', '', $this->get('url')); if ($this->get('url') == 'profile_info') { $sProfileUrl = 'profile'; } if (!Phpfox::isModule($sProfileUrl)) { Phpfox_Error::set('Trying to load an invalid module.'); } else { if (!Phpfox::hasCallback($sProfileUrl, 'getAjaxProfileController')) { Phpfox_Error::set('Unable to load the section you are looking for.'); } } if (Phpfox_Error::isPassed()) { $oModule = Phpfox::getLib('module'); $oTpl = Phpfox::getLib('template'); $oTpl->assign(array('bIsAjaxLoader' => true)); $aStyleInUse = $oTpl->getStyleInUse(); $oModule->loadBlocks(); $aUrlParams = array($this->get('user_name')); if ($this->get('url') != 'profile') { $aUrlParams[] = str_replace('profile_', '', $this->get('url')); } Phpfox::getLib('url')->setParam($aUrlParams); $oModule->setController(Phpfox::callback($sProfileUrl . '.getAjaxProfileController')); if ($aStyleInUse['total_column'] == '3') { $oTpl->assign(array('aBlocks1' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(1), 'aBlocks3' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(3), 'aAdBlocks1' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(1) : null), 'aAdBlocks3' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(3) : null))); } else { $oTpl->assign(array('aBlocks1' => array(), 'aBlocks3' => array(), 'aAdBlocks1' => array(), 'aAdBlocks3' => array())); } $oTpl->assign(array('sPublicMessage' => Phpfox::getMessage(), 'aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'aStyleInUse' => $aStyleInUse)); list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb(); $this->remove('#js_temp_breadcrumb'); if (count($aBreadCrumbs)) { foreach ($aBreadCrumbs as $sLink => $sPhrase) { $this->append('h1', '<span id="js_temp_breadcrumb"><span class="profile_breadcrumb">»</span><a href="' . $sLink . '">' . $sPhrase . '</a></span>'); break; } } $oTpl->getLayout($oTpl->sDisplayLayout); $this->html($aStyleInUse['total_column'] == '3' ? '#content_load_data' : '#content', $this->getContent(false)); if ($this->get('url') == 'profile_info') { $this->call('$Core.loadProfileInfo();'); } } else { $this->html('#js_profile_block_view_data_' . $this->get('url'), implode('', Phpfox_Error::get())); } $this->call('$Core.loadInit();'); }
public function add($aVals, $iUserId = null) { if ($iUserId === null) { Phpfox::isUser(true); } $aForms = array('package_id' => array('message' => Phpfox::getPhrase('subscribe.package_is_required'), 'type' => 'int:required'), 'currency_id' => array('message' => Phpfox::getPhrase('subscribe.currency_is_required'), 'type' => array('string:required', 'regex:currency_id')), 'price' => array('message' => Phpfox::getPhrase('subscribe.price_is_required'), 'type' => 'price:required')); $aVals = $this->validator()->process($aForms, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aExtra = array('user_id' => $iUserId === null ? Phpfox::getUserId() : $iUserId, 'time_stamp' => PHPFOX_TIME); $iId = $this->database()->insert($this->_sTable, array_merge($aExtra, $aVals)); return $iId; }
/** * Uploads an emoticon and inserts it in the package it belongs to, it also updates an emoticon's title and replace. * @param array $aVals */ public function addEmoticon($aVals, $sFileName = null) { // check completeness of the array $aForm = array('title' => array('message' => Phpfox::getPhrase('emoticon.select_a_module'), 'type' => 'string:required'), 'text' => array('message' => Phpfox::getPhrase('emoticon.provide_a_emoticon_symbol'), 'type' => 'string:required'), 'package_path' => array('message' => Phpfox::getPhrase('emoticon.define_a_path_for_the_package'), 'type' => 'string:required')); $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } // check that there is not another replace for the same package $bExists = $this->database()->select('*')->from($this->_sTable)->where('text = \'' . $aVals['text'] . '\'')->execute('getSlaveRow'); // if is not updating and the one in the DB matches in text and package_PATH then throw an error if (!isset($aVals['emoticon_id']) && isset($bExists['emoticon_id']) && $bExists['emoticon_id'] > 0) { return Phpfox_Error::set(Phpfox::getPhrase('emoticon.symbol_already_exists')); } // if is updating then update all the fields except the image field right away if (isset($aVals['emoticon_id']) && $aVals['emoticon_id'] > 0) { $aUpdate = array('title' => Phpfox::getLib('parse.input')->clean($aVals['title']), 'text' => Phpfox::getLib('parse.input')->clean($aVals['text']), 'package_path' => Phpfox::getLib('parse.input')->clean($aVals['package_path'])); $this->database()->update($this->_sTable, $aUpdate, 'emoticon_id = ' . (int) $aVals['emoticon_id']); } // Upload image if (!empty($aVals['file']['tmp_name'])) { if ($sFileName === null) { $oFile = Phpfox::getLib('file'); $oImage = Phpfox::getLib('image'); $aImage = $oFile->load('file', array('png', 'jpg', 'gif')); if ($aImage === false) { return false; } $sFileName = Phpfox::getLib('parse.input')->cleanFileName(preg_replace("/^(.*?)\\.(jpg|jpeg|gif|png)\$/i", "\$1", $aVals['file']['name'])); $sDirectory = $this->database()->select('package_path')->from(Phpfox::getT('emoticon_package'))->where('package_path =\'' . $this->database()->escape(Phpfox::getLib('parse.input')->clean($aVals['package_path'])) . '\'')->execute('getSlaveField'); $sDirectory = Phpfox::getParam('core.dir_emoticon') . $sDirectory . PHPFOX_DS; if (!($sFileName = $oFile->upload('file', $sDirectory, $sFileName, false, 0644, false))) { return Phpfox_Error::set(Phpfox::getPhrase('emoticon.image_could_not_be_uploaded')); } } } if (isset($aVals['emoticon_id']) && is_numeric($aVals['emoticon_id'])) { // Update the image field $this->database()->update($this->_sTable, array('title' => $this->preParse()->clean($aVals['title']), 'text' => $this->preParse()->clean($aVals['text'])), 'emoticon_id = ' . (int) $aVals['emoticon_id']); } else { // insert in the database $aInsert = array('title' => $this->preParse()->clean($aVals['title']), 'text' => $this->preParse()->clean($aVals['text']), 'image' => str_replace('%s', '', $sFileName), 'package_path' => Phpfox::getLib('parse.input')->clean($aVals['package_path'])); $this->database()->insert($this->_sTable, $aInsert); } // remove cache $this->cache()->remove('emoticon'); $this->cache()->remove('emoticon_parse'); return true; }
public function preview() { $this->error(false); Phpfox::getBlock('link.preview'); if (!Phpfox_Error::isPassed()) { echo json_encode(array('error' => implode('', Phpfox_Error::get()))); } else { $this->call('<script text/javascript">$Core.loadInit();</script>'); } }
public function preview() { $this->error(false); Phpfox::getBlock('link.preview'); if (!Phpfox_Error::isPassed()) { echo json_encode(array('error' => implode('', Phpfox_Error::get()))); } else { // http://www.phpfox.com/tracker/view/15230/ // button has been disabled while the site grabs the URL $this->call('<script text/javascript">$("#activity_feed_submit").removeAttr("disabled");</script>'); // http://www.phpfox.com/tracker/view/15116/ // $bIsPreview is never set back to false, therefore, once you close the window, you cannot link anything else. $this->call('<script text/javascript">$bIsPreview = false;</script>'); $this->call('<script text/javascript">$Core.loadInit();</script>'); } }
public function process() { //Get POST values if ($this->request()->get('select_service')) { $aVals = $this->request()->getArray('val'); if (!isset($aVals['dropbox']) && !isset($aVals['gdrive']) && !isset($aVals['email']) && !isset($aVals['folder'])) { Phpfox_Error::set(Phpfox::getPhrase('backuprestore.service_select_message')); } if (isset($aVals['dropbox']) && $aVals['dropbox'] == 1) { $service['dropbox'] = 1; } if (isset($aVals['gdrive']) && $aVals['gdrive'] == 1) { $service['gdrive'] = 1; } if (isset($aVals['email']) && $aVals['email'] == 1 && $aVals['email_address'] != "") { $service['email'] = 1; } if (isset($aVals['folder']) && $aVals['folder'] == 1 && $aVals['server_folder'] != "") { $service['folder'] = 1; } //save server folder if (isset($aVals['server_folder']) && !empty($aVals['server_folder'])) { Phpfox::getService('backuprestore.services')->addServerFolder($aVals['server_folder']); } //save email address if (isset($aVals['email_address']) && !empty($aVals['email_address'])) { Phpfox::getService('backuprestore.services')->addUserEmail($aVals['email_address']); } if (Phpfox_Error::isPassed()) { //Save selected services if (Phpfox::getService('backuprestore.services')->addSelectedService($service)) { // success message Phpfox::addMessage(Phpfox::getPhrase('backuprestore.changes_updated_successfully')); } } } //Saved Selected services from DB if ($selected_service = Phpfox::getService('backuprestore.backuprestore')->getBTDBSettingByName('selected_services')) { $selected_service = unserialize(array_shift($selected_service)); } else { Phpfox::getService('backuprestore.backuprestore')->addBTDBSetting('selected_services', ''); } $this->template()->assign(array('selected_service' => $selected_service, 'aForms' => Phpfox::getService('backuprestore.services')->getServicesForEdit())); $this->template()->setBreadcrumb(Phpfox::getPhrase('backuprestore.backup_destination'), $this->url()->makeUrl('admincp.backuprestore.destination'))->setHeader(array('btdbstyles.css' => 'module_backuprestore', 'scripts.js' => 'module_backuprestore')); }
public function process() { $this->googledrive = PhpFox::getService('backuprestore.googledrivefront'); $this->btdbsett = PhpFox::getService('backuprestore.backuprestore'); //Clients deny for Application Register if (isset($_GET['error'])) { $this->url()->forward($this->url()->makeUrl('backuprestore.continue'), Phpfox::getPhrase('backuprestore.gd_auth_deny')); } //Get Access Tokens usung authorization code returnedfrom Google API if (isset($_GET['code'])) { try { $this->tokens['access_token'] = $this->googledrive->exchangeCode($_GET['code']); if (!empty($this->tokens['access_token'])) { $this->btdbsett->addBTDBSetting('googledrive_tokens', serialize(json_decode($this->tokens['access_token'], true))); } //Redirct to main page $this->url()->forward($this->url()->makeUrl('admincp.backuprestore.destination'), Phpfox::getPhrase('backuprestore.gd_register_complete')); } catch (Exception $e) { $e->getMessage(); } } //Insert GDrive client keys if ($aVals = $this->request()->getArray('val')) { if (empty($aVals['gdrive_clientid'])) { return Phpfox_Error::set(Phpfox::getPhrase('backuprestore.please_insert_your_application_client_id')); } if (empty($aVals['gdrive_clientsecret'])) { return Phpfox_Error::set(Phpfox::getPhrase('backuprestore.please_insert_your_application_client_secret_key')); } if (Phpfox_Error::isPassed()) { if ($gdrive = Phpfox::getService('backuprestore.process')->addGDriveKeys($aVals)) { $this->url()->send('admincp.backuprestore.gdrivesett', null, Phpfox::getPhrase('backuprestore.changes_successfully_saved')); } } } //Values from DB for edit $gdkeys = Phpfox::getService('backuprestore.backuprestore')->getBTDBSettingByName('gdclient_keys'); if (!empty($gdkeys)) { $gdkeys = unserialize(array_shift($gdkeys)); $this->template()->assign('aForms', $gdkeys); } $this->template()->assign(array('redirect_url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'support_page' => $this->url()->makeUrl('admincp.backuprestore.gdrivesupp'))); $this->template()->setBreadcrumb(Phpfox::getPhrase('backuprestore.google_drive'), $this->url()->makeUrl('admincp.backuprestore.gdrivesett'))->setHeader(array('btdbstyles.css' => 'module_backuprestore', 'scripts.js' => 'module_backuprestore')); }
public function addNewPrivacyRule($aVals) { if (empty($aVals['url'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.provide_a_url')); } if (empty($aVals['user_group'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.provide_atleast_one_user_group_for_this_rule')); } if (!Phpfox_Error::isPassed()) { return false; } $aFind = array(Phpfox::getParam('core.path'), 'index.php?do=', '/'); $aReplace = array('', '', '.'); $sUrl = $aVals['url']; $sUrl = str_replace($aFind, $aReplace, $sUrl); $sUrl = trim($sUrl, '.'); $iId = $this->database()->insert(Phpfox::getT('admincp_privacy'), array('url' => $sUrl, 'time_stamp' => PHPFOX_TIME, 'user_id' => Phpfox::getUserId(), 'user_group' => json_encode($aVals['user_group']), 'wildcard' => (int) $aVals['wildcard'])); $this->cache()->remove(); return $iId; }
/** * This function adds a ban filter, it was not renamed after 2.1 for compatibility * @param array $aVals * @param <type> $aBanFilter * @return true */ public function add($aVals, &$aBanFilter = null) { Phpfox::isAdmin(true); $aForm = array('type_id' => array('type' => 'string:required'), 'find_value' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_value_is_required')), 'reason' => array('type' => 'string'), 'days_banned' => array('type' => 'int'), 'return_user_group' => array('type' => 'int'), 'bShow' => array('type' => 'string'), 'user_groups_affected' => array('type' => 'array')); if ($aBanFilter !== null && isset($aBanFilter['replace'])) { $aForm['replacement'] = array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_replacement_is_required')); } $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } if ($aVals['find_value'] == Phpfox::getIp()) { return Phpfox_Error::set('You cannot ban yourself.'); } $aVals['user_id'] = Phpfox::getUserId(); $aVals['time_stamp'] = PHPFOX_TIME; $aVals['find_value'] = $this->preParse()->convert($aVals['find_value']); if (isset($aVals['bShow']) && $aVals['bShow'] == '0' || !isset($aVals['bShow'])) { unset($aVals['reason']); unset($aVals['days_banned']); unset($aVals['return_user_group']); } else { $aVals['reason'] = !Phpfox_Locale::instance()->isPhrase($aVals['reason']) ? Phpfox::getLib('parse.input')->clean($aVals['reason']) : $aVals['reason']; $aVals['days_banned'] = (int) $aVals['days_banned']; $aVals['return_user_group'] = (int) $aVals['return_user_group']; if (!isset($aVals['user_groups_affected'])) { $aVals['user_groups_affected'] = array(); } $aVals['user_groups_affected'] = serialize($aVals['user_groups_affected']); } unset($aVals['bShow']); if (isset($aVals['replacement'])) { $aVals['replacement'] = $this->preParse()->convert($aVals['replacement']); } if (empty($aVals['user_groups_affected'])) { $aVals['user_groups_affected'] = ''; } $this->database()->insert($this->_sTable, $aVals); $this->cache()->remove('ban', 'substr'); return true; }
/** * Class process method wnich is used to execute this component. */ public function process() { $bFriendIsSelected = false; if ($iUserId = $this->request()->getInt('to')) { $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField()); if (isset($aUser['user_id'])) { //if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'mail.send_message')) if (!Phpfox::getService('mail')->canMessageUser($aUser['user_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_send_a_private_message_to_this_user_at_the_moment')); } $bFriendIsSelected = true; $this->template()->assign('aUser', $aUser); } } if (Phpfox::getParam('mail.spam_check_messages') && Phpfox::isSpammer()) { return Phpfox_Error::display(Phpfox::getPhrase('mail.currently_your_account_is_marked_as_a_spammer')); } $aValidation = array('subject' => Phpfox::getPhrase('mail.provide_subject_for_your_message'), 'message' => Phpfox::getPhrase('mail.provide_message')); $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { // Lets make sure they are actually trying to send someone a message. if ((!isset($aVals['to']) || isset($aVals['to']) && !count($aVals['to'])) && (!isset($aVals['copy_to_self']) || $aVals['copy_to_self'] != 1)) { Phpfox_Error::set(Phpfox::getPhrase('mail.select_a_member_to_send_a_message_to')); } if ($oValid->isValid($aVals)) { if (Phpfox::getParam('mail.mail_hash_check')) { Phpfox::getLib('spam.hash', array('table' => 'mail_hash', 'total' => Phpfox::getParam('mail.total_mail_messages_to_check'), 'time' => Phpfox::getParam('mail.total_minutes_to_wait_for_pm'), 'content' => $aVals['message']))->isSpam(); } if (Phpfox::getParam('mail.spam_check_messages')) { if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['message']))))) { Phpfox_Error::set(Phpfox::getPhrase('mail.this_message_feels_like_spam_try_again')); } } if (Phpfox_Error::isPassed()) { $aIds = Phpfox::getService('mail.process')->add($aVals); $this->url()->send('mail.view', array('id' => $aIds[0])); } } } $this->template()->assign(array('bMobileInboxIsActive' => true, 'bFriendIsSelected' => $bFriendIsSelected, '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', 'compose'))); }
/** * This function receives an array coming directly from the user and the register * controller. It receives an image and creates a page as well as the thumbnails * for the app * @param type $aVals */ public function addApp($aVals) { Phpfox::getUserParam('apps.can_add_app', true); if (empty($aVals['name'])) { Phpfox_Error::set(Phpfox::getPhrase('apps.every_field_is_required')); } $oParse = Phpfox::getLib('parse.input'); if (Phpfox_Error::isPassed()) { $aInsert = array( 'app_title' => $oParse->clean($aVals['name']), 'public_key' => $this->generateKey(32), 'private_key' => $this->generateKey(32), 'user_id' => Phpfox::getUserId(), 'time_stamp' => PHPFOX_TIME, 'view_id' => Phpfox::getUserParam('apps.apps_require_moderation') ? '1' : '0' ); // Insert in phpfox_app $iId = $this->database()->insert(Phpfox::getT('app'), $aInsert); // Assign category $iCategory = $this->database()->insert(Phpfox::getT('app_category_data'), array( 'category_id' => (int)$aVals['category'], 'app_id' => $iId )); define('PHPFOX_APP_CREATED', $iId); // Create the page $iPage = Phpfox::getService('pages.process')->add(array( 'app_id' => $iId, 'title' => $aVals['name'] ) ); return array('app_id' => $iId, 'app_title' => $aInsert['app_title']); } return false; }
public function add($aVals, $iUpdateId = null) { $aForm = array('product_id' => array('message' => Phpfox::getPhrase('rss.select_a_product'), 'type' => 'product_id:required'), 'module_id' => array('message' => Phpfox::getPhrase('rss.select_a_module'), 'type' => 'module_id:required'), 'group_id' => array('message' => Phpfox::getPhrase('rss.select_a_group_for_this_feed'), 'type' => 'int:required'), 'title_var' => array('message' => Phpfox::getPhrase('rss.at_least_one_title_for_the_feed_is_required'), 'type' => 'phrase:required'), 'description_var' => array('message' => Phpfox::getPhrase('rss.at_least_one_description_for_the_feed_is_required'), 'type' => 'phrase:required'), 'feed_link' => array('message' => Phpfox::getPhrase('rss.provide_a_link_for_the_feed'), 'type' => 'string:required'), 'php_group_code' => array('message' => Phpfox::getPhrase('rss.provide_proper_php_code'), 'type' => 'php_code'), 'php_view_code' => array('message' => Phpfox::getPhrase('rss.php_code_for_the_feed_is_required'), 'type' => 'php_code:required'), 'is_site_wide' => array('message' => Phpfox::getPhrase('rss.select_if_the_feed_can_be_seen_site_wide'), 'type' => 'int:required'), 'is_active' => array('message' => Phpfox::getPhrase('rss.select_if_the_feed_is_active_or_not'), 'type' => 'int:required')); if ($iUpdateId !== null) { unset($aForm['product_id'], $aForm['module_id']); $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['title_var']; $aDescriptions = $aVals['description_var']; unset($aVals['title_var'], $aVals['description_var']); $this->database()->update($this->_sTable, $aVals, 'feed_id = ' . $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]); } foreach ($aDescriptions as $sPhrase => $aPhrase) { $aLanguage = array_keys($aPhrase); $aText = array_values($aPhrase); Phpfox::getService('language.phrase.process')->updateVarName($aLanguage[0], $sPhrase, $aText[0]); } } else { $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aPhrases = $aVals['title_var']; $aDescriptions = $aVals['description_var']; unset($aVals['title_var'], $aVals['description_var']); $iId = $this->database()->insert($this->_sTable, $aVals); $sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'rss_title_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aPhrases)); $sDescriptionVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'rss_description_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aDescriptions)); $this->database()->update($this->_sTable, array('title_var' => $sPhraseVar, 'description_var' => $sDescriptionVar), 'feed_id = ' . $iId); } $this->cache()->remove(); return true; }
public function add($aVals) { $aForm = array('product_id' => array('type' => 'string'), 'group_id' => array('type' => 'string:required'), 'folder' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.select_a_theme_for_this_template')), 'name' => array('type' => 'string:required', 'message' => 'Add a file name.'), 'full_name' => array('type' => 'string'), 'html_data' => array('type' => 'string')); if (!empty($aVals['group_id']) && $aVals['group_id'] != 'layout') { $aForm['type_id'] = array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.select_what_type_of_a_template_this_is')); } $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $aVals['name'] = $this->preParse()->cleanFileName($aVals['name']); if (empty($aVals['name'])) { return Phpfox_Error::set(Phpfox::getPhrase('theme.file_name_is_not_valid')); } $aVals['name'] = $aVals['name'] . '.html.php'; if (empty($aVals['group_id']) || !empty($aVals['group_id']) && $aVals['group_id'] == 'layout') { if (file_exists(PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aVals['folder'] . PHPFOX_DS . 'template' . PHPFOX_DS . $aVals['name'])) { return Phpfox_Error::set(Phpfox::getPhrase('theme.the_file_name_is_already_in_use')); } } else { if (file_exists(PHPFOX_DIR_MODULE . $aVals['group_id'] . PHPFOX_DS . 'template' . PHPFOX_DS . $aVals['folder'] . PHPFOX_DS . $aVals['type_id'] . PHPFOX_DS . $aVals['name'])) { return Phpfox_Error::set(Phpfox::getPhrase('theme.the_file_name_is_already_in_use')); } } $aVals['full_name'] = empty($aVals['full_name']) ? null : $this->preParse()->clean($aVals['full_name'], 255); $aVals['time_stamp'] = PHPFOX_TIME; $aVals['is_custom'] = '1'; $aVals['module_id'] = empty($aVals['group_id']) || !empty($aVals['group_id']) && $aVals['group_id'] == 'layout' ? null : $aVals['group_id']; $aVals['type_id'] = empty($aVals['group_id']) || !empty($aVals['group_id']) && $aVals['group_id'] == 'layout' ? 'layout' : $aVals['type_id']; $aVals['html_data_original'] = $aVals['html_data']; unset($aVals['group_id']); $iCheck = $this->database()->select('COUNT(*)')->from(Phpfox::getT('theme_template'))->where('folder = \'' . $this->database()->escape($aVals['folder']) . '\' AND type_id = \'' . $this->database()->escape($aVals['type_id']) . '\' AND module_id = \'' . $this->database()->escape($aVals['module_id']) . '\' AND name = \'' . $this->database()->escape($aVals['name']) . '\'')->execute('getField'); if ($iCheck) { return Phpfox_Error::set(Phpfox::getPhrase('theme.the_file_name_is_already_in_use')); } $this->database()->insert(Phpfox::getT('theme_template'), $aVals); return true; }
/** * Create a new user or log them in if they exist * * @param \Facebook\GraphUser $fb * @return bool * @throws \Exception */ public function create(\Facebook\GraphUser $fb) { $email = $fb->getId() . '@fb'; $user = $this->db->select('*')->from(':user')->where(['email' => $email])->get(); if (isset($user['user_id'])) { $_password = $fb->getId() . uniqid(); $password = (new \Core\Hash())->make($_password); $this->db->update(':user', ['password' => $password], ['user_id' => $user['user_id']]); } else { $_password = $fb->getId() . uniqid(); $password = (new \Core\Hash())->make($_password); $id = $this->db->insert(':user', ['user_group_id' => NORMAL_USER_ID, 'email' => $email, 'password' => $password, 'full_name' => $fb->getFirstName() . ' ' . $fb->getLastName(), 'user_name' => 'fb-' . $fb->getId(), 'user_image' => '{"fb":"' . $fb->getId() . '"}', 'joined' => PHPFOX_TIME, 'last_activity' => PHPFOX_TIME]); $tables = ['user_activity', 'user_field', 'user_space', 'user_count']; foreach ($tables as $table) { $this->db->insert(':' . $table, ['user_id' => $id]); } } \User_Service_Auth::instance()->login($email, $_password, true, 'email'); if (!\Phpfox_Error::isPassed()) { throw new \Exception(implode('', \Phpfox_Error::get())); } return true; }