/** * Controller */ public function process() { if (!$this->getParam('bIsValidImage')) { return false; } $aUser = $this->getParam('aUser'); $aPhoto = $this->getParam('aPhoto'); $bIsInPhoto = $this->getParam('is_in_photo'); if ($aPhoto === null) { return false; } $sCategories = ''; if (isset($aPhoto['categories']) && is_array($aPhoto['categories'])) { foreach ($aPhoto['categories'] as $aCategory) { $sCategories .= $aCategory[0] . ','; } $sCategories = rtrim($sCategories, ','); } $aInfo = array(Phpfox::getPhrase('photo.added') => '<span itemprop="dateCreated">' . Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aPhoto['time_stamp']) . '</span>', Phpfox::getPhrase('photo.category') => $sCategories, Phpfox::getPhrase('photo.file_size') => Phpfox_File::instance()->filesize($aPhoto['file_size']), Phpfox::getPhrase('photo.resolution') => $aPhoto['width'] . '×' . $aPhoto['height'], Phpfox::getPhrase('photo.comments') => $aPhoto['total_comment'], Phpfox::getPhrase('photo.views') => '<span itemprop="interactionCount">' . $aPhoto['total_view'] . '</span>', Phpfox::getPhrase('photo.rating') => round($aPhoto['total_rating']), Phpfox::getPhrase('photo.battle_wins') => round($aPhoto['total_battle']), Phpfox::getPhrase('photo.downloads') => $aPhoto['total_download']); if ($bIsInPhoto) { unset($aInfo[Phpfox::getPhrase('photo.added')]); } foreach ($aInfo as $sKey => $mValue) { if (empty($mValue)) { unset($aInfo[$sKey]); } } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('photo.image_details'), 'aPhotoDetails' => $aInfo, 'bIsInPhoto' => $bIsInPhoto, 'sUrlPath' => preg_match("/\\{file\\/pic\\/(.*)\\/(.*)\\.jpg\\}/i", $aPhoto['destination'], $aMatches) ? Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]) : ($aPhoto['server_id'] && Phpfox::getParam('core.allow_cdn') ? Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500'), $aPhoto['server_id']) : Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500')))); // return 'block'; }
public function process() { $check = array(); $unknown = array(); if ($this->request()->get('check')) { $this->template()->assign('check', true); $lines = file(PHPFOX_DIR_INCLUDE . 'checksum/md5'); foreach ($lines as $line) { $line = trim($line); $parts = explode(' ', $line); $check[trim($parts[1])] = true; } $files = Phpfox_File::instance()->getAllFiles(PHPFOX_DIR); foreach ($files as $file) { $file = str_replace(PHPFOX_DIR, '', $file); if (substr($file, -15) == 'server.sett.php' || substr($file, 0, 5) == 'file/' || substr($file, 0, 8) == 'install/' || $file == '.DS_Store' || $file == '.htaccess' || $file == 'include/setting/dev.sett.php') { continue; } if (!isset($check[$file])) { $unknown[] = $file; } // $check[str_replace(PHPFOX_DIR, '', $file)] = md5(file_get_contents($file)); // echo $hash . " " . $file . "\n"; } } $this->template()->setTitle('Checking Unknown Files')->setSectionTitle('Unknown Files')->assign(array('url' => $this->url()->makeUrl('admincp.checksum.unknown', ['check' => true]), 'unknown' => $unknown, 'total' => count($unknown))); }
public function export($sIso) { $aCountry = $this->database()->select('*')->from(Phpfox::getT('country'))->where('country_iso = \'' . $this->database()->escape($sIso) . '\'')->execute('getRow'); if (!isset($aCountry['country_iso'])) { return false; } $aChildren = $this->database()->select('*')->from(Phpfox::getT('country_child'))->where('country_iso = \'' . $this->database()->escape($sIso) . '\'')->execute('getRows'); if (!count($aChildren)) { return false; } $oXmlBuilder = Phpfox::getLib('xml.builder'); $oXmlBuilder->addGroup('country'); $oXmlBuilder->addGroup('info'); $oXmlBuilder->addTag('iso', $aCountry['country_iso']); $oXmlBuilder->addTag('name', $aCountry['name']); $oXmlBuilder->closeGroup(); if (count($aChildren)) { $oXmlBuilder->addGroup('children'); foreach ($aChildren as $aChild) { $oXmlBuilder->addTag('child', $aChild['name']); } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); $sCacheName = 'country_export_cache_' . md5($aCountry['country_iso'] . PHPFOX_TIME) . '.xml'; Phpfox_File::instance()->writeToCache($sCacheName, $oXmlBuilder->output()); return array('name' => $aCountry['country_iso'], 'file' => $sCacheName); }
public function set($content) { $dir = $this->_theme->getPath() . 'html/'; if (!is_dir($dir)) { mkdir($dir); } $path = $this->_theme->getPath() . 'html/layout.html'; file_put_contents($path, $content); $twig = PHPFOX_DIR_FILE . 'cache/twig/'; if (is_dir($twig)) { \Phpfox_File::instance()->delete_directory($twig); } /* if ($this->_get()) { $this->db->update(':theme_template', [ 'html_data' => $content, 'time_stamp_update' => PHPFOX_TIME ], [ 'folder' => $this->_theme->folder, 'type_id' => 'theme', 'name' => 'layout.html' ]); return true; } $this->db->insert(':theme_template', [ 'folder' => $this->_theme->folder, 'type_id' => 'theme', 'name' => 'layout.html', 'html_data' => $content, 'html_data_original' => $content, 'time_stamp' => PHPFOX_TIME ]); */ return true; }
/** * @param $val * @param null $files * @return Theme\Object */ public function make($val, $files = null) { /* $check = $this->db->select('COUNT(*) AS total') ->from(':theme') ->where(['folder' => $val['folder']]) ->get(); if ($check['total']) { throw error('Folder already exists.'); } */ $id = $this->db->insert(':theme', ['name' => $val['name'], 'website' => isset($val['extra']) ? $val['extra'] : null, 'created' => PHPFOX_TIME, 'is_active' => 1]); $this->db->update(':theme', ['folder' => $id], ['theme_id' => $id]); if ($files !== null) { foreach ($files as $name => $content) { $path = PHPFOX_DIR_SITE . 'themes/' . $id . '/' . $name; $parts = pathinfo($path); if (!is_dir($parts['dirname'])) { mkdir($parts['dirname'], 0777, true); } file_put_contents($path, $content); } return $id; } $flavorId = $this->db->insert(':theme_style', ['theme_id' => $id, 'is_active' => 1, 'is_default' => 1, 'name' => 'Default']); $this->db->update(':theme_style', ['folder' => $flavorId], ['style_id' => $flavorId]); $File = \Phpfox_File::instance(); $copy = []; $dirs = []; $files = $File->getAllFiles(PHPFOX_DIR . 'theme/default/'); foreach ($files as $file) { if (!in_array($File->extension($file), ['html', 'js', 'css', 'less'])) { continue; } $parts = pathinfo($file); $dirs[] = str_replace(PHPFOX_DIR . 'theme/default/', '', $parts['dirname']); $copy[] = $file; } $path = PHPFOX_DIR_SITE . 'themes/' . $id . '/'; foreach ($dirs as $dir) { if (!is_dir($path . $dir)) { mkdir($path . $dir, 0777, true); } } foreach ($copy as $file) { $newFile = $path . str_replace(PHPFOX_DIR . 'theme/default/', '', $file); if (in_array($File->extension($file), ['less', 'css'])) { $newFile = str_replace('default.' . $File->extension($file), $flavorId . '.' . $File->extension($file), $newFile); } copy($file, $newFile); if ($File->extension($file) == 'less') { $content = file_get_contents($newFile); $content = str_replace('../../../', '../../../../PF.Base/', $content); file_put_contents($newFile, $content); } } return $this->get($id); }
/** * Controller */ public function process() { $aUser = Phpfox::getService('user')->get(Phpfox::getUserId(), true); $aGroup = Phpfox::getService('user.group')->getGroup($aUser['user_group_id']); $aInfo = array(Phpfox::getPhrase('core.membership') => (empty($aGroup['icon_ext']) ? '' : '<img src="' . Phpfox::getParam('core.url_icon') . $aGroup['icon_ext'] . '" class="v_middle" alt="' . Phpfox_Locale::instance()->convert($aGroup['title']) . '" title="' . Phpfox_Locale::instance()->convert($aGroup['title']) . '" /> ') . $aGroup['prefix'] . Phpfox_Locale::instance()->convert($aGroup['title']) . $aGroup['suffix'], Phpfox::getPhrase('core.activity_points') => $aUser['activity_points'], Phpfox::getPhrase('core.profile_views') => $aUser['total_view'], Phpfox::getPhrase('core.space_used') => Phpfox::getUserParam('user.total_upload_space') === 0 ? Phpfox::getPhrase('user.space_total_out_of_unlimited', array('space_total' => Phpfox_File::instance()->filesize($aUser['space_total']))) : Phpfox::getPhrase('user.space_total_out_of_total', array('space_total' => Phpfox_File::instance()->filesize($aUser['space_total']), 'total' => Phpfox::getUserParam('user.total_upload_space'))), Phpfox::getPhrase('core.member_since') => Phpfox::getLib('date')->convertTime($aUser['joined'], 'core.profile_time_stamps')); if (Phpfox::isModule('rss')) { $aInfo[Phpfox::getPhrase('rss.rss_subscribers')] = '<a href="#" onclick="tb_show(\'' . Phpfox::getPhrase('rss.rss_subscribers_log') . '\', $.ajaxBox(\'rss.log\', \'height=500&width=500\')); return false;">' . $aUser['rss_count'] . '</a>'; } $this->template()->assign(array('aInfos' => $aInfo)); }
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 page_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('pages.add_page') == false) { return $this->_oApi->error('pages.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('pages.process')->add($aInsert); if (!$iId) { return $this->_oApi->error('pages.unable_to_add_page', implode('', Phpfox_Error::get())); } $aPages = $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('pages.dir_image') . $aPages[0]['page_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_File::instance(); $oImage = Phpfox_Image::instance(); $aImage = $oFile->load('photo', array('jpg', 'gif', 'png'), Phpfox::getUserParam('pages.max_upload_size_pages') === 0 ? null : Phpfox::getUserParam('pages.max_upload_size_pages') / 1024); $sFileName = $oFile->upload('photo', Phpfox::getParam('pages.dir_image'), $iId); $sPath = Phpfox::getParam('pages.dir_image'); $iFileSizes = filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '')); $aUpdate['image_path'] = $sFileName; $aUpdate['image_server_id'] = Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'); $iSize = 50; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); $iSize = 120; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); $iSize = 200; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); define('PHPFOX_PAGES_IS_IN_UPDATE', true); Phpfox::getService('user.process')->uploadImage($aPages[0]['profile_user_id'], true, Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '')); // Update user space usage Phpfox::getService('user.space')->update(Phpfox::getUserId(), 'pages', $iFileSizes); $this->database()->update($this->_sTable, $aUpdate, 'page_id = ' . (int) $iId); $aPages = $this->get($iId); } return $aPages[0]; }
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 add() { /* @title @info @method POST @extra title=#{Title of the listing|string|yes}¤cy_id=#{Currency ID. Use [action]core.getCurrencies[/action] to get a list of valid currencies|string|yes}&price=#{Price|decimal|no}&country_iso=#{Country ISO ID. Use [action]core.getCurrencies[/action]|string|no}&country_child_id=#{State/Province ID#. Use [action]core.getCurrencies[/action]|int|no}&postal_code=#{Postal code|string|no}&city=#{City|string|no}&mini_description=#{Mini description|string|yes}&description=#{Description|string|yes}&category=#{Comma separated category ID#'s. Use [action]marketplace.categories[/action]|string|yes}&images=#{Comma separated URL to images|string|no} @return id=#{Item ID#|int}&title=#{Title of the item|string}&description=#{Description of the item|string}&likes=#{Total number of likes|int}&permalink=#{Link to the item|string}&mini_description=#{Mini description of the listing|string}¤cy_id=#{Currency ID|string}&price=#{Price|decimal}&country_iso=#{Country ISO|string}&postal_code=#{Postal code|string}&city=#{City|string}&images=#{Array of images|array} */ $aCategories = array(); if ($this->_oApi->get('category')) { $aCategories = explode(',', $this->_oApi->get('category')); } $aVals = array('title' => $this->_oApi->get('title'), 'currency_id' => $this->_oApi->get('currency_id'), 'price' => $this->_oApi->get('price'), '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'), 'mini_description' => $this->_oApi->get('mini_description'), 'description' => $this->_oApi->get('description'), 'category' => (array) $aCategories); if (($iId = Phpfox::getService('marketplace.process')->add($aVals)) !== false) { if ($this->_oApi->get('images') != '') { $oImage = Phpfox_Image::instance(); $oFile = Phpfox_File::instance(); $aSizes = array(50, 120, 200, 400); $iFileSizes = 0; foreach (explode(',', $this->_oApi->get('images')) as $sImage) { $sType = $oFile->getFileExt($sImage); $sImageContent = file_get_contents($sImage); $sImagePath = Phpfox::getParam('marketplace.dir_image') . $iId . '.' . $sType; $hFile = fopen($sImagePath, 'w'); fwrite($hFile, $sImageContent); fclose($hFile); $_FILES['photo']['error'] = ''; $_FILES['photo']['tmp_name'] = $sImagePath; $_FILES['photo']['name'] = basename($sImagePath); if ($aImage = $oFile->load('photo', array('jpg', 'gif', 'png'), Phpfox::getUserParam('marketplace.max_upload_size_listing') === 0 ? null : Phpfox::getUserParam('marketplace.max_upload_size_listing') / 1024)) { $sFileName = Phpfox_File::instance()->upload('photo', Phpfox::getParam('marketplace.dir_image'), $iId); $iFileSizes += filesize(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '')); $this->database()->insert(Phpfox::getT('marketplace_image'), array('listing_id' => $iId, 'image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'))); foreach ($aSizes as $iSize) { $oImage->createThumbnail(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $oImage->createThumbnail(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize . '_square'), $iSize, $iSize, false); $iFileSizes += filesize(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize)); } } } if ($iFileSizes === 0) { return false; } $this->database()->update($this->_sTable, array('image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')), 'listing_id = ' . $iId); Phpfox::getService('user.space')->update(Phpfox::getUserId(), 'marketplace', $iFileSizes); } $aReturn = $this->get($iId); return $aReturn[0]; } }
public function isAllowedToUpload($iUserId, $iUploaded = null) { $this->_build($iUserId); if ($this->_iTotalUploadSpace === 0) { return true; } if ($this->_iTotalSpaceUsed > $this->_iTotalUploadSpace) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_upload_you_have_reached_your_limit_of_current_you_are_currently_using_total', array('current' => Phpfox_File::instance()->filesize($this->_iTotalUploadSpace), 'total' => Phpfox_File::instance()->filesize($this->_iTotalSpaceUsed)))); } if ($iUploaded !== null && $this->_iTotalSpaceUsed + $iUploaded > $this->_iTotalUploadSpace) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_upload_you_have_reached_your_limit_of_limit_with_this_upload_you_will_be_using_total', array('limit' => Phpfox_File::instance()->filesize($this->_iTotalUploadSpace), 'total' => Phpfox_File::instance()->filesize($this->_iTotalSpaceUsed + $iUploaded)))); } return true; }
/** * Method used to compress data and then send it to the user to download on the spot. * * @param string $sName Name of the archive * @param string $sExt File extension of the archive (zip, tar.gz, xml) * @param string $sFolder Folder to compress. Must be located within the "file/cache/" folder. * @return bool Only returns false if we were unable to compress the data */ public function download($sName, $sExt, $sFolder, $iServerId = 0) { if (!($sNewFile = Phpfox::getLib('phpfox.archive', $sExt)->compress($sName, $sFolder))) { return false; } if (Phpfox::getParam('core.allow_cdn')) { Phpfox::getLib('cdn')->put($sNewFile); } if (is_dir(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS)) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS); } ($sPlugin = Phpfox_Plugin::get('archive_export_download')) ? eval($sPlugin) : false; // Phpfox::getlib('phpfox.file')->forceDownload($sNewFile, $sName . '.' . $sExt); Phpfox::getlib('phpfox.file')->forceDownload($sNewFile, $sName . '.' . $sExt, '', '', $iServerId); }
/** * Controller */ public function process() { if (!Phpfox::isModule('ad')) { return false; } if (defined('PHPFOX_IS_GROUP_VIEW') || defined('PHPFOX_IS_PAGES_VIEW') || defined('PHPFOX_IS_USER_PROFILE')) { return false; } $aSponsorPhoto = Phpfox::getService('photo')->getRandomSponsored(); if (empty($aSponsorPhoto)) { return false; } Phpfox::getService('ad.process')->addSponsorViewsCount($aSponsorPhoto['sponsor_id'], 'photo'); $aSponsorPhoto['details'] = array(Phpfox::getPhrase('photo.submitted') => Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aSponsorPhoto['time_stamp']), Phpfox::getPhrase('photo.file_size') => Phpfox_File::instance()->filesize($aSponsorPhoto['file_size']), Phpfox::getPhrase('photo.resolution') => $aSponsorPhoto['width'] . '×' . $aSponsorPhoto['height'], Phpfox::getPhrase('photo.views') => $aSponsorPhoto['total_view']); $this->template()->assign(array('aSponsorPhoto' => $aSponsorPhoto, 'sHeader' => Phpfox::getPhrase('photo.sponsored_photo'), 'aFooter' => array(Phpfox::getPhrase('photo.encourage_sponsor') => $this->url()->makeUrl('profile.photo', array('sponsor' => '1'))))); return 'block'; }
/** * Controller */ public function process() { $iId = $this->request()->get('id'); $aRow = Phpfox::getService('attachment')->getForDownload($iId); if (!isset($aRow['destination'])) { return Phpfox_Error::display(Phpfox::getPhrase('attachment.no_such_download_found')); } $sPath = Phpfox::getParam('core.dir_attachment') . sprintf($aRow['destination'], ''); if (Phpfox::hasCallback($aRow['category_id'], 'attachmentControl')) { $bAllowed = Phpfox::callback($aRow['category_id'] . '.attachmentControl', $aRow['item_id']); if ($bAllowed == false) { return Phpfox_Error::display(Phpfox::getPhrase('attachment.you_are_not_allowed_to_download_this_attachment')); } } Phpfox::getService('attachment.process')->updateCounter($aRow['attachment_id']); Phpfox_File::instance()->forceDownload($sPath, $aRow['file_name'], $aRow['mime_type'], $aRow['file_size'], $aRow['server_id']); exit; }
/** * Start the session. * * @return mixed NULL if no errors, however FALSE if session cannot start. */ public function init() { session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); if (PHPFOX_SAFE_MODE) { $this->_sSavePath = PHPFOX_DIR_CACHE; } else { $sSessionSavePath = PHPFOX_OPEN_BASE_DIR ? PHPFOX_DIR_FILE . 'session' . PHPFOX_DS : session_save_path(); if (empty($sSessionSavePath) || !empty($sSessionSavePath) && !Phpfox_File::instance()->isWritable($sSessionSavePath)) { $this->_sSavePath = rtrim(Phpfox_File::instance()->getTempDir(), PHPFOX_DS) . PHPFOX_DS; } else { $this->_sSavePath = rtrim($sSessionSavePath, PHPFOX_DS) . PHPFOX_DS; } } if (!Phpfox_File::instance()->isWritable($this->_sSavePath)) { return Phpfox_Error::trigger('Session path is not wriable: ' . $this->_sSavePath, E_USER_ERROR); } if (!isset($_SESSION)) { session_start(); } }
/** * Compress data into the archive * * @param string $sFile Name of the ZIP file * @param string $sFolder Name of the folder we are going to compress. Must be located within the "file/cache/" folder. * @return mixed Returns the full path to the newly created ZIP file. */ public function compress($sFile, $sFolder) { // Create random ZIP $sArchive = PHPFOX_DIR_CACHE . md5((is_array($sFile) ? serialize($sFile) : $sFile) . Phpfox::getParam('core.salt') . PHPFOX_TIME) . '.zip'; chdir(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS); if (is_object($this->_oZip)) { if ($this->_oZip->open($sArchive, ZipArchive::CREATE)) { $aFiles = Phpfox_File::instance()->getAllFiles(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS); foreach ($aFiles as $sNewFile) { $sNewFile = str_replace(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS, '', $sNewFile); $this->_oZip->addFile($sNewFile); } $this->_oZip->close(); } } else { shell_exec(Phpfox::getParam('core.zip_path') . ' -r ' . escapeshellarg($sArchive) . ' ./'); } chdir(PHPFOX_DIR); return $sArchive; }
public function get() { $oFile = Phpfox_File::instance(); $bSlaveEnabled = Phpfox::getParam(array('db', 'slave')); $sDriver = Phpfox::getParam(array('db', 'driver')); $aStats = array(Phpfox::getPhrase('admincp.phpfox_version') => PhpFox::getVersion() . '<i>(build ' . Phpfox::getBuild() . ')</i>', Phpfox::getPhrase('admincp.php_version') => '<a href="' . Phpfox_Url::instance()->makeUrl('admincp.core.phpinfo') . '">' . PHP_VERSION . '</a>', Phpfox::getPhrase('admincp.php_sapi') => php_sapi_name(), Phpfox::getPhrase('admincp.php_safe_mode') => PHPFOX_SAFE_MODE ? Phpfox::getPhrase('admincp.true') : Phpfox::getPhrase('admincp.false'), Phpfox::getPhrase('admincp.php_open_basedir') => PHPFOX_OPEN_BASE_DIR ? Phpfox::getPhrase('admincp.true') : Phpfox::getPhrase('admincp.false'), Phpfox::getPhrase('admincp.php_disabled_functions') => @ini_get('disable_functions') ? str_replace(",", ", ", @ini_get('disable_functions')) : Phpfox::getPhrase('admincp.none'), Phpfox::getPhrase('admincp.php_loaded_extensions') => implode(' ', get_loaded_extensions()), Phpfox::getPhrase('admincp.operating_system') => PHP_OS, Phpfox::getPhrase('admincp.server_time_stamp') => date('F j, Y, g:i a', PHPFOX_TIME) . ' (GMT)', Phpfox::getPhrase('admincp.gzip') => Phpfox::getParam('core.use_gzip') ? Phpfox::getPhrase('admincp.enabled') : Phpfox::getPhrase('admincp.disabled'), Phpfox::getPhrase('admincp.sql_driver_version') => $sDriver == 'DATABASE_DRIVER' ? Phpfox::getPhrase('admincp.n_a') : Phpfox_Database::instance()->getServerInfo(), Phpfox::getPhrase('admincp.sql_slave_enabled') => $bSlaveEnabled ? Phpfox::getPhrase('admincp.yes') : Phpfox::getPhrase('admincp.no'), Phpfox::getPhrase('admincp.sql_total_slaves') => $bSlaveEnabled ? count(Phpfox::getParam(array('db', 'slave_servers'))) : Phpfox::getPhrase('admincp.n_a'), Phpfox::getPhrase('admincp.sql_slave_server') => $bSlaveEnabled ? Phpfox_Database::instance()->sSlaveServer : Phpfox::getPhrase('admincp.n_a'), Phpfox::getPhrase('admincp.memory_limit') => $oFile->filesize($this->_getUsableMemory()) . ' (' . @ini_get('memory_limit') . ')', Phpfox::getPhrase('admincp.load_balancing_enabled') => Phpfox::getParam(array('balancer', 'enabled')) ? Phpfox::getPhrase('admincp.yes') : Phpfox::getPhrase('admincp.no')); if (strpos(strtolower(PHP_OS), 'win') === 0 || PHPFOX_SAFE_MODE || PHPFOX_OPEN_BASE_DIR) { } else { if (function_exists('shell_exec')) { $sMemory = @shell_exec("free -m"); $aMemory = explode("\n", str_replace("\r", "", $sMemory)); if (is_array($aMemory)) { $aMemory = array_slice($aMemory, 1, 1); if (isset($aMemory[0])) { $aMemory = preg_split("#\\s+#", $aMemory[0]); $aStats[Phpfox::getPhrase('admincp.total_server_memory')] = isset($aMemory[1]) ? $aMemory[1] . ' MB' : '--'; $aStats[Phpfox::getPhrase('admincp.available_server_memory')] = isset($aMemory[3]) ? $aMemory[3] . ' MB' : '--'; } } } else { if (stristr(PHP_OS, "win") === false) { $sMemory = file_get_contents('/proc/meminfo'); $aMemoryStats = explode("n", $sMemory); // escape the "new line" $aMem = null; foreach ($aMemoryStats as $iKey => $sMemoryStat) { $aMemoryStats[$iKey] = preg_replace('/s+/', ' ', $sMemoryStat); if (preg_match('/[0-9]+/', $sMemoryStat, $aMem)) { $aMemoryStats[$iKey] = $aMem[0] / 1024; } } $aStats[Phpfox::getPhrase('admincp.total_server_memory')] = (int) $aMemoryStats[0] . ' MB'; $aStats[Phpfox::getPhrase('admincp.available_server_memory')] = (int) $aMemoryStats[1] . ' MB'; } } } if (!PHPFOX_OPEN_BASE_DIR && ($sLoad = Phpfox::getService('core.load')->get()) !== null) { $aStats[Phpfox::getPhrase('admincp.current_server_load')] = $sLoad; } return $aStats; }
/** * Controller */ public function process() { $this->_setMenuName('admincp.theme'); $aStyle = Theme_Service_Style_Style::instance()->getStyle($this->request()->getInt('id')); if (!isset($aStyle['theme_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('theme.not_a_valid_style')); } if ($this->request()->get('revert')) { if (Theme_Service_Style_Process::instance()->revertLogo($aStyle['style_id'])) { $this->url()->send('admincp.theme.style.logo', array('id' => $aStyle['style_id']), Phpfox::getPhrase('theme.logo_successfully_reverted')); } } if (!empty($_FILES['logo'])) { $aImage = Phpfox_File::instance()->load('logo', array('jpg', 'gif', 'png')); if (isset($aImage['tmp_name']) && Theme_Service_Style_Process::instance()->changeLogo($aStyle['style_id'], $aImage, $this->request()->get('resize') == '1' ? true : false)) { $this->url()->send('admincp.theme.style.logo', array('id' => $aStyle['style_id']), Phpfox::getPhrase('theme.logo_successfully_uploaded')); } } list($sCurrentStyleLogo, $bIsNewLogo, $iWidth, $iHeight) = Theme_Service_Style_Style::instance()->getCurrentLogo($aStyle['style_id']); $this->template()->setTitle(Phpfox::getPhrase('theme.change_site_logo'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb($aStyle['theme_name'], $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.styles'), $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb($aStyle['name'], $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb(Phpfox::getPhrase('theme.change_logo'), null, true)->assign(array('aStyle' => $aStyle, 'sCurrentStyleLogo' => $sCurrentStyleLogo, 'bIsNewLogo' => $bIsNewLogo, 'iWidth' => 100, 'iHeight' => 100)); }
/** * Controller */ public function process() { Phpfox::getUserParam('photo.can_view_photos', true); // Make sure the user group can download this photo Phpfox::getUserParam('photo.can_download_user_photos', true); // Check if we want to download a specific photo size $iDownloadSize = $this->request()->get('size'); // Get photo array $aPhoto = $this->getParam('aPhoto'); if (!$aPhoto['allow_download']) { return Phpfox_Error::display(Phpfox::getPhrase('photo.not_allowed_to_download_this_image')); } // Prepare the image path $sPath = Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['original_destination'], is_numeric($iDownloadSize) ? '_' . $iDownloadSize : ''); // Increment the download counter Phpfox::getService('photo.process')->updateCounter($aPhoto['photo_id'], 'total_download'); // Download the photo Phpfox_File::instance()->forceDownload($sPath, $aPhoto['file_name'], $aPhoto['mime_type'], $aPhoto['file_size'], $aPhoto['server_id']); // We are done, lets get out of here exit; }
/** * Controller */ public function process() { if (!Phpfox::isUser()) { exit; } $aImage = Phpfox_File::instance()->load('image', array('jpg', 'gif', 'png')); if ($aImage === false) { return j('#js_image_error')->show(); } $aParts = explode('x', $this->request()->get('ad_size')); if ($sFileName = Phpfox_File::instance()->upload('image', Phpfox::getParam('ad.dir_image'), Phpfox::getUserId() . uniqid())) { Phpfox_Image::instance()->createThumbnail(Phpfox::getParam('ad.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('ad.dir_image') . sprintf($sFileName, '_thumb'), Phpfox::getParam('ad.multi_ad') ? 100 : $aParts[0] / 3, Phpfox::getParam('ad.multi_ad') ? 72 : $aParts[1] - 20); Phpfox_File::instance()->unlink(Phpfox::getParam('ad.dir_image') . sprintf($sFileName, '')); rename(Phpfox::getParam('ad.dir_image') . sprintf($sFileName, '_thumb'), Phpfox::getParam('ad.dir_image') . sprintf($sFileName, '')); // http://www.phpfox.com/tracker/view/14922/ -> If CDN, the unlink function above deletes the image!! if (Phpfox::getParam('core.allow_cdn')) { Phpfox::getLib('cdn')->put(Phpfox::getParam('ad.dir_image') . sprintf($sFileName, '')); } return ['run' => '$(\'.js_ad_image\').html(\'<a href="#ad-link"><img src="' . Phpfox::getParam('ad.url_image') . sprintf($sFileName, '') . '" alt="" /></a>\').show(); window.parent.$(\'#js_image_holder_message\').hide(); window.parent.$(\'#js_image_holder_link\').show(); window.parent.$(\'#js_image_id\').val(\'' . sprintf($sFileName, '') . '\');']; } exit; }
public function process($aFile) { if (!Phpfox::getParam('core.is_auto_hosted')) { return Phpfox_Error::set('Unable to import data using the current routine. Use the manual method of importing data.'); } if (!preg_match('/^(.*?)\\.zip$/i', $aFile['name'])) { return Phpfox_Error::set('Not a valid ZIP package.'); } $sExt = 'zip'; $sLocationId = md5(PHPFOX_TIME . uniqid() . $aFile['name']) . PHPFOX_DS; $sLocation = PHPFOX_DIR_CACHE . $sLocationId; mkdir($sLocation); $sThemeName = str_replace(array('phpfox-theme-', '.zip'), '', $aFile['name']); Phpfox::getLib('archive', $sExt)->extract($aFile['tmp_name'], $sLocation); $aFiles = Phpfox_File::instance()->getAllFiles($sLocation); foreach ($aFiles as $sFile) { $sNewFile = str_replace($sLocation, '', $sFile); if (!preg_match('/([a-zA-Z0-9-]\\.(xml|css|png|gif|jpg|jpeg|html.php))/i', $sFile) || !preg_match('/theme\\/frontend\\/' . $sThemeName . '\\//i', $sFile)) { continue; } if (substr($sFile, -9) == '.html.php') { $sContent = file_get_contents($sFile); $hFile = fopen($sFile, 'w'); fwrite($hFile, "<?php defined('PHPFOX') or exit('NO DICE!'); ?>\n" . $sContent); fclose($hFile); } $aParts = explode(PHPFOX_DS, $sNewFile); unset($aParts[count($aParts) - 1]); $sDirPath = implode(PHPFOX_DS, $aParts); $sDirPath = ltrim($sDirPath, 'upload/'); if (preg_match('/([a-zA-Z0-9-]\\.(png|gif|jpg|jpeg))/i', $sFile)) { Phpfox::getLib('cdn')->put($sFile, str_replace('upload/', '', $sNewFile)); } // Phpfox::getLib('ftp')->mkdir(PHPFOX_DIR . $sDirPath, true); // Phpfox::getLib('ftp')->put($sFile, PHPFOX_DIR . $sNewFile); } // Phpfox_File::instance()->delete_directory($sLocation); return $sLocationId; }
public function installThemeFromFolder($sTheme, $mForce = false) { if (!$mForce) { $sDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $sTheme . PHPFOX_DS; if (!file_exists($sDir . 'phpfox.xml')) { return Phpfox_Error::set('Not a valid theme to install.'); } } $iInstalled = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('theme'))->where('folder = \'' . $this->database()->escape($sTheme) . '\'')->execute('getField'); if ($iInstalled) { return Phpfox_Error::set('This theme is already installed.'); } $aParams = Phpfox::getLib('xml.parser')->parse(file_get_contents($mForce ? PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS . 'upload/theme/frontend/' . $sTheme . '/phpfox.xml' : $sDir . 'phpfox.xml')); $aForm = array('name' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.theme_requires_a_name')), 'folder' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.theme_requires_a_folder_name')), 'created' => array('type' => 'int'), 'creator' => array('type' => 'string'), 'website' => array('type' => 'string'), 'version' => array('type' => 'string'), 'parent_id' => array('type' => 'string')); $aParams['parent_id'] = 0; if (!empty($aParams['parent'])) { $aParent = Theme_Service_Theme::instance()->getTheme($aParams['parent'], true); if (isset($aParent['theme_id'])) { $aParams['parent_id'] = $aParent['theme_id']; } } $aParams = $this->validator()->process($aForm, $aParams); if (!empty($aParams['creator'])) { $aParams['creator'] = $this->preParse()->clean($aParams['creator'], 255); } if (!Phpfox_Error::isPassed()) { return false; } $aParams['is_active'] = 1; $aParams['is_default'] = 0; $iId = $this->database()->insert(Phpfox::getT('theme'), $aParams); // I dont think we need to clear cache for profiles here, seems to be working fine without doing this -Purefan if ($mForce && Phpfox::getParam('core.phpfox_is_hosted')) { $sStyleDir = PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS . 'upload' . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aParams['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS; } else { $sStyleDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aParams['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS; } $hDir = opendir($sStyleDir); while ($sFolder = readdir($hDir)) { if ($sFolder == '.' || $sFolder == '..') { continue; } if (!file_exists($sStyleDir . $sFolder . PHPFOX_DS . 'phpfox.xml')) { continue; } $iInstalled = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('theme_style'))->where('theme_id = ' . (int) $iId . ' AND folder = \'' . $this->database()->escape($sFolder) . '\'')->execute('getField'); if (!$iInstalled) { Theme_Service_Style_Process::instance()->installStyleFromFolder($aParams['folder'], $sFolder, $mForce); } } closedir($hDir); if ($mForce && Phpfox::getParam('core.phpfox_is_hosted')) { $aFiles = Phpfox_File::instance()->getAllFiles(PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS); $aCssContent = array(); foreach ($aFiles as $sFile) { if ($sFile == '.' || $sFile == '..' || empty($sFile)) { continue; } if (substr($sFile, -4) == '.css') { preg_match('/(.*)\\/style\\/(.*)\\/css\\/(.*)/i', $sFile, $aMatches); if (isset($aMatches[2])) { if (!isset($aCssContent[$aMatches[2]])) { $aCssContent[$aMatches[2]] = ''; } $aCssContent[$aMatches[2]] .= file_get_contents($sFile); } } elseif (substr($sFile, -9) == '.html.php') { $sTypeId = 'layout'; $sModuleId = null; $aNameParts = explode('/', $sFile); $sTemplateName = $aNameParts[count($aNameParts) - 1]; $sTemplateContent = file_get_contents($sFile); $this->database()->insert(Phpfox::getT('theme_template'), array('is_custom' => '1', 'folder' => $sTheme, 'type_id' => $sTypeId, 'product_id' => 'phpfox', 'module_id' => $sModuleId, 'name' => $sTemplateName, 'html_data' => $sTemplateContent, 'time_stamp' => PHPFOX_TIME)); } } if (!empty($sFile)) { foreach ($aCssContent as $sStyleName => $sStyleContent) { $this->_sStyleDir = $sStyleDir . $sStyleName; $sStyleContent = preg_replace_callback('/url\\((.*)\\)/i', array($this, 'replaceCdnImages'), $sStyleContent); $iStyleId = $this->database()->select('style_id')->from(Phpfox::getT('theme_style'))->where('folder = \'' . $this->database()->escape($sStyleName) . '\'')->execute('getSlaveField'); if ($iStyleId) { $sName = md5(PHPFOX_IS_HOSTED_SCRIPT . uniqid()) . '.css'; $sTempFile = PHPFOX_DIR_CACHE . $sName; $hFile = fopen($sTempFile, 'w+'); fwrite($hFile, $sStyleContent); fclose($hFile); Phpfox::getLib('cdn')->put($sTempFile, 'file/static/' . $sName); unlink($sTempFile); $this->database()->delete(Phpfox::getT('theme_css'), 'style_id = ' . (int) $iStyleId); $this->database()->insert(Phpfox::getT('theme_css'), array('module_id' => null, 'product_id' => null, 'style_id' => $iStyleId, 'file_name' => 'custom.css', 'css_data' => $sStyleContent, 'css_data_original' => $sName, 'full_name' => null, 'time_stamp' => PHPFOX_TIME)); } } } Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS); } return $iId; }
/** * This function scans every .php file in PHPFOX_DIR for >subject() and >message() and picks up * the language phrase used in each case then it renews the cache file * @param bool $bForce Forces to create the cache file anew, if false it only returns the cache file if available * @return array */ public function getMailPhrases($bForce = false) { $sCacheId = $this->cache()->set('language_mail_phrases'); $aPhrases = array(); if ($bForce || !($aPhrases = $this->cache()->get($sCacheId))) { $aAllFiles = Phpfox_File::instance()->getAllFiles(PHPFOX_DIR_MODULE, true); foreach ($aAllFiles as $sFileName) { $aSubjects = $aMessages = array(); if (substr($sFileName, strrpos($sFileName, '.') + 1) != 'php') { // only check .php files continue; } $sContent = file_get_contents($sFileName); $iSubject = preg_match_all('/>subject\\((.+[^ ])\\)/', $sContent, $aSubjects); $iMessage = preg_match_all('/>message\\((.+[^ ])\\)/', $sContent, $aMessages); if ($iSubject === false || $iMessage === false) { return Phpfox_Error::set('Error finding subjects and messages'); } if (empty($aSubjects) && empty($aMessages) || empty($aSubjects[1]) && empty($aMessages[1])) { continue; } $aTemp = array_merge($aSubjects[1], $aMessages[1]); foreach ($aTemp as $sTemp) { if (preg_match('/([a-z]+\\.[a-z\\_]+)/', $sTemp, $aMatch)) { if (!Phpfox_Locale::instance()->isPhrase($aMatch[1])) { continue; } $aPhrase = explode('.', $aMatch[1]); $aPhrases[$aMatch[1]] = array('file' => $sFileName, 'var_name' => $aPhrase[1], 'module' => $aPhrase[0], 'phrase_id' => $aMatch[1]); } } } $this->cache()->save($sCacheId, $aPhrases); } return $aPhrases; }
/** * 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' => '© ' . 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(['''], ["'"], 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(); } } }
/** * Get all the modules found within the module folder. * * @return array ARRAY of modules. */ public function getModuleFiles() { // Create a cache of modules we need to skip $aSkip = array(); if (defined('PHPFOX_INSTALL_MOD_IGNORE')) { $aParts = explode(',', PHPFOX_INSTALL_MOD_IGNORE); foreach ($aParts as $sPart) { $aSkip[] = trim($sPart); } } $aFolders = array(); $iCoreId = 0; $aModules = Phpfox_File::instance()->getFiles(PHPFOX_DIR_MODULE); foreach ($aModules as $iKey => $sModule) { if (!file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_XML . PHPFOX_DS . 'phpfox' . PHPFOX_XML_SUFFIX)) { continue; } if (count($aSkip) && in_array($sModule, $aSkip)) { continue; } $sContent = file_get_contents(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_XML . PHPFOX_DS . 'phpfox' . PHPFOX_XML_SUFFIX); $sCore = preg_match("/<is_core>1<\\/is_core>/i", $sContent) ? 'core' : 'plugin'; $aFolders[$sCore][$iKey] = array('name' => $sModule); if ($sModule === 'core') { $iCoreId = $iKey; } } unset($aFolders['core'][$iCoreId]); array_unshift($aFolders['core'], array('name' => 'core')); return $aFolders; }
public function export($sProduct) { $aFiles = array(); $oFile = Phpfox_File::instance(); $oDatabaseSupport = Phpfox::getLib('database.support'); define('PHPFOX_XML_SKIP_STAMP', true); $aRow = $this->database()->select('*')->from($this->_sTable)->where("product_id = '" . $this->database()->escape($sProduct) . "'")->execute('getRow'); if (!isset($aRow['product_id'])) { return false; } $oXmlBuilder = Phpfox::getLib('xml.builder'); $oXmlBuilder->addGroup('product'); $oXmlBuilder->addGroup('data'); foreach ($aRow as $sKey => $sValue) { $oXmlBuilder->addTag($sKey, $sValue); } $oXmlBuilder->closeGroup(); $aDependencies = $this->database()->select('type_id, check_id, dependency_start, dependency_end')->from(Phpfox::getT('product_dependency'))->where("product_id = '" . $this->database()->escape($sProduct) . "'")->execute('getRows'); if (count($aDependencies)) { $oXmlBuilder->addGroup('dependencies'); foreach ($aDependencies as $aDependency) { $oXmlBuilder->addGroup('dependency'); foreach ($aDependency as $sKey => $sValue) { $oXmlBuilder->addTag($sKey, $sValue); } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); } $aInstalls = $this->database()->select('version, install_code, uninstall_code')->from(Phpfox::getT('product_install'))->where("product_id = '" . $this->database()->escape($sProduct) . "'")->order('version ASC')->execute('getRows'); if (count($aInstalls)) { $oXmlBuilder->addGroup('installs'); foreach ($aInstalls as $aInstall) { $oXmlBuilder->addGroup('install'); foreach ($aInstall as $sKey => $sValue) { $oXmlBuilder->addTag($sKey, $sValue); } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); } $aModules = $this->database()->select('*')->from(Phpfox::getT('module'))->where('product_id = \'' . $this->database()->escape($sProduct) . '\'')->execute('getRows'); if (count($aModules)) { $aModuleCache = array(); $oXmlBuilder->addGroup('modules'); foreach ($aModules as $aModule) { $oXmlBuilder->addTag('module_id', $aModule['module_id']); $aModuleCache[$aModule['module_id']] = true; } $oXmlBuilder->closeGroup(); } $oXmlBuilder->closeGroup(); $sDirectoryId = 'product_' . $aRow['product_id'] . '_' . uniqid(); if (is_dir(PHPFOX_DIR_CACHE . $sDirectoryId)) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS); } $sUploadPath = PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'upload' . PHPFOX_DS; Phpfox_File::instance()->mkdir($sUploadPath, true); Phpfox_File::instance()->mkdir($sUploadPath . 'include' . PHPFOX_DS . 'xml' . PHPFOX_DS, true); Phpfox_File::instance()->write($sUploadPath . 'include' . PHPFOX_DS . 'xml' . PHPFOX_DS . $aRow['product_id'] . '.xml', $oXmlBuilder->output()); Phpfox::getService('admincp.module')->exportForModules($sProduct, false, isset($aModuleCache) ? $aModuleCache : null, $sDirectoryId . PHPFOX_DS . 'upload' . PHPFOX_DS); if ($sPlugin = Phpfox_Plugin::get('admincp.service_product_product_export')) { eval($sPlugin); } return array('name' => $aRow['product_id'] . (!empty($aRow['version']) ? '-' . $aRow['version'] : ''), 'folder' => $sDirectoryId); }
public function addStyle($aVals, $iEditId = null, &$aStyle = null) { $aForm = array('name' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.style_requires_a_name')), 'folder' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.style_requires_a_folder_name')), 'theme_id' => array('type' => 'int:required', 'message' => Phpfox::getPhrase('theme.select_a_parent_theme_for_this_style')), 'parent_id' => array('type' => 'int'), 'creator' => array('type' => 'string'), 'website' => array('type' => 'string'), 'version' => array('type' => 'string'), 'is_active' => array('type' => 'int:required', 'message' => Phpfox::getPhrase('theme.provide_if_the_style_is_active_or_not')), 'is_default' => array('type' => 'int'), 'logo_image' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.provide_a_default_logo_name')), 'l_width' => array('type' => 'int'), 'c_width' => array('type' => 'int'), 'r_width' => array('type' => 'int')); if ($aStyle !== null) { $aCache = $aVals; } if ($iEditId !== null) { unset($aForm['folder'], $aForm['theme_id'], $aForm['parent_id']); } if (isset($aVals['theme_id'])) { $aTheme = Theme_Service_Theme::instance()->getTheme($aVals['theme_id']); } $aVals = $this->validator()->process($aForm, $aVals); if (!empty($aVals['creator'])) { $aVals['creator'] = $this->preParse()->clean($aVals['creator'], 255); } if (!Phpfox_Error::isPassed()) { return false; } if ($iEditId === null) { $aVals['created'] = PHPFOX_TIME; $aVals['folder'] = $this->preParse()->cleanFileName($aVals['folder']); if (empty($aVals['folder'])) { return Phpfox_Error::set(Phpfox::getPhrase('theme.folder_is_not_valid')); } if (is_dir(PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aVals['folder'])) { return Phpfox_Error::set(Phpfox::getPhrase('theme.this_folder_is_already_in_use')); } /* $iCheck = $this->database()->select('COUNT(*)') ->from(Phpfox::getT('theme_style')) ->where('folder = \'' . $this->database()->escape($aVals['folder']) . '\'') ->execute('getField'); if ($iCheck) { return Phpfox_Error::set('There is already a style with the same folder name.'); } */ $iId = $this->database()->insert(Phpfox::getT('theme_style'), $aVals); /* if (Phpfox::getParam('core.ftp_enabled')) { $sDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $this->database()->escape($aVals['folder']) . PHPFOX_DS; Phpfox::getLib('ftp')->mkdir($sDir); foreach ($this->_aStyleStructure as $sFileDirectory) { Phpfox::getLib('ftp')->mkdir($sDir . $sFileDirectory . PHPFOX_DS); } } */ } else { if (isset($aVals['is_default']) && $aVals['is_default']) { $this->database()->update($this->_sTable, array('is_default' => '0'), 'style_id > 0'); Phpfox::getLib('session')->remove(Phpfox::getParam('core.theme_session_prefix') . 'theme'); } $this->database()->update(Phpfox::getT('theme_style'), $aVals, 'style_id = ' . (int) $iEditId); if (Phpfox::getParam('core.super_cache_system')) { // The function get() in the user service queries the table theme_style $this->cache()->remove('profile', 'substr'); } $iId = $iEditId; } if ($aStyle !== null) { if (isset($aCache)) { $aVals = $aCache; } $sDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aVals['folder'] . PHPFOX_DS; if (!is_dir($sDir)) { Phpfox::getLib('ftp')->mkdir($sDir); } foreach ($this->_aStyleStructure as $sFileDirectory) { if (!is_dir($sDir . $sFileDirectory . PHPFOX_DS)) { Phpfox::getLib('ftp')->mkdir($sDir . $sFileDirectory . PHPFOX_DS); } } if (isset($aStyle['css']['data']['name'])) { $aStyle['css']['data'] = array($aStyle['css']['data']); } if (isset($aStyle['css']['data']) && is_array($aStyle['css']['data'])) { foreach ($aStyle['css']['data'] as $aCss) { if (!empty($aCss['module'])) { $sModuleDirectory = PHPFOX_DIR_MODULE . $aCss['module'] . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . $aVals['folder'] . PHPFOX_DS; if (!is_dir($sModuleDirectory)) { Phpfox::getLib('ftp')->mkdir($sModuleDirectory, true); } $sTempFile = 'theme_style_cache_css_' . md5($aCss['module'] . $aCss['name'] . $iId); Phpfox_File::instance()->writeToCache($sTempFile, $aCss['value']); if (file_exists($sModuleDirectory . $aCss['name'])) { Phpfox::getLib('ftp')->unlink($sModuleDirectory . $aCss['name']); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sModuleDirectory . $aCss['name']); if (file_exists($sTempFile)) { unlink($sTempFile); } } else { $sTempFile = 'theme_style_cache_css_' . md5($aCss['name'] . $iId); Phpfox_File::instance()->writeToCache($sTempFile, $aCss['value']); if (file_exists($sDir . 'css' . PHPFOX_DS . $aCss['name'])) { Phpfox::getLib('ftp')->unlink($sDir . 'css' . PHPFOX_DS . $aCss['name']); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sDir . 'css' . PHPFOX_DS . $aCss['name']); if (file_exists($sTempFile)) { unlink($sTempFile); } } } } if (isset($aStyle['images']['image']['name'])) { $aStyle['images']['image'] = array($aStyle['images']['image']); } if (isset($aStyle['images']['image']) && is_array($aStyle['images']['image'])) { foreach ($aStyle['images']['image'] as $aImage) { if (!empty($aImage['path'])) { if (!is_dir($sDir . 'image' . PHPFOX_DS . $aImage['path'] . PHPFOX_DS)) { Phpfox::getLib('ftp')->mkdir($sDir . 'image' . PHPFOX_DS . $aImage['path'] . PHPFOX_DS); } } $sTempFile = 'theme_style_cache_image_' . md5($aImage['name'] . $iId); Phpfox_File::instance()->writeToCache($sTempFile, base64_decode($aImage['value'])); if (file_exists($sDir . 'image' . PHPFOX_DS . (empty($aImage['path']) ? '' : $aImage['path'] . PHPFOX_DS) . $aImage['name'])) { Phpfox::getLib('ftp')->unlink($sDir . 'image' . PHPFOX_DS . (empty($aImage['path']) ? '' : $aImage['path'] . PHPFOX_DS) . $aImage['name']); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sDir . 'image' . PHPFOX_DS . (empty($aImage['path']) ? '' : $aImage['path'] . PHPFOX_DS) . $aImage['name']); if (file_exists($sTempFile)) { unlink($sTempFile); } } } if (isset($aStyle['scripts']['script']['name'])) { $aStyle['scripts']['script'] = array($aStyle['scripts']['script']); } if (isset($aStyle['scripts']['script']) && is_array($aStyle['scripts']['script'])) { foreach ($aStyle['scripts']['script'] as $aScript) { $sTempFile = 'theme_style_cache_script_' . md5($aScript['name'] . $iId); Phpfox_File::instance()->writeToCache($sTempFile, $aScript['value']); if (file_exists($sDir . 'jscript' . PHPFOX_DS . $aScript['name'])) { Phpfox::getLib('ftp')->unlink($sDir . 'jscript' . PHPFOX_DS . $aScript['name']); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sDir . 'jscript' . PHPFOX_DS . $aScript['name']); if (file_exists($sTempFile)) { unlink($sTempFile); } } } if (isset($aStyle['display_logo'])) { $sTempFile = 'theme_style_cache_logo_' . $iId; Phpfox_File::instance()->writeToCache($sTempFile, base64_decode($aStyle['display_logo'])); if (file_exists($sDir . 'phpfox.gif')) { Phpfox::getLib('ftp')->unlink($sDir . 'phpfox.gif'); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sDir . 'phpfox.gif'); if (file_exists($sTempFile)) { unlink($sTempFile); } } if (isset($aStyle['php_header']['code'])) { $sTempFile = 'theme_style_cache_php_header_' . $iId; Phpfox_File::instance()->writeToCache($sTempFile, $aStyle['php_header']['code']); if (file_exists($sDir . 'php' . PHPFOX_DS . 'header.php')) { Phpfox::getLib('ftp')->unlink($sDir . 'php' . PHPFOX_DS . 'header.php'); } Phpfox::getLib('ftp')->move(PHPFOX_DIR_CACHE . $sTempFile, $sDir . 'php' . PHPFOX_DS . 'header.php'); if (file_exists($sTempFile)) { unlink($sTempFile); } } } return true; }
public function export($iStyleId, $bIncludeParent = false, $bMultiple = false, $sNewHomeFolder = null, $sDirectoryId = null) { if ($bMultiple === false) { define('PHPFOX_XML_SKIP_STAMP', true); } $oXmlBuilder = Phpfox::getLib('xml.builder'); $aStyle = Theme_Service_Style_Style::instance()->getStyle($iStyleId); if (isset($aStyle['style_id'])) { $sCacheHash = md5(serialize($aStyle) . PHPFOX_TIME); if ($sDirectoryId === null) { $sDirectoryIdReturn = 'theme_' . $aStyle['style_id'] . '_' . uniqid(); if (is_dir(PHPFOX_DIR_CACHE . $sDirectoryIdReturn)) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sDirectoryIdReturn . PHPFOX_DS); } $sDirectoryId = $sDirectoryIdReturn . PHPFOX_DS . 'upload' . PHPFOX_DS; Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId, true); $sNewHomeFolder = PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS; } $sThemePath = $sNewHomeFolder . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS; Phpfox_File::instance()->mkdir($sThemePath, true); Phpfox_File::instance()->mkdir($sThemePath . 'css' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'image' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'jscript' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'php' . PHPFOX_DS, true); $oXmlBuilder->addGroup('style', array('name' => $aStyle['name'], 'folder' => $aStyle['folder'], 'parent_style' => $aStyle['parent_theme_folder'] . '::' . $aStyle['parent_style_folder'], 'parent_theme' => $aStyle['theme_folder'], 'created' => $aStyle['created'], 'logo_image' => $aStyle['logo_image'])); // Display Logo $oXmlBuilder->addTag('creator', $aStyle['creator']); $oXmlBuilder->addTag('website', $aStyle['website']); $oXmlBuilder->addTag('version', $aStyle['version']); $oXmlBuilder->closeGroup(); Phpfox_File::instance()->write($sThemePath . 'phpfox.xml', $oXmlBuilder->output()); $sLogoPath = Theme_Service_Style_Style::instance()->getStyleDisplayLogo($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); if (file_exists($sLogoPath) && is_readable($sLogoPath)) { Phpfox_File::instance()->write($sThemePath . 'phpfox.gif', file_get_contents($sLogoPath)); } // Css $aFiles = Theme_Service_Style_Style::instance()->getFiles($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], true, $bIncludeParent); foreach ($aFiles as $sModule => $aCssFiles) { foreach ($aCssFiles as $sFile) { $aCss = Theme_Service_Style_Style::instance()->getFile($aStyle['style_id'], $sFile, $sModule, $bIncludeParent); if (empty($sModule)) { Phpfox_File::instance()->write($sThemePath . 'css' . PHPFOX_DS . $sFile, $aCss['content']); } else { Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'module' . PHPFOX_DS . $sModule . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'module' . PHPFOX_DS . $sModule . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . $sFile, $aCss['content']); } } } // Images $aImages = Theme_Service_Style_Style::instance()->getImages($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); foreach ($aImages as $sImagePath => $mImages) { if (is_numeric($sImagePath)) { $mImages = array($mImages); } foreach ($mImages as $aNewImage) { $sNewFileName = str_replace(PHPFOX_DIR, '', $aNewImage['file']); $aParts = explode(PHPFOX_DS, $sNewFileName); unset($aParts[count($aParts) - 1]); $sDirPath = implode(PHPFOX_DS, $aParts); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS . $aNewImage['name'], file_get_contents($aNewImage['file'])); } } // JavaScript $aScripts = Theme_Service_Style_Style::instance()->getScript($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); foreach ($aScripts as $aScript) { $sNewFileName = str_replace(PHPFOX_DIR, '', $aScript['file']); $aParts = explode(PHPFOX_DS, $sNewFileName); unset($aParts[count($aParts) - 1]); $sDirPath = implode(PHPFOX_DS, $aParts); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS . $aScript['name'], file_get_contents($aScript['file'])); } $sPhpHeaderFile = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . 'php' . PHPFOX_DS . 'header.php'; if (file_exists($sPhpHeaderFile)) { Phpfox_File::instance()->write($sThemePath . 'php' . PHPFOX_DS . 'header.php', file_get_contents($sPhpHeaderFile)); } $sSamplePngFile = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . 'sample.png'; if (file_exists($sSamplePngFile)) { Phpfox_File::instance()->write($sThemePath . 'sample.png', file_get_contents($sSamplePngFile)); } if ($bMultiple === false) { Phpfox_File::instance()->writeToCache('theme_styles_' . $sCacheHash . '.xml', $oXmlBuilder->output()); return array('name' => $aStyle['theme_folder'] . '-' . $aStyle['folder'] . (empty($aStyle['version']) ? '' : '-' . $aStyle['version']), 'folder' => $sDirectoryIdReturn); } } if ($bMultiple === false) { return Phpfox_Error::set(Phpfox::getPhrase('theme.not_a_valid_style')); } }
/** * Used to delete a photo. * * @param int $iId ID of the photo we want to delete. * * @return boolean We return true since if nothing fails we were able to delete the image. */ public function delete($iId, $bPass = false) { // Get the image ID and full path to the image. $aPhoto = $this->database()->select('user_id, module_id, group_id, is_sponsor, album_id, photo_id, destination, server_id')->from($this->_sTable)->where('photo_id = ' . (int) $iId)->execute('getRow'); if (!isset($aPhoto['user_id'])) { return false; } if ($aPhoto['module_id'] == 'pages' && Phpfox::getService('pages')->isAdmin($aPhoto['group_id'])) { $bPass = true; } if ($bPass === false && !Phpfox::getService('user.auth')->hasAccess('photo', 'photo_id', $iId, 'photo.can_delete_own_photo', 'photo.can_delete_other_photos', $aPhoto['user_id'])) { return false; } // Create the total file size var for all the images $iFileSizes = 0; // Make sure the original image exists if (!empty($aPhoto['destination']) && file_exists(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], ''))) { // Add to the file size var $iFileSizes += filesize(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '')); // Remove the image Phpfox_File::instance()->unlink(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '')); } // If CDN is in use, remove the original image, as done above if (Phpfox::getParam('core.allow_cdn') && $aPhoto['server_id'] > 0) { // Get the file size stored when the photo was uploaded $iFileSizes += $this->database()->select('file_size')->from(Phpfox::getT('photo_info'))->where('photo_id = ' . (int) $iId)->execute('getField'); Phpfox::getLib('cdn')->remove(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '')); } // Loop thru all the other smaller images foreach (Phpfox::getParam('photo.photo_pic_sizes') as $iSize) { // Make sure the image exists if (!empty($aPhoto['destination']) && file_exists(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '_' . $iSize))) { // Add to the file size var $iFileSizes += filesize(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '_' . $iSize)); // Remove the image Phpfox_File::instance()->unlink(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '_' . $iSize)); } // If CDN is in use, remove the thumbnails there too if (Phpfox::getParam('core.allow_cdn') && $aPhoto['server_id'] > 0) { // Get the file size stored when the photo was uploaded $sTempUrl = Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_' . $iSize)); $aHeaders = get_headers($sTempUrl, true); if (preg_match('/200 OK/i', $aHeaders[0])) { $iFileSizes += (int) $aHeaders["Content-Length"]; } Phpfox::getLib('cdn')->remove(Phpfox::getParam('photo.dir_photo') . sprintf($aPhoto['destination'], '_' . $iSize)); } } // Delete this entry from the database $this->database()->delete($this->_sTable, 'photo_id = ' . $aPhoto['photo_id']); $this->database()->delete(Phpfox::getT('photo_info'), 'photo_id = ' . $aPhoto['photo_id']); // delete the ratings for this photo $this->database()->delete(Phpfox::getT('photo_rating'), 'photo_id = ' . $aPhoto['photo_id']); // delete the photo tags $this->database()->delete(Phpfox::getT('photo_tag'), 'photo_id = ' . $aPhoto['photo_id']); // delete the category_data $this->database()->delete(Phpfox::getT('photo_category_data'), 'photo_id = ' . $aPhoto['photo_id']); // delete the battles $this->database()->delete(Phpfox::getT('photo_battle'), 'photo_1 = ' . $aPhoto['photo_id'] . ' OR photo_2 = ' . $aPhoto['photo_id']); ($sPlugin = Phpfox_Plugin::get('photo.service_process_delete__1')) ? eval($sPlugin) : false; Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->delete('photo', $iId) : null; Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->delete('comment_photo', $iId) : null; Phpfox::isModule('tag') ? Phpfox::getService('tag.process')->deleteForItem($aPhoto['user_id'], $iId, 'photo') : null; // Update user space usage if ($iFileSizes > 0) { Phpfox::getService('user.space')->update($aPhoto['user_id'], 'photo', $iFileSizes, '-'); } // Update user activity Phpfox::getService('user.activity')->update($aPhoto['user_id'], 'photo', '-'); if ($aPhoto['album_id'] > 0) { Phpfox::getService('photo.album.process')->updateCounter($aPhoto['album_id'], 'total_photo', true); } if ($aPhoto['is_sponsor'] == 1) { $this->cache()->remove('photo_sponsored'); } return true; }
/** * Controller */ public function process() { Phpfox::isUser(true); $bIsInLegacyView = false; if (Phpfox::getParam('mail.threaded_mail_conversation') && $this->request()->get('legacy')) { Phpfox::getLib('setting')->setParam('mail.threaded_mail_conversation', false); $bIsInLegacyView = true; } $this->setParam('bIsInLegacyView', $bIsInLegacyView); if ($aItemModerate = $this->request()->get('item_moderate')) { $sFile = Mail_Service_Mail::instance()->getThreadsForExport($aItemModerate); Phpfox_File::instance()->forceDownload($sFile, 'mail.xml'); } $iPage = $this->request()->getInt('page'); $iPageSize = 10; $bIsSentbox = $this->request()->get('view') == 'sent' ? true : false; $bIsTrash = $this->request()->get('view') == 'trash' ? true : false; $iPrivateBox = $this->request()->get('view') == 'box' ? $this->request()->getInt('id') : false; $bIs = $this->getParam('bIsSentbox'); if ($this->request()->get('action') == 'archive') { Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 1); $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.message_successfully_archived')); } if ($this->request()->get('action') == 'forcedelete') { Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 2); $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.conversation_successfully_deleted')); } if ($this->request()->get('action') == 'unarchive') { Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 0); $this->url()->send('mail', null, Phpfox::getPhrase('mail.message_successfully_unarchived')); } if ($this->request()->get('action') == 'delete') { $iMailId = $this->request()->getInt('id'); if (!is_int($iMailId) || empty($iMailId)) { Phpfox_Error::set(Phpfox::getPhrase('mail.no_mail_specified')); } else { $bTrash = $this->getParam('bIsTrash'); if (!isset($bTrash) || !is_bool($bTrash)) { $bIsTrash = Mail_Service_Mail::instance()->isDeleted($iMailId); } if ($bIsTrash) { if (Mail_Service_Process::instance()->deleteTrash($iMailId)) { $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.mail_deleted_successfully')); } else { Phpfox_Error::set(Phpfox::getPhrase('mail.mail_could_not_be_deleted')); } } else { $bIsSent = $this->getParam('bIsSentbox'); if (!isset($bIsSent) || !is_bool($bIsSent)) { $bIsSentbox = Mail_Service_Mail::instance()->isSent($iMailId); } if (Mail_Service_Process::instance()->delete($iMailId, $bIsSentbox)) { $this->url()->send($bIsSentbox == true ? 'mail.sentbox' : 'mail', null, Phpfox::getPhrase('mail.mail_deleted_successfully')); } else { Phpfox_Error::set(Phpfox::getPhrase('mail.mail_could_not_be_deleted')); } } } } if (($aVals = $this->request()->getArray('val')) && isset($aVals['action'])) { if (isset($aVals['id'])) { //make sure there is at least one selected $oMailProcess = Mail_Service_Process::instance(); switch ($aVals['action']) { case 'unread': case 'read': foreach ($aVals['id'] as $iId) { $oMailProcess->toggleView($iId, $aVals['action'] == 'unread' ? true : false); } $sMessage = Phpfox::getPhrase('mail.messages_updated'); break; case 'delete': if (isset($aVals['select']) && $aVals['select'] == 'every') { $aMail = Mail_Service_Mail::instance()->getAllMailFromFolder(Phpfox::getUserId(), (int) $aVals['folder'], $bIsSentbox, $bIsTrash); $aVals['id'] = $aMail; } foreach ($aVals['id'] as $iId) { $bIsTrash ? $oMailProcess->deleteTrash($iId) : $oMailProcess->delete($iId, $bIsSentbox); } $sMessage = Phpfox::getPhrase('mail.messages_deleted'); break; case 'undelete': foreach ($aVals['id'] as $iId) { $oMailProcess->undelete($iId); } $sMessage = Phpfox::getPhrase('mail.messages_updated'); break; } } else { // didnt select any message $sMessage = Phpfox::getPhrase('mail.error_you_did_not_select_any_message'); } // define the mail box that the user was looking at $mSend = null; if ($bIsSentbox) { $mSend = array('sentbox'); } elseif ($bIsTrash) { $mSend = array('trash'); } elseif ($iPrivateBox) { $mSend = array('box', 'id' => $iPrivateBox); } // send the user to that folder with the message $this->url()->send('mail', $mSend, $sMessage); } $this->search()->set(array('type' => 'mail', 'field' => 'mail.mail_id', 'search_tool' => array('table_alias' => 'm', 'search' => array('action' => $this->url()->makeUrl('mail', array('view' => $this->request()->get('view'), 'id' => $this->request()->get('id'))), 'default_value' => Phpfox::getPhrase('mail.search_messages'), 'name' => 'search', 'field' => array('m.subject', 'm.preview')), 'sort' => array('latest' => array('m.time_stamp', Phpfox::getPhrase('mail.latest')), 'most-viewed' => array('m.viewer_is_new', Phpfox::getPhrase('mail.unread_first'))), 'show' => array(10, 15, 20)))); $iPageSize = $this->search()->getDisplay(); $aFolders = Phpfox::getService('mail.folder')->get(); $sUrl = ''; $sFolder = ''; if (Phpfox::getParam('mail.threaded_mail_conversation')) { if ($bIsTrash) { $sUrl = $this->url()->makeUrl('mail.trash'); $this->search()->setCondition('AND m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.is_archive = 1'); } else { if ($bIsSentbox) { $sUrl = $this->url()->makeUrl('mail.sentbox'); } else { $sUrl = $this->url()->makeUrl('mail'); } $this->search()->setCondition('AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.is_archive = 0'); } } else { if ($bIsTrash) { $sFolder = Phpfox::getPhrase('mail.trash'); $sUrl = $this->url()->makeUrl('mail.trash'); $this->search()->setCondition('AND (m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 1) OR (m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 1)'); // $this->search()->setCondition('AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 1'); } elseif ($iPrivateBox) { if (isset($aFolders[$iPrivateBox])) { $sFolder = $aFolders[$iPrivateBox]['name']; $sUrl = $this->url()->makeUrl('mail.box', array('id' => (int) $iPrivateBox)); $this->search()->setCondition('AND m.viewer_folder_id = ' . (int) $iPrivateBox . ' AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0'); } else { $this->url()->send('mail', null, Phpfox::getPhrase('mail.mail_folder_does_not_exist')); } } else { if ($bIsSentbox) { $sFolder = Phpfox::getPhrase('mail.sent_messages'); $sUrl = $this->url()->makeUrl('mail.sentbox'); $this->search()->setCondition('AND m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 0'); } else { $sFolder = Phpfox::getPhrase('mail.inbox'); $sUrl = $this->url()->makeUrl('mail'); $this->search()->setCondition('AND m.viewer_folder_id = 0 AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0'); } } } list($iCnt, $aRows, $aInputs) = Mail_Service_Mail::instance()->get($this->search()->getConditions(), $this->search()->getSort(), $this->search()->getPage(), $iPageSize, $bIsSentbox, $bIsTrash); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); Mail_Service_Mail::instance()->buildMenu(); $aActions = array(); $aActions[] = array('phrase' => Phpfox::getPhrase('mail.delete'), 'action' => 'delete'); if (!$bIsSentbox && !$bIsInLegacyView) { $aActions[] = array('phrase' => Phpfox::getPhrase('mail.move'), 'action' => 'move'); } $aModeration = array('name' => 'mail', 'ajax' => 'mail.moderation', 'menu' => $aActions); if ($bIsSentbox) { $aModeration['custom_fields'] = '<div><input type="hidden" name="sent" value="1" /></div>'; } elseif ($bIsTrash) { $aModeration['custom_fields'] = '<div><input type="hidden" name="trash" value="1" /></div>'; } if (Phpfox::getParam('mail.threaded_mail_conversation')) { $aModeration['ajax'] = 'mail.archive'; $aMenuOptions = array(); if ($bIsTrash) { $aMenuOptions = array('phrase' => Phpfox::getPhrase('mail.un_archive'), 'action' => 'un-archive'); } else { $aMenuOptions = array('phrase' => Phpfox::getPhrase('mail.archive'), 'action' => 'archive'); } $aModeration['menu'] = array($aMenuOptions, array('phrase' => Phpfox::getPhrase('mail.export'), 'action' => 'export')); } $this->setParam('global_moderation', $aModeration); if (empty($sFolder)) { $sFolder = Phpfox::getPhrase('mail.mail'); } $iMailSpaceUsed = 0; if (!Phpfox::getUserParam('mail.override_mail_box_limit') && Phpfox::getParam('mail.enable_mail_box_warning')) { $iMailSpaceUsed = Mail_Service_Mail::instance()->getSpaceUsed(Phpfox::getUserId()); if ($iMailSpaceUsed > 100) { $iMailSpaceUsed = 100; } } $this->template()->setTitle($sFolder)->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setPhrase(array('mail.add_new_folder', 'mail.adding_new_folder', 'mail.view_folders', 'mail.edit_folders', 'mail.you_will_delete_every_message_in_this_folder', 'mail.updating'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'quick_edit.js' => 'static_script', 'selector.js' => 'static_script', 'mail.js' => 'module_mail', 'pager.css' => 'style_css', 'mail.css' => 'style_css'))->assign(array('aMails' => $aRows, 'bIsSentbox' => $bIsSentbox, 'bIsTrash' => $bIsTrash, 'aInputs' => $aInputs, 'aFolders' => $aFolders, 'iMailSpaceUsed' => $iMailSpaceUsed, 'iMessageAge' => Phpfox::getParam('mail.message_age_to_delete'), 'sUrl' => $sUrl, 'iFolder' => isset($aFolders[$iPrivateBox]['folder_id']) ? $aFolders[$iPrivateBox]['folder_id'] : 0, 'iTotalMessages' => $iCnt, 'sSiteName' => Phpfox::getParam('core.site_title'), 'bIsInLegacyView' => $bIsInLegacyView)); }
public function process() { $Theme = new Core\Theme(); $file = null; if ($this->request()->get('type') == 'language') { $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { // Phpfox_File::instance()->delete_directory($dir); }); $Zip = new \ZipArchive(); $Zip->open($file); $Zip->extractTo($dir); $Zip->close(); $pack = ''; $path = $dir . 'upload/include/xml/language/'; foreach (scandir($path) as $newDir) { if ($newDir == '.' || $newDir == '..') { continue; } $pack = $newDir; $path .= $newDir . '/'; break; } \Language_Service_Process::instance()->installPackFromFolder($pack, $path); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.language.import', ['dir' => base64_encode($path)]) . '\';</script>'; exit; } if ($this->request()->get('type') == 'theme') { $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { Phpfox_File::instance()->delete_directory($dir); }); Phpfox::addMessage('Theme successfully installed.'); $id = $Theme->import($file); // $this->url()->send('admincp.theme'); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.theme') . '\';</script>'; exit; } if (isset($_SERVER['HTTP_X_FILE_NAME']) || $this->request()->get('download')) { $App = (new Core\App())->import($this->request()->get('download'), $this->request()->get('download') ? true : false); if ($this->request()->get('download')) { // $this->url()->send('admincp.app', ['id' => $App->id]); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.app', ['id' => $App->id]) . '\';</script>'; exit; } return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } if ($token = $this->request()->get('m9token')) { (new Core\App())->vendor($token); d($token); exit; } if ($val = $this->request()->getArray('val')) { $App = (new Core\App())->make($val['name']); Phpfox::addMessage('App successfully created.'); return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } $this->template()->setBreadCrumb('New App', $this->url()->current(), true); }