Пример #1
0
 function __construct()
 {
     parent::__construct();
     Configure::write('Community.profileUrl', $this->profileUrl);
     if (file_exists(PATH_ROOT . 'components' . _DS . 'com_community' . _DS . 'community.php')) {
         $this->community = true;
         $Menu = ClassRegistry::getClass('MenuModel');
         $this->menu_id = $Menu->getComponentMenuId('com_community&view=frontpage');
         if (!$this->menu_id) {
             $this->menu_id = $Menu->getComponentMenuId('com_community&view=profile');
         }
         if (!$this->menu_id) {
             $this->menu_id = $Menu->getComponentMenuId('com_community');
         }
         // For JomSocial <= 2.1
         if (!file_exists(PATH_ROOT . 'components/com_community/assets/user_thumb.png')) {
             $this->default_thumb = 'components/com_community/assets/default_thumb.jpg';
         }
         $cache_key = 'jomsocial_config_' . md5(cmsFramework::getConfig('secret'));
         $JSConfig = S2Cache::read($cache_key);
         if (false == $JSConfig) {
             // Read the JomSocial configuration to determine the storage location for avatars
             $JSConfig = json_decode($this->query("SELECT params FROM #__community_config WHERE name = 'config'", 'loadResult'), true);
             $JSConfigForJReviews = array('user_avatar_storage' => $JSConfig['user_avatar_storage'], 'storages3bucket' => $JSConfig['storages3bucket']);
             S2Cache::write($cache_key, $JSConfigForJReviews);
         }
         $this->avatar_storage = $JSConfig['user_avatar_storage'];
         $this->s3_bucket = $JSConfig['storages3bucket'];
         Configure::write('Community.register_url', sprintf($this->registerUrl, $this->menu_id));
     }
 }
Пример #2
0
 function &getInstance()
 {
     static $instance = array();
     if (!isset($instance[0]) || !$instance[0]) {
         $instance[0] = new sef_jreviews();
         require dirname(__FILE__) . DS . 'jreviews' . DS . 'framework.php';
         App::import('Model', 'Menu', 'jreviews');
         $instance[0]->__Menu = ClassRegistry::getClass('MenuModel');
         // Read url param style setting from JReviews config cache file
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
         $instance[0]->joomla_style_params = is_object($Config) and isset($Config->url_param_joomla) ? $Config->url_param_joomla : false;
         $version = new JVersion();
         $instance[0]->cmsVersion = $version->RELEASE;
     }
     return $instance[0];
 }
Пример #3
0
 function onProfileDisplay()
 {
     if (!file_exists($this->_path . DS . 'admin.jreviews.php')) {
         return JText::_('jReviews is not installed. Please contact site administrator.');
     } else {
         $user = CFactory::getActiveProfile();
         $userId = $user->id;
         $cacheSetting = $this->params->get('cache', 1) ? JApplication::getCfg('caching') : 0;
         # Load CSS stylesheets -- done here because when cache is on css is not loaded
         if ($cacheSetting) {
             # MVC initalization script
             if (!defined('DS')) {
                 define('DS', DIRECTORY_SEPARATOR);
             }
             require 'components' . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php';
             $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
             $Config =& S2Cache::read($cache_file);
             if (!is_object($Config)) {
                 //Create config file
                 $eParams['data']['controller'] = 'common';
                 $eParams['data']['action'] = 'index';
                 $Dispatcher = new S2Dispatcher('jreviews', false, true);
                 $Dispatcher->dispatch($eParams);
                 $Config =& S2Cache::read($cache_file);
                 unset($Dispatcher);
             }
             App::import('Helper', 'html');
             $Html =& RegisterClass::getInstance('HtmlHelper');
             $Html->viewTheme = $Config->template;
             $Html->app = 'jreviews';
             $Html->startup();
             App::import('Helper', 'libraries', 'jreviews');
             $Libraries =& RegisterClass::getInstance('LibrariesHelper');
             $Html->css(array('theme', 'plugins', 'paginator'));
             $Html->js(array('jreviews', 'jquery' => 'jquery', 'jq.scrollable'), $Libraries->js());
         }
         $cache =& JFactory::getCache('plgCommunityJreviews_myfavorites');
         $cache->setCaching($cacheSetting);
         $callback = array('plgCommunityJreviews_myfavorites', '_getPage');
         $contents = $cache->call($callback, $userId, $this->params, $cacheSetting);
         return $contents;
     }
 }
 function plgAfterSave(&$model)
 {
     if (!isset($model->data['Email']) || !Sanitize::getInt($model->data['Email'], 'send')) {
         return false;
     }
     # Read cms mail config settings
     $configSendmailPath = cmsFramework::getConfig('sendmail');
     $configSmtpAuth = cmsFramework::getConfig('smtpauth');
     $configSmtpUser = cmsFramework::getConfig('smtpuser');
     $configSmtpPass = cmsFramework::getConfig('smtppass');
     $configSmtpHost = cmsFramework::getConfig('smtphost');
     $configSmtpSecure = cmsFramework::getConfig('smtpsecure');
     $configSmtpPort = cmsFramework::getConfig('smtpport');
     $configMailFrom = cmsFramework::getConfig('mailfrom');
     $configFromName = cmsFramework::getConfig('fromname');
     $configMailer = cmsFramework::getConfig('mailer');
     if (!class_exists('PHPMailer')) {
         App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
     }
     $mail = new PHPMailer();
     $mail->CharSet = cmsFramework::getCharset();
     $mail->SetLanguage('en', S2_VENDORS . 'PHPMailer' . DS . 'language' . DS);
     $mail->Mailer = $configMailer;
     // Mailer used mail,sendmail,smtp
     switch ($configMailer) {
         case 'smtp':
             $mail->Host = $configSmtpHost;
             $mail->SMTPAuth = $configSmtpAuth;
             $mail->Username = $configSmtpUser;
             $mail->Password = $configSmtpPass;
             $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
             $mail->Port = $configSmtpPort;
             break;
         case 'sendmail':
             $mail->Sendmail = $configSendmailPath;
             break;
         default:
             break;
     }
     $mail->isHTML(true);
     $mail->From = $configMailFrom;
     $mail->FromName = $configFromName;
     $mail->AddReplyTo($configMailFrom, $configFromName);
     //    	$model->data[$this->notifyModel->name]['key'] = $value;
     $model->data['Email']['body'] = urldecode($model->data['__raw']['Email']['body']);
     // Send html email
     # In this observer model we just use the existing data to send the email notification
     switch ($this->notifyModel->name) {
         // Notification for claims moderation
         case 'Claim':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
             } else {
                 switch ($model->data['Claim']['approved']) {
                     case 1:
                         $subject = __a("Your claim has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your claim has been rejected", true);
                         break;
                     case 0:
                         $subject = __a("Your claim has been reviewed, but still pending moderation", true);
                         break;
                 }
             }
             // Get permalink
             $listing_id = $model->data['Listing']['id'];
             $listing = $this->controller->Listing->findRow(array('conditions' => 'Listing.id = ' . $listing_id), array('afterFind'));
             $permalink = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin claim moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             # Notification for discussion post moderation
         # Notification for discussion post moderation
         case 'Discussion':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
             } else {
                 switch ($model->data['Discussion']['approved']) {
                     case 1:
                         $subject = __a("Your comment has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your comment has been rejected", true);
                         break;
                 }
             }
             // Get permalink
             $this->controller->EverywhereAfterFind = true;
             $this->controller->Review->runProcessRatings = false;
             $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $model->data['Discussion']['review_id'])));
             $this->controller->viewVars['review'] = $review;
             // Make it available to other plugins
             App::import('helper', 'routes', 'jreviews');
             $Routes = ClassRegistry::getClass('RoutesHelper');
             $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin post discussion moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             // Notification for listing moderation
         // Notification for listing moderation
         case 'Listing':
             if (Sanitize::getInt($model->data, 'moderation')) {
                 if ($model->data['Email']['subject'] != '') {
                     $subject = $model->data['Email']['subject'];
                     $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                     $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                 } else {
                     switch ($model->data['Listing']['state']) {
                         case 1:
                             $subject = __a("Your listing has been approved", true);
                             break;
                         case -2:
                             $subject = __a("Your listing has been rejected", true);
                             break;
                         case 0:
                             $subject = __a("Your listing has been reviewed, but it is still pending moderation", true);
                             break;
                     }
                 }
                 // Get permalink
                 $listing_id = $model->data['Listing']['id'];
                 $listing = $this->controller->Listing->findRow(array('conditions' => 'Listing.id = ' . $listing_id), array('afterFind'));
                 $permalink = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
                 $message = $model->data['Email']['body'];
                 $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
                 $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
                 $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
                 if ($message != '') {
                     $mail->Subject = $subject;
                     // Convert line breaks to br tags if html code not found on the message body
                     $mail->Body = nl2br($message);
                     $mail->AddAddress($model->data['Email']['email']);
                     if (!$mail->Send()) {
                         appLogMessage(array("Admin listing moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             break;
             // Notification for reviews moderation
         // Notification for reviews moderation
         case 'Review':
             if (Sanitize::getInt($model->data, 'moderation')) {
                 if ($model->data['Email']['subject'] != '') {
                     $subject = $model->data['Email']['subject'];
                     $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                     $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                     $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
                 } else {
                     switch ($model->data['Review']['published']) {
                         case 1:
                             $subject = __a("Your review has been approved", true);
                             break;
                         case -1:
                             $subject = __a("Your review has been rejected", true);
                             break;
                         case 0:
                             $subject = __a("Your review has been reviewed, but still pending moderation", true);
                             break;
                     }
                 }
                 // Get permalink
                 $this->controller->EverywhereAfterFind = true;
                 $this->controller->Review->runProcessRatings = false;
                 $review_id = $model->data['Review']['id'];
                 $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)));
                 $this->controller->viewVars['review'] = $review;
                 // Make it available to other plugins
                 App::import('helper', 'routes', 'jreviews');
                 $Routes = ClassRegistry::getClass('RoutesHelper');
                 $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
                 $permalink = cmsFramework::makeAbsUrl($permalink);
                 $message = $model->data['Email']['body'];
                 $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
                 $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
                 $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
                 $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
                 if ($message != '') {
                     $mail->Subject = $subject;
                     // Convert line breaks to br tags if html code not found on the message body
                     $mail->Body = nl2br($message);
                     $mail->AddAddress($model->data['Email']['email']);
                     if (!$mail->Send()) {
                         appLogMessage(array("Admin review moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             break;
             // Notification for owner reply to reviews moderation
         // Notification for owner reply to reviews moderation
         case 'OwnerReply':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                 $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
             } else {
                 switch ($model->data['OwnerReply']['owner_reply_approved']) {
                     case 1:
                         $subject = __a("Your reply has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your reply has been rejected", true);
                         break;
                     case 0:
                         $subject = __a("Your reply has been reviewed, but still pending moderation", true);
                         break;
                 }
             }
             // Get permalink
             $this->controller->EverywhereAfterFind = true;
             $this->controller->Review->runProcessRatings = false;
             $review_id = $model->data['OwnerReply']['id'];
             $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)));
             $this->controller->viewVars['review'] = $review;
             // Make it available to other plugins
             App::import('helper', 'routes', 'jreviews');
             $Routes = ClassRegistry::getClass('RoutesHelper');
             $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
             $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin owner reply moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
     }
     unset($mail);
     return true;
 }
Пример #5
0
S2Paths::set($s2_app, 'S2_JS_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_OVERRIDES') . 'js' . DS);
S2Paths::set($s2_app, 'S2_VIEWS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_APP_URL_OVERRIDES') . 'views' . _DS);
S2Paths::set($s2_app, 'S2_THEMES_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'themes' . _DS);
S2Paths::set($s2_app, 'S2_IMAGES_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'images' . _DS);
S2Paths::set($s2_app, 'S2_CSS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'css' . _DS);
S2Paths::set($s2_app, 'S2_JS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'js' . _DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES', S2Paths::get($s2_app, 'S2_APP_OVERRIDES') . 'views' . DS . 'admin' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_HELPERS_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES') . 'helpers' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'admin' . _DS);
S2Paths::set($s2_app, 'S2_CSS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'css' . _DS);
S2Paths::set($s2_app, 'S2_JS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'js' . _DS);
# Set default theme
if (defined('MVC_FRAMEWORK_ADMIN')) {
    $db = cmsFramework::getDB();
    $tables = $db->getTableList();
    $dbprefix = cmsFramework::getConfig('dbprefix');
    if (in_array($dbprefix . 'jreviews_config', $tables)) {
        $db->setQuery("SELECT value FROM #__jreviews_config WHERE id = 'fallback_theme'");
        $fallback_theme = $db->loadResult();
        S2Paths::set($s2_app, 'S2_FALLBACK_THEME', $fallback_theme != '' ? $fallback_theme : 'default');
    }
    unset($db);
}
# Create the file registry
$Configure =& Configure::getInstance($s2_app);
$s2App =& App::getInstance($s2_app);
require_once dirname(__FILE__) . DS . 'config' . DS . 'core.php';
# Set app variable in I18n class
$import = App::import('Lib', 'I18n');
if (!$import) {
    $clear = clearCache('', 'core');
 function create_j16()
 {
     $this->name = 'categories';
     $this->autoRender = true;
     $sectionid = Sanitize::getInt($this->params, 'sectionid', '');
     $limit = Sanitize::getInt($this->params, 'limit', cmsFramework::getConfig('list_limit'));
     $limitstart = Sanitize::getInt($this->params, 'limitstart', '');
     $this->set(array('sectionid' => $sectionid, 'limit' => $limit, 'limitstart' => $limitstart, 'criterias' => $this->Criteria->getSelectList(), 'directories' => $this->Directory->getSelectList(), 'review_categories' => $this->Category->getReviewCategoryIds(), 'categories' => $this->Category->getNonReviewCategories()));
 }
Пример #7
0
/**
 * Returns the request uri for ajax requests for each application
 *
 * @param string $app
 * @return ajax request uri
 */
function getAjaxUri($app = 'jreviews')
{
    $lang = cmsFramework::getUrlLanguageCode();
    $language = Sanitize::getString($_REQUEST, 'language');
    $core_sef = cmsFramework::getConfig('sef') && !function_exists('sefEncode') && !class_exists('shRouter');
    $ie = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false;
    $lang_segment = $ie && $core_sef && $language != '' && $lang != '';
    if (defined('MVC_FRAMEWORK_ADMIN')) {
        $ajaxUri = WWW_ROOT . 'administrator' . _DS . 'index.php?option=' . S2Paths::get($app, 'S2_CMSCOMP') . '&format=raw&tmpl=component';
    } else {
        $ajaxUri = WWW_ROOT . ($lang_segment ? $lang . _DS : '') . 'index.php?option=' . S2Paths::get($app, 'S2_CMSCOMP') . '&format=raw&tmpl=component' . ($lang != '' ? '&lang=' . $lang : '');
    }
    if (defined('MVC_FRAMEWORK_ADMIN')) {
        return str_replace('&amp;', '&', $ajaxUri);
    }
    return $ajaxUri;
}
Пример #8
0
 function load()
 {
     $Model = new MyModel();
     $Config = new stdClass();
     $Model->_db->setQuery("SELECT id, value FROM #__jreviews_config");
     $rows = $Model->_db->loadObjectList();
     if ($rows) {
         foreach ($rows as $row) {
             $prop = $row->id;
             $length = strlen($row->value) - 1;
             if (substr($row->value, 0, 1) == '[' && substr($row->value, $length, 1) == ']') {
                 $row->value = json_decode($row->value);
             } else {
                 $row->value = stripcslashes($row->value);
             }
             $Config->{$prop} = $row->value;
         }
     }
     $Config->rss_title = @$Config->rss_title != '' ? $Config->rss_title : $Model->makeSafe(cmsFramework::getConfig('sitename'));
     $Config->rss_description = @$Config->rss_description != '' ? $Config->rss_description : $Model->makeSafe(cmsFramework::getConfig('MetaDesc'));
     # Get current version number
     include_once PATH_ROOT . 'components' . DS . 'com_jreviews' . DS . 'jreviews.info.php';
     if (isset($package_info)) {
         $version = $package_info['jreviews']['version'];
         $Config->version = $version;
     }
     return $Config;
 }
Пример #9
0
 function store($arr = null)
 {
     $db = cmsFramework::getDB();
     if (is_null($arr)) {
         $arr = get_object_vars($this);
     }
     while (list($prop, $val) = each($arr)) {
         if ($prop != 'c') {
             if (is_array($val)) {
                 $val = json_encode($val);
             } else {
                 // Fixes an issue where an Array string is added to some values
                 $val = str_replace(',Array', '', $val);
             }
             $db->setQuery("\n                    UPDATE \n                        #__jreviews_config\n\t\t\t\t\tSET \n                        value= '" . $db->getEscaped($val) . "'\n\t\t\t\t\tWHERE \n                        id = '" . $db->getEscaped($prop) . "'");
             $db->query();
             $db->setQuery("SELECT \n                        count(*) \n                    FROM \n                        #__jreviews_config \n                    WHERE \n                        id = '" . $db->getEscaped($prop) . "'");
             $saved = $db->loadResult();
             if (!$saved) {
                 $db->setQuery("\n                        INSERT INTO\n                            #__jreviews_config (id, value) \n\t\t\t\t\t\tVALUES\n                            ('" . $db->getEscaped($prop) . "', '" . $db->getEscaped($val) . "')\n                    ");
                 if (!$db->query()) {
                     echo "<br/>" . $db->getErrorMsg();
                     exit;
                 }
             }
         }
     }
     if (defined('MVC_FRAMEWORK_ADMIN')) {
         // Forces clear cache when config settings are modified in the administration
         clearCache('', 'views');
         clearCache('', '__data');
     } else {
         // Push updates to the cached file
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = $this->load();
         S2Cache::write($cache_file, $Config);
     }
 }
 function _postVote()
 {
     # Check if FB integration for reviews is enabled
     $facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_reviews');
     if (!$facebook_integration) {
         return;
     }
     $review_id = Sanitize::getInt($this->params, 'id');
     # First check - review id
     if (!$review_id) {
         return;
     }
     # Stop form data tampering
     $formToken = cmsFramework::getCustomToken($review_id);
     if (!cmsFramework::isAdmin() && !$this->__validateToken($formToken)) {
         return s2Messages::accessDenied();
     }
     $facebook = $this->_getFBClass();
     $uid = $facebook->getUser();
     if ($uid) {
         try {
             //get user id
             //                $user = $facebook->api('/me');
             $fql = "SELECT publish_stream FROM permissions WHERE uid = " . $uid;
             $param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
             $fqlResult = $facebook->api($param);
             if (!$fqlResult[0]['publish_stream']) {
                 return false;
             } else {
                 $review = $this->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)), array());
                 $this->Everywhere->loadListingModel($this, $review['Review']['extension']);
                 $listing = $this->Listing->findRow(array('conditions' => array('Listing.' . $this->Listing->realKey . ' = ' . $review['Review']['listing_id'])), array('afterFind'));
                 $listing_url = $this->makeUrl($listing['Listing']['url']);
                 $review['Review']['comments'] = strip_tags($review['Review']['comments']);
                 if ($this->Config->facebook_posts_trim >= 0 && $review['Review']['comments'] != '') {
                     App::import('Helper', 'text', 'jreviews');
                     $Text = ClassRegistry::getClass('TextHelper');
                     $message = $this->Config->facebook_posts_trim == '' ? $review['Review']['comments'] : $Text->truncateWords($review['Review']['comments'], $this->Config->facebook_posts_trim);
                     $review['Review']['comments'] = $message;
                 }
                 # Publish stream permission granted so we can post on the user's wall!
                 # Begin building the stream $fbArray
                 $fbArray = array();
                 $fbArray['method'] = 'stream.publish';
                 $fbArray['message'] = sprintf($this->activities['vote helpful'], $listing['Listing']['title']);
                 $fbArray['attachment'] = array('name' => $listing['Listing']['title'], 'href' => $listing_url, 'description' => $review['Review']['comments']);
                 $fbArray['attachment']['properties'][__t("Website", true)] = array('text' => cmsFramework::getConfig('sitename'), 'href' => WWW_ROOT);
                 $review['Rating']['average_rating'] > 0 and $fbArray['attachment']['properties'][__t("Rating", true)] = sprintf(__t("%s stars", true), round($review['Rating']['average_rating'], 1));
                 isset($listing['Listing']['images'][0]) and $fbArray['attachment']['media'] = array(array('type' => 'image', 'src' => WWW_ROOT . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path'], 'href' => $listing_url));
                 $fbArray['attachment'] = json_encode($fbArray['attachment']);
                 $fbArray['action_links'] = json_encode(array(array('text' => __t("Read review", true), 'href' => $listing_url)));
                 $fbArray['comments_xid'] = $listing['Listing']['listing_id'];
                 if ($this->Config->facebook_optout) {
                     $fbArray['display'] = Configure::read('System.isMobile') ? 'touch' : 'popup';
                     return json_encode($fbArray);
                 }
                 $fb_update = $facebook->api($fbArray);
                 return true;
             }
         } catch (Exception $o) {
             // Error reading permissions
             return false;
         }
     }
     return false;
 }
Пример #11
0
 /**
  * Loads app/config/bootstrap.php.
  * If the alternative paths are set in this file
  * they will be added to the paths vars.
  *
  * @param boolean $boot Load application bootstrap (if true)
  * @return void
  * @access private
  */
 function __loadBootstrap($app)
 {
     S2Cache::config('_s2framework_core_', array('duration' => 86400, 'engine' => 'File', 'path' => S2Paths::get($app, 'S2_CACHE') . 'core'));
     $fallback_theme = S2Paths::get($app, 'S2_FALLBACK_THEME', 'default');
     $path_root_replace = PATH_ROOT != DS ? PATH_ROOT : '';
     $cache_key = $app . '_paths_' . md5(WWW_ROOT . PATH_ROOT . cmsFramework::getConfig('secret'));
     if (!($fileArray = S2Cache::read($cache_key, '_s2framework_core_'))) {
         $configPath = S2Paths::get($app, 'S2_APP_CONFIG');
         if (@(!(include $configPath . 'paths.php'))) {
             trigger_error(sprintf(__t("Can't find application paths file. Please create %spaths.php, and make sure it is readable by PHP.", true), $configPath), E_USER_ERROR);
         }
         $this->basePaths = $basePaths;
         $fileArray = $this->buildPaths($relativePaths);
         $Folder = new Folder();
         $items = array();
         // Build the Theme file array
         foreach ($basePaths as $basePath) {
             if (false === strstr($basePath, 's2framework')) {
                 // Front end theme folder
                 $Folder->path = $basePath . $themePath;
                 $baseRelPath = ltrim(str_replace($path_root_replace, '', $basePath), DS);
                 list($dirs) = $Folder->read(true);
                 if (!empty($dirs)) {
                     foreach ($dirs as $theme) {
                         $tree = $Folder->tree($basePath . $themePath . DS . $theme);
                         if (is_array($tree) && !empty($tree)) {
                             if (strstr($basePath, 'com_jreviews_addons')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'addon';
                             } elseif (strstr($basePath, 'com_jreviews')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'jreviews';
                             } elseif (strstr($basePath, 'jreviews_overrides')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'overrides';
                             }
                             $themeRelPath = $baseRelPath . $themePath . DS . $theme . DS;
                             $items['Theme'][$theme]['.info']['path'] = $themeRelPath;
                             // Read theme info xml file
                             $infoFile = $basePath . $themePath . DS . $theme . DS . 'themeInfo.xml';
                             if (file_exists($infoFile)) {
                                 $xml = simplexml_load_file($infoFile);
                                 $items['Theme'][$theme]['.info']['name'] = Sanitize::getString($xml->settings, 'name');
                                 $items['Theme'][$theme]['.info']['title'] = Sanitize::getString($xml->settings, 'title');
                                 $items['Theme'][$theme]['.info']['configuration'] = Sanitize::getString($xml->settings, 'configuration', 1);
                                 $items['Theme'][$theme]['.info']['fallback'] = Sanitize::getString($xml->settings, 'fallback', 0);
                                 $items['Theme'][$theme]['.info']['addon'] = Sanitize::getString($xml->settings, 'addon', 0);
                                 $items['Theme'][$theme]['.info']['mobile'] = Sanitize::getString($xml->settings, 'mobile', 0);
                                 $items['Theme'][$theme]['.info']['description'] = Sanitize::getString($xml, 'description');
                             } else {
                                 // Support for themes without xml file
                                 $items['Theme'][$theme]['.info']['name'] = $theme;
                                 $items['Theme'][$theme]['.info']['title'] = $theme;
                                 $items['Theme'][$theme]['.info']['configuration'] = '1';
                                 $items['Theme'][$theme]['.info']['fallback'] = '0';
                                 $items['Theme'][$theme]['.info']['addon'] = $items['Theme'][$theme]['.info']['location'] == (string) 'addon' ? 1 : 0;
                                 $items['Theme'][$theme]['.info']['mobile'] = '0';
                                 $items['Theme'][$theme]['.info']['description'] = 'themeInfo.xml file is missing for this theme.';
                             }
                             foreach ($tree[1] as $file) {
                                 // Get the theme name and folder to build an array
                                 $path = strtolower(str_replace($basePath . $themePath . DS, '', $file));
                                 if (count(explode(DS, $path)) > 2) {
                                     # Adds file to theme folder array
                                     extract(pathinfo($path));
                                     $theme_folder = str_replace($theme . DS, '', $dirname);
                                     $theme_file_path = ltrim(str_replace($path_root_replace, '', $file), DS);
                                     $theme_folder_parts = explode(DS, $theme_folder);
                                     $theme_folder = array_shift($theme_folder_parts);
                                     if ($theme_folder == 'theme_images' && !empty($theme_folder_parts)) {
                                         // Adds support for theme images in sub-folders
                                         $basename = implode(DS, $theme_folder_parts) . DS . $basename;
                                     } elseif (!empty($theme_folder_parts)) {
                                         $basename = array_shift($theme_folder_parts) . DS . $basename;
                                     }
                                     // Exclude images from theme_css folder
                                     if (strstr($theme_folder, 'theme_css') && $extension != 'css') {
                                         continue;
                                     }
                                     $items['Theme'][$theme][$theme_folder][$basename] = $basename;
                                     // $theme_file_path;
                                     # Add any extra files to the default theme.
                                     # This makes the system think files from different themes are in the default folder without forcing users to move files around
                                     // In Component folder we use full relative path because we don't know which theme has been selected
                                     if ($items['Theme'][$theme]['.info']['location'] == "jreviews") {
                                         $items['Theme'][$theme][$theme_folder][$basename] = $theme_file_path;
                                     }
                                     // For any non-default folder, add missing files to default folder with full relative path
                                     if ($items['Theme'][$theme]['.info']['location'] != "jreviews" && !isset($items['Theme'][$fallback_theme][$theme_folder][$basename])) {
                                         $items['Theme'][$fallback_theme][$theme_folder][$basename] = $theme_file_path;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Admin theme folder
                 $Folder->path = $basePath . $themePathAdmin;
                 list($dirs) = $Folder->read(true);
                 if (!empty($dirs)) {
                     foreach ($dirs as $theme) {
                         # Begin theme info
                         if (!isset($items['AdminTheme'][$theme]['.info'])) {
                             $themeRelPath = $baseRelPath . $themePathAdmin . DS . $theme . DS;
                             $items['AdminTheme'][$theme]['.info']['path'] = $themeRelPath;
                             $items['AdminTheme'][$theme]['.info']['name'] = $theme;
                             $items['AdminTheme'][$theme]['.info']['title'] = $theme;
                         }
                         $tree = $Folder->tree($basePath . $themePathAdmin . DS . $theme);
                         if (is_array($tree) && !empty($tree)) {
                             foreach ($tree[1] as $file) {
                                 // Get the theme name and folder to build an array
                                 $path = strtolower(str_replace($basePath . $themePathAdmin . DS, '', $file));
                                 if (count(explode(DS, $path)) > 2) {
                                     # Adds file to theme folder array
                                     extract(pathinfo($path));
                                     $theme_folder = str_replace($theme . DS, '', $dirname);
                                     $theme_file_path = ltrim(str_replace($path_root_replace, '', $file), DS);
                                     $theme_folder_parts = explode(DS, $theme_folder);
                                     $theme_folder = array_shift($theme_folder_parts);
                                     !empty($theme_folder_parts) and $basename = array_shift($theme_folder_parts) . DS . $basename;
                                     // Exclude images from theme_css folder
                                     if (strstr($theme_folder, 'theme_css') && $extension != 'css') {
                                         continue;
                                     }
                                     $items['AdminTheme'][$theme][$theme_folder][$basename] = $basename;
                                     //$theme_file_path;
                                     if (!strstr($theme_file_path, 'components' . DS . 'com_jreviews' . DS)) {
                                         $items['AdminTheme']['default'][$theme_folder][$basename] = $theme_file_path;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Front end js folder
                 $tree = $Folder->tree($basePath . $jsPath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPath . DS, DS), array('', _DS), $file);
                             $items['Javascript'][$path] = ltrim(str_replace(array($path_root_replace, DS), array('', _DS), $file), _DS);
                         }
                     }
                 }
                 // Admin js folder
                 $tree = $Folder->tree($basePath . $jsPathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPathAdmin . DS, DS), array('', _DS), $file);
                             $items['AdminJavascript'][$path] = ltrim(str_replace(array($path_root_replace, DS), array('', _DS), $file), _DS);
                         }
                     }
                 }
             }
         }
         $fileArray = array_merge($fileArray, $items);
         //prx($items['AdminTheme']);exit;
         //prx($items['Theme']);exit;
         //prx($fileArray);exit;
         S2Cache::write($cache_key, $fileArray, '_s2framework_core_');
         unset($Folder, $tree);
     }
     $App =& App::getInstance();
     $App->{$app . 'Paths'} = $fileArray;
     unset($this->__items, $items);
 }
Пример #12
0
 function index()
 {
     $response = array();
     if (Sanitize::getString($this->params, 'task') == 'upgrade') {
         // Where running the install script for upgrade we want a json object returned
         $this->autoLayout = false;
         $this->autoRender = false;
     } else {
         $this->autoLayout = true;
         $this->autoRender = true;
     }
     $this->name = 'install';
     # Create database tables
     // Start db upgrade logic
     $action = array();
     $action['db_install'] = true;
     $tables = $this->_db->getTableList();
     $dbprefix = cmsFramework::getConfig('dbprefix');
     $old_build = 0;
     if (is_array($tables) && in_array($dbprefix . 'jreviews_categories', array_values($tables))) {
         // Tables exist so we check the current build and upgrade accordingly, otherwise it's a clean install and no upgrade is necessary
         $query = "SELECT value FROM #__jreviews_config WHERE id = 'version'";
         $this->_db->setQuery($query);
         $old_version = trim(strip_tags($this->_db->loadResult()));
         if ($old_version != '') {
             $version_parts = explode('.', $old_version);
             $old_build = array_pop($version_parts);
         }
         // Get current version number
         $xml = file(S2_CMS_ADMIN . 'jreviews.xml');
         foreach ($xml as $xml_line) {
             if (strstr($xml_line, 'version')) {
                 $new_version = trim(strip_tags($xml_line));
                 continue;
             }
         }
         $version_parts = explode('.', $new_version);
         $new_build = array_pop($version_parts);
         if (Sanitize::getBool($this->params, 'sql')) {
             $old_build = 0;
         }
         //            prx($old_build . '<br/>' . $new_build) ;
         if ($new_build > $old_build) {
             $i = $old_build + 1;
             for ($i = $old_build + 1; $i <= $new_build; $i++) {
                 // Run sql updates
                 $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.sql';
                 if (file_exists($sql_file)) {
                     $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix) && $action['db_install'];
                 }
                 // Run php updates
                 $php_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.php';
                 if (file_exists($php_file)) {
                     include $php_file;
                 }
             }
         }
     } else {
         // It's a clean install so we use the whole jReviews sql file
         $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'jreviews.sql';
         $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix);
     }
     # Update component id in pre-existing jReviews menus
     if (getCmsVersion() == CMS_JOOMLA16) {
         $query = "\n                SELECT \n                    extension_id AS id\n                FROM \n                    #__extensions \n                WHERE \n                    element = '" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "' AND type = 'component'\n            ";
     } else {
         $query = "\n                SELECT \n                    id \n                FROM \n                    #__components \n                WHERE \n                    admin_menu_link = 'option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n            ";
     }
     $this->_db->setQuery($query);
     if ($id = $this->_db->loadResult()) {
         if (getCmsVersion() == CMS_JOOMLA16) {
             $query = "\n                    UPDATE \n                        `#__menu` \n                    SET \n                        component_id = {$id} \n                    WHERE \n                        type IN ('component','components') \n                            AND \n                        link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n                ";
         } else {
             $query = "\n                    UPDATE \n                        `#__menu` \n                    SET \n                        componentid = {$id} \n                    WHERE \n                        type IN ('component','components') \n                            AND \n                        link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n                ";
         }
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     $result = false;
     // Install jReviews plugin
     $package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
     if (getCmsVersion() == CMS_JOOMLA16) {
         @mkdir(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews');
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews';
     } else {
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
     }
     $target_file = $target . DS . 'jreviews.php';
     $first_pass = false;
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if ($result) {
         $this->Config->version = $new_version;
         $this->Config->store();
     }
     if (getCmsVersion() == CMS_JOOMLA15 && !file_exists($target_file)) {
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         $extract = new PclZip($package);
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $result = $extract->extract(PCLZIP_OPT_PATH, $target);
     }
     if (!file_exists($target_file)) {
         $action['plugin_install'] = false;
     } else {
         $action['plugin_install'] = true;
         if (getCmsVersion() == CMS_JOOMLA16) {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        extension_id AS ud \n                    FROM \n                        #__extensions \n                    WHERE \n                        type = 'plugin' AND element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadResult();
             if (!$result || empty($result)) {
                 $query = "\n                        INSERT INTO \n                            #__extensions \n                                (`name`, `type`,`element`, `folder`, `access`, `ordering`, `enabled`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                            VALUES \n                                ('JReviews Plugin', 'plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 if ($this->_db->query()) {
                     $action['plugin_install'] = true;
                 } else {
                     $action['plugin_install'] = false;
                 }
             }
         } else {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        id \n                    FROM \n                        #__plugins \n                    WHERE \n                        element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadResult();
             if (!$result || empty($result)) {
                 $query = "\n                        INSERT INTO #__plugins \n                            (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                        VALUES \n                            ('jReviews Comment Plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 if ($this->_db->query()) {
                     $action['plugin_install'] = true;
                 } else {
                     $action['plugin_install'] = false;
                 }
             }
         }
         // end else
     }
     # Create image upload and thumbnail folders
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) {
         $Config = new JConfig();
         if (isset($Config->ftp_enable) && $Config->ftp_enable) {
             // set up basic connection
             $conn_id = ftp_connect($Config->ftp_host, $Config->ftp_port);
             // login with username and password
             $login_result = ftp_login($conn_id, $Config->ftp_user, $Config->ftp_pass);
             ftp_chdir($conn_id, $Config->ftp_root);
             ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews');
             ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews' . DS . 'tn');
             ftp_close($conn_id);
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html');
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
         }
     }
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) {
         $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS, 0755);
         if (!$result) {
             $action['thumbnail_dir'] = false;
         } else {
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html');
             $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755);
             if (!$result) {
                 $action['thumbnail_dir'] = false;
             } else {
                 @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
             }
         }
     }
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) {
         $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755);
         if (!$result) {
             $action['thumbnail_dir'] = false;
         } else {
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
         }
     }
     if (is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS) && is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) {
         $action['thumbnail_dir'] = true;
     }
     // Clear data and core caches
     clearCache('', '__data');
     clearCache('', 'core');
     //var_dump($action);
     if (Sanitize::getString($this->params, 'task') == 'upgrade') {
         $response = array('error' => false, 'html' => '');
         // {"db_install":true,"plugin_install":true,"thumbnail_dir":true}
         if (!$action['db_install']) {
             $response['error'] = true;
             $response['html'] = '<div style="color:red>There was a problem upgrading the database</div>';
         }
         if (!$action['plugin_install']) {
             $response['error'] = true;
             $response['html'] .= '<div style="color:red>There was a problem upgrading the JReviews plugin</div>';
         }
         return json_encode($response);
     }
     $this->set(array('action' => $action));
 }
Пример #13
0
 function getCategory()
 {
     $core = null;
     $jr = null;
     # Process parameters whether passed individually or as an array
     $params = func_get_args();
     $keys = array('cat_id', 'section_id', 'dir_id', 'listing');
     if (count($params) > 1) {
         // Individual parameters
         while ($params) {
             ${array_shift($keys)} = array_shift($params);
         }
     } else {
         extract(array_shift($params));
     }
     // Process article urls using Joomla core menus
     if (!empty($listing)) {
         $core = $this->get('core_content_menu_id_' . $listing, '');
         if ($core != '') {
             return $core;
         }
         $core = $this->cmsVersion == CMS_JOOMLA15 ? $this->get('core_category_menu_id_' . $cat_id, $this->getSection($section_id, $dir_id, $listing)) : $this->get('core_category_menu_id_' . $cat_id);
         if ($core != '') {
             return $core;
         }
         if ($this->cmsVersion == CMS_JOOMLA16) {
             $parent_cat_ids = $this->get('parent_cat_ids_' . $cat_id);
             if (!$parent_cat_ids) {
                 $parent_cat_ids = $this->getParentCatIds($cat_id);
                 $this->set('parent_cat_ids_' . $cat_id, $parent_cat_ids);
             }
             # Loop through parent categories to find the correct Itemid
             foreach ($parent_cat_ids as $pcat_id) {
                 $tmp = $this->get('core_category_menu_id_' . $pcat_id->cat_id);
                 if ($tmp) {
                     $this->set('core_category_menu_id_' . $pcat_id->cat_id, $tmp);
                     $core = $tmp;
                 }
             }
             if ($core) {
                 return $core;
             }
         }
         if (cmsFramework::getConfig('sef') == 1) {
             // There's a problem with core sef urls having Itemids from non-core menus, so we make sure the JReviews menu ids are not used
             return false;
         }
     }
     // Process JReviews category urls using JReviews menus
     if ($this->cmsVersion == CMS_JOOMLA15) {
         return $this->get('jr_category_menu_id_' . $cat_id, $this->getSection($section_id, $dir_id));
     }
     $parent_cat_ids = $this->get('parent_cat_ids_' . $cat_id);
     if (!$parent_cat_ids) {
         $parent_cat_ids = $this->getParentCatIds($cat_id);
         $this->set('parent_cat_ids_' . $cat_id, $parent_cat_ids);
     }
     # Loop through parent jr categories to find the correct Itemid
     foreach ($parent_cat_ids as $pcat_id) {
         $tmp = $this->get('jr_category_menu_id_' . $pcat_id->cat_id);
         if ($tmp) {
             $this->set('jr_category_menu_id_' . $pcat_id->cat_id, $tmp);
             $jr = $tmp;
         }
     }
     if ($jr) {
         return $jr;
     }
     return $this->getDir($dir_id);
 }
Пример #14
0
 /**
  * Facebook Open Graph implementation
  * 
  * @param mixed $listing
  * @param mixed $meta
  */
 function facebookOpenGraph(&$listing, $meta)
 {
     // http://developers.facebook.com/docs/opengraph/
     $option = Sanitize::getString($_REQUEST, 'option', '');
     $view = Sanitize::getString($_REQUEST, 'view', '');
     $id = Sanitize::getInt($_REQUEST, 'id');
     // Make sure this is a Joomla article page
     if (!($option == 'com_content' && $view == 'article' && $id)) {
         return;
     }
     $Config = Configure::read('JreviewsSystem.Config');
     if (empty($Config)) {
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
     }
     $facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
     // Make sure FB is enabled and we have an FB App Id
     if (!$facebook_xfbml) {
         return;
     }
     extract($meta);
     $title == '' and $title = $listing['Listing']['title'];
     $description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
     $image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
     if (!$image) {
         $img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
         preg_match($img_src, $listing['Listing']['summary'], $matches);
         if (isset($matches[1])) {
             $image = $matches[1];
         }
     }
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
     $fields = $listing['Field']['pairs'];
     // You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
     $tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
     cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
     Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
     //        cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
     # Loop through the tags array to add the additional FB meta tags
     foreach ($tags as $attr => $fname) {
         $content = '';
         if (substr($fname, 0, 3) == 'jr_') {
             // It's a custom field
             $content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
         } elseif ($fname != '') {
             // It's a static text, not a custom field
             $content = htmlspecialchars($fname);
         }
         $content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
     }
 }
Пример #15
0
 function route($link, $xhtml = true, $ssl = null)
 {
     $menu_alias = '';
     if (false === strpos($link, 'index.php') && false === strpos($link, 'index2.php')) {
         $link = 'index.php?' . $link;
     }
     // Check core sef
     $sef = cmsFramework::getConfig('sef');
     $sef_rewrite = cmsFramework::getConfig('sef_rewrite');
     if (false === strpos($link, 'option=com_jreviews') && !$sef) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         if (false === strpos($url, 'http')) {
             $parsedUrl = parse_url(WWW_ROOT);
             $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
             $url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . $url;
         }
         return $url;
     } elseif (false === strpos($link, 'option=com_jreviews')) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         return $url;
     }
     // Fixes component menu urls with pagination and ordering parameters when core sef is enabled.
     $link = str_replace('//', '/', $link);
     if ($sef) {
         $mod_rewrite = cmsFramework::getConfig('sef_rewrite');
         // Mod Rewrite is not enabled
         if (!$mod_rewrite) {
             preg_match('/Itemid=([0-9]+)/', $link, $matches);
             if (isset($matches[1]) && is_numeric($matches[1])) {
                 $link2 = 'index.php?option=com_jreviews&Itemid=' . $matches[1];
                 $menu_alias = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link2, $xhtml, $ssl) : JRoute::_($link2, $xhtml, $ssl);
                 strstr($menu_alias, 'index.php') and $menu_alias = str_replace('.html', '/', substr($menu_alias, strpos($menu_alias, 'index.php' . _DS) + 10));
                 $menu_alias .= '/';
                 $menu_alias = '/' . ltrim(array_shift(explode('?', $menu_alias)), '/');
             }
         }
         // Core sef doesn't know how to deal with colons, so we convert them to something else and then replace them again.
         $link = $nonsef_link = str_replace(_PARAM_CHAR, '*@*', $link);
         $sefUrl = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         $sefUrl = str_replace('%2A%40%2A', _PARAM_CHAR, $sefUrl);
         $sefUrl = str_replace('*@*', _PARAM_CHAR, $sefUrl);
         // For non sef links
         if (!class_exists('shRouter')) {
             // Get rid of duplicate menu alias segments added by the JRoute function
             if (strstr($sefUrl, 'order:') || strstr($sefUrl, 'page:') || strstr($sefUrl, 'limit:')) {
                 $sefUrl = str_replace(array('/format:html/', '.html'), '/', $sefUrl);
             }
             // Get rid of duplicate menu alias segments added by the JRoute function
             if ($menu_alias != '' && $menu_alias != '/' && !$mod_rewrite) {
                 $sefUrl = str_replace($menu_alias, '--menuAlias--', $sefUrl, $count);
                 $sefUrl = str_replace(str_repeat('--menuAlias--', $count), $menu_alias, $sefUrl);
             }
         }
         $link = $sefUrl;
         // If it's not a JReviews menu url remove the suffix
         $nonsef_link = str_replace('&amp;', '&', $nonsef_link);
         if (substr($nonsef_link, -5) == '.thtml' && !preg_match('/^index.php\\?option=com_jreviews&Itemid=([0-9]+)$/i', $nonsef_link)) {
             $link = str_replace('.html', '', $sefUrl);
         }
     }
     if (false !== strpos($link, 'http')) {
         return $link;
     } else {
         $parsedUrl = parse_url(WWW_ROOT);
         $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
         $www_root = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . ($sef ? _DS : $parsedUrl['path']);
         return $www_root . ltrim($link, _DS);
     }
 }
Пример #16
0
 function UrlTransliterate($string)
 {
     if (cmsFramework::getConfig('unicodeslugs') == 1) {
         $output = JFilterOutput::stringURLUnicodeSlug($string);
     } else {
         $output = JFilterOutput::stringURLSafe($string);
     }
     return $output;
 }
Пример #17
0
 function route($link, $xhtml = true, $ssl = null)
 {
     if (false === strpos($link, 'index.php') && false === strpos($link, 'index2.php')) {
         $link = 'index.php?' . $link;
     }
     // Check core sef
     $sef = cmsFramework::getConfig('sef');
     $sef_rewrite = cmsFramework::getConfig('sef_rewrite');
     if (false === strpos($link, 'option=com_jreviews') && !$sef) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         if (false === strpos($url, 'http')) {
             $parsedUrl = parse_url(WWW_ROOT);
             $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
             $url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . $url;
         }
         return $url;
     } elseif (false === strpos($link, 'option=com_jreviews')) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         return $url;
     }
     // Fixes component menu urls with pagination and ordering parameters when core sef is enabled.
     $link = str_replace('//', '/', $link);
     if ($sef) {
         if (substr($link, 0, 10) === 'index.php') {
             $link = str_replace('/', '%2F', $link);
         }
         // Core sef doesn't know how to deal with colons, so we convert them to something else and then replace them again.
         $link = str_replace(_PARAM_CHAR, '*@*', $link);
         $sefUrl = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         $sefUrl = str_replace('%2A%40%2A', _PARAM_CHAR, $sefUrl);
         $sefUrl = str_replace('*@*', _PARAM_CHAR, $sefUrl);
         // For non sef links
         $link = $sefUrl;
     }
     if (false !== strpos($link, 'http')) {
         return $link;
     } else {
         $parsedUrl = parse_url(WWW_ROOT);
         $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
         $www_root = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . ($sef ? _DS : $parsedUrl['path']);
         return $www_root . ltrim($link, _DS);
     }
 }
Пример #18
0
 function _postVote()
 {
     # Check if FB integration for reviews is enabled
     $facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_reviews');
     if (!$facebook_integration) {
         return;
     }
     $review_id = Sanitize::getInt($this->params, 'id');
     # First check - review id
     if (!$review_id) {
         return;
     }
     $facebook = $this->_getFBClass();
     # Second check - FB session
     if ($fbsession = $facebook->getSession()) {
         try {
             //get user id
             $uid = $facebook->getUser();
             $user = $facebook->api('/me');
             $fql = "SELECT publish_stream FROM permissions WHERE uid = " . $uid;
             $param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
             $fqlResult = $facebook->api($param);
             if (!$fqlResult[0]['publish_stream']) {
                 return false;
             } else {
                 $review = $this->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)), array());
                 $this->Everywhere->loadListingModel($this, $review['Review']['extension']);
                 $listing = $this->Listing->findRow(array('conditions' => array('Listing.' . $this->Listing->realKey . ' = ' . $review['Review']['listing_id'])), array('afterFind'));
                 $listing_url = $this->makeUrl($listing['Listing']['url']);
                 # Publish stream permission granted so we can post on the user's wall!
                 # Begin building the stream $fbArray
                 $fbArray = array();
                 $fbArray['method'] = 'stream.publish';
                 $fbArray['message'] = sprintf($this->activities['vote helpful'], $listing['Listing']['title']);
                 $fbArray['attachment'] = array('name' => $listing['Listing']['title'], 'href' => $listing_url, 'description' => strip_tags($review['Review']['comments']));
                 $fbArray['attachment']['properties'][__t("Website", true)] = array('text' => cmsFramework::getConfig('sitename'), 'href' => WWW_ROOT);
                 $review['Rating']['average_rating'] > 0 and $fbArray['attachment']['properties'][__t("Rating", true)] = sprintf(__t("%s stars", true), round($review['Rating']['average_rating'], 1));
                 isset($listing['Listing']['images'][0]) and $fbArray['attachment']['media'] = array(array('type' => 'image', 'src' => WWW_ROOT . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path'], 'href' => $listing_url));
                 $fbArray['attachment'] = json_encode($fbArray['attachment']);
                 $fbArray['action_links'] = json_encode(array(array('text' => __t("Read review", true), 'href' => $listing_url)));
                 $fbArray['comments_xid'] = $listing['Listing']['listing_id'];
                 if ($this->Config->facebook_optout) {
                     return "FB.ui(" . json_encode($fbArray) . ")";
                 }
                 $fb_update = $facebook->api($fbArray);
                 return true;
             }
         } catch (Exception $o) {
             // Error reading permissions
             return false;
         }
     }
     return false;
 }
Пример #19
0
function S2cacheWrite($prefix, $key, $data)
{
    # Send to cache
    if ((!defined('MVC_FRAMEWORK_ADMIN') || MVC_FRAMEWORK_ADMIN == 0) && Configure::read('Cache.enable') && Configure::read('Cache.query')) {
        $cacheKey = $prefix . '_' . md5(cmsFramework::getConfig('secret') . serialize($key));
        S2Cache::write($cacheKey, $data);
    }
}
Пример #20
0
 function index()
 {
     $response = array();
     if (Sanitize::getString($this->params, 'task') == 'upgrade') {
         // Where running the install script for upgrade we want a json object returned
         $this->autoLayout = false;
         $this->autoRender = false;
     } else {
         $this->autoLayout = true;
         $this->autoRender = true;
     }
     $this->name = 'install';
     # Remove views folder in J1.5
     if ($this->cmsVersion == CMS_JOOMLA15) {
         $Folder = ClassRegistry::getClass('Folder');
         $target = PATH_ROOT . 'components' . DS . 'com_jreviews' . DS . 'views';
         $Folder->rm($target);
     }
     # Create database tables
     // Start db upgrade logic
     $action = array();
     $action['db_install'] = true;
     $tables = $this->_db->getTableList();
     $dbprefix = cmsFramework::getConfig('dbprefix');
     $old_build = 0;
     // Get current version number
     $jreviewsxml = $this->cmsVersion == CMS_JOOMLA15 ? 'jreviews.xml' : 'jreviewg.xml';
     $xml = file(S2_CMS_ADMIN . $jreviewsxml);
     foreach ($xml as $xml_line) {
         if (strstr($xml_line, 'version')) {
             $new_version = trim(strip_tags($xml_line));
             continue;
         }
     }
     $version_parts = explode('.', $new_version);
     $new_build = array_pop($version_parts);
     if (is_array($tables) && in_array($dbprefix . 'jreviews_categories', array_values($tables))) {
         // Tables exist so we check the current build and upgrade accordingly, otherwise it's a clean install and no upgrade is necessary
         $query = "SELECT value FROM #__jreviews_config WHERE id = 'version'";
         $this->_db->setQuery($query);
         $old_version = trim(strip_tags($this->_db->loadResult()));
         if ($old_version != '') {
             $version_parts = explode('.', $old_version);
             $old_build = array_pop($version_parts);
         }
         if (Sanitize::getBool($this->params, 'sql')) {
             $old_build = 0;
         }
         //            prx($old_build . '<br/>' . $new_build) ;
         if ($new_build > $old_build) {
             $i = $old_build + 1;
             for ($i = $old_build + 1; $i <= $new_build; $i++) {
                 // Run sql updates
                 $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.sql';
                 if (file_exists($sql_file)) {
                     $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix) && $action['db_install'];
                 }
                 // Run php updates
                 $php_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.php';
                 if (file_exists($php_file)) {
                     include $php_file;
                 }
             }
         }
     } else {
         // It's a clean install so we use the whole jReviews sql file
         $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'jreviews.sql';
         $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix);
     }
     # Update component id in pre-existing jReviews menus
     if ($this->cmsVersion == CMS_JOOMLA16) {
         $query = "\n                SELECT \n                    extension_id AS id\n                FROM \n                    #__extensions \n                WHERE \n                    element = '" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "' AND type = 'component'\n            ";
     } else {
         $query = "\n                SELECT \n                    id \n                FROM \n                    #__components \n                WHERE \n                    admin_menu_link = 'option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n            ";
     }
     $this->_db->setQuery($query);
     if ($id = $this->_db->loadResult()) {
         if ($this->cmsVersion == CMS_JOOMLA16) {
             $query = "\n                    UPDATE \n                        `#__menu` \n                    SET \n                        component_id = {$id} \n                    WHERE \n                        type IN ('component','components') \n                            AND \n                        link LIKE 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "%'\n                ";
         } else {
             $query = "\n                    UPDATE \n                        `#__menu` \n                    SET \n                        componentid = {$id} \n                    WHERE \n                        type IN ('component','components') \n                            AND \n                        link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n                ";
         }
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     # Update version number in the database
     $this->Config->version = $new_version;
     $this->Config->store();
     $action['plugin_install'] = $this->_installPlugin();
     # Create image upload and thumbnail folders
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) {
         $Config = new JConfig();
         if (isset($Config->ftp_enable) && $Config->ftp_enable) {
             // set up basic connection
             $conn_id = ftp_connect($Config->ftp_host, $Config->ftp_port);
             // login with username and password
             $login_result = ftp_login($conn_id, $Config->ftp_user, $Config->ftp_pass);
             ftp_chdir($conn_id, $Config->ftp_root);
             ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews');
             ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews' . DS . 'tn');
             ftp_close($conn_id);
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html');
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
         }
     }
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) {
         $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS, 0755);
         if (!$result) {
             $action['thumbnail_dir'] = false;
         } else {
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html');
             $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755);
             if (!$result) {
                 $action['thumbnail_dir'] = false;
             } else {
                 @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
             }
         }
     }
     if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) {
         $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755);
         if (!$result) {
             $action['thumbnail_dir'] = false;
         } else {
             @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html');
         }
     }
     if (is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS) && is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) {
         $action['thumbnail_dir'] = true;
     }
     # Ensure that all field group names are slugs
     $query = "\n            SELECT \n                groupid, name\n            FROM\n                #__jreviews_groups\n        ";
     $this->_db->setQuery($query);
     $groups = $this->_db->loadAssocList();
     if (!empty($groups)) {
         foreach ($groups as $group) {
             if (strpos($group['name'], ' ') !== false) {
                 $name = cmsFramework::StringTransliterate($group['name']) . $group['groupid'];
                 $query = "\n                        UPDATE\n                            #__jreviews_groups\n                        SET \n                            name = " . $this->quote($name) . "\n                        WHERE\n                            groupid = " . $group['groupid'];
                 $this->_db->setQuery($query);
                 $this->_db->query();
             }
         }
     }
     # Clear data and core caches
     clearCache('', '__data');
     clearCache('', 'core');
     //var_dump($action);
     if (Sanitize::getString($this->params, 'task') == 'upgrade') {
         $response = array('error' => false, 'html' => '');
         // {"db_install":true,"plugin_install":true,"thumbnail_dir":true}
         if (!$action['db_install']) {
             $response['error'] = true;
             $response['html'] = '<div style="color:red>There was a problem upgrading the database</div>';
         }
         if (!$action['plugin_install']) {
             $response['error'] = true;
             $response['html'] .= '<div style="color:red>There was a problem upgrading the JReviews plugin</div>';
         }
         return json_encode($response);
     }
     $this->set(array('action' => $action));
 }
Пример #21
0
 function find($type, $queryData, $callbacks = array('plgAfterFind', 'afterFind', 'plgAfterAfterFind'), $cache = false)
 {
     $queryData = $this->__mergeArrays($queryData);
     if ($cache === true && !Configure::read('Cache.disable') && Configure::read('Cache.query') === true) {
         $cache_key = md5(cmsFramework::getConfig('secret') . $type . serialize($queryData) . serialize($callbacks));
         $rows = S2Cache::read($cache_key);
         /*            if($type != 'one' && in_array('plgAfterFind',$this->cacheCallbacks) && method_exists($this,'plgAfterFind')) {
                         $rows = $this->plgAfterFind($rows);
                     }
                     if($type != 'one' && in_array('afterFind',$this->cacheCallbacks) && method_exists($this,'afterFind')) {
                         $rows = $this->afterFind($rows);
                     }
         */
         if ($type != 'one' && in_array('plgAfterAfterFind', $this->cacheCallbacks) && method_exists($this, 'plgAfterAfterFind')) {
             $rows = $this->plgAfterAfterFind($rows);
         }
         if (false !== $rows) {
             return $rows;
         }
     }
     $query = "SELECT " . implode(",\n", $queryData['fields']) . "\n FROM " . $this->useTable . (!empty($queryData['joins']) ? "\n" . implode("\n", $queryData['joins']) : '') . (!empty($queryData['conditions']) ? "\n WHERE 1 = 1 AND ( \n   " . implode("\n   AND ", $queryData['conditions']) . "\n )" : '') . (!empty($queryData['group']) ? "\n GROUP BY " . implode(',', $queryData['group']) : '') . (!empty($queryData['having']) ? "\n HAVING " . implode(' AND ', $queryData['having']) : '') . (!empty($queryData['order']) ? "\n ORDER BY " . implode(',', $queryData['order']) : '') . (!empty($queryData['limit']) ? "\n LIMIT " . (Sanitize::getInt($queryData, 'offset', null) ? $queryData['offset'] . ", " : '') . $queryData['limit'] : '');
     $this->_db->setQuery($query);
     //        prx($this->_db->getQuery());
     $message = array();
     $message[] = '*********' . get_class($this) . ' | find';
     $message[] = $this->_db->getQuery();
     appLogMessage($message, 'database');
     switch ($type) {
         case 'all':
             $rows = $this->_db->loadObjectList();
             $rows = $this->__reformatArray($rows);
             break;
         case 'one':
             $rows = $this->_db->loadResult();
             break;
     }
     $message = array();
     if ($this->_db->getErrorMsg()) {
         $message[] = '*********' . get_class($this) . ' | find ERROR';
         $message[] = $this->_db->getErrorMsg();
         appLogMessage($message, 'database');
     }
     if ($type != 'one' && in_array('plgAfterFind', $callbacks) && method_exists($this, 'plgAfterFind')) {
         $rows = $this->plgAfterFind($rows);
     }
     if ($type != 'one' && in_array('afterFind', $callbacks) && method_exists($this, 'afterFind')) {
         $rows = $this->afterFind($rows);
     }
     if ($cache === true && !Configure::read('Cache.disable') && Configure::read('Cache.query') === true) {
         S2Cache::write($cache_key, $rows);
     }
     if ($type != 'one' && in_array('plgAfterAfterFind', $callbacks) && method_exists($this, 'plgAfterAfterFind')) {
         $rows = $this->plgAfterAfterFind($rows);
     }
     return $rows;
 }
Пример #22
0
 function getCategory($id, $section_id, $dir_id, $listing = false)
 {
     if ($listing) {
         $core = $this->get('core_content_menu_id_' . $listing, '');
         if ($core != '') {
             return $core;
         }
         $core = $this->get('core_category_menu_id_' . $id, $this->getSection($section_id, $dir_id, $listing));
         if ($core != '') {
             return $core;
         } elseif (getCmsVersion() == CMS_JOOMLA15 && cmsFramework::getConfig('sef') == 1) {
             // There's a problem with J1.5 core sef urls with Itemids from non-core menus, so we make sure the jReviews menu ids are not used
             return false;
         }
     }
     return $this->get('jr_category_menu_id_' . $id, $this->getSection($section_id, $dir_id));
 }
Пример #23
0
<?php

/**
 * jReviews - Reviews Extension
 * Copyright (C) 2006 ClickFWD LLC
 * This is not free software, do not distribute it.
 * For licencing information visit http://www.reviewsforjoomla.com
 * or contact sales@reviewsforjoomla.com
**/
defined('_VALID_MOS') || defined('_JEXEC') or die('Direct Access to this location is not allowed.');
# MVC initalization script
require JPATH_SITE . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php';
# Populate $params array with module settings
$module_params = isset($params->_raw) ? stringToArray($params->_raw) : $params->toArray();
$moduleParams['module'] = $module_params;
$moduleParams['module_id'] = $module->id;
$moduleParams['page'] = 1;
$moduleParams['data']['module'] = true;
$moduleParams['data']['controller'] = 'module_favorite_users';
$moduleParams['data']['action'] = 'index';
$moduleParams['secret'] = cmsFramework::getConfig('secret');
$moduleParams['token'] = cmsFramework::formIntegrityToken($moduleParams, array('module', 'module_id', 'form', 'data'), false);
$Dispatcher = new S2Dispatcher('jreviews');
echo $Dispatcher->dispatch($moduleParams);
unset($Dispatcher);
Пример #24
0
 function plgAfterSave(&$model)
 {
     appLogMessage('**** BEGIN Notifications Plugin AfterSave', 'database');
     # Read cms mail config settings
     $configSendmailPath = cmsFramework::getConfig('sendmail');
     $configSmtpAuth = cmsFramework::getConfig('smtpauth');
     $configSmtpUser = cmsFramework::getConfig('smtpuser');
     $configSmtpPass = cmsFramework::getConfig('smtppass');
     $configSmtpHost = cmsFramework::getConfig('smtphost');
     $configSmtpSecure = cmsFramework::getConfig('smtpsecure');
     $configSmtpPort = cmsFramework::getConfig('smtpport');
     $configMailFrom = cmsFramework::getConfig('mailfrom');
     $configFromName = cmsFramework::getConfig('fromname');
     $configMailer = cmsFramework::getConfig('mailer');
     if (!class_exists('PHPMailer')) {
         App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
     }
     $mail = new PHPMailer();
     $mail->CharSet = cmsFramework::getCharset();
     $mail->SetLanguage('en', S2_VENDORS . 'PHPMailer' . DS . 'language' . DS);
     $mail->Mailer = $configMailer;
     // Mailer used mail,sendmail,smtp
     switch ($configMailer) {
         case 'smtp':
             $mail->Host = $configSmtpHost;
             $mail->SMTPAuth = $configSmtpAuth;
             $mail->Username = $configSmtpUser;
             $mail->Password = $configSmtpPass;
             $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
             $mail->Port = $configSmtpPort;
             break;
         case 'sendmail':
             $mail->Sendmail = $configSendmailPath;
             break;
         default:
             break;
     }
     $mail->isHTML(true);
     $mail->From = $configMailFrom;
     $mail->FromName = $configFromName;
     # In this observer model we just use the existing data to send the email notification
     switch ($this->notifyModel->name) {
         # Notification for new/edited listings
         case 'Listing':
             if ($this->c->Config->notify_content || $this->c->Config->notify_user_listing) {
                 $this->c->autoRender = false;
                 $listing = $this->_getListing($model);
                 $this->c->set(array('isNew' => isset($model->data['insertid']), 'User' => $this->c->_user, 'listing' => $listing));
             } else {
                 return;
             }
             // Admin listing email
             if ($this->c->Config->notify_content) {
                 $mail->ClearAddresses();
                 $mail->ClearAllRecipients();
                 $mail->ClearBCCs();
                 # Process configuration emails
                 if ($this->c->Config->notify_content_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_content_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 $subject = isset($model->data['insertid']) ? __t("New listing", true) . ": {$listing['Listing']['title']}" : __t("Edited listing", true) . ": {$listing['Listing']['title']}";
                 $guest = !$this->c->_user->id ? ' (Guest)' : " ({$this->c->_user->id})";
                 $author = $this->c->_user->id ? $this->c->_user->name : 'Guest';
                 $message = $this->c->render('email_templates', 'admin_listing_notification');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin listing message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             // End admin listing email
             // User listing email - to user submitting the listing as long as he is also the owner of the listing
             if ($this->c->Config->notify_user_listing) {
                 $mail->ClearAddresses();
                 $mail->ClearAllRecipients();
                 $mail->ClearBCCs();
                 //Check if submitter and owner are the same or else email is not sent
                 // This is to prevent the email from going out if admins are doing the editing
                 if ($this->c->_user->id == $listing['User']['user_id']) {
                     // Process configuration emails
                     if ($this->c->Config->notify_user_listing_emails != '') {
                         $recipient = explode("\n", $this->c->Config->notify_user_listing_emails);
                         foreach ($recipient as $bcc) {
                             if (trim($bcc) != '') {
                                 $mail->AddBCC(trim($bcc));
                             }
                         }
                     }
                     $mail->AddAddress(trim($listing['User']['email']));
                     $subject = isset($model->data['insertid']) ? sprintf(__t("New listing: %s", true), $listing['Listing']['title']) : sprintf(__t("Edited listing: %s", true), $listing['Listing']['title']);
                     $guest = !$this->c->_user->id ? ' (Guest)' : " ({$this->c->_user->id})";
                     $author = $this->c->_user->id ? $this->c->_user->name : 'Guest';
                     $message = $this->c->render('email_templates', 'user_listing_notification');
                     $mail->Subject = $subject;
                     $mail->Body = $message;
                     if (!$mail->Send()) {
                         appLogMessage(array("User listing message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             // End user listing email
             break;
             # Notification for new/edited reviews
         # Notification for new/edited reviews
         case 'Review':
             // Perform common actions for all review notifications
             if ($this->c->Config->notify_review || $this->c->Config->notify_user_review || $this->c->Config->notify_owner_review) {
                 $extension = $model->data['Review']['mode'];
                 $review = $this->_getReview($model);
                 $listing = $review;
                 $entry_title = $listing['Listing']['title'];
                 $this->c->autoRender = false;
                 $this->c->set(array('isNew' => isset($model->data['insertid']), 'extension' => $extension, 'listing' => $listing, 'User' => $this->c->_user, 'review' => $review));
             } else {
                 return;
             }
             // Admin review email
             if ($this->c->Config->notify_review) {
                 $mail->ClearAddresses();
                 $mail->ClearAllRecipients();
                 $mail->ClearBCCs();
                 # Process configuration emails
                 if ($this->c->Config->notify_review_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_review_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 $subject = isset($model->data['insertid']) ? sprintf(__t("New review: %s", true), $entry_title) : sprintf(__t("Edited review: %s", true), $entry_title);
                 $message = $this->c->render('email_templates', 'admin_review_notification');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin review message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             // User review email - sent to review submitter
             if ($this->c->Config->notify_user_review && $this->c->_user->id == $review['User']['user_id'] && !empty($review['User']['email'])) {
                 $mail->ClearAddresses();
                 $mail->ClearAllRecipients();
                 $mail->ClearBCCs();
                 //Check if submitter and owner are the same or else email is not sent
                 // This is to prevent the email from going out if admins are doing the editing
                 if ($this->c->_user->id == $review['User']['user_id']) {
                     // Process configuration emails
                     if ($this->c->Config->notify_user_review_emails != '') {
                         $recipient = explode("\n", $this->c->Config->notify_user_review_emails);
                         foreach ($recipient as $bcc) {
                             if (trim($bcc) != '') {
                                 $mail->AddBCC(trim($bcc));
                             }
                         }
                     }
                     $mail->AddAddress(trim($review['User']['email']));
                     $subject = isset($model->data['insertid']) ? sprintf(__t("New review: %s", true), $entry_title) : sprintf(__t("Edited review: %s", true), $entry_title);
                     $message = $this->c->render('email_templates', 'user_review_notification');
                     $mail->Subject = $subject;
                     $mail->Body = $message;
                     if (!$mail->Send()) {
                         appLogMessage(array("User review message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             // Listing owner review email
             if ($this->c->Config->notify_owner_review && isset($listing['ListingUser']['email'])) {
                 $mail->ClearAddresses();
                 $mail->ClearAllRecipients();
                 $mail->ClearBCCs();
                 // Process configuration emails
                 if ($this->c->Config->notify_owner_review_emails != '') {
                     $recipient = explode("\n", $this->c->Config->notify_owner_review_emails);
                     foreach ($recipient as $bcc) {
                         if (trim($bcc) != '') {
                             $mail->AddBCC(trim($bcc));
                         }
                     }
                 }
                 $mail->AddAddress(trim($listing['ListingUser']['email']));
                 $subject = isset($model->data['insertid']) ? sprintf(__t("New review: %s", true), $entry_title) : sprintf(__t("Edited review: %s", true), $entry_title);
                 $message = $this->c->render('email_templates', 'owner_review_notification');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send()) {
                     appLogMessage(array("Listing owner review message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             # Notification for new owner replies to user reviews
         # Notification for new owner replies to user reviews
         case 'OwnerReply':
             if ($this->c->Config->notify_owner_reply) {
                 # Process configuration emails
                 if ($this->c->Config->notify_owner_reply_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_owner_reply_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 # Get review data
                 $this->c->Review->runProcessRatings = false;
                 $review = $this->c->Review->findRow(array('conditions' => array('Review.id = ' . (int) $model->data['OwnerReply']['id'])));
                 $extension = $review['Review']['extension'];
                 # Load jReviewsEverywhere extension model
                 $name = 'everywhere_' . $extension;
                 App::import('Model', $name, 'jreviews');
                 $class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
                 $EverywhereListingModel = new $class_name();
                 # Get the listing title based on the extension being reviewed
                 $listing = $EverywhereListingModel->findRow(array('conditions' => array("Listing.{$EverywhereListingModel->realKey} = " . $review['Review']['listing_id'])));
                 $subject = sprintf(__t("Owner review reply submitted for listing %s", true), $listing['Listing']['title']);
                 $this->c->autoRender = false;
                 $this->c->set(array('User' => $this->c->_user, 'reply' => $model->data, 'review' => $review, 'listing' => $listing));
                 $message = $this->c->render('email_templates', 'admin_owner_reply_notification');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send() && _MVC_DEBUG_ERR) {
                     appLogMessage(array("Owner reply message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             # Notification for new review reports
         # Notification for new review reports
         case 'Report':
             if ($this->c->Config->notify_report) {
                 # Process configuration emails
                 if ($this->c->Config->notify_review_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_review_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 # Get review data
                 $this->c->Review->runProcessRatings = false;
                 $review = $this->c->Review->findRow(array('conditions' => array('Review.id = ' . (int) $model->data['Report']['review_id'])), array());
                 $extension = $review['Review']['extension'];
                 # Load jReviewsEverywhere extension model
                 $name = 'everywhere_' . $extension;
                 App::import('Model', $name, 'jreviews');
                 $class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
                 $EverywhereListingModel = new $class_name();
                 # Get the listing title based on the extension being reviewed
                 $listing = $EverywhereListingModel->findRow(array('conditions' => array("Listing.{$EverywhereListingModel->realKey} = " . $review['Review']['listing_id'])));
                 $subject = __t("A new report has been submitted", true);
                 $this->c->autoRender = false;
                 $this->c->set(array('User' => $this->c->_user, 'report' => $model->data, 'review' => $review, 'listing' => $listing));
                 $message = $this->c->render('email_templates', 'admin_report_notification');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send() && _MVC_DEBUG_ERR) {
                     appLogMessage(array("Review report message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
         case 'Discussion':
             if ($this->c->Config->notify_review_post) {
                 # Process configuration emails
                 if ($this->c->Config->notify_review_post_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_review_post_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 # Get review data
                 $this->c->Review->runProcessRatings = false;
                 $review = $this->c->Review->findRow(array('conditions' => array('Review.id = ' . (int) $model->data['Discussion']['review_id'])));
                 $extension = $review['Review']['extension'];
                 # Load jReviewsEverywhere extension model
                 $name = 'everywhere_' . $extension;
                 App::import('Model', $name, 'jreviews');
                 $class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
                 $EverywhereListingModel = new $class_name();
                 # Get the listing title based on the extension being reviewed
                 $listing = $EverywhereListingModel->findRow(array('conditions' => array("Listing.{$EverywhereListingModel->realKey} = " . $review['Review']['listing_id'])));
                 $subject = isset($model->data['insertid']) ? sprintf(__t("New comment for review: %s", true), $review['Review']['title']) : sprintf(__t("Edited comment for review: %s", true), $review['Review']['title']);
                 $this->c->autoRender = false;
                 $this->c->set(array('User' => $this->c->_user, 'post' => $model->data, 'review' => $review, 'listing' => $listing));
                 $message = $this->c->render('email_templates', 'admin_review_discussion_post');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send() && _MVC_DEBUG_ERR) {
                     appLogMessage(array("Review comment message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
         case 'Claim':
             if ($this->c->Config->notify_claim) {
                 # Process configuration emails
                 if ($this->c->Config->notify_claim_emails == '') {
                     $mail->AddAddress($configMailFrom);
                 } else {
                     $recipient = explode("\n", $this->c->Config->notify_claim_emails);
                     foreach ($recipient as $to) {
                         if (trim($to) != '') {
                             $mail->AddAddress(trim($to));
                         }
                     }
                 }
                 # Get claim data
                 $callbacks = array();
                 $listing = $this->c->Listing->findRow(array('conditions' => array('Listing.id = ' . (int) $model->data['Claim']['listing_id'])), $callbacks);
                 $subject = sprintf(__t("Listing claim submitted for %s", true), $listing['Listing']['title']);
                 $this->c->autoRender = false;
                 $this->c->set(array('User' => $this->c->_user, 'claim' => $model->data['Claim'], 'listing' => $listing));
                 $message = $this->c->render('email_templates', 'admin_listing_claim');
                 $mail->Subject = $subject;
                 $mail->Body = $message;
                 if (!$mail->Send() && _MVC_DEBUG_ERR) {
                     appLogMessage(array("Listing claim message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
     }
     $this->published = false;
     // Run once. With paid listings it is possible for a plugin to run a 2nd time when the order is processed together with the listing (free)
     return true;
 }
Пример #25
0
 function _send()
 {
     $recipient = '';
     $error = array();
     $response = array();
     $this->components = array('security');
     $this->__initComponents();
     if ($this->invalidToken) {
         $error[] = 'jQuery("#jr_inquiryTokenValidation").show();';
         return json_encode(array('error' => $this->makeJS($error)));
     }
     // Required fields
     $fields = array('name', 'email', 'text');
     //        $fields = array('name','email','phone','text');
     foreach ($fields as $id) {
         $input_id = '#jr_inquiry' . Inflector::camelize($id) . 'Validation';
         if ($this->data['Inquiry'][$id] == '') {
             $error[] = 'jQuery("' . $input_id . '").show();';
         } else {
             $reponse[] = 'jQuery("' . $input_id . '").hide();';
         }
     }
     # Validate user's email
     $this->Listing->validateInput($this->data['Inquiry']['email'], "email", "email", __t("You must fill in a valid email address.", true), 1);
     # Validate security code
     if ($this->Access->showCaptcha()) {
         if (!isset($this->data['Captcha']['code'])) {
             $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true));
         } elseif ($this->data['Captcha']['code'] == '') {
             $this->Listing->validateSetError("code", __t("You must fill in the security code.", true));
         } else {
             if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) {
                 $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true));
             }
         }
     }
     # Process validation errors
     $validation = $this->Listing->validateGetErrorArray();
     $validation = is_array($validation) ? implode("<br />", $validation) : '';
     if (!empty($error) || $validation != '') {
         // Reissue form token
         if (isset($this->Security)) {
             $error[] = "jQuery('#jr_inquiryToken').val('" . $this->Security->reissueToken() . "');";
         }
         if ($this->Access->showCaptcha()) {
             // Replace captcha with new instance
             $captcha = $this->Captcha->displayCode();
             $error[] = "jQuery('#captcha').attr('src','{$captcha['src']}');";
             $error[] = "jQuery('#jr_inquiryCode').val('');";
         }
         if ($validation != '') {
             $error[] = "jQuery('#jr_inquiryCodeValidation').html('{$validation}').show();";
         }
         return json_encode(array('error' => $this->makeJS($error)));
     }
     // Now we can send the email
     # Read cms mail config settings
     $configSendmailPath = cmsFramework::getConfig('sendmail');
     $configSmtpAuth = cmsFramework::getConfig('smtpauth');
     $configSmtpUser = cmsFramework::getConfig('smtpuser');
     $configSmtpPass = cmsFramework::getConfig('smtppass');
     $configSmtpHost = cmsFramework::getConfig('smtphost');
     $configSmtpSecure = cmsFramework::getConfig('smtpsecure');
     $configSmtpPort = cmsFramework::getConfig('smtpport');
     $configMailFrom = cmsFramework::getConfig('mailfrom');
     $configFromName = cmsFramework::getConfig('fromname');
     $configMailer = cmsFramework::getConfig('mailer');
     # Get the recipient email
     Configure::write('Cache.query', false);
     $listing = $this->Listing->findRow(array('fields' => array('User.email AS `Listing.email`'), 'conditions' => array('Listing.id = ' . (int) $this->data['Inquiry']['listing_id'])));
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
     $link = '<a href="' . $url . '">' . $listing['Listing']['title'] . '</a>';
     switch ($this->Config->inquiry_recipient) {
         case 'owner':
             $recipient = Sanitize::getString($listing['Listing'], 'email');
             break;
         case 'admin':
             $recipient = $configMailFrom;
             break;
         case 'field':
             if (isset($listing['Field']['pairs'][$this->Config->inquiry_field])) {
                 $recipient = $listing['Field']['pairs'][$this->Config->inquiry_field]['value'][0];
             }
             break;
     }
     if ($recipient == '') {
         $recipient = $configMailFrom;
     }
     if (!class_exists('PHPMailer')) {
         App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
     }
     $mail = new PHPMailer();
     $mail->CharSet = cmsFramework::getCharset();
     $mail->SetLanguage('en', S2_VENDORS . 'phpmailer' . DS . 'language' . DS);
     $mail->Mailer = $configMailer;
     // Mailer used mail,sendmail,smtp
     switch ($configMailer) {
         case 'smtp':
             $mail->Host = $configSmtpHost;
             $mail->SMTPAuth = $configSmtpAuth;
             $mail->Username = $configSmtpUser;
             $mail->Password = $configSmtpPass;
             $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
             $mail->Port = $configSmtpPort;
             break;
         case 'sendmail':
             $mail->Sendmail = $configSendmailPath;
             break;
         default:
             break;
     }
     $mail->isHTML(true);
     $mail->From = $configMailFrom;
     $mail->FromName = $configFromName;
     $mail->addReplyTo($this->data['Inquiry']['email']);
     $mail->AddAddress($recipient);
     $mail->Subject = sprintf(__t("New inquiry for: %s", true), $listing['Listing']['title']);
     $mail->Body = sprintf(__t("From: %s", true), Sanitize::getString($this->data['Inquiry'], 'name')) . "<br />";
     $mail->Body .= sprintf(__t("Email: %s", true), Sanitize::getString($this->data['Inquiry'], 'email')) . "<br />";
     //        $mail->Body .= sprintf(__t("Phone number: %s",true),Sanitize::getString($this->data['Inquiry'],'phone')) . "<br />";
     $mail->Body .= sprintf(__t("Listing: %s", true), $listing['Listing']['title']) . "<br />";
     $mail->Body .= sprintf(__t("Listing link: %s", true), $link) . "<br />";
     $mail->Body .= $this->data['Inquiry']['text'];
     if (!$mail->Send()) {
         unset($mail);
         $error[] = 'jQuery("#jr_inquiryTokenValidation").show();';
         return json_encode(array('error' => $this->makeJS($error)));
     }
     $mail->ClearAddresses();
     $bccAdmin = $this->Config->inquiry_bcc;
     if ($bccAdmin != '' && $bccAdmin != $recipient) {
         $mail->AddAddress($bccAdmin);
         $mail->Send();
     }
     unset($mail);
     return json_encode(array('error' => $this->makeJS($response), 'html' => true));
 }
Пример #26
0
 /**
  * Loads app/config/bootstrap.php.
  * If the alternative paths are set in this file
  * they will be added to the paths vars.
  *
  * @param boolean $boot Load application bootstrap (if true)
  * @return void
  * @access private
  */
 function __loadBootstrap($app)
 {
     S2Cache::config('_s2framework_core_', array('duration' => 86400, 'engine' => 'File', 'path' => S2Paths::get($app, 'S2_CACHE') . 'core'));
     if (!($fileArray = S2Cache::read($app . '_paths_' . md5(cmsFramework::getConfig('secret')), '_s2framework_core_'))) {
         $configPath = S2Paths::get($app, 'S2_APP_CONFIG');
         if (@(!(include $configPath . 'paths.php'))) {
             trigger_error(sprintf(__t("Can't find application paths file. Please create %spaths.php, and make sure it is readable by PHP.", true), $configPath), E_USER_ERROR);
         }
         $this->basePaths = $basePaths;
         $fileArray = $this->buildPaths($relativePaths);
         $Folder = new Folder();
         $items = array();
         // Build the Theme file array
         foreach ($basePaths as $basePath) {
             if (false === strstr($basePath, 's2framework')) {
                 // Front end theme folder
                 $tree = $Folder->tree($basePath . $themePath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         // Get the theme name and folder to build an array
                         $path = str_replace($basePath . $themePath . DS, '', $file);
                         $path = explode(DS, $path);
                         if (count($path) > 2) {
                             $theme_folder = array_shift($path);
                             # Begin theme info
                             $pathinfo = pathinfo($file);
                             $parts = explode(DS, str_replace(PATH_ROOT, '', $pathinfo['dirname']));
                             array_pop($parts);
                             $items['Theme'][$theme_folder]['.info']['path'] = str_replace(PATH_ROOT, '', implode(DS, $parts)) . DS;
                             if ($theme_css_pos = strpos($items['Theme'][$theme_folder]['.info']['path'], 'theme_css')) {
                                 $items['Theme'][$theme_folder]['.info']['path'] = substr($items['Theme'][$theme_folder]['.info']['path'], 0, $theme_css_pos);
                             }
                             if ($theme_images_pos = strpos($items['Theme'][$theme_folder]['.info']['path'], 'theme_images')) {
                                 $items['Theme'][$theme_folder]['.info']['path'] = substr($items['Theme'][$theme_folder]['.info']['path'], 0, $theme_images_pos);
                             }
                             $secondToLast = array_pop($parts);
                             $thirdToLast = array_pop($parts);
                             array_pop($parts);
                             if ($secondToLast == 'theme_css' || $thirdToLast == 'theme_css') {
                                 array_pop($parts);
                             }
                             if ($thirdToLast == 'theme_css') {
                                 array_pop($parts);
                             }
                             $items['Theme'][$theme_folder]['.info']['location'] = array_pop($parts);
                             if (strstr($file, 'com_jreviews_addon')) {
                                 $items['Theme'][$theme_folder]['.info']['addon'] = 1;
                             } else {
                                 $items['Theme'][$theme_folder]['.info']['addon'] = 0;
                             }
                             # End theme info
                             # Adds file to theme folder array
                             $theme_subdir = array_shift($path);
                             $theme_file = strtolower(implode(DS, $path));
                             $theme_file_path = str_replace(PATH_ROOT, '', $file);
                             // Exclude images from theme_css folder
                             if ($theme_subdir == 'theme_css' && !strstr($theme_file, '.css')) {
                                 continue;
                             }
                             $items['Theme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file;
                             // $theme_file_path;
                             # Add any extra files to the default theme.
                             # This makes the system think files from different themes are in the default folder without forcing users to move files around
                             // In Component folder we use full relative path because we don't know which theme has been selected
                             if ($items['Theme'][$theme_folder]['.info']['location'] == "jreviews") {
                                 $items['Theme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                             // For any non-default folder, add missing files to default folder with full relative path
                             if ($items['Theme'][$theme_folder]['.info']['location'] != "jreviews" && !isset($items['Theme']['default'][$theme_subdir][$theme_file])) {
                                 $items['Theme']['default'][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                         }
                     }
                 }
                 // Admin theme folder
                 $tree = $Folder->tree($basePath . $themePathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         // Get the theme name and folder to build an array
                         $path = str_replace($basePath . $themePathAdmin . DS, '', $file);
                         $path = explode(DS, $path);
                         if (count($path) > 2) {
                             $theme_folder = array_shift($path);
                             # Begin theme info
                             if (!isset($items['AdminTheme'][$theme_folder]['.info'])) {
                                 $pathinfo = pathinfo($file);
                                 $parts = explode(DS, $pathinfo['dirname']);
                                 array_pop($parts);
                                 $items['AdminTheme'][$theme_folder]['.info']['path'] = str_replace(PATH_ROOT, '', implode(DS, $parts)) . DS;
                             }
                             # End theme info
                             # Adds file to theme folder array
                             $theme_subdir = array_shift($path);
                             $theme_file = strtolower(implode(DS, $path));
                             $theme_file_path = str_replace(PATH_ROOT, '', $file);
                             if ($theme_subdir == 'theme_css' && !strstr($theme_file, '.css')) {
                                 continue;
                             }
                             $items['AdminTheme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file;
                             //$theme_file_path;
                             if (!strstr($theme_file_path, 'components' . DS . 'com_jreviews' . DS)) {
                                 $items['AdminTheme']['default'][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                         }
                     }
                 }
                 // Front end js folder
                 $tree = $Folder->tree($basePath . $jsPath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPath . DS, DS), array('', _DS), $file);
                             $items['Javascript'][$path] = str_replace(array(PATH_ROOT, DS), array('', _DS), $file);
                         }
                     }
                 }
                 // Admin js folder
                 $tree = $Folder->tree($basePath . $jsPathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPathAdmin . DS, DS), array('', _DS), $file);
                             $items['AdminJavascript'][$path] = str_replace(array(PATH_ROOT, DS), array('', _DS), $file);
                         }
                     }
                 }
             }
         }
         $fileArray = array_merge($fileArray, $items);
         //prx($items['Theme']);exit;
         S2Cache::write($app . '_paths_' . md5(cmsFramework::getConfig('secret')), $fileArray, '_s2framework_core_');
         unset($Folder, $tree);
     }
     $App =& App::getInstance();
     $App->{$app . 'Paths'} = $fileArray;
     unset($this->__items, $items);
 }