コード例 #1
0
 /**
  * Gets a param that is part of this component group.
  *
  * @param string $sData Param name.
  * @return mixed If param exists we return the param value otherwise we return NULL.
  */
 public function __get($sData)
 {
     if (isset(self::$_aParams[$this->_sCacheVar][$sData])) {
         return self::$_aParams[$this->_sCacheVar][$sData];
     }
     Phpfox_Error::trigger('Undefined property: ' . $sData, E_USER_ERROR);
 }
コード例 #2
0
ファイル: process.class.php プロジェクト: Lovinity/EQM
 public function __call($sMethod, $aArguments)
 {
     if ($sPlugin = Phpfox_Plugin::get('younetcore.service_process__call')) {
         return eval($sPlugin);
     }
     Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
 }
コード例 #3
0
ファイル: CSS.php プロジェクト: Goudarzi-hahram/phpfox
 /**
  * @param $content
  * @param null $vars
  * @param string $more_content will not add to less files
  * @return bool
  */
 public function set($content, $vars = null, $more_content = '', $themeName = 'default')
 {
     $less = new \lessc();
     $lessContent = ($vars === null ? $this->get(true) : $vars) . "/** START CSS */\n";
     $saveLestContent = $lessContent . trim($content);
     $newContent = $saveLestContent . trim($more_content);
     if (strtolower($themeName) == 'bootstrap') {
         $less->setImportDir(PHPFOX_DIR . 'theme/frontend/bootstrap/less/');
     } else {
         $less->setImportDir(PHPFOX_DIR . 'less/');
     }
     $content = str_replace('../../../../PF.Base/less/', '', $newContent);
     $content = '@import "variables";' . PHP_EOL . $content;
     $parsed = null;
     try {
         $parsed = $less->compile($content);
     } catch (\Exception $ex) {
         if (PHPFOX_DEBUG) {
             \Phpfox_Error::trigger($ex->getMessage(), E_USER_ERROR);
         }
     }
     $path = $this->_theme->getPath() . 'flavor/' . $this->_theme->flavor_folder;
     file_put_contents($path . '.less', $saveLestContent);
     /* remove comments */
     $minify = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $parsed);
     /* remove tabs, spaces, newlines, etc. */
     $minify = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $minify);
     file_put_contents($path . '.css', $minify);
     $this->db->update(':setting', array('value_actual' => (int) \Phpfox::getParam('core.css_edit_id') + 1), 'var_name = \'css_edit_id\'');
     $this->cache->del('setting');
     return true;
     // file_put_contents($this->_theme->getPath() . 'flavor/' . $this->_theme->flavor_folder . '.min.css', $parsed);
     // if ($this->_get()) {
     /*
     $this->db->update(':theme_template', [
     	'html_data' => $parsed,
     	'html_data_original' => $content,
     	'time_stamp_update' => PHPFOX_TIME
     ], [
     	'folder' => $this->_theme->folder, 'type_id' => 'css', 'name' => $this->_theme->flavor_folder . '.css'
     ]);
     */
     //	return true;
     // }
     /*
     $this->db->insert(':theme_template', [
     	'folder' => $this->_theme->folder,
     	'type_id' => 'css',
     	'name' => $this->_theme->flavor_folder . '.css',
     	'html_data' => $parsed,
     	'html_data_original' => $content,
     	'time_stamp' => PHPFOX_TIME
     ]);
     */
 }
コード例 #4
0
ファイル: data.class.php プロジェクト: Lovinity/EQM
 /**
  * If a call is made to an unknown method attempt to connect
  * it to a specific plug-in with the same name thus allowing 
  * plug-in developers the ability to extend classes.
  *
  * @param string $sMethod is the name of the method
  * @param array $aArguments is the array of arguments of being passed
  */
 public function __call($sMethod, $aArguments)
 {
     /**
      * Check if such a plug-in exists and if it does call it.
      */
     if ($sPlugin = Phpfox_Plugin::get('report.service_data_data__call')) {
         return eval($sPlugin);
     }
     /**
      * No method or plug-in found we must throw a error.
      */
     Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
 }
コード例 #5
0
ファイル: phpfox.class.php プロジェクト: googlesky/snsp.vn
 /**
  * Loads the amazons3 library developed by another group.
  *
  */
 public function __construct()
 {
     if (!file_exists(PHPFOX_DIR_SETTING . 'cdn.sett.php')) {
         Phpfox_Error::trigger('CDN setting file is missing.', E_USER_DEPRECATED);
     }
     require_once PHPFOX_DIR_SETTING . 'cdn.sett.php';
     foreach ($aServers as $iKey => $aServer) {
         $iKey++;
         $iKey++;
         $this->_aServers[$iKey] = $aServer;
     }
     $this->_iServerId = array_rand($this->_aServers);
     //rand(2, (count($this->_aServers) + 1));
 }
コード例 #6
0
ファイル: item.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::getParam('tag.enable_hashtag_support')) {
         return false;
     }
     if (!defined('PHPFOX_TAG_PARENT_MODULE')) {
         define('PHPFOX_TAG_PARENT_MODULE', $this->getParam('sTagListParentModule', null));
     }
     if (!defined('PHPFOX_TAG_PARENT_ID')) {
         define('PHPFOX_TAG_PARENT_ID', $this->getParam('iTagListParentId', 0));
     }
     $this->template()->assign('sMicroKeywords', $this->getParam('sMicroKeywords'));
     if ($sType = $this->getParam('type')) {
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $iItemId = $this->getParam('item_id');
         $sTags = '';
         $sTagsClean = '';
         $aMainTags = Tag_Service_Tag::instance()->getTagsById($sType, $iItemId);
         if (!isset($aMainTags[$iItemId])) {
             return false;
         }
         foreach ($aMainTags[$iItemId] as $iKey => $aTag) {
             $aMainTags[$iItemId][$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iItemId][$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags[$iItemId], 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     } else {
         if (!($sType = $this->getParam('sType'))) {
             return Phpfox_Error::trigger(Phpfox::getPhrase('tag.missing_param_stype'), E_USER_ERROR);
         }
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $aMainTags = $this->getParam('sTags');
         $sTags = '';
         $sTagsClean = '';
         foreach ($aMainTags as $iKey => $aTag) {
             $aMainTags[$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags, 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     }
 }
コード例 #7
0
ファイル: file.class.php プロジェクト: lev1976g/core
 /**
  * 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();
     }
 }
コード例 #8
0
ファイル: mail.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * Sends out an email.
  *
  * @param mixed $mTo Can either be a persons email (STRING) or an ARRAY of emails.
  * @param string $sSubject Subject message of the email.
  * @param string $sTextPlain Plain text of the message.
  * @param string $sTextHtml HTML version of the message.
  * @param string $sFromName Name the email is from.
  * @param string $sFromEmail Email the email is from.
  * @return bool TRUE on success, FALSE on failure.
  */
 public function send($mTo, $sSubject, $sTextPlain, $sTextHtml, $sFromName = null, $sFromEmail = null)
 {
     $this->_oMail->AddAddress($mTo);
     $this->_oMail->Subject = $sSubject;
     $this->_oMail->Body = $sTextHtml;
     $this->_oMail->AltBody = $sTextPlain;
     if ($sFromName !== null) {
         $this->_oMail->FromName = $sFromName;
     }
     if ($sFromEmail !== null) {
         $this->_oMail->From = $sFromEmail;
     }
     if (!$this->_oMail->Send()) {
         $this->_oMail->ClearAddresses();
         return false;
         return Phpfox_Error::trigger($this->_oMail->ErrorInfo, E_USER_ERROR);
     }
     $this->_oMail->ClearAddresses();
     return true;
 }
コード例 #9
0
ファイル: smtp.class.php プロジェクト: Lovinity/EQM
 /**
  * Class constructor that loads PHPMailer class and sets all the needed variables.
  *
  * @return mixed FALSE if we cannot load PHPMailer, or NULL if we were.
  */
 public function __construct()
 {
     if (!file_exists(PHPFOX_DIR_LIB . 'phpmailer' . PHPFOX_DS . 'class.phpmailer.php')) {
         return Phpfox_Error::trigger('Unable to load lib: ' . PHPFOX_DIR_LIB . 'phpmailer' . PHPFOX_DS . 'class.phpmailer.php', E_USER_ERROR);
     }
     require_once PHPFOX_DIR_LIB . 'phpmailer' . PHPFOX_DS . 'class.phpmailer.php';
     $this->_oMail = new PHPMailer();
     $this->_oMail->From = Phpfox::getParam('core.email_from_email') ? Phpfox::getParam('core.email_from_email') : 'server@localhost';
     $this->_oMail->FromName = Phpfox::getParam('core.mail_from_name') ? Phpfox::getParam('core.mail_from_name') : Phpfox::getParam('core.site_title');
     if (Phpfox::getParam('core.mail_smtp_authentication')) {
         $this->_oMail->SMTPAuth = true;
         $this->_oMail->Username = Phpfox::getParam('core.mail_smtp_username');
         $this->_oMail->Password = Phpfox::getParam('core.mail_smtp_password');
     }
     $this->_oMail->Port = Phpfox::getParam('core.mail_smtp_port');
     $this->_oMail->Host = Phpfox::getParam('core.mailsmtphost');
     $this->_oMail->Mailer = "smtp";
     $this->_oMail->WordWrap = 75;
     $this->_oMail->CharSet = 'utf-8';
 }
コード例 #10
0
ファイル: spam.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * If a call is made to an unknown method attempt to connect
  * it to a specific plug-in with the same name thus allowing 
  * plug-in developers the ability to extend classes.
  *
  * @param string $sMethod is the name of the method
  * @param array $aArguments is the array of arguments of being passed
  */
 public function __call($sMethod, $aArguments)
 {
     /**
      * Check if such a plug-in exists and if it does call it.
      */
     if (($sPlugin = Phpfox_Plugin::get('spam_methods')) !== false) {
         eval($sPlugin);
         return;
     }
     /**
      * No method or plug-in found we must throw a error.
      */
     Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
 }
コード例 #11
0
ファイル: cache.class.php プロジェクト: noikiy/phpfox-dist
 /**
  * Complie sections {section}{/section}
  *
  * @param string $sArguments Section arguments.
  * @return string Converted PHP foreach().
  */
 private function _compileSectionStart($sArguments)
 {
     $aAttrs = $this->_parseArgs($sArguments);
     $sOutput = '<?php ';
     $sSectionName = $aAttrs['name'];
     if (empty($sSectionName)) {
         Phpfox_Error::trigger("missing section name", E_USER_ERROR);
     }
     $sOutput .= "if (isset(\$this->_aSections['{$sSectionName}'])) unset(\$this->_aSections['{$sSectionName}']);\n";
     $sSectionProps = "\$this->_aSections['{$sSectionName}']";
     foreach ($aAttrs as $sAttrName => $sAttrValue) {
         switch ($sAttrName) {
             case 'loop':
                 $sOutput .= "{$sSectionProps}['loop'] = is_array({$sAttrValue}) ? count({$sAttrValue}) : max(0, (int){$sAttrValue});\n";
                 break;
             case 'show':
                 if (is_bool($sAttrValue)) {
                     $bShowAttrValue = $sAttrValue ? 'true' : 'false';
                 } else {
                     $bShowAttrValue = "(bool){$sAttrValue}";
                 }
                 $sOutput .= "{$sSectionProps}['show'] = {$bShowAttrValue};\n";
                 break;
             case 'name':
                 $sOutput .= "{$sSectionProps}['{$sAttrName}'] = '{$sAttrValue}';\n";
                 break;
             case 'max':
             case 'start':
                 $sOutput .= "{$sSectionProps}['{$sAttrName}'] = (int){$sAttrValue};\n";
                 break;
             case 'step':
                 $sOutput .= "{$sSectionProps}['{$sAttrName}'] = ((int){$sAttrValue}) == 0 ? 1 : (int){$sAttrValue};\n";
                 break;
             default:
                 Phpfox_Error::trigger("unknown section attribute - '{$sAttrName}'", E_USER_ERROR);
                 break;
         }
     }
     if (!isset($aAttrs['show'])) {
         $sOutput .= "{$sSectionProps}['show'] = true;\n";
     }
     if (!isset($aAttrs['loop'])) {
         $sOutput .= "{$sSectionProps}['loop'] = 1;\n";
     }
     if (!isset($aAttrs['max'])) {
         $sOutput .= "{$sSectionProps}['max'] = {$sSectionProps}['loop'];\n";
     } else {
         $sOutput .= "if ({$sSectionProps}['max'] < 0)\n" . "\t{$sSectionProps}['max'] = {$sSectionProps}['loop'];\n";
     }
     if (!isset($aAttrs['step'])) {
         $sOutput .= "{$sSectionProps}['step'] = 1;\n";
     }
     if (!isset($aAttrs['start'])) {
         $sOutput .= "{$sSectionProps}['start'] = {$sSectionProps}['step'] > 0 ? 0 : {$sSectionProps}['loop']-1;\n";
     } else {
         $sOutput .= "if ({$sSectionProps}['start'] < 0)\n" . "\t{$sSectionProps}['start'] = max({$sSectionProps}['step'] > 0 ? 0 : -1, {$sSectionProps}['loop'] + {$sSectionProps}['start']);\n" . "else\n" . "\t{$sSectionProps}['start'] = min({$sSectionProps}['start'], {$sSectionProps}['step'] > 0 ? {$sSectionProps}['loop'] : {$sSectionProps}['loop']-1);\n";
     }
     $sOutput .= "if ({$sSectionProps}['show']) {\n";
     if (!isset($aAttrs['start']) && !isset($aAttrs['step']) && !isset($aAttrs['max'])) {
         $sOutput .= "\t{$sSectionProps}['total'] = {$sSectionProps}['loop'];\n";
     } else {
         $sOutput .= "\t{$sSectionProps}['total'] = min(ceil(({$sSectionProps}['step'] > 0 ? {$sSectionProps}['loop'] - {$sSectionProps}['start'] : {$sSectionProps}['start']+1)/abs({$sSectionProps}['step'])), {$sSectionProps}['max']);\n";
     }
     $sOutput .= "\tif ({$sSectionProps}['total'] == 0)\n" . "\t\t{$sSectionProps}['show'] = false;\n" . "} else\n" . "\t{$sSectionProps}['total'] = 0;\n";
     $sOutput .= "if ({$sSectionProps}['show']):\n";
     $sOutput .= "\n\t\t\tfor ({$sSectionProps}['index'] = {$sSectionProps}['start'], {$sSectionProps}['iteration'] = 1;\n\t\t\t\t {$sSectionProps}['iteration'] <= {$sSectionProps}['total'];\n\t\t\t\t {$sSectionProps}['index'] += {$sSectionProps}['step'], {$sSectionProps}['iteration']++):\n";
     $sOutput .= "{$sSectionProps}['rownum'] = {$sSectionProps}['iteration'];\n";
     $sOutput .= "{$sSectionProps}['index_prev'] = {$sSectionProps}['index'] - {$sSectionProps}['step'];\n";
     $sOutput .= "{$sSectionProps}['index_next'] = {$sSectionProps}['index'] + {$sSectionProps}['step'];\n";
     $sOutput .= "{$sSectionProps}['first']\t  = ({$sSectionProps}['iteration'] == 1);\n";
     $sOutput .= "{$sSectionProps}['last']\t   = ({$sSectionProps}['iteration'] == {$sSectionProps}['total']);\n";
     $sOutput .= "?>";
     return $sOutput;
 }
コード例 #12
0
ファイル: callback.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * If a call is made to an unknown method attempt to connect
  * it to a specific plug-in with the same name thus allowing 
  * plug-in developers the ability to extend classes.
  *
  * @param string $sMethod is the name of the method
  * @param array $aArguments is the array of arguments of being passed
  */
 public function __call($sMethod, $aArguments)
 {
     if (preg_match("/^getNewsFeed(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.getCommentNewsFeed', $aArguments[0], isset($aArguments[1]) ? $aArguments[1] : null);
     } elseif (preg_match("/^getFeedRedirect(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.getFeedRedirect', $aArguments[0], $aArguments[1]);
     } elseif (preg_match("/^getNotificationFeed(.*?)\$/i", $sMethod, $aMatches)) {
         if (empty($aMatches[1])) {
             $aMatches[1] = 'feed';
         }
         return Phpfox::callback(strtolower($aMatches[1]) . '.getCommentNotificationFeed', $aArguments[0]);
     } elseif (preg_match("/^getNotification(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.getCommentNotification', $aArguments[0]);
     } elseif (preg_match("/^getAjaxCommentVar(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.getAjaxCommentVar');
     } elseif (preg_match("/^getCommentItem(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.getCommentItem', $aArguments[0]);
     } elseif (preg_match("/^addComment(.*?)\$/i", $sMethod, $aMatches)) {
         return Phpfox::callback(strtolower($aMatches[1]) . '.addComment', $aArguments[0], isset($aArguments[1]) ? $aArguments[1] : null, isset($aArguments[2]) ? $aArguments[2] : null);
     }
     /*
     elseif (preg_match("/^sendLikeEmail(.*?)$/i", $sMethod, $aMatches))
     {			
     	return Phpfox::getPhrase('comment.a_href_user_link_full_name_a_likes_your_a_href_link_comment_a', array(
     				'full_name' => Phpfox::getLib('parse.output')->clean(Phpfox::getUserBy('full_name')),
     				'user_link' => Phpfox_Url::instance()->makeUrl(Phpfox::getUserBy('user_name')),
     				'link' => Phpfox::callback(strtolower($aMatches[1]) . '.getFeedRedirect', $aArguments[0])
     			)
     		);			
     }
     */
     /**
      * Check if such a plug-in exists and if it does call it.
      */
     if ($sPlugin = Phpfox_Plugin::get('comment.service_callback__call')) {
         return eval($sPlugin);
     }
     /**
      * No method or plug-in found we must throw a error.
      */
     Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
 }
コード例 #13
0
ファイル: parser.class.php プロジェクト: googlesky/snsp.vn
 /**
  * Parse XML code and convert into an ARRAY.
  *
  * @param string $mFile XML data or XML file name.
  * @param string $sEncoding Encoding.
  * @param bool $bEmptyData TRUE to empty XML data.
  * @return mixed FALSE if errors were found, ARRAY if no errors and XML was converted into an ARRAY.
  */
 public function parse($mFile, $sEncoding = 'ISO-8859-1', $bEmptyData = true)
 {
     $this->_sXml = $this->getXml($mFile);
     if (empty($this->_sXml) || $this->_iError > 0) {
         return false;
     }
     if (!($this->_oXml = xml_parser_create($sEncoding))) {
         return false;
     }
     xml_parser_set_option($this->_oXml, XML_OPTION_SKIP_WHITE, 0);
     xml_parser_set_option($this->_oXml, XML_OPTION_CASE_FOLDING, 0);
     xml_set_character_data_handler($this->_oXml, array(&$this, '_handleCdata'));
     xml_set_element_handler($this->_oXml, array(&$this, '_handleElementStart'), array(&$this, '_handleElementEnd'));
     xml_parse($this->_oXml, $this->_sXml);
     $bError = xml_get_error_code($this->_oXml);
     if ($bEmptyData) {
         $this->_sXml = '';
         $this->_aStack = array();
         $this->_sCdata = '';
     }
     if ($bError) {
         $this->_iErrorCode = @xml_get_error_code($this->_oXml);
         $this->_iErrorLine = @xml_get_current_line_number($this->_oXml);
         xml_parser_free($this->_oXml);
         return Phpfox_Error::trigger($this->errorString(), E_USER_ERROR);
     }
     xml_parser_free($this->_oXml);
     return $this->_aData;
 }
コード例 #14
0
ファイル: rackspace.class.php プロジェクト: Lovinity/EQM
 /**
  * Uploads the file to Rackspace server.
  *
  * @param string $sFile Full path to where the file is located.
  * @param string $sName Optional name of the file once it is uploaded. By default we just use the original file name.
  * @return bool We only return a bool false if we were not able to upload the item.
  */
 public function put($sFile, $sName = null)
 {
     $this->connect();
     Phpfox_Error::skip(true);
     if (empty($sName)) {
         $sName = str_replace("\\", '/', str_replace(PHPFOX_DIR, '', $sFile));
     }
     $object = $this->_oContainer->create_object($sName);
     try {
         $object->load_from_filename($sFile);
     } catch (Exception $hException) {
         Phpfox_Error::trigger($hException->getMessage());
     }
     $this->_bIsUploaded = true;
     if (Phpfox::getParam('core.keep_files_in_server') == false) {
         $oSess = Phpfox::getLib('session');
         $aFiles = $oSess->get('deleteFiles');
         if (is_array($aFiles)) {
             $aFiles[] = $sFile;
         } else {
             $aFiles = array($sFile);
         }
         $oSess->set('deleteFiles', $aFiles);
     }
     Phpfox_Error::skip(false);
     return true;
 }
コード例 #15
0
ファイル: phpfox.class.php プロジェクト: html5ravi/phpfox
 /**
  * Fine and load a library class and make sure it exists.
  *
  * @param string $sClass Library class name.
  * @return bool TRUE if library has loaded, FALSE if not.
  */
 public static function getLibClass($sClass)
 {
     class_exists('Phpfox_Plugin') && ($sPlugin = Phpfox_Plugin::get('library_phpfox_getlibclass_0')) ? eval($sPlugin) : false;
     if (isset(self::$_aLibs[$sClass])) {
         return true;
     }
     self::$_aLibs[$sClass] = md5($sClass);
     $sClass = str_replace('.', PHPFOX_DS, $sClass);
     $sFile = PHPFOX_DIR_LIB . $sClass . '.class.php';
     if (file_exists($sFile)) {
         require $sFile;
         return true;
     }
     $aParts = explode(PHPFOX_DS, $sClass);
     if (isset($aParts[1])) {
         $sSubClassFile = PHPFOX_DIR_LIB . $sClass . PHPFOX_DS . $aParts[1] . '.class.php';
         if (file_exists($sSubClassFile)) {
             require $sSubClassFile;
             return true;
         }
     }
     if (class_exists($sClass)) {
         return true;
     }
     ($sPlugin = Phpfox_Plugin::get('library_phpfox_getlibclass_1')) ? eval($sPlugin) : false;
     if (isset($mPluginReturn)) {
         return $mPluginReturn;
     }
     Phpfox_Error::trigger('Unable to load class: ' . $sClass, E_USER_ERROR);
     return false;
 }
コード例 #16
0
ファイル: process.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * If a call is made to an unknown method attempt to connect
  * it to a specific plug-in with the same name thus allowing 
  * plug-in developers the ability to extend classes.
  *
  * @param string $sMethod is the name of the method
  * @param array $aArguments is the array of arguments of being passed
  */
 public function __call($sMethod, $aArguments)
 {
     $aDeprecated = array('approve', 'like', 'rate', 'updateCommentText', 'deleteLikes');
     if (in_array($sMethod, $aDeprecated)) {
         return Phpfox_Error::set('Method deprecated since 2.1.0beta1');
     }
     /**
      * Check if such a plug-in exists and if it does call it.
      */
     if ($sPlugin = Phpfox_Plugin::get('feed.service_process__call')) {
         return eval($sPlugin);
     }
     /**
      * No method or plug-in found we must throw a error.
      */
     Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
 }
コード例 #17
0
ファイル: postgres.class.php プロジェクト: googlesky/snsp.vn
 public function execute($sType, $aParams = array())
 {
     $sSql = $this->_aQuery['select'] . "\n";
     $sSql .= $this->_aQuery['table'] . "\n";
     $sSql .= isset($this->_aQuery['join']) ? $this->_aQuery['join'] . "\n" : '';
     $sSql .= isset($this->_aQuery['where']) ? $this->_aQuery['where'] . "\n" : '';
     $sSql .= isset($this->_aQuery['group']) ? $this->_aQuery['group'] . "\n" : '';
     $sSql .= isset($this->_aQuery['having']) ? $this->_aQuery['having'] . "\n" : '';
     $sSql .= isset($this->_aQuery['order']) ? $this->_aQuery['order'] . "\n" : '';
     $sSql .= isset($this->_aQuery['limit']) ? $this->_aQuery['limit'] . "\n" : '';
     $this->_aQuery = array();
     $bDoCache = false;
     if (isset($aParams['cache']) && $aParams) {
         $bDoCache = true;
         $oCache = Phpfox::getLib('cache');
     }
     if ($bDoCache) {
         $sCacheId = $oCache->set($aParams['cache_name']);
         if (isset($aParams['cache_limit']) && ($aRows = $oCache->get($sCacheId, $aParams['cache_limit'])) || ($aRows = $oCache->get($sCacheId))) {
             return $aRows;
         }
     }
     switch ($sType) {
         case 'getSlaveRows':
             $aRows = $this->getSlaveRows($sSql);
             break;
         case 'getSlaveRow':
             $aRows = $this->getSlaveRow($sSql);
             break;
         case 'getRow':
             $aRows = $this->getRow($sSql);
             break;
         case 'getRows':
             $aRows = $this->getRows($sSql);
             break;
         case 'getField':
             $aRows = $this->getField($sSql);
             break;
         case 'getSlaveField':
             $aRows = $this->getSlaveField($sSql);
             break;
         default:
             Phpfox_Error::trigger('Invalid execute on SQL query.', E_USER_ERROR);
     }
     if ($bDoCache) {
         $oCache->save($sCacheId, $aRows);
     }
     if (isset($aParams['free_result'])) {
         $this->freeResult();
     }
     return $aRows;
 }
コード例 #18
0
ファイル: locale.class.php プロジェクト: Lovinity/EQM
 /**
  * Gets a phrase from a language.
  * 
  * Example Usage (PHP)
  * <code>
  * Phpfox::getPhrase('foo.bar');
  * </code>
  * 
  * Example Usage (HTML)
  * <code>
  * {phrase var='for.bar'}
  * </code>
  *
  * @param string $sParam Phrase param that is unique for that specific phrase.
  * @param array $aParams (Optional) ARRAY of data we need to replace in the phrase
  * @param bool $bNoDebug (Optional) FALSE allows debug mode to be executed, while TRUE forces that there is no debug output.
  * @param string $sDefault (Optional) If the phrase is not found you can pass a default string in its place and we will return that instead.
  * @param string $sLang (Optional) By default we use the default language ID, however you can specifiy to load a phrase for a specific language package here.
  * @return string Phrase value associated with the 1st argument passed.
  */
 public function getPhrase($sParam, $aParams = array(), $bNoDebug = false, $sDefault = null, $sLang = '')
 {
     if (strpos($sParam, '.') === false) {
         if (Phpfox::getParam('language.lang_pack_helper') && !$bNoDebug) {
             return "#{$sParam}#";
         }
         return '';
     }
     list($sModule, $sVar) = explode('.', $sParam);
     if ($sLang != null && $sLang != '' && $sLang != $this->getLangId() && isset($this->_aLanguages[$sLang])) {
         $this->_sOverride = $sLang;
         $this->_aPhrases = array();
         $this->_getModuleLanguage($sModule);
         $sPhrase = $this->getPhrase($sParam, $aParams);
         $this->_sOverride = '';
         $this->_aPhrases = array();
         return $sPhrase;
     }
     if (!isset($this->_aPhrases[$sModule])) {
         $this->_getModuleLanguage($sModule);
     }
     $bPassed = true;
     if (!isset($this->_aPhrases[$sModule][$sVar])) {
         $bPassed = false;
         if (defined('PHPFOX_INSTALLER') || Phpfox::getParam('language.cache_phrases')) {
             $this->_getModuleLanguage($sModule, true);
             if (isset($this->_aPhrases[$sModule][$sVar])) {
                 $bPassed = true;
             }
         }
         if (!$bPassed) {
             if ($sDefault !== null) {
                 return $sDefault;
             }
             if ($sPlugin = Phpfox_Plugin::get('library_phpfox_locale_phrase_not_found')) {
                 eval($sPlugin);
                 if (isset($mPluginReturn)) {
                     return $mPluginReturn;
                 }
             }
             if (PHPFOX_DEBUG) {
                 Phpfox_Error::trigger('Unable to find the phrase: ' . strip_tags($sParam));
             }
             return '';
         }
     }
     $sPhrase = $this->_aPhrases[$sModule][$sVar];
     if (defined('PHPFOX_INSTALLER') || Phpfox::getParam('language.cache_phrases') && !$this->_bIsCached) {
         $this->_aCache[$sModule][$sVar] = $sPhrase;
     }
     if (isset($aParams['user'])) {
         if (!is_array($aParams['user'])) {
             Phpfox_Error::trigger('The key "user" needs to be an array of the users details.');
         }
         $sUserPrefix = isset($aParams['user_prefix']) ? $aParams['user_prefix'] : '';
         $aUser = $aParams['user'];
         $aUser['user_link'] = '<a href="' . Phpfox::getLib('url')->makeUrl($aUser[$sUserPrefix . 'user_name']) . '">' . Phpfox::getLib('parse.output')->clean($aUser[$sUserPrefix . 'full_name']) . '</a>';
         unset($aParams['user']);
         $aParams = array_merge($aParams, $aUser);
     }
     if ($aParams) {
         $aFind = array();
         $aReplace = array();
         foreach ($aParams as $sKey => $sValue) {
             if (is_array($sValue)) {
                 continue;
             }
             $aFind[] = '{' . $sKey . '}';
             $aReplace[] = '' . $sValue . '';
         }
         $sPhrase = str_replace($aFind, $aReplace, $sPhrase);
     }
     if (isset($this->_aRules[$sModule . '.' . $sVar])) {
         $sEval = '';
         $iCnt = 0;
         foreach ($this->_aRules[$sModule . '.' . $sVar] as $aRule) {
             $iCnt++;
             $aFind = array();
             $aReplace = array();
             foreach ($aParams as $sKey => $sValue) {
                 $aFind[] = '/{' . $sKey . '}/i';
                 $aReplace[] = '' . $sValue . '';
             }
             $aRule['rule'] = preg_replace($aFind, $aReplace, $aRule['rule']);
             $aRule['rule_value'] = preg_replace($aFind, $aReplace, $aRule['rule_value']);
             $sEval .= ($iCnt === 1 ? 'if' : 'elseif') . ' (' . $aRule['rule'] . ') { $sPhrase = \'' . str_replace("'", "\\'", $aRule['rule_value']) . '\'; } ';
         }
         eval($sEval);
     }
     $sPhrase = Phpfox::getParam('language.lang_pack_helper') && !$bNoDebug ? '{' . $sPhrase . '}' : $sPhrase;
     if (isset($aParams['phpfox_squote'])) {
         $sPhrase = str_replace("'", "\\'", $sPhrase);
     }
     if (!defined('PHPFOX_INSTALLER') && $sParam == 'user.full_name' && Phpfox::getParam('user.display_or_full_name') == 'display_name') {
         return Phpfox::getPhrase('user.display_name');
     }
     $this->_aPhraseHistory[md5($sPhrase)] = array('var_name' => $sParam, 'params' => $aParams);
     return $sPhrase;
 }
コード例 #19
0
ファイル: ftp.class.php プロジェクト: hoanghd/tools
	/**
	 * Moves a file from one location to another on the FTP server.
	 *
	 * @see ftp_rename()
	 * @param string $sOld Full path to the file we are going to move
	 * @param string $sNew Full path to where we are going to place the file
	 * @return bool TRUE on success, FALSE on failure
	 */
	public function move($sOld, $sNew)
	{		
		// Use ftp_rename to move the item
		if (!ftp_rename($this->_oFtp, str_replace(PHPFOX_DIR, Phpfox::getParam('core.ftp_dir_path'), $sOld), str_replace(PHPFOX_DIR, Phpfox::getParam('core.ftp_dir_path'), $sNew)))
		{			
			return Phpfox_Error::trigger('Unable to move file ' . str_replace(PHPFOX_DIR, Phpfox::getParam('core.ftp_dir_path'), $sOld) . ' to ' . str_replace(PHPFOX_DIR, Phpfox::getParam('core.ftp_dir_path'), $sNew) . '.', E_USER_ERROR);
		}
		
		return true;
	}
コード例 #20
0
ファイル: session.class.php プロジェクト: nima7r/phpfox-dist
 private function _log($sMessage)
 {
     if (PHPFOX_DEBUG) {
         Phpfox_Error::trigger($sMessage, E_USER_ERROR);
     }
     exit($sMessage);
 }
コード例 #21
0
ファイル: phpfox.class.php プロジェクト: hoanghd/tools
	/**
	 * Fine and load a library class and make sure it exists.
	 *
	 * @param string $sClass Library class name.
	 * @return bool TRUE if library has loaded, FALSE if not.
	 */
	public static function getLibClass($sClass)
	{
		if (isset(self::$_aLibs[$sClass]))
		{
			return true;
		}

		self::$_aLibs[$sClass] = md5($sClass);		
		
		$sClass = str_replace('.', PHPFOX_DS, $sClass);
		$sFile = PHPFOX_DIR_LIB . $sClass . '.class.php';
		
		if (file_exists($sFile))
		{			
			require($sFile);
			return true;
		}		
		
		$aParts = explode(PHPFOX_DS, $sClass);		
		if (isset($aParts[1]))
		{
			$sSubClassFile = PHPFOX_DIR_LIB . $sClass . PHPFOX_DS . $aParts[1] . '.class.php';			
			if (file_exists($sSubClassFile))
			{
				require($sSubClassFile);
				return true;
			}
		}		
	
		Phpfox_Error::trigger('Unable to load class: ' . $sClass, E_USER_ERROR);
		
		return false;
	}
コード例 #22
0
ファイル: item.class.php プロジェクト: hoanghd/tools
	/**
	 * Class process method wnich is used to execute this component.
	 */
	public function process()
	{
		if (($sType = $this->getParam('type')))
		{
			$aUser = $this->getParam('aUser');
			$sLink = Phpfox::callback($sType . '.getTagLink', $aUser);		
			$iItemId = $this->getParam('item_id');				
			$sTags = '';
			$sTagsClean = '';
			$aMainTags = Phpfox::getService('tag')->getTagsById($sType, $iItemId);	
			
			if (!isset($aMainTags[$iItemId]))
			{
				return false;
			}
			
			foreach ($aMainTags[$iItemId] as $iKey => $aTag)
			{
				$aMainTags[$iItemId][$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
				$sTags .= ', <a href="' . $aMainTags[$iItemId][$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';	
				$sTagsClean .= ', ' . $aTag['tag_text'];
			}
			$sTags = ltrim($sTags, ',');
			$sTagsClean = ltrim($sTagsClean, ',');			
			
			$this->template()->assign(array(
					'sLink' => $sLink,
					'sType' => Phpfox::callback($sType . '.getTagType'),
					'sTags' => $sTags,
					'sMainTags' => $sTagsClean,
					'aTags' => $aMainTags[$iItemId],
					'iItemId' => $this->getParam('iItemId'),
					'iUserId' => $this->getParam('iUserId'),
					'bIsInline' => $this->getParam('bIsInline'),
					'bDontCleanTags' => $this->getParam('bDontCleanTags')
				)
			);
		}
		else 
		{			
			if (!($sType = $this->getParam('sType')))
			{
				return Phpfox_Error::trigger(Phpfox::getPhrase('tag.missing_param_stype'), E_USER_ERROR);
			}
	
			$aUser = $this->getParam('aUser');
			$sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
			
			$aMainTags = $this->getParam('sTags');
			$sTags = '';
			$sTagsClean = '';
			foreach ($aMainTags as $iKey => $aTag)
			{
				$aMainTags[$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
				$sTags .= ', <a href="' . $aMainTags[$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';	
				$sTagsClean .= ', ' . $aTag['tag_text'];
			}
			$sTags = ltrim($sTags, ',');
			$sTagsClean = ltrim($sTagsClean, ',');
			
			$this->template()->assign(array(
					'sLink' => $sLink,
					'sType' => Phpfox::callback($sType . '.getTagType'),
					'sTags' => $sTags,
					'sMainTags' => $sTagsClean,
					'aTags' => $aMainTags,
					'iItemId' => $this->getParam('iItemId'),
					'iUserId' => $this->getParam('iUserId'),
					'bIsInline' => $this->getParam('bIsInline'),
					'bDontCleanTags' => $this->getParam('bDontCleanTags')
				)
			);			
		}		
	}
コード例 #23
0
 /**
  * Loads a module component. Components are the building blocks of the site and
  * include controllers which build up the pages we see and blocks that build up the controllers.
  *
  * @param string $sClass Name of the component to load.
  * @param array $aParams (Optional) Custom params you can pass to the component.
  * @param string $sType (Optional) Identify if this component is a block or a controller.
  * @param boolean $bTemplateParams Assign $aParams to the template
  * @return mixed Return the component object if it exists, otherwise FALSE.
  */
 public function getComponent($sClass, $aParams = array(), $sType = 'block', $bTemplateParams = false)
 {
     ($sPlugin = Phpfox_Plugin::get('module_getcomponent_start')) ? eval($sPlugin) : false;
     if ($sType == 'ajax' && strpos($sClass, '.') === false) {
         $sClass = $sClass . '.ajax';
     }
     if (is_array($sClass)) {
         return Phpfox::getBlock('core.holder', array('block_location' => $this->_aCacheBlockId[md5($sClass[0])]['location'], 'block_custom_id' => $this->_aCacheBlockId[md5($sClass[0])]['block_id'], 'content' => $sClass[0]));
     }
     $aParts = explode('.', $sClass);
     $sModule = $aParts[0];
     $sComponent = $sType . PHPFOX_DS . substr_replace(str_replace('.', PHPFOX_DS, $sClass), '', 0, strlen($sModule . PHPFOX_DS));
     if ($sType == 'controller') {
         $this->_sModule = $sModule;
         $this->_sController = substr_replace(str_replace('.', PHPFOX_DS, $sClass), '', 0, strlen($sModule . PHPFOX_DS));
     }
     static $sBlockName = '';
     if ($sModule == 'custom') {
         if (preg_match('/block\\' . PHPFOX_DS . 'cf_(.*)/i', $sComponent, $aCustomMatch)) {
             $aParams = array('type_id' => 'user_main', 'template' => 'content', 'custom_field_id' => $aCustomMatch[1]);
             $sBlockName = 'custom_cf_' . $aCustomMatch[1];
             $sComponent = 'block' . PHPFOX_DS . 'display';
             $sClass = 'custom.display';
         }
     }
     /*if (Theme_Service_Theme::instance()->isInDnDMode() || defined('PHPFOX_IN_DESIGN_MODE'))
     		{
     			Phpfox_Template::instance()->assign(array('sDeleteBlock' => str_replace('.','_',$sClass),
     				'bBlockCanMove' => true));				
     		}*/
     $sMethod = $sModule . '_component_' . str_replace(PHPFOX_DS, '_', $sComponent) . '_process';
     /*
     if (preg_match('/(.*?)\((.*?)\)/', $sComponent, $aMatches) && !empty($aMatches[2]))
     {
     	eval('$aParams = array_merge($aParams, array(' . $aMatches[2] . '));');
     
     	$sComponent = $aMatches[1];		
     	$sClass = $aMatches[1];			
     }		
     */
     $sHash = md5($sClass . $sType);
     if (!isset($this->_aModules[$sModule])) {
         return false;
     }
     if (isset($this->_aComponent[$sHash])) {
         $this->_aComponent[$sHash]->__construct(array('sModule' => $sModule, 'sComponent' => $sComponent, 'aParams' => $aParams));
     } else {
         $sClassFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . $sComponent . '.class.php';
         if (!file_exists($sClassFile) && isset($aParts[1])) {
             $sClassFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . $sComponent . PHPFOX_DS . $aParts[1] . '.class.php';
         }
         ($sPlugin = Phpfox_Plugin::get('library_module_getcomponent_1')) ? eval($sPlugin) : false;
         if (isset($mPluginReturn)) {
             return $mPluginReturn;
         }
         // Lets check if there is such a component
         if (!file_exists($sClassFile)) {
             ($sPlugin = Phpfox_Plugin::get('library_module_getcomponent_2')) ? eval($sPlugin) : false;
             if (isset($mPluginReturn)) {
                 return $mPluginReturn;
             }
             // Opps, for some reason we have loaded an invalid component. Lets send back info to the dev.
             Phpfox_Error::trigger('Failed to load component: ' . $sClass . ' (' . $sClassFile . ')', E_USER_ERROR);
         }
         // Require the component
         require $sClassFile;
         // Get the object
         $this->_aComponent[$sHash] = Phpfox::getObject($sModule . '_component_' . str_replace(PHPFOX_DS, '_', $sComponent), array('sModule' => $sModule, 'sComponent' => $sComponent, 'aParams' => $aParams));
     }
     $mReturn = 'blank';
     if ($sType != 'ajax') {
         ($sPlugin = Phpfox_Plugin::get('component_pre_process')) ? eval($sPlugin) : false;
         $mReturn = $this->_aComponent[$sHash]->process();
         if (is_object($mReturn) && $mReturn instanceof Closure) {
             ob_clean();
             echo $mReturn->__invoke();
             exit;
         }
         if ($sType == 'controller' && (is_array($mReturn) || is_object($mReturn))) {
             if ($mReturn instanceof Core\jQuery) {
                 $mReturn = ['run' => (string) $mReturn];
             }
             ob_clean();
             header('Content-type: application/json');
             echo json_encode($mReturn);
             exit;
         }
         ($sPlugin = Phpfox_Plugin::get('component_post_process')) ? eval($sPlugin) : false;
     }
     $this->_aReturn[$sClass] = $mReturn;
     // If we return the component as 'false' then there is no need to display it.
     if (is_bool($mReturn) && !$mReturn || $this->_bNoTemplate) {
         if ($this->_bNoTemplate) {
             $this->_bNoTemplate = false;
         }
         return $this->_aComponent[$sHash];
     }
     /* Should we pass the params to the template? */
     if ($bTemplateParams) {
         Phpfox_Template::instance()->assign($aParams);
     }
     // Check if we don't want to display a template
     if (!isset($aParams['bNoTemplate']) && $mReturn != 'blank') {
         if ($mReturn && is_string($mReturn)) {
             $sBlockShowName = $sModule == 'custom' && !empty($sBlockName) ? $sBlockName : ucwords(str_replace('.', ' ', $sClass));
             $sBlockBorderJsId = $sModule == 'custom' && !empty($sBlockName) ? $sBlockName : str_replace('.', '_', $sClass);
             $sBlockPath = $sModule . '.' . str_replace('block' . PHPFOX_DS, '', $sComponent);
             $bCanMove = !isset($this->_aMoveBlocks[$this->_sModule . '.' . $this->_sController][$sBlockPath]) || isset($this->_aMoveBlocks[$this->_sModule . '.' . $this->_sController][$sBlockPath]) && $this->_aMoveBlocks[$this->_sModule . '.' . $this->_sController][$sBlockPath] == true;
             Phpfox_Template::instance()->assign(array('sBlockShowName' => $sBlockShowName, 'sBlockBorderJsId' => $sBlockBorderJsId, 'bCanMove' => $bCanMove, 'sClass' => $sClass))->setLayout($mReturn);
         }
         if (!is_array($mReturn)) {
             $sComponentTemplate = $sModule . '.' . str_replace(PHPFOX_DS, '.', $sComponent);
             ($sPlugin = Phpfox_Plugin::get('module_getcomponent_gettemplate')) ? eval($sPlugin) : false;
             Phpfox_Template::instance()->getTemplate($sComponentTemplate);
         }
         // Check if the component we have loaded has the clean() method
         if (is_object($this->_aComponent[$sHash]) && method_exists($this->_aComponent[$sHash], 'clean')) {
             // This method is used to clean out any garbage we don't need later on in the script. In most cases Template assigns.
             $this->_aComponent[$sHash]->clean();
         }
     }
     return $this->_aComponent[$sHash];
 }
コード例 #24
0
 /**
  * Process a form and perform regex checks on all the values.
  *
  * @param array $aParams ARRAY of regex checks.
  * @param array $aValues ARRAY of form values.
  * @return mixed Returns all the values cleaned if everything is okay, however if something failed a regex check we return FALSE.
  */
 public function process($aParams, $aValues)
 {
     foreach ($aValues as $sValueKey => $sValue) {
         if (!isset($aParams[$sValueKey])) {
             unset($aValues[$sValueKey]);
         }
     }
     $sDebug = '';
     foreach ($aParams as $sKey => $aParam) {
         if (!is_array($aParam)) {
             $aParam = array('type' => $aParam);
         }
         if (!is_array($aParam['type'])) {
             $aParam['type'] = array($aParam['type']);
         }
         $bFailed = false;
         foreach ($aParam['type'] as $sType) {
             switch ($sType) {
                 case 'array:required':
                 case 'array':
                     if ($sType == 'array:required') {
                         if (empty($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value for array is empty.';
                         }
                     }
                     if ($bFailed === false && isset($aValues[$sKey]) && !is_array($aValues[$sKey])) {
                         $bFailed = true;
                         $sDebug = 'Value is not an array.';
                     }
                     break;
                 case 'phrase':
                 case 'phrase:required':
                     if ($sType == 'phrase:required') {
                         if (empty($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value for phrase is empty.';
                         }
                     }
                     if ($bFailed === false && isset($aValues[$sKey]) && !is_array($aValues[$sKey])) {
                         $bFailed = true;
                         $sDebug = 'Value for phrase is not an array.';
                     }
                     if ($bFailed === false) {
                         $iPhraseCount = 0;
                         foreach ($aValues[$sKey] as $sLanguage => $sPhrase) {
                             if (!empty($sPhrase)) {
                                 $iPhraseCount++;
                             }
                         }
                         if ($iPhraseCount === 0) {
                             $bFailed = true;
                             $sDebug = 'Phrase values are all empty.';
                         }
                     }
                     break;
                 case 'php_code':
                 case 'php_code:required':
                     if ($sType == 'php_code:required') {
                         if (empty($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value for PHP code is empty.';
                         }
                     }
                     if ($bFailed === false) {
                         if (!empty($aValues[$sKey])) {
                             $aValues[$sKey] = Phpfox::getLib('parse.format')->phpCode($aValues[$sKey]);
                         }
                     }
                     break;
                 case 'currency:required':
                     if (!isset($aValues[$sKey])) {
                         $bFailed = true;
                         $sDebug = 'Value not found.';
                     } else {
                         if (!is_array($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value is not an array.';
                         }
                     }
                     if ($bFailed === false) {
                         $aValues[$sKey] = (array) $aValues[$sKey];
                         foreach ($aValues[$sKey] as $sCurrency => $mValue) {
                             if (empty($mValue) && strlen($mValue) < 1) {
                                 // unset($aValues[$sKey][$sCurrency]);
                                 $bFailed = true;
                                 $sDebug = 'Value of array is empty.';
                                 break;
                             }
                             $sPrice = str_replace(array(' ', ','), '', $mValue);
                             $aParts = explode('.', $sPrice);
                             if (count($aParts) > 2) {
                                 $iCnt = 0;
                                 $sPrice = '';
                                 foreach ($aParts as $sPart) {
                                     $iCnt++;
                                     $sPrice .= (count($aParts) == $iCnt ? '.' : '') . $sPart;
                                 }
                             }
                             if (!is_numeric($sPrice)) {
                                 unset($aValues[$sKey][$sCurrency]);
                             }
                         }
                         if (!count($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value of array is empty.';
                         }
                     }
                     break;
                 case 'price:required':
                     if (empty($aValues[$sKey]) && (int) $aValues[$sKey] !== 0) {
                         $bFailed = true;
                         $sDebug = 'Value not found.';
                     } else {
                         $sPrice = str_replace(array(' ', ','), '', $aValues[$sKey]);
                         $aParts = explode('.', $sPrice);
                         if (count($aParts) > 2) {
                             $iCnt = 0;
                             $sPrice = '';
                             foreach ($aParts as $sPart) {
                                 $iCnt++;
                                 $sPrice .= (count($aParts) == $iCnt ? '.' : '') . $sPart;
                             }
                         }
                         if (is_numeric($sPrice)) {
                             $aValues[$sKey] = $sPrice;
                         } else {
                             $bFailed = true;
                             $sDebug = 'Value is not a numeric value.';
                         }
                     }
                     break;
                 case 'string:required':
                 case 'string':
                     $bCatchZero = true;
                     if ($this->_bAllowZero == true && $aValues[$sKey] == '0') {
                         $bCatchZero = false;
                     }
                     if ($sType == 'string:required' && empty($aValues[$sKey]) && $bCatchZero) {
                         $bFailed = true;
                         $sDebug = 'Value not found.';
                     }
                     if (!empty($aValues[$sKey]) && !is_string($aValues[$sKey]) && $bCatchZero) {
                         $bFailed = true;
                         $sDebug = 'Value is not a string.';
                     }
                     break;
                 case 'int:required':
                     if (!isset($aValues[$sKey])) {
                         $bFailed = true;
                         $sDebug = 'Value not found.';
                     } else {
                         if (!is_numeric($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value is not a numeric value.';
                         }
                     }
                     if ($bFailed === false) {
                         $aValues[$sKey] = (int) $aValues[$sKey];
                     }
                     break;
                 case 'int':
                     if (isset($aValues[$sKey])) {
                         if (!is_numeric($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value is not a numeric value.';
                         } else {
                             $aValues[$sKey] = (int) $aValues[$sKey];
                         }
                     }
                     break;
                 case 'boolean':
                     if (isset($aValues[$sKey])) {
                         if (!is_bool($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Value is not a boolean value.';
                         }
                     }
                     break;
                 case 'product_id':
                 case 'product_id:required':
                     if ($sType == 'php_code:required') {
                         if (empty($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Product ID is missing.';
                         }
                     }
                     break;
                 case 'module_id':
                 case 'module_id:required':
                     if ($sType == 'module_id:required') {
                         if (empty($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Module ID is missing.';
                         }
                     }
                     if ($bFailed === false && $sType == 'module_id:required' || $sType == 'module_id' && !empty($aValues[$sKey])) {
                         if (!Phpfox::isModule($aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Not a valid module.';
                         }
                     }
                     break;
                 default:
                     if (preg_match('/^regex:(.*?)$/', $sType, $aMatches)) {
                         if (isset($this->_aRegex[$aMatches[1]]) && !preg_match($this->_aRegex[$aMatches[1]], $aValues[$sKey])) {
                             $bFailed = true;
                             $sDebug = 'Regex "' . $aMatches[1] . '" failed.';
                         }
                     } else {
                         return Phpfox_Error::trigger('Not a valid validation type: ' . $sType, E_USER_ERROR);
                     }
                     break;
             }
             if ($bFailed) {
                 Phpfox_Error::set((isset($aParam['message']) ? $aParam['message'] : $sDebug . '(' . $sKey . ')') . (PHPFOX_DEBUG && isset($aParam['message']) ? ' DEBUG: ' . $sDebug : ''));
             }
         }
         if ($bFailed === false) {
             if (isset($aParam['convert'])) {
                 $aValues[$sKey] = Phpfox::getLib('parse.input')->convert($aValues[$sKey]);
             }
         }
     }
     return $aValues;
 }
コード例 #25
0
ファイル: module.class.php プロジェクト: hoanghd/tools
	/**
	 * Execute a callback on a specific module based on the 1st argument.
	 *
	 * @param string $sCall Module and callback method to execute.
	 * @param array $aParams ARRAY of params you can pass to the callback.
	 * @return mixed Returns the value the callback itself returns. FALSE if not callback was found.
	 */
	public function callback($sCall, $aParams = array())
	{
		static $aModules = array();
		
		// Lets get the module and method we plan on calling
		$aParts1 = explode('.', $sCall);		
		$sModule = $aParts1[0];
		$sMethod = $aParts1[1];
		
		if (strpos($sModule, '_'))
		{
			$aParts = explode('_', $sModule);			
			$sModule = $aParts[0];
			$sMethod = $sMethod . ucfirst(strtolower($aParts[1]));			
			if (isset($aParts[2]))
			{
				$sMethod .= '_' . ucfirst(strtolower($aParts[2]));
			}			
		}		
		
		// Have we cached the object?
		if (!isset($aModules[$sModule]))
		{			
			// Make sure its a valid/enabled module
			if (!Phpfox::isModule($sModule))
			{
				return Phpfox_Error::trigger('Invalid module: ' . $sModule, E_USER_ERROR);
			}
			
			// Cache the object and get the callback service
			$aModules[$sModule] = $this->getService($sModule . '.callback');
		}	
			
		// Do we have any args. to pass?
		if (count($aParams) && isset($aParams[1]))
		{			
			// Prepare the args.
			$sEval = '$mReturn = $aModules[$sModule]->$sMethod(';			
			for ($i = 1; $i < count($aParams); $i++)
			{
				$sEval .= var_export($aParams[$i], true) . ',';
			}
			$sEval = rtrim($sEval, ',') . ');';

			eval($sEval);			
		}
		else 
		{
			eval('$mReturn = $aModules[$sModule]->$sMethod();');
		}
		
		return $mReturn;
	}
コード例 #26
0
ファイル: dba.class.php プロジェクト: lev1976g/core
 /**
  * Performs all the joins based on information passed from JOIN methods within this class.
  *
  * @see self::join()
  * @see self::leftJoin()
  * @see self::innerJoin()
  * @param string $sType The type of join we are going to use (LEFT JOIN, JOIN, INNER JOIM)
  * @param string $sTable Table to join
  * @param string $sAlias Alias to use to identify the table and make it unique
  * @param mixed $mParam Can be a string or an array of how to link the tables. This is usually a string that contains the part found with an SQL ON(__STRING__)
  */
 protected function _join($sType, $sTable, $sAlias, $mParam = null)
 {
     if (PHPFOX_DEBUG && in_array(strtoupper($sAlias), $this->_aWords)) {
         Phpfox_Error::trigger('The alias "' . $sAlias . '" is a reserved SQL word. Use another alias to resolve this problem.', E_USER_ERROR);
     }
     if (!isset($this->_aQuery['join'])) {
         $this->_aQuery['join'] = '';
     }
     $this->_aQuery['join'] .= $sType . " " . $this->table($sTable) . " AS " . $sAlias;
     if (is_array($mParam)) {
         $this->_aQuery['join'] .= "\n\tON(";
         $sJoins = '';
         foreach ($mParam as $sKey => $sValue) {
             if (is_string($sKey)) {
                 //
                 $sJoins .= $this->_where($sKey, $sValue);
                 continue;
             }
             $sJoins .= $sValue . " ";
         }
         $this->_aQuery['join'] .= preg_replace("/^(AND|OR)(.*?)/i", "", trim($sJoins));
     } else {
         if (preg_match("/(AND|OR|=|LIKE)/", $mParam)) {
             $this->_aQuery['join'] .= "\n\tON({$mParam}";
         } else {
             // Not supported with other drivers so we don't use this anymore
             Phpfox_Error::trigger('Not allowed to use "USING()" in SQL queries any longer.', E_USER_ERROR);
         }
     }
     $this->_aQuery['join'] = preg_replace("/^(AND|OR)(.*?)/i", "", trim($this->_aQuery['join'])) . ")\n";
 }
コード例 #27
0
ファイル: mysql.class.php プロジェクト: googlesky/snsp.vn
 /**
  * Performs sql query with error reporting and logging.
  * 
  * @see mysql_query()
  * @param  string $sSql MySQL query to perform
  * @param resource $hLink MySQL resource. If nothing is passed we load the default master server.
  * @return resource Returns the MYSQL resource from the function mysql_query()
  */
 public function query($sSql, &$hLink = '')
 {
     if (!$hLink) {
         $hLink =& $this->_hMaster;
     }
     PHPFOX_DEBUG ? Phpfox_Debug::start('sql') : '';
     $hRes = @($this->_aCmd['mysql_query'] == 'mysqli_query' ? $this->_aCmd['mysql_query']($hLink, $sSql) : $this->_aCmd['mysql_query']($sSql, $hLink));
     if (defined('PHPFOX_LOG_SQL') && Phpfox::getLib('file')->isWritable(PHPFOX_DIR_FILE . 'log' . PHPFOX_DS)) {
         $hFile = fopen(PHPFOX_DIR_FILE . 'log' . PHPFOX_DS . 'phpfox_query_' . date('d.m.y', PHPFOX_TIME) . '_' . md5(Phpfox::getVersion()) . '.php', 'a');
         fwrite($hFile, '<?php defined(\'PHPFOX\') or exit(\'NO DICE!\');  ?>' . "##\n{$sSql}##\n");
         fclose($hFile);
     }
     if (!$hRes) {
         Phpfox_Error::trigger('Query Error:' . $this->_sqlError(), PHPFOX_DEBUG ? E_USER_ERROR : E_USER_WARNING);
     }
     PHPFOX_DEBUG ? Phpfox_Debug::end('sql', array('sql' => $sSql, 'slave' => $this->_bIsSlave, 'rows' => is_bool($hRes) ? '-' : @$this->_aCmd['mysql_num_rows']($hRes))) : '';
     $this->_bIsSlave = false;
     return $hRes;
 }
コード例 #28
0
ファイル: template.class.php プロジェクト: auzunov/phpfox
 /**
  * Get the full path to the modular template file we are loading.
  *
  * @param string $sTemplate Name of the file.
  * @param bool $bCheckDb TRUE to check the database if the file exists there.
  * @return string Full path to the file we are loading.
  */
 public function getTemplateFile($sTemplate, $bCheckDb = false)
 {
     ($sPlugin = Phpfox_Plugin::get('template_gettemplatefile')) ? eval($sPlugin) : false;
     $aParts = explode('.', $sTemplate);
     $sModule = $aParts[0];
     if (defined('PHPFOX_INSTALLER') && !Phpfox::isModule('video')) {
         return array('', '');
     }
     unset($aParts[0]);
     $sName = implode('.', $aParts);
     $sName = str_replace('.', PHPFOX_DS, $sName);
     if (!defined('PHPFOX_INSTALLER') && !defined('PHPFOX_LIVE_TEMPLATES')) {
         $oDb = Phpfox_Database::instance();
         $aTemplate = $oDb->select('html_data')->from(Phpfox::getT('theme_template'))->where("type_id = 'controller' AND name = '" . $oDb->escape($sTemplate) . "'")->execute('getSlaveRow');
         if (!empty($aTemplate)) {
             return array($aTemplate['html_data']);
         }
     }
     $bPass = false;
     if (file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX)) {
         $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX;
         $bPass = true;
     }
     if ($bPass === false && file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX)) {
         $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX;
         $bPass = true;
     }
     if ($bPass === false && isset($aParts[2]) && file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_DS . $aParts[2] . PHPFOX_TPL_SUFFIX)) {
         $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_sThemeFolder . PHPFOX_DS . $sName . PHPFOX_DS . $aParts[2] . PHPFOX_TPL_SUFFIX;
         $bPass = true;
     }
     if (isset($this->_aTheme['theme_parent_id']) && $this->_aTheme['theme_parent_id'] > 0 && !empty($this->_aTheme['parent_theme_folder'])) {
         if ($bPass === false && file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX)) {
             $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX;
             $bPass = true;
         }
         if ($bPass === false && file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX)) {
             $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX;
             $bPass = true;
         }
         if ($bPass === false && isset($aParts[2]) && file_exists(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_DS . $aParts[2] . PHPFOX_TPL_SUFFIX)) {
             $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . $this->_aTheme['parent_theme_folder'] . PHPFOX_DS . $sName . PHPFOX_DS . $aParts[2] . PHPFOX_TPL_SUFFIX;
             $bPass = false;
         }
     }
     if (!isset($sFile)) {
         $sFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DIR_MODULE_TPL . PHPFOX_DS . 'default' . PHPFOX_DS . $sName . PHPFOX_TPL_SUFFIX;
     }
     if (!file_exists($sFile)) {
         Phpfox_Error::trigger('Unable to load module template: ' . $sModule . '->' . $sName, E_USER_ERROR);
     }
     return $sFile;
 }
コード例 #29
0
ファイル: ajax.class.php プロジェクト: lev1976g/core
 /**
  * Emulate jQuery calls.
  *
  * @param string $sMethod jQuery method we are trying to call.
  * @param array $aArguments Array of option arguments being passed to jQuery.
  * @return $this
  */
 public function __call($sMethod, $aArguments)
 {
     if (!in_array($sMethod, $this->_aJquery)) {
         return Phpfox_Error::trigger('Not a valid jQuery function', E_USER_ERROR);
     }
     $sArgs = '';
     foreach ($aArguments as $iKey => $sArgument) {
         if ($iKey == 0) {
             continue;
         }
         $sValue = '\'' . str_replace("'", "\\'", $sArgument) . '\'';
         if (is_bool($sArgument)) {
             $sValue = $sArgument === true ? 'true' : 'false';
         }
         $sArgs .= $sValue . ',';
     }
     $sArgs = rtrim($sArgs, ',');
     $this->call('$(\'' . $aArguments[0] . '\').' . $sMethod . '(' . $sArgs . ');');
     return $this;
 }
コード例 #30
0
ファイル: setting.class.php プロジェクト: JerwinPRO/phpfox
 /**
  * Get a setting and its value.
  *
  * @param mixed $mVar STRING name of the setting or ARRAY name of the setting.
  * @param string $sDef Default value in case the setting cannot be found.
  * @return nixed Returns the value of the setting, which can be a STRING, ARRAY, BOOL or INT.
  */
 public function getParam($mVar, $sDef = '')
 {
     if ($mVar == 'core.branding' && Phpfox::isPackage(array('premium', 'ultimate'))) {
         return true;
     }
     if ($mVar == 'im.enable_im_in_footer_bar' && Phpfox::isMobile()) {
         return false;
     }
     // http://www.phpfox.com/tracker/view/15079/
     /*if ($mVar == 'core.wysiwyg' && !defined('PHPFOX_INSTALLER') && Phpfox::isMobile())
     		{
     			return 'default';
     		}*/
     if ($mVar == 'core.phpfox_is_hosted') {
         return $this->getParam('core.is_auto_hosted');
     }
     if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
         /*
         if ($mVar == 'core.url_static_script')
         {
         	return Phpfox::getCdnPath() . 'static/jscript/';
         }
         */
         if ($mVar == 'core.setting_session_prefix') {
             return PHPFOX_IS_HOSTED_SCRIPT;
         } elseif ($mVar == 'video.allow_video_uploading') {
             return true;
         }
         /*
         elseif ($mVar == 'core.cache_js_css')
         {
         	return true;			
         }
         */
     }
     if (defined('PHPFOX_INSTALLER') && $mVar == 'core.cache_js_css') {
         return false;
     }
     if (is_array($mVar)) {
         $sParam = isset($this->_aParams[$mVar[0]][$mVar[1]]) ? $this->_aParams[$mVar[0]][$mVar[1]] : (isset($this->_aDefaults[$mVar[0]][$mVar[1]]) ? $this->_aDefaults[$mVar[0]][$mVar[1]] : Phpfox_Error::trigger('Missing Param: ' . $mVar[0] . '][' . $mVar[1]));
     } else {
         $sParam = isset($this->_aParams[$mVar]) ? $this->_aParams[$mVar] : (isset($this->_aDefaults[$mVar]) ? $this->_aDefaults[$mVar] : Phpfox_Error::trigger('Missing Param: ' . $mVar));
         if (!defined('PHPFOX_INSTALLER') && ($mVar == 'core.footer_bar_site_name' || $mVar == 'core.site_copyright')) {
             $sParam = Phpfox_Locale::instance()->convert($sParam);
         }
         if ($mVar == 'admincp.admin_cp') {
             $sParam = strtolower($sParam);
         }
         if ($mVar == 'user.points_conversion_rate') {
             $sParam = empty($sParam) ? array() : json_decode($sParam, true);
         }
     }
     if ($mVar == 'core.wysiwyg' && !defined('PHPFOX_INSTALLER') && $sParam == 'tiny_mce' && !Phpfox::isModule('tinymce')) {
         return 'default';
     }
     return $sParam;
 }