示例#1
0
 /**
  * Actually manages the sending of the message
  */
 public function sendCongrats()
 {
     $aVal = $this->getAll('val');
     $iUser = (int) $aVal['val']['iUser'];
     $sMessage = $aVal['val']['message'];
     /* id for the egift*/
     $iEgift = $fCost = 0;
     if (isset($aVal['val']['egift_id'])) {
         $iEgift = (int) $aVal['val']['egift_id'];
         $fCost = Phpfox::getService('egift')->getCost($iEgift);
     }
     /* Add it to the database, but if its not free then hide it and dont send the notification */
     $mSent = Phpfox::getService('friend.process')->sendCongrats($iUser, $sMessage, $iEgift, $fCost);
     /* $mSent is the invoice_id from egift_invoice*/
     if ($mSent > 0 && !is_bool($mSent)) {
         Phpfox::getBlock('api.gateway.form', array('gateway_data' => array('item_number' => 'egift|' . $mSent, 'currency_code' => Phpfox::getService('core.currency')->getDefault(), 'amount' => $fCost, 'item_name' => 'egift card with message: ' . $sMessage . '', 'return' => Phpfox::getLib('url')->makeUrl('friend.invoice'), 'recurring' => 0, 'recurring_cost' => '', 'alternative_cost' => 0, 'alternative_recurring_cost' => 0)));
         $this->html('#TB_ajaxContent', $this->getContent(false));
     } else {
         $this->error(false);
         if ($mSent) {
             $this->height('#TB_ajaxContent', '30px')->html('#TB_ajaxContent', '<div class="valid_message">' . Phpfox::getPhrase('friend.your_message_has_been_sent') . '</div>')->call('setTimeout("tb_remove();", 1000);');
             $this->call('$("#js_congratulate_' . $iUser . '").hide("slow");');
             $this->hide('#js_form_congratulate');
             $this->alert(Phpfox::getPhrase('friend.your_message_has_been_sent'));
         } else {
             $sErrors = implode(',', Phpfox_Error::get());
             $this->call('$("#TB_ajaxContent").find(".error_message").remove();');
             $this->append('#TB_ajaxContent', '<div class="error_message">' . $sErrors . '</div>');
         }
     }
 }
 /**
  * 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'));
 }
示例#3
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     exit('Use AJAX method');
     Phpfox::isUser(true);
     if (!($iId = $this->request()->get('id'))) {
         return Phpfox_Error::display(Phpfox::getPhrase('video.id_must_be_defined'));
     }
     echo '<script type="text/javascript">';
     if (Phpfox::getService('video.convert')->process($iId)) {
         if ($this->request()->get('video-inline') == '1') {
             $iFeedId = Phpfox::getService('feed.process')->getLastId();
             echo 'window.parent.$.ajaxCall(\'video.displayFeed\', \'id=' . $iFeedId . '&video_id=' . $iId . '\', \'GET\');';
         } elseif ($this->request()->get('isajax')) {
             echo 'window.parent.Editor.insert({type: \'video\', id: \'' . (int) $iId . '\', editor_id: \'' . base64_decode($this->request()->get('editor-id')) . '\'});';
         } else {
             $aVideo = Phpfox::getService('video')->getForEdit($iId);
             echo 'window.parent.location.href = \'' . Phpfox::permalink('video', $aVideo['video_id'], $aVideo['title']) . '\';';
         }
     } else {
         Phpfox::getService('video.process')->delete($iId);
         echo 'window.parent.document.getElementById(\'js_video_upload_error\').style.display = \'block\';';
         echo 'window.parent.document.getElementById(\'js_video_upload_message\').innerHTML = \'' . implode('<br />', Phpfox_Error::get()) . '\';';
         echo 'window.parent.document.getElementById(\'js_upload_inner_form\').style.display = \'block\';';
         echo 'window.parent.document.getElementById(\'js_video_detail\').style.display = \'none\';';
         echo 'window.parent.document.getElementById(\'js_video_process\').style.display = \'none\';';
     }
     echo '</script>';
     exit;
 }
示例#4
0
 public function process()
 {
     if ($this->request()->get('vidlypost')) {
         /*
         $hFile = fopen(PHPFOX_DIR_FILE . 'log' . PHPFOX_DS . 'vidly.log', 'a+');
         fwrite($hFile, print_r($_REQUEST, true) . "\n");
         fclose($hFile);
         */
         if ($this->request()->get('vidlypost') == 'AddMedia') {
             Phpfox::getService('video.process')->vidlyUpdateNewUrl($this->request()->getInt('vidid'), $_REQUEST);
         }
         exit;
     }
     if (!isset($_POST['hash'])) {
         echo json_encode(array('error' => true, 'error_message' => 'No post hash'));
     }
     if ($iId = Phpfox::getService('video')->checkVidlyHash($_POST['hash'])) {
         if (isset($_POST['cmd']) && $_POST['cmd'] == 'done') {
             if (!Phpfox::getService('video.process')->vidlyIsDone()) {
                 echo json_encode(array('error' => true, 'error_message' => implode('', Phpfox_Error::get())));
             }
         }
         echo json_encode(array('passed' => true, 'vidly_id' => $iId));
     } else {
         echo json_encode(array('error' => true, 'error_message' => implode('', Phpfox_Error::get())));
     }
     exit;
 }
示例#5
0
 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>';
     }
 }
示例#6
0
文件: User.php 项目: lev1976g/core
 public function post()
 {
     $this->requires(['name', 'email', 'password']);
     \User_Service_Validate::instance()->email($this->request('email'));
     $userId = \User_Service_Process::instance()->add(['full_name' => $this->request('name'), 'email' => $this->request('email'), 'password' => $this->request('password')]);
     if (!$userId) {
         throw new \Exception(implode('', \Phpfox_Error::get()));
     }
     return $this->get($userId);
 }
示例#7
0
 public function add()
 {
     /*
     @title
     @info Create a page. On success it will return information about the new page.
     @method POST
     @extra title=#{Title of the page|string|yes}&info=#{Information about the page|string|yes}&type_id=#{Parent category ID#. Use [action]page.categories[/action]|int|yes}&category_id=#{Sub-category ID#. Use [action]page.categories[/action]|int|yes}&image=#{Default avatar/logo for the page. Must be an HTTP path to an image|string|no}
     @return organization_id=#{Page ID#|int}&profile_user_id=#{This is the profile user ID# for the page|int}&title=#{Title of the page|string}&likes=#{Total number of likes|int}&permalink=#{Link to the page|string}&info=#{Information about the page|string}&created_by=#{Person who created the page|string}&created_by_url=#{Profile link of the person who created the page|string}&photo_100px=#{Photo of the page. 100px|string}&photo_100px_square=#{Square photo of the page. 100px|string}
     */
     if ($this->_oApi->isAllowed('organization.add_page') == false) {
         return $this->_oApi->error('organization.add_page', 'Unable to create a page for this user.');
     }
     $aInsert = array('title' => $this->_oApi->get('title'), 'info' => $this->_oApi->get('info'), 'type_id' => $this->_oApi->get('type_id'), 'category_id' => $this->_oApi->get('category_id'));
     $iId = Phpfox::getService('organization.process')->add($aInsert);
     if (!$iId) {
         return $this->_oApi->error('organization.unable_to_add_page', implode('', Phpfox_Error::get()));
     }
     $aorganization = $this->get($iId);
     if ($this->_oApi->get('image') != '') {
         $sType = $this->_oApi->get('image_type');
         $sImageContent = file_get_contents($this->_oApi->get('image'));
         $sImagePath = Phpfox::getParam('organization.dir_image') . $aorganization[0]['organization_id'] . '.' . $sType;
         $hFile = fopen($sImagePath, 'w');
         fwrite($hFile, $sImageContent);
         fclose($hFile);
         $_FILES['photo']['error'] = '';
         $_FILES['photo']['tmp_name'] = $sImagePath;
         $_FILES['photo']['name'] = $this->_oApi->get('photo_name');
         $oFile = Phpfox::getLib('file');
         $oImage = Phpfox::getLib('image');
         $aImage = $oFile->load('photo', array('jpg', 'gif', 'png'), Phpfox::getUserParam('organization.max_upload_size_organization') === 0 ? null : Phpfox::getUserParam('organization.max_upload_size_organization') / 1024);
         $sFileName = $oFile->upload('photo', Phpfox::getParam('organization.dir_image'), $iId);
         $sPath = Phpfox::getParam('organization.dir_image');
         $iFileSizes = filesize(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, ''));
         $aUpdate['image_path'] = $sFileName;
         $aUpdate['image_server_id'] = Phpfox::getLib('request')->getServer('PHPFOX_SERVER_ID');
         $iSize = 50;
         $oImage->createThumbnail(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize);
         $iFileSizes += filesize(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize));
         $iSize = 120;
         $oImage->createThumbnail(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize);
         $iFileSizes += filesize(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize));
         $iSize = 200;
         $oImage->createThumbnail(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize);
         $iFileSizes += filesize(Phpfox::getParam('organization.dir_image') . sprintf($sFileName, '_' . $iSize));
         define('PHPFOX_organization_IS_IN_UPDATE', true);
         Phpfox::getService('user.process')->uploadImage($aorganization[0]['profile_user_id'], true, Phpfox::getParam('organization.dir_image') . sprintf($sFileName, ''));
         // Update user space usage
         Phpfox::getService('user.space')->update(Phpfox::getUserId(), 'organization', $iFileSizes);
         $this->database()->update($this->_sTable, $aUpdate, 'organization_id = ' . (int) $iId);
         $aorganization = $this->get($iId);
     }
     return $aorganization[0];
 }
示例#8
0
 public function process()
 {
     // $app = Phpfox_Module::instance()->get(($this->request()->get('id')));
     $App = (new Core\App())->get($this->request()->get('id'));
     if (!$App->is_module) {
         if ($val = $this->request()->get('val')) {
             if (!($error = User_Service_Auth::instance()->loginAdmin($val['email'], $val['password']))) {
                 throw new \Exception(implode('', Phpfox_Error::get()));
             }
             $App->delete();
             Phpfox::addMessage('App successfully uninstalled.');
             return ['redirect' => $this->url()->makeUrl('admincp/apps')];
         }
         if ($settings = $this->request()->get('setting')) {
             $Setting = new Core\Setting\Service($App);
             $Setting->save($settings);
             return ['updated' => true];
         }
         if ($this->request()->get('export')) {
             $App->export();
             exit;
         }
         $menus = [];
         if ($App->admincpMenu) {
             foreach ($App->admincpMenu as $key => $value) {
                 $menus[$key] = ['url' => $this->url()->makeUrl('admincp/' . $value)];
             }
         }
         $menus['Uninstall'] = ['url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'uninstall' => 'yes'])];
         $settings = [];
         foreach ($App->settings as $key => $value) {
             if (!isset($value->type)) {
                 $value->type = 'input:text';
             }
             if (!isset($value->value)) {
                 $value->value = '';
             }
             if (setting($key) !== null) {
                 $value->value = setting($key);
             }
             $settings[$key] = ['info' => $value->info, 'value' => $value->value, 'type' => $value->type];
         }
         $this->template()->assign(['sSectionTitle' => $App->name, 'aSectionAppMenus' => $menus, 'ActiveApp' => $App, 'settings' => $settings]);
         if (defined('PHPFOX_IS_TECHIE') && PHPFOX_IS_TECHIE) {
             $this->template()->setActionMenu(['Export' => ['url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'export' => '1']), 'class' => '']]);
         }
     }
     $customContent = '';
     // if ($App->storeId) {
     // $customContent = '<iframe src="http://store.phpfox.com/product/' . $App->storeId . '/go" frameborder="0" class="acp_frame_product"></iframe>';
     // }
     $this->template()->setTitle($App->name)->assign(['App' => $App, 'uninstall' => $this->request()->get('uninstall'), 'customContent' => $customContent]);
 }
示例#9
0
 /**
  * Controller
  */
 public function process()
 {
     $bIsEdit = false;
     $oSession = Phpfox::getLib('session');
     $aValidation = array('product_id' => Phpfox::getPhrase('page.select_product'), 'title' => Phpfox::getPhrase('page.missing_title'), 'title_url' => Phpfox::getPhrase('page.missing_url_title'), 'is_active' => Phpfox::getPhrase('page.specify_page_active'), 'text' => Phpfox::getPhrase('page.page_missing_data'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if (($iPageId = $this->request()->getInt('id')) || ($iPageId = $this->request()->getInt('page_id'))) {
         Phpfox::getUserParam('page.can_manage_custom_pages', true);
         $aPage = Phpfox::getService('page')->getForEdit($iPageId);
         if (isset($aPage['page_id'])) {
             $bIsEdit = true;
             // $aPage['attachment'] = (Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getForItemEdit($aPage['page_id'], 'page', Phpfox::getUserId()) : '');
             if (Phpfox::isModule('tag')) {
                 $aTags = Tag_Service_Tag::instance()->getTagsById('page', $aPage['page_id']);
                 if (isset($aTags[$aPage['page_id']])) {
                     $aPage['tag_list'] = '';
                     foreach ($aTags[$aPage['page_id']] as $aTag) {
                         $aPage['tag_list'] .= ' ' . $aTag['tag_text'] . ',';
                     }
                     $aPage['tag_list'] = trim(trim($aPage['tag_list'], ','));
                 }
             }
             $this->template()->assign(array('aForms' => $aPage, 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access'])));
         }
     }
     if ($aVals = $this->request()->getArray('val')) {
         Phpfox::getLib('parse.input')->allowTitle(Phpfox::getLib('parse.input')->cleanTitle($aVals['title_url']), Phpfox::getPhrase('page.invalid_title'));
         if ($oValid->isValid($aVals)) {
             if ($bIsEdit) {
                 $sMessage = Phpfox::getPhrase('page.page_successfully_updated');
                 $sReturn = Phpfox::getService('page.process')->update($aPage['page_id'], $aVals, $aPage['user_id']);
                 $aUrl = null;
             } else {
                 $sMessage = Phpfox::getPhrase('page.successfully_added');
                 $sReturn = Phpfox::getService('page.process')->add($aVals);
                 $aUrl = null;
             }
             if ($sReturn) {
                 return ['redirect' => $this->url()->makeUrl($sReturn, null, $sMessage)];
             }
         } else {
             $aError = Phpfox_Error::get();
             $sError = '';
             if (is_array($aError)) {
                 $sError = implode(' ', $aError);
             } else {
                 $sError = $aError;
             }
             return ['error' => $sError];
         }
     }
     $this->template()->setSectionTitle('<a href="' . $this->url()->makeUrl('admincp.page') . '">Custom Pages</a>')->setTitle(Phpfox::getPhrase('page.add_new_page'))->setBreadCrumb(Phpfox::getPhrase('page.add_new_page'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aModules' => Phpfox_Module::instance()->getModules(), 'bFormIsPosted' => count($aVals) ? true : false))->setEditor()->setHeader(array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_menu.js' => 'static_script', '<script type="text/javascript">var Attachment = {sCategory: "page", iItemId: "' . (isset($aPage['page_id']) ? $aPage['page_id'] : '') . '"};</script>'));
 }
示例#10
0
 public function add($aUserInfo)
 {
     $aVals = array('user_group_id' => NORMAL_USER_ID, 'joined' => PHPFOX_TIME, 'last_ip_address' => Phpfox::getIp(), 'last_activity' => PHPFOX_TIME);
     $aVals['full_name'] = $aUserInfo['displayName'];
     if (empty($aVals['full_name'])) {
         Phpfox::getLib('url')->send('janrain.account', array('type' => 'full-name'));
     }
     if (!empty($aUserInfo['preferredUsername'])) {
         $aVals['user_name'] = $aUserInfo['preferredUsername'];
     }
     if (empty($aVals['user_name'])) {
         $aVals['user_name'] = $aUserInfo['displayName'];
     }
     if (!empty($aUserInfo['email'])) {
         Phpfox::getService('user.validate')->email($aUserInfo['email']);
         if (Phpfox_Error::get()) {
             Phpfox::getLib('url')->send('janrain.account', array('type' => 'email'));
         }
     }
     $aVals['user_name'] = Phpfox::getLib('parse.input')->prepareTitle('user', $aVals['user_name'], 'user_name', null, Phpfox::getT('user'));
     $aVals['email'] = empty($aUserInfo['email']) ? null : $aUserInfo['email'];
     $aVals['gender'] = !isset($aUserInfo['gender']) ? '0' : ($aUserInfo['gender'] == 'female' ? '2' : '1');
     $iUserId = $this->database()->insert(Phpfox::getT('user'), $aVals);
     $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);
     $this->database()->insert($this->_sTable, array('user_id' => $iUserId, 'identifier' => md5($aUserInfo['identifier']), 'time_stamp' => PHPFOX_TIME));
     if (!empty($aUserInfo['photo'])) {
         $sImage = $aUserInfo['photo'];
         $sNewImage = md5($iUserId . PHPFOX_TIME . uniqid()) . '%s.jpg';
         Phpfox::getLib('file')->writeToCache($sNewImage, file_get_contents($sImage));
         copy(PHPFOX_DIR_CACHE . $sNewImage, Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''));
         unlink(PHPFOX_DIR_CACHE . $sNewImage);
         foreach (Phpfox::getParam('user.user_pic_sizes') as $iSize) {
             Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize), $iSize, $iSize);
             Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize . '_square'), $iSize, $iSize, false);
         }
         Phpfox::getLib('database')->update(Phpfox::getT('user'), array('user_image' => $sNewImage, 'server_id' => 0), 'user_id = ' . (int) $iUserId);
     }
     // Taken from user.process->add
     $iFriendId = (int) Phpfox::getParam('user.on_signup_new_friend');
     if ($iFriendId > 0) {
         $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iUserId, 'friend_user_id' => $iFriendId, 'time_stamp' => PHPFOX_TIME));
         $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iFriendId, 'friend_user_id' => $iUserId, 'time_stamp' => PHPFOX_TIME));
         Phpfox::getService('friend.process')->updateFriendCount($iUserId, $iFriendId);
         Phpfox::getService('friend.process')->updateFriendCount($iFriendId, $iUserId);
     }
     return $iUserId;
 }
示例#11
0
 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">&#187;</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();');
 }
示例#12
0
 /**
  * Controller
  */
 public function process()
 {
     if ($aVals = $this->request()->getArray('val')) {
         if ($this->request()->get('widget_id') ? Phpfox::getService('pages.process')->updateWidget($this->request()->get('widget_id'), $this->request()->get('val')) : Phpfox::getService('pages.process')->addWidget($this->request()->get('val'))) {
             $aVals = $this->request()->get('val');
             echo '<script type="text/javascript">window.parent.location.href = \'' . Phpfox_Url::instance()->makeUrl('pages.add.widget', array('id' => $aVals['page_id'])) . '\';</script>';
         } else {
             echo '<script type="text/javascript">';
             echo 'window.parent.$(\'#js_pages_widget_error\').html(\'<div class="error_message">' . implode('', Phpfox_Error::get()) . '</div>\');';
             echo '</script>';
         }
     }
     exit;
 }
示例#13
0
	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>');
		}
	}
示例#14
0
 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>');
     }
 }
示例#15
0
 public function add()
 {
     /*
     @title 
     @info Post an event.
     @method POST
     @extra title=#{Title of the event|string|yes}&venue=#{Venue of where the event will take place|string|yes}&description=#{Information about the event|string|yes}&country_iso=#{Country ISO ID. Use [action]core.getCountries[/action]|string|no}&country_child_id=#{State/Province ID#. Use [action]core.getCountries[/action] to get the correct ID#|int|no}&postal_code=#{Postal code|int|no}&city=#{City|string|no}&address=#{Address|string|no}&start_hour=#{24-hour format of an hour of when the event starts with leading zeros|int|yes}&start_minute=#{Minutes with leading zeros of when the event starts|int|yes}&start_day=#{Day of the month of when the event starts, 2 digits with leading zeros|int|yes}&start_month=#{A full numeric representation of a month of when the event starts, 2 digits|int|yes}&start_year=#{A full numeric representation of a year of when the event starts, 4 digits|int|yes}&end_hour=#{24-hour format of an hour of when the event ends with leading zeros|int|yes}&end_minute=#{Minutes with leading zeros of when the event ends|int|yes}&end_day=#{Day of the month of when the event ends, 2 digits with leading zeros|int|yes}&end_month=#{A full numeric representation of the month when the event ends, 2 digits|int|yes}&end_year=#{A full numeric representation of a year of when the event ends, 4 digits|int|yes}
     */
     if ($this->_oApi->isAllowed('event.add_event') == false) {
         return $this->_oApi->error('event.add_event', 'Unable to add an event for this user.');
     }
     $aInsert = array('title' => $this->_oApi->get('title'), 'location' => $this->_oApi->get('venue'), 'country_iso' => $this->_oApi->get('country_iso'), 'country_child_id' => $this->_oApi->get('country_child_id'), 'postal_code' => $this->_oApi->get('postal_code'), 'city' => $this->_oApi->get('city'), 'address' => $this->_oApi->get('address'), 'description' => $this->_oApi->get('description'), 'start_hour' => $this->_oApi->get('start_hour'), 'start_minute' => $this->_oApi->get('start_minute'), 'start_month' => $this->_oApi->get('start_month'), 'start_day' => $this->_oApi->get('start_day'), 'start_year' => $this->_oApi->get('start_year'), 'end_hour' => $this->_oApi->get('end_hour'), 'end_minute' => $this->_oApi->get('end_minute'), 'end_month' => $this->_oApi->get('end_month'), 'end_day' => $this->_oApi->get('end_day'), 'end_year' => $this->_oApi->get('end_year'));
     $iId = Phpfox::getService('event.process')->add($aInsert);
     if (!$iId) {
         return $this->_oApi->error('event.unable_to_add_blog', implode('', Phpfox_Error::get()));
     }
     $aRows = $this->get($iId);
     return $aRows[0];
 }
示例#16
0
 public function add()
 {
     /*
     @title
     @info Create a blog for a user.
     @method POST
     @extra title=#{Title of the blog|string|yes}&text=#{Content for the blog|string|yes}
     @return id=#{ID# for the blog|int}&title=#{Title of the blog|string}&likes=#{Total number of likes|int}&content=#{Blog content|string}&created_by=#{User that created the blog|string}&created_by_url=#{Link to the users profile|string}
     */
     if ($this->_oApi->isAllowed('blog.add_blog') == false) {
         return $this->_oApi->error('blog.add_blog', 'Unable to add a blog for this user.');
     }
     $aInsert = array('title' => $this->_oApi->get('title'), 'text' => $this->_oApi->get('text'));
     $iId = Phpfox::getService('blog.process')->add($aInsert);
     if (!$iId) {
         return $this->_oApi->error('blog.unable_to_create_blog', implode('', Phpfox_Error::get()));
     }
     $aRows = $this->get($iId);
     return $aRows[0];
 }
示例#17
0
 /**
  * Process the controller
  *
  */
 public function process()
 {
     if (Phpfox::isUser()) {
         $this->url()->send('');
     }
     if ($sEmail = $this->request()->get('email')) {
         if (Phpfox::getService('user.password')->requestPassword($sEmail)) {
             if (PHPFOX_IS_AJAX) {
                 echo '$("#" + tb_get_active() + " .js_box_content").html("' . Phpfox::getPhrase('user.password_request_successfully_sent_check_your_email_to_verify_your_request') . '");setTimeout("tb_remove();",3000);';
                 die;
             }
             $this->url()->send('user.password.request', null, Phpfox::getPhrase('user.password_request_successfully_sent_check_your_email_to_verify_your_request'));
         }
         if (PHPFOX_IS_AJAX) {
             $aErrors = Phpfox_Error::get();
             Phpfox::getLib('ajax')->alert(implode(' ', $aErrors));
             die;
         }
     }
     $this->template()->setTitle(Phpfox::getPhrase('user.password_request'))->setBreadcrumb(Phpfox::getPhrase('user.password_request'));
 }
示例#18
0
 /**
  * This controller orchestrates to register a new application
  */
 public function process()
 {
     $bIsAdd = $bIsEdit = false;
     Phpfox::getUserParam('apps.can_add_app', true);
     if (!Phpfox::getParam('apps.enable_api_support')) {
         //return Phpfox_Error::display('No api');
     }
     if ($aVals = $this->request()->getArray('app')) {
         $bIsAdd = true;
         $aApp = Phpfox::getService('apps.process')->addApp($aVals);
         if ($aApp == false) {
             $this->template()->assign(array('sErrorMessage' => Phpfox_Error::get()));
         } else {
             $this->url()->send('apps.add', array('id' => $aApp['app_id']), Phpfox::getPhrase('apps.app_successfully_created'));
         }
     }
     if (($iId = $this->request()->getInt('id')) && $this->request()->get('req2') == 'add') {
         // is editing an app
         $aApp = Phpfox::getService('apps')->getAppById($iId);
         $this->template()->assign('aForms', $aApp);
         $bIsEdit = true;
         $aMenus = array('general' => Phpfox::getPhrase('apps.general'), 'photo' => Phpfox::getPhrase('apps.photo'), 'url' => Phpfox::getPhrase('apps.url'));
         $this->template()->buildPageMenu('js_apps_block', $aMenus, array('link' => Phpfox::permalink('apps', $aApp['app_id'], $aApp['app_title']), 'phrase' => Phpfox::getPhrase('apps.view_this_app')));
         if ($aVals = $this->request()->getArray('val')) {
             if (Phpfox::getService('apps.process')->updateApp($aVals, $aApp)) {
                 $this->url()->send('apps.add', array('id' => $aApp['app_id']), Phpfox::getPhrase('apps.successfully_updated_the_app'));
             }
         }
         // check that this user is owner of the app
         // we can have a user group setting here
         if ($aApp['user_id'] != Phpfox::getUserId() && !Phpfox::isAdmin()) {
             Phpfox_Error::display(Phpfox::getPhrase('apps.you_are_not_allowed_to_edit_this_app'));
         } else {
             $this->template()->assign(array('aApp' => $aApp))->setHeader(array('index.js' => 'module_apps'));
         }
     }
     $aCategories = Phpfox::getService('apps.category')->getAllCategories();
     $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('apps.editing_app') . ': ' . $aApp['app_title'] : Phpfox::getPhrase('apps.create_an_app'))->setFullSite()->setBreadcrumb(Phpfox::getPhrase('apps.apps'), $this->url()->makeUrl('apps'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('apps.editing_app') . ': ' . $aApp['app_title'] : Phpfox::getPhrase('apps.create_an_app'), $this->url()->makeUrl('apps.add'), true)->assign(array('aCategories' => $aCategories));
 }
示例#19
0
 /**
  * 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;
 }
示例#20
0
文件: init.php 项目: hoanghd/tools
							else 
							{
								$aParts = explode('/', $aUserInfo['birthday']);		
								$aVals['day'] = (isset($aParts[1]) ? $aParts[1] : '1');
								$aVals['month'] = (isset($aParts[0]) ? $aParts[0] : '1');
								$aVals['year'] = (isset($aParts[2]) ? $aParts[2] : '1982');
							}	
							
							define('PHPFOX_SKIP_EMAIL_INSERT', true);
							define('PHPFOX_IS_FB_USER', true);
							
							$iUserId = Phpfox::getService('user.process')->add($aVals);
							
							if ($iUserId === false)
							{
								Phpfox::getLib('url')->send('facebook.account', array('type' => 'no-account', 'error' => serialize(Phpfox_Error::get())));
							}
							else 
							{
								Phpfox::getService('facebook.process')->addUser($iUserId, $aUserInfo['id']);					
								
								$sImage = 'https://graph.facebook.com/me/picture?type=large&access_token=' . Phpfox::getService('facebook')->getToken();
								Phpfox::getLib('file')->writeToCache('fb_' . $iUserId . '_' . md5($sImage), file_get_contents($sImage));							
								$sNewImage = 'fb_' . $iUserId . '_' . md5($sImage) . '%s.jpg';
								copy(PHPFOX_DIR_CACHE . 'fb_' . $iUserId . '_' . md5($sImage), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''));
								foreach(Phpfox::getParam('user.user_pic_sizes') as $iSize)
								{
									Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize), $iSize, $iSize);
									Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize . '_square'), $iSize, $iSize, false);
								}	
								unlink(PHPFOX_DIR_CACHE . 'fb_' . $iUserId . '_' . md5($sImage));
示例#21
0
 public function processMerge()
 {
     Phpfox::isUser(true);
     $this->error(false);
     $aThread = Phpfox::getService('forum.thread')->getActualThread($this->get('thread_id'));
     $bHasAccess = false;
     $mReturn = false;
     if ((int) $aThread['group_id'] > 0) {
         $aPage = Phpfox::getService('pages')->getForView($aThread['group_id']);
         if (isset($aPage['is_admin']) && $aPage['is_admin']) {
             $bHasAccess = true;
         }
     } else {
         if (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($this->get('forum_id'), 'merge_thread')) {
             $bHasAccess = true;
         }
     }
     if ($bHasAccess) {
         $mReturn = Phpfox::getService('forum.thread.process')->merge($this->get('thread_id'), $this->get('forum_id'), $this->get('url'));
     } else {
         Phpfox_Error::set(Phpfox::getPhrase('forum.not_allowed_to_merge_threads_from_this_specific_forum'));
     }
     if ($mReturn !== false) {
         Phpfox::addMessage(Phpfox::getPhrase('forum.threads_successfully_merged'));
         $this->call('window.location.href = \'' . $mReturn . '\';');
     } else {
         $aErrors = Phpfox_Error::get();
         $sErrors = '';
         foreach ($aErrors as $sError) {
             $sErrors .= '<div class="error_message">' . $sError . '</div>';
         }
         $this->html('#js_error_message', '' . $sErrors . '');
     }
 }
示例#22
0
 /**
  * Starts the phpFox engine. Used to get and display the pages controller.
  *
  */
 public static function run()
 {
     if (isset($_REQUEST['m9callback'])) {
         header('Content-type: application/json');
         try {
             $Home = new Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY);
             $callback = $_REQUEST['m9callback'];
             unset($_GET['m9callback'], $_GET['do']);
             if (!$_GET) {
                 $_GET = [];
             }
             echo json_encode(call_user_func([$Home, $callback], $_GET));
         } catch (\Exception $e) {
             // throw new \Exception($e->getMessage(), 0, $e);
             echo json_encode(['error' => $e->getMessage()]);
         }
         exit;
     }
     $oTpl = Phpfox_Template::instance();
     $aLocale = Phpfox_Locale::instance()->getLang();
     $oReq = Phpfox_Request::instance();
     $oModule = Phpfox_Module::instance();
     if ($oReq->segment(1) == 'favicon.ico') {
         header('Content-type: image/x-icon');
         echo file_get_contents('http://www.phpfox.com/favicon.ico');
         exit;
     }
     $aStaticFolders = ['file', 'static', 'module', 'apps', 'Apps', 'themes'];
     if (in_array($oReq->segment(1), $aStaticFolders) || $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'demo' && $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'sample') {
         $sUri = Phpfox_Url::instance()->getUri();
         if ($sUri == '/static/ajax.php') {
             $oAjax = Phpfox_Ajax::instance();
             $oAjax->process();
             echo $oAjax->getData();
             exit;
         }
         if (Phpfox::getParam('core.url_rewrite') == '1') {
             header("HTTP/1.0 404 Not Found");
             header('Content-type: application/json');
             echo json_encode(['error' => 404]);
             exit;
         }
         $HTTPCache = new Core\HTTP\Cache();
         $HTTPCache->checkCache();
         $sDir = PHPFOX_DIR;
         if ($oReq->segment(1) == 'Apps' || $oReq->segment(1) == 'apps' || $oReq->segment(1) == 'themes') {
             $sDir = PHPFOX_DIR_SITE;
         }
         $sPath = $sDir . ltrim($sUri, '/');
         if ($oReq->segment(1) == 'themes' && $oReq->segment(2) == 'default') {
             $sPath = PHPFOX_DIR . str_replace('themes/default', 'theme/default', $sUri);
         }
         if ($oReq->segment(3) == 'emoticon') {
             $sPath = str_replace('/file/pic/emoticon/default/', PHPFOX_DIR . 'static/image/emoticon/', $sUri);
         }
         $sType = Phpfox_File::instance()->mime($sUri);
         $sExt = Phpfox_File::instance()->extension($sUri);
         if (!file_exists($sPath)) {
             $sPath = str_replace('PF.Base', 'PF.Base/..', $sPath);
             // header('Content-type: ' . $sType);
             if (!file_exists($sPath)) {
                 header("HTTP/1.0 404 Not Found");
                 header('Content-type: application/json');
                 echo json_encode(['error' => 404]);
                 exit;
             }
         }
         // header('Content-type: ' . $sType);
         $HTTPCache->cache($sType, filemtime($sPath), 7);
         if ($oReq->segment(1) == 'themes') {
             $Theme = $oTpl->theme()->get();
             $Service = new Core\Theme\Service($Theme);
             if ($sType == 'text/css') {
                 echo $Service->css()->getParsed();
             } else {
                 echo $Service->js()->get();
             }
         } else {
             echo @file_get_contents($sPath);
         }
         exit;
     }
     ($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false;
     // Load module blocks
     $oModule->loadBlocks();
     if (!Phpfox::getParam('core.branding')) {
         $oTpl->setHeader(array('<meta name="author" content="PHPfox" />'));
     }
     if (strtolower(Phpfox_Request::instance()->get('req1')) == Phpfox::getParam('admincp.admin_cp')) {
         self::$_bIsAdminCp = true;
     }
     $View = $oModule->setController();
     if ($View instanceof Core\View) {
     } else {
         if (!self::$_bIsAdminCp) {
             $View = new Core\View();
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         $oTpl->setImage(array('ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif'));
         $oTpl->setHeader(array('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />', '<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico?v=' . $oTpl->getStaticVersion() . '" />'))->setMeta('keywords', Phpfox_Locale::instance()->convert(Phpfox::getParam('core.keywords')))->setMeta('robots', 'index,follow');
         $oTpl->setHeader('cache', Phpfox::getMasterFiles());
         if (Phpfox::isModule('friend')) {
             $oTpl->setPhrase(array('friend.show_more_results_for_search_term'));
         }
         if (PHPFOX_DEBUG) {
             $oTpl->setHeader('cache', array('debug.css' => 'style_css'));
         }
         if (!Phpfox::isMobile() && Phpfox::isUser() && Phpfox::getParam('user.enable_user_tooltip')) {
             $oTpl->setHeader('cache', array('user_info.js' => 'static_script'));
         }
         if (Phpfox::isModule('captcha') && Phpfox::getParam('captcha.recaptcha')) {
             // http://www.phpfox.com/tracker/view/14456/
             $sUrl = (Phpfox::getParam('core.force_https_secure_pages') ? 'https' : 'http') . "://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
             $oTpl->setHeader('<script type="text/javascript" src="' . $sUrl . '"></script>');
         }
     }
     if ($sPlugin = Phpfox_Plugin::get('get_controller')) {
         eval($sPlugin);
     }
     $oTpl->assign(['aGlobalUser' => Phpfox::isUser() ? Phpfox::getUserBy(null) : array()]);
     $oModule->getController();
     Phpfox::getService('admincp.seo')->setHeaders();
     if (!defined('PHPFOX_DONT_SAVE_PAGE')) {
         Phpfox::getLib('session')->set('redirect', Phpfox_Url::instance()->getFullUrl(true));
     }
     if (!defined('PHPFOX_NO_CSRF')) {
         Phpfox::getService('log.session')->verifyToken();
     }
     ($sPlugin = Phpfox_Plugin::get('run')) ? eval($sPlugin) : false;
     if (!self::isAdminPanel()) {
         if (!Phpfox::isMobile() && !PHPFOX_IS_AJAX_PAGE && Phpfox::isModule('rss') && !defined('PHPFOX_IS_USER_PROFILE')) {
             $aFeeds = Phpfox::getService('rss')->getLinks();
             if (is_array($aFeeds) && count($aFeeds)) {
                 foreach ($aFeeds as $sLink => $sPhrase) {
                     $oTpl->setHeader('<link rel="alternate" type="application/rss+xml" title="' . $sPhrase . '" href="' . $sLink . '" />');
                 }
             }
         }
         $aPageLastLogin = Phpfox::isModule('pages') && Phpfox::getUserBy('profile_page_id') ? Phpfox::getService('pages')->getLastLogin() : false;
         $oTpl->assign(array('aMainMenus' => $oTpl->getMenu('main'), 'aSubMenus' => $oTpl->getMenu(), 'bIsUsersProfilePage' => defined('PHPFOX_IS_USER_PROFILE') ? true : false, 'sGlobalUserFullName' => Phpfox::isUser() ? Phpfox::getUserBy('full_name') : null, 'sFullControllerName' => str_replace(array('.', '/'), '_', Phpfox_Module::instance()->getFullControllerName()), 'iGlobalProfilePageId' => Phpfox::getUserBy('profile_page_id'), 'aGlobalProfilePageLogin' => $aPageLastLogin));
         $oTpl->setEditor();
         if (Phpfox::isModule('captcha')) {
             $sCaptchaHeader = Phpfox::getParam('captcha.recaptcha_header');
             if (strlen(preg_replace('/\\s\\s+/', '', $sCaptchaHeader)) > 0) {
                 $oTpl->setHeader(array($sCaptchaHeader));
             }
         }
         if (Phpfox::isModule('notification') && Phpfox::isUser() && Phpfox::getParam('notification.notify_on_new_request')) {
             $oTpl->setHeader('cache', array('update.js' => 'module_notification'));
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE && ($sHeaderFile = $oTpl->getHeaderFile())) {
         ($sPlugin = Phpfox_Plugin::get('run_get_header_file_1')) ? eval($sPlugin) : false;
         require_once $sHeaderFile;
     }
     list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb();
     $oTpl->assign(array('aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'sPublicMessage' => Phpfox::getMessage(), 'sLocaleDirection' => $aLocale['direction'], 'sLocaleCode' => $aLocale['language_code'], 'sLocaleFlagId' => $aLocale['image'], 'sLocaleName' => $aLocale['title'], 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'sCopyright' => '&copy; ' . Phpfox::getPhrase('core.copyright') . ' ' . Phpfox::getParam('core.site_copyright')));
     Phpfox::clearMessage();
     unset($_SESSION['phpfox']['image']);
     if (Phpfox::getParam('core.cron')) {
         require_once PHPFOX_DIR_CRON . 'exec.php';
     }
     if ($oReq->isPost()) {
         header('X-Is-Posted: true');
         exit;
     }
     if ($oReq->get('is_ajax_get')) {
         header('X-Is-Get: true');
         exit;
     }
     if (defined('PHPFOX_SITE_IS_OFFLINE')) {
         $oTpl->sDisplayLayout = 'blank';
         unset($View);
     }
     if (!PHPFOX_IS_AJAX_PAGE && $oTpl->sDisplayLayout && !isset($View) || !PHPFOX_IS_AJAX_PAGE && self::isAdminPanel()) {
         $oTpl->getLayout($oTpl->sDisplayLayout);
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         header('Content-type: application/json; charset=utf-8');
         /*
         if (isset($View) && $View instanceof \Core\View) {
         	$content = $View->getContent();
         }
         else {
         	Phpfox_Module::instance()->getControllerTemplate();
         	$content = ob_get_contents(); ob_clean();
         }
         */
         if ($View instanceof \Core\View) {
             $content = $View->getContent();
         } else {
             Phpfox_Module::instance()->getControllerTemplate();
             $content = ob_get_contents();
             ob_clean();
         }
         $oTpl->getLayout('breadcrumb');
         $breadcrumb = ob_get_contents();
         ob_clean();
         $aHeaderFiles = Phpfox_Template::instance()->getHeader(true);
         $aCss = [];
         $aLoadFiles = [];
         foreach ($aHeaderFiles as $sHeaderFile) {
             if (!is_string($sHeaderFile)) {
                 continue;
             }
             if (preg_match('/<style(.*)>(.*)<\\/style>/i', $sHeaderFile)) {
                 $aCss[] = strip_tags($sHeaderFile);
                 continue;
             }
             if (preg_match('/href=(["\']?([^"\'>]+)["\']?)/', $sHeaderFile, $aMatches) > 0 && strpos($aMatches[1], '.css') !== false) {
                 $sHeaderFile = str_replace(array('"', "'"), '', $aMatches[1]);
                 $sHeaderFile = substr($sHeaderFile, 0, strpos($sHeaderFile, '?'));
             }
             $sHeaderFile = strip_tags($sHeaderFile);
             $sNew = preg_replace('/\\s+/', '', $sHeaderFile);
             if (empty($sNew)) {
                 continue;
             }
             $aLoadFiles[] = $sHeaderFile;
         }
         $blocks = [];
         foreach (range(1, 12) as $location) {
             if ($location == 3) {
                 echo \Phpfox_Template::instance()->getSubMenu();
             }
             $aBlocks = Phpfox_Module::instance()->getModuleBlocks($location);
             $blocks[$location] = [];
             foreach ($aBlocks as $sBlock) {
                 Phpfox::getBlock($sBlock);
                 $blocks[$location][] = ob_get_contents();
                 ob_clean();
             }
         }
         $oTpl->getLayout('search');
         $search = ob_get_contents();
         ob_clean();
         Phpfox::getBlock('core.template-menusub');
         $menuSub = ob_get_contents();
         ob_clean();
         $h1 = '';
         if (isset($aBreadCrumbTitle[1])) {
             $h1 .= '<h1><a href="' . $aBreadCrumbTitle[1] . '">' . Phpfox_Parse_Output::instance()->clean($aBreadCrumbTitle[0]) . '</a></h1>';
         }
         $oTpl->getLayout('error');
         $error = ob_get_contents();
         ob_clean();
         $controller = Phpfox_Module::instance()->getFullControllerName();
         $data = json_encode(['content' => str_replace(['&#039;'], ["'"], Phpfox_Parse_Input::instance()->convert($content)), 'title' => html_entity_decode($oTpl->instance()->getTitle()), 'phrases' => Phpfox_Template::instance()->getPhrases(), 'files' => $aLoadFiles, 'css' => $aCss, 'breadcrumb' => $breadcrumb, 'blocks' => $blocks, 'search' => $search, 'menuSub' => $menuSub, 'id' => Phpfox_Module::instance()->getPageId(), 'class' => Phpfox_Module::instance()->getPageClass(), 'h1' => $h1, 'h1_clean' => strip_tags($h1), 'error' => $error, 'controller_e' => Phpfox::isAdmin() ? Phpfox_Url::instance()->makeUrl('admincp.element.edit', ['controller' => base64_encode(Phpfox_Module::instance()->getFullControllerName())]) : null, 'meta' => Phpfox_Template::instance()->getPageMeta(), 'keep_body' => Phpfox_Template::instance()->keepBody()]);
         // header("Content-length: " . strlen($data));
         echo $data;
         // sleep(4);
     } else {
         if (isset($View)) {
             echo $View->getContent();
         }
     }
 }
示例#23
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     define('PHPFOX_DONT_SAVE_PAGE', true);
     if (Phpfox::isUser()) {
         $this->url()->send('profile');
     }
     switch (Phpfox::getParam('user.login_type')) {
         case 'user_name':
             $aValidation['login'] = Phpfox::getPhrase('user.provide_your_user_name');
             break;
         case 'email':
             $aValidation['login'] = Phpfox::getPhrase('user.provide_your_email');
             break;
         default:
             $aValidation['login'] = Phpfox::getPhrase('user.provide_your_user_name_email');
     }
     $aValidation['password'] = Phpfox::getPhrase('user.provide_your_password');
     $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_login_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->getArray('val')) {
         if ($oValid->isValid($aVals)) {
             list($bLogged, $aUser) = Phpfox::getService('user.auth')->login($aVals['login'], $aVals['password'], isset($aVals['remember_me']) ? true : false, Phpfox::getParam('user.login_type'));
             if ($bLogged) {
                 $sReturn = '';
                 if (Phpfox::getParam('core.redirect_guest_on_same_page')) {
                     $sReturn = Phpfox::getLib('session')->get('redirect');
                     if (is_bool($sReturn)) {
                         $sReturn = '';
                     }
                     if ($sReturn) {
                         $aParts = explode('/', trim($sReturn, '/'));
                         if (isset($aParts[0])) {
                             $aParts[0] = Phpfox::getLib('url')->reverseRewrite($aParts[0]);
                         }
                         if (isset($aParts[0]) && !Phpfox::isModule($aParts[0])) {
                             $aUserCheck = Phpfox::getService('user')->getByUserName($aParts[0]);
                             if (isset($aUserCheck['user_id'])) {
                                 if (isset($aParts[1]) && !Phpfox::isModule($aParts[1])) {
                                     $sReturn = '';
                                 }
                             } else {
                                 $sReturn = '';
                             }
                         }
                     }
                 }
                 if (!$sReturn) {
                     $sReturn = Phpfox::getParam('user.redirect_after_login');
                 }
                 if ($sReturn == 'profile') {
                     $sReturn = $aUser['user_name'];
                 }
                 Phpfox::getLib('session')->remove('redirect');
                 if (preg_match('/^(http|https):\\/\\/(.*)$/i', $sReturn)) {
                     $this->url()->forward($sReturn);
                 }
                 $sReturn = trim($sReturn, '/');
                 $sReturn = str_replace('/', '.', $sReturn);
                 Phpfox::getLib('session')->remove('redirect');
                 if (isset($aUser['status_id']) && $aUser['status_id'] == 1) {
                     if (PHPFOX_IS_AJAX) {
                         echo 'window.location.href = "' . Phpfox::getLib('url')->makeUrl($sReturn) . '";';
                         die;
                     }
                     $this->url()->send($sReturn, null, Phpfox::getPhrase('user.you_still_need_to_verify_your_email_address'));
                 }
                 if (Phpfox::getParam('user.verify_email_at_signup')) {
                     $bDoRedirect = Phpfox::getLib('session')->get('verified_do_redirect');
                     Phpfox::getLib('session')->remove('verified_do_redirect');
                     if ((int) $bDoRedirect == 1 && Phpfox::getParam('user.redirect_after_signup') != '') {
                         $sReturn = Phpfox::getParam('user.redirect_after_signup');
                     }
                 }
                 if (PHPFOX_IS_AJAX) {
                     echo 'window.location.href = "' . Phpfox::getLib('url')->makeUrl($sReturn) . '";';
                     die;
                 }
                 $this->url()->send($sReturn);
             } else {
                 if (PHPFOX_IS_AJAX) {
                     $aErrors = Phpfox_Error::get();
                     Phpfox::getLib('ajax')->alert(implode(' ', $aErrors));
                     die;
                 }
                 if ($sPlugin = Phpfox_Plugin::get('user.controller_login_login_failed')) {
                     eval($sPlugin);
                 }
             }
         }
     }
     $sSiteName = Phpfox::getParam('core.site_title');
     $this->template()->setBreadCrumb(Phpfox::getPhrase('user.login_title'))->setTitle(Phpfox::getPhrase('user.login_title'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sSiteName' => $sSiteName, 'sSignUpPage' => $this->url()->makeUrl('user.register'), 'sDefaultEmailInfo' => $this->request()->get('email') ? trim(base64_decode($this->request()->get('email'))) : ''));
 }
示例#24
0
 public function removeCoverPhoto()
 {
     if (Phpfox::getService('pages.process')->removeCoverPhoto($this->get('page_id'))) {
         $this->call('window.location.href=window.location.href;');
     } else {
         $aErr = Phpfox_Error::get();
         $sErr = implode($aErr);
     }
 }
示例#25
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     if (!Phpfox::isUser()) {
         exit;
     }
     if (!Phpfox::getParam('video.allow_video_uploading') && !Phpfox::getParam('video.vidly_support')) {
         exit;
     }
     if (!Phpfox::getUserParam('video.can_upload_videos')) {
         exit;
     }
     $bMassUploader = Phpfox::getParam('video.video_enable_mass_uploader') && (isset($_POST['sMethod']) && $_POST['sMethod'] == 'massuploader');
     if (isset($_FILES['Filedata']) && !isset($_FILES['video'])) {
         $_FILES['video'] = $_FILES['Filedata'];
     }
     $bIsInline = false;
     $aVals = $this->request()->get('val');
     if (isset($aVals['video_inline'])) {
         $bIsInline = true;
     }
     if (!isset($_FILES['video'])) {
         echo '<script type="text/javascript">';
         if (!$bIsInline) {
             echo 'if (window.parent.$Core.exists(\'#js_video_upload_error\')){';
             echo 'window.parent.document.getElementById(\'js_video_upload_error\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_upload_message\').innerHTML = \'' . Phpfox::getPhrase('video.upload_failed_file_is_too_large') . '\';';
             echo 'window.parent.document.getElementById(\'js_upload_inner_form\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_detail\').style.display = \'none\';';
             echo 'window.parent.document.getElementById(\'js_video_process\').style.display = \'none\';';
             echo '}else{';
             echo 'window.parent.$Core.resetActivityFeedError(\'' . Phpfox::getPhrase('video.upload_failed_file_is_too_large') . '\');';
             echo '}';
         } else {
             echo 'window.parent.$Core.resetActivityFeedError(\'' . Phpfox::getPhrase('video.upload_failed_file_is_too_large') . '\');';
         }
         echo '</script>';
         exit;
     }
     if (($iFlood = Phpfox::getUserParam('video.flood_control_videos')) !== 0) {
         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('video'), 'condition' => 'view_id = 0 AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
         // actually check if flooding
         if (Phpfox::getLib('spam')->check($aFlood)) {
             Phpfox_Error::set(Phpfox::getPhrase('video.you_are_uploading_a_video_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
         }
     }
     if (!Phpfox_Error::isPassed()) {
         if (!empty($_FILES['video']['tmp_name'])) {
             Phpfox::getService('video.process')->delete();
         }
         echo '<script type="text/javascript">';
         if (!$bIsInline) {
             echo 'window.parent.document.getElementById(\'js_video_upload_error\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_upload_message\').innerHTML = \'' . implode('<br />', Phpfox_Error::get()) . '\';';
             echo 'window.parent.document.getElementById(\'js_upload_inner_form\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_detail\').style.display = \'none\';';
             echo 'window.parent.document.getElementById(\'js_video_process\').style.display = \'none\';';
         } else {
             // echo 'window.parent.$(\'.activity_feed_form_share_process\').hide(); window.parent.$(\'.activity_feed_form_button .button\').removeClass(\'button_not_active\'); window.parent.$bButtonSubmitActive = true;';
             echo 'window.parent.$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
         }
         echo '</script>';
         exit;
     }
     if ($iId = Phpfox::getService('video.process')->add($this->request()->get('val'))) {
         if (Phpfox::getParam('video.vidly_support')) {
             $aVideo = Phpfox::getService('video')->getVideo($iId, true);
             Phpfox::getLib('cdn')->put(Phpfox::getParam('video.dir') . sprintf($aVideo['destination'], ''));
             Phpfox::getLib('database')->insert(Phpfox::getT('vidly_url'), array('video_id' => $aVideo['video_id'], 'video_url' => rtrim(Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('video.url') . sprintf($aVideo['destination'], ''), $aVideo['server_id'])), 'upload_video_id' => '0'));
             $mReturn = Phpfox::getService('video')->vidlyPost('AddMedia', array('Source' => array('SourceFile' => rtrim(Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('video.url') . sprintf($aVideo['destination'], ''), $aVideo['server_id'])), 'CDN' => Phpfox::getParam('core.cdn_service') == 's3' ? 'S3' : 'RS')), 'vidid_' . $aVideo['video_id'] . '/');
             if ($bMassUploader) {
                 echo 'window.location.href = \'' . Phpfox::permalink('video', $iId, $aVideo['title']) . '\';';
             } else {
                 echo '<script type="text/javascript">';
                 echo 'window.parent.location.href = \'' . Phpfox::permalink('video', $iId, $aVideo['title']) . '\';';
                 echo '</script>';
             }
         } else {
             if ($bMassUploader) {
                 // echo 'uploadCompleted('.$iId.', "'.$this->request()->get('fObjectId').'");';
                 // echo '$(\'#js_video_process\').show();';
                 Phpfox::getLib('ajax')->alert(Phpfox::getLib('image.helper')->display(array('theme' => 'ajax/add.gif', 'class' => 'v_middle')) . ' ' . Phpfox::getPhrase('video.your_video_has_successfully_been_uploaded_please_standby_while_we_convert_your_video'), Phpfox::getPhrase('video.converting_video'), 600);
                 echo '$.ajaxCall(\'video.convert\', \'attachment_id=' . $iId . '&twitter_connection=' . (isset($aVals['connection']['twitter']) ? $aVals['connection']['twitter'] : '0') . '&facebook_connection=' . (isset($aVals['connection']) && isset($aVals['connection']['facebook']) ? $aVals['connection']['facebook'] : '0') . '&full=true&custom_pages_post_as_page=' . $this->request()->get('custom_pages_post_as_page') . '\', \'GET\');';
             } else {
                 echo '<script type="text/javascript">';
                 if (!$bIsInline) {
                     $sAlert = Phpfox::getLib('ajax')->alert(Phpfox::getLib('image.helper')->display(array('theme' => 'ajax/add.gif', 'class' => 'v_middle')) . ' ' . Phpfox::getPhrase('video.your_video_has_successfully_been_uploaded_please_standby_while_we_convert_your_video'), Phpfox::getPhrase('video.converting_video'), 600, 150, false, true);
                     echo str_replace('tb_show', 'window.parent.tb_show', str_replace('$.ajaxBox', 'window.parent.$.ajaxBox', $sAlert));
                 }
                 echo 'window.parent.$.ajaxCall(\'video.convert\', \'attachment_id=' . $iId . '&twitter_connection=' . (isset($aVals['connection']['twitter']) ? $aVals['connection']['twitter'] : '0') . '&facebook_connection=' . (isset($aVals['connection']) && isset($aVals['connection']['facebook']) ? $aVals['connection']['facebook'] : '0') . '&' . ($bIsInline ? 'inline=true' : 'full=true') . '&custom_pages_post_as_page=' . $this->request()->get('custom_pages_post_as_page') . '\', \'GET\');';
                 echo '</script>';
                 // $this->url()->send('video.convert', array('id' => $iId, 'editor-id' => base64_encode($this->request()->get('editor_id')), 'video-inline' => ($bIsInline ? '1' : '0'), 'isajax' => $this->request()->get('is_ajax', '0')));
             }
         }
     } else {
         if (!empty($_FILES['video']['tmp_name'])) {
             Phpfox::getService('video.process')->delete($this->request()->get('video_id'));
         }
         echo '<script type="text/javascript">';
         if (!$bIsInline) {
             echo 'window.parent.document.getElementById(\'js_video_upload_error\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_upload_message\').innerHTML = \'' . implode('<br />', Phpfox_Error::get()) . '\';';
             echo 'window.parent.document.getElementById(\'js_upload_inner_form\').style.display = \'block\';';
             echo 'window.parent.document.getElementById(\'js_video_detail\').style.display = \'none\';';
             echo 'window.parent.document.getElementById(\'js_video_process\').style.display = \'none\';';
         } else {
             // echo 'window.parent.$(\'.activity_feed_form_share_process\').hide(); window.parent.$(\'.activity_feed_form_button .button\').removeClass(\'button_not_active\'); window.parent.$bButtonSubmitActive = true;';
             echo 'window.parent.$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
         }
         echo '</script>';
     }
     exit;
 }
示例#26
0
 public function run()
 {
     if ($this->_bUpgrade && (int) substr($this->_getCurrentVersion(), 0, 1) < 2 && file_exists(PHPFOX_DIR . '.htaccess')) {
         $sHtaccessContent = file_get_contents(PHPFOX_DIR . '.htaccess');
         if (preg_match('/RewriteEngine/i', $sHtaccessContent)) {
             exit('In order for us to continue with the upgrade you will need to rename or remove the file ".htaccess".');
         }
     }
     $sStep = $this->_oReq->get('step') ? strtolower($this->_oReq->get('step')) : 'start';
     // $this->_oTpl->setTitle(self::getPhrase('phpfox_installer'))->setBreadcrumb(self::getPhrase('phpfox_installer'));
     $bPass = false;
     if (!in_array($sStep, $this->_aSteps)) {
         if (in_array($sStep, $this->_aModuleInstalls)) {
             $bPass = true;
         } else {
             exit('Invalid step.');
         }
     }
     $sMethod = '_' . $sStep;
     $iStep = 0;
     foreach ($this->_aSteps as $iKey => $sMyStep) {
         if ($sMyStep === $sStep) {
             $iStep = $iKey - 1;
             break;
         }
     }
     if ($bPass === false && isset($this->_aSteps[$iStep]) && !$this->_isPassed($this->_aSteps[$iStep])) {
         $this->_oUrl->forward($this->_step($this->_aSteps[$iStep]));
     }
     $this->_sStep = $sStep;
     $this->_oTpl->assign(['sUrl' => $this->_sUrl]);
     if (method_exists($this, $sMethod)) {
         $data = call_user_func(array(&$this, $sMethod));
         if (!Phpfox_Error::isPassed()) {
             $data = ['errors' => Phpfox_Error::get()];
         }
         if ($sStep != 'start' && !is_array($data)) {
             $content = $this->_oTpl->getLayout($sStep, true);
             $data = ['content' => $content];
         }
         if (is_array($data)) {
             header('Content-type: application/json');
             echo json_encode($data);
             exit;
         }
     } else {
         $sStep = 'start';
     }
     if (!file_exists($this->_oTpl->getLayoutFile($sStep))) {
         $sStep = 'default';
     }
     list($aBreadCrumbs, $aBreadCrumbTitle) = $this->_oTpl->getBreadCrumb();
     /*
     $this->_oTpl->setImage(array(
     		'ajax_small' => 'ajax/small.gif',
     		'ajax_large' => 'ajax/large.gif',
     		'loading_animation' => 'misc/loading_animation.gif',
     		'close' => 'misc/close.gif'
     	)
     );
     */
     $base = self::getHostPath() . 'PF.Base/';
     $this->_oTpl->setHeader(array('<script>var BasePath = \'' . self::getHostPath() . '\';</script>', '<link href="' . $base . 'theme/install/default/style/default/css/layout.css" rel="stylesheet">', '<link href="' . $base . 'static/css/font-awesome.min.css" rel="stylesheet">', '<script src="' . $base . 'static/jscript/jquery/jquery.js"></script>', '<script src="' . $base . 'static/jscript/install.js"></script>'))->assign(array('sTemplate' => $sStep, 'sLocaleDirection' => 'ltr', 'sLocaleCode' => 'en', 'sUrl' => $this->_sUrl, 'aErrors' => Phpfox_Error::get(), 'sPublicMessage' => Phpfox::getMessage(), 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'aSteps' => $this->_getSteps(), 'sCurrentVersion' => Phpfox::getVersion()));
     if ($this->_bUpgrade) {
         $this->_oTpl->setTitle('Upgrading from: ' . $this->_getCurrentVersion());
     }
     $this->_oTpl->getLayout('template');
     Phpfox::clearMessage();
 }
示例#27
0
 public function addInactiveJob()
 {
     $iId = Phpfox::getService('user.process')->addInactiveJob($this->get('iDays'), $this->get('iBatchSize'));
     if ($iId == false) {
         $sErr = implode('.', Phpfox_Error::get());
         $this->alert($sErr);
         return false;
     }
     $this->html('#progress', Phpfox::getPhrase('mail.processing_batch_number', array('number' => 1)));
     $this->call('startJob(' . $iId . ');');
     $this->call('processJob(' . $iId . ');');
 }
示例#28
0
    /**
     * Class process method wnich is used to execute this component.
     */
    public function process()
    {
        Phpfox::isUser(true);
        Phpfox::getUserParam('music.can_upload_music_public', true);
        $sModule = $this->request()->get('module', false);
        $iItem = $this->request()->getInt('item', false);
        $aCallback = false;
        if ($sModule !== false && $iItem !== false && Phpfox::hasCallback($sModule, 'getMusicDetails')) {
            if ($aCallback = Phpfox::callback($sModule . '.getMusicDetails', array('item_id' => $iItem))) {
                $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
                $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
                if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItem, 'music.share_music')) {
                    return Phpfox_Error::display('Unable to view this item due to privacy settings.');
                }
            }
        }
        $bIsEdit = false;
        $aValidation = array('title' => Phpfox::getPhrase('music.provide_a_name_for_this_song'));
        $oValidator = Phpfox::getLib('validator')->set(array('sFormName' => 'js_music_form', 'aParams' => $aValidation));
        if (($iId = $this->request()->getInt('id')) && ($aEditSong = Phpfox::getService('music')->getForEdit($iId))) {
            if ($aEditSong['module_id'] == 'pages') {
                Phpfox::getService('pages')->setIsInPage();
            }
            $bIsEdit = true;
            $this->template()->assign(array('aForms' => $aEditSong));
        }
        $sMethod = Phpfox::getParam('music.music_enable_mass_uploader') && $this->request()->get('method', 'massuploader') == 'massuploader' ? 'massuploader' : 'simple';
        // used to tell the template where to link for the opposite method
        $sMethodUrl = str_replace(array('method_simple/', 'method_massuploader/'), '', $this->url()->getFullUrl()) . 'method_' . ($sMethod == 'simple' ? 'massuploader' : 'simple') . '/';
        $aVals = $this->request()->getArray('val');
        if (isset($aVals['method'])) {
            $sMethod = $aVals['method'];
        }
        if ($bIsEdit && !empty($aVals) && $this->request()->get('upload_via_song')) {
            if ($oValidator->isValid($aVals)) {
                if (Phpfox::getService('music.process')->update($aEditSong['song_id'], $aVals)) {
                    $this->url()->permalink('music', $aEditSong['song_id'], $aEditSong['title'], true, 'Song successfully updated.');
                }
            }
        } else {
            if ($sMethod == 'simple' && !empty($aVals)) {
                if (isset($aVals['music_title'])) {
                    $aVals['title'] = $aVals['music_title'];
                }
                if ($oValidator->isValid($aVals)) {
                    if ($aSong = Phpfox::getService('music.process')->upload($aVals, isset($aVals['album_id']) ? (int) $aVals['album_id'] : 0)) {
                        if (isset($aVals['iframe'])) {
                            if (isset($aVals['music_title'])) {
                                $iFeedId = Phpfox::getService('feed.process')->getLastId();
                                echo "<script type=\"text/javascript\">";
                                if (Phpfox::isModule('video') && Phpfox::getParam('video.convert_servers_enable')) {
                                    echo 'document.domain = "' . Phpfox::getParam('video.convert_js_parent') . '";';
                                }
                                ($sPlugin = Phpfox_Plugin::get('music.component_controller_upload_feed')) ? eval($sPlugin) : false;
                                echo 'window.parent.$.ajaxCall(\'music.displayFeed\', \'id=' . $iFeedId . '&song_id=' . $aSong['song_id'] . '\', \'GET\');';
                                echo "</script>";
                            } else {
                                Phpfox::addMessage(Phpfox::getPhrase('music.song_successfully_uploaded'));
                                echo "<script type=\"text/javascript\">";
                                echo 'window.parent.location.href = "' . $this->url()->makeUrl('music.album.track', array('id' => $aVals['album_id'], 'method' => 'simple')) . '";';
                                echo '</script>';
                            }
                        } else {
                            Phpfox::addMessage(Phpfox::getPhrase('music.song_successfully_uploaded'));
                            echo "<script type=\"text/javascript\">";
                            echo 'window.parent.location.href = "' . $this->url()->permalink('music', $aSong['song_id'], $aSong['title']) . '";';
                            echo '</script>';
                            exit;
                        }
                        exit;
                    } else {
                        if (isset($aVals['music_title'])) {
                            echo "<script type=\"text/javascript\">";
                            echo 'window.parent.$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
                            echo "</script>";
                        } else {
                            echo "<script type=\"text/javascript\">";
                            echo 'window.parent.$(\'#js_music_upload_song\').show(); window.parent.$(\'.js_upload_song\').remove();';
                            echo 'window.parent.alert(\'' . implode('\\n', Phpfox_Error::get()) . '\');';
                            echo "</script>";
                            exit;
                        }
                    }
                } else {
                    if (isset($aVals['music_title'])) {
                        echo "<script type=\"text/javascript\">";
                        echo 'window.parent.$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
                        echo "</script>";
                    } else {
                        echo '<script type="text/javascript">';
                        echo 'window.parent.$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
                        echo 'window.parent.$Core.music.resetUploadForm(\'' . implode('<br />', Phpfox_Error::get()) . '\');';
                        echo '</script>';
                        exit;
                    }
                }
            } elseif ($sMethod == 'massuploader' && isset($_FILES['Filedata'])) {
                $_FILES['mp3'] = $_FILES['Filedata'];
                if ($aSong = Phpfox::getService('music.process')->upload($aVals, isset($aVals['album_id']) ? (int) $aVals['album_id'] : 0)) {
                    if (isset($aVals['inline'])) {
                        $aSong = Phpfox::getService('music')->getSong($aSong['song_id']);
                        $this->template()->assign(array('aSong' => $aSong));
                        $this->template()->getTemplate('music.block.track-entry');
                        $sOutput = Phpfox::getLib('ajax')->getContent(false);
                        Phpfox::addMessage(Phpfox::getPhrase('music.song_successfully_uploaded'));
                        echo 'window.location.href = "' . $this->url()->makeUrl('music.album.track', array('id' => $aVals['album_id'])) . '";';
                        exit;
                    }
                    echo 'window.location.href = "' . $this->url()->permalink('music', $aSong['song_id'], $aSong['title']) . '";';
                    exit;
                } else {
                    echo '$(\'#js_music_upload_song\').show(); $(\'.js_upload_song\').remove();';
                    echo 'alert(\'' . implode('\\n', Phpfox_Error::get()) . '\');';
                    exit;
                }
            }
        }
        if ($sMethod == 'massuploader') {
            $iMaxFileSize = Phpfox::getUserParam('music.music_max_file_size') === 0 ? null : Phpfox::getUserParam('music.music_max_file_size');
            $this->template()->setHeader('cache', array('massuploader/swfupload.js' => 'static_script', 'massuploader/upload.js' => 'static_script', '<script type="text/javascript">
						$oSWF_settings =
						{
							object_holder: function()
							{
								return \'swf_music_upload_button_holder\';
							},
							
							div_holder: function()
							{
								return \'swf_music_upload_button\';
							},
							
							get_settings: function()
							{		
								swfu.setUploadURL("' . $this->url()->makeUrl('music.upload') . '");
								swfu.setFileSizeLimit("' . $iMaxFileSize . ' MB");
								swfu.setFileUploadLimit(1);
								swfu.setFileQueueLimit(1);
								swfu.customSettings.flash_user_id = ' . Phpfox::getUserId() . ';
								swfu.customSettings.sHash = "' . Phpfox::getService('core')->getHashForUpload() . '";
								swfu.setFileTypes("*.mp3","*.mp3");
								swfu.atFileQueue = function()
								{
									$(\'#js_music_form :input\').each(function(iKey, oObject)
									{
										swfu.addPostParam($(oObject).attr(\'name\'), $(oObject).val());
									});
								}
							}
						}
					</script>', 'upload.css' => 'module_music'))->setPhrase(array('core.name', 'core.status', 'core.in_queue', 'core.upload_failed_your_file_size_is_larger_then_our_limit_file_size', 'core.more_queued_than_allowed'));
        }
        $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('music.editing_song') . ': ' . $aEditSong['title'] : Phpfox::getPhrase('music.upload_a_song'))->setBreadcrumb(Phpfox::getPhrase('music.music'), $aCallback === false ? $this->url()->makeUrl('music') : $aCallback['url_home_photo'])->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('music.editing_song') . ': ' . $aEditSong['title'] : Phpfox::getPhrase('music.upload_a_song'), $this->url()->makeUrl('music.upload'), true)->setFullSite()->setPhrase(array('music.select_an_mp3'))->setHeader('cache', array('upload.js' => 'module_music', 'progress.css' => 'style_css', 'progress.js' => 'static_script', '<script type="text/javascript">$Behavior.musicUpload = function(){ if ($Core.exists(\'#js_music_form_holder\')) { oProgressBar = {holder: \'#js_music_form_holder\', progress_id: \'#js_progress_bar\', total: 1, max_upload: 1, uploader: \'#js_progress_uploader\', frame_id: \'js_upload_frame\', file_id: \'mp3\'}; $Core.progressBarInit(); }}</script>'))->assign(array('sModule' => $sModule, 'iItem' => $iItem, 'bIsEdit' => $bIsEdit, 'aUploadAlbums' => Phpfox::getService('music.album')->getForUpload($aCallback), 'sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm(false), 'iUploadLimit' => Phpfox::getLib('file')->getLimit(Phpfox::getUserParam('music.music_max_file_size')), 'aGenres' => Phpfox::getService('music.genre')->getList(), 'sMethod' => $sMethod, 'sMethodUrl' => $sMethodUrl));
    }
示例#29
0
 public function doGiftPoints()
 {
     if (Phpfox::getService('user.activity')->doGiftPoints($this->get('user_id'), $this->get('amount'))) {
         $this->html('#div_show_gift_points', Phpfox::getPhrase('core.gift_sent_successfully'));
     } else {
         $sError = Phpfox_Error::get();
         $this->html('#div_show_gift_points', 'An error occurred: ' . array_pop($sError));
     }
 }
示例#30
0
 /**
  * This is the final output to the browser once the AJAX request is complete.
  *
  * @return string Data to return back to the browser. It must be JavaScript code.
  */
 public function getData()
 {
     if ($this->get('js_block_click_lis_cache')) {
         $this->remove('.js_block_click_lis_cache');
     }
     if ($this->get('global_ajax_message')) {
         $this->hide('#global_ajax_message');
     }
     if (empty($this->_aRequest)) {
         return '';
     }
     if (isset($this->_aRequest['call']) && $this->_aRequest['call'] != 'im.getRooms' && $this->_aRequest['call'] != 'im.getMessages' && !isset(self::$_aParams['js_disable_ajax_restart'])) {
         if (isset($this->_aRequest['last_call'])) {
             if ($this->_aRequest['call'] != 'im.load' && $this->_aRequest['call'] != 'im.open' && $this->_aRequest['call'] != 'im.chat' && $this->_aRequest['call'] != 'im.close' && $this->_aRequest['call'] != 'im.getRooms' && $this->_aRequest['call'] != 'im.getMessages') {
                 switch ($this->_aRequest['last_call']) {
                     case 'im.getRooms':
                         $this->call("\$.ajaxCall('im.getRooms','','GET');");
                         break;
                     case 'im.getMessages':
                         $this->call("\$.ajaxCall('im.getMessages', 'im_id=" . $this->_aRequest['last_param'] . "','GET');");
                         break;
                 }
             }
         }
     }
     $sXml = '';
     foreach (self::$_aCalls as $sCall) {
         $sXml .= $this->_ajaxSafe($sCall);
     }
     ($sPlugin = Phpfox_Plugin::get('ajax_getdata')) ? eval($sPlugin) : false;
     if (self::$_bShowErrors && !Phpfox_Error::isPassed()) {
         $sErrors = '';
         foreach (Phpfox_Error::get() as $sError) {
             $sErrors .= '<div class="error_message">' . $sError . '</div>';
         }
         echo $sXml;
         if (self::$_sErrorHolder !== null) {
             self::$_aCalls = array();
             $this->show(self::$_sErrorHolder)->html(self::$_sErrorHolder, $sErrors);
             return implode('', self::$_aCalls);
         } else {
             $this->alert($sErrors, empty($this->sPopupMessage) ? Phpfox::getPhrase('core.error') : $this->sPopupMessage);
         }
         return '';
     }
     return $sXml;
 }