Exemple #1
0
 public function changeTemplateId()
 {
     $app = JFactory::getApplication();
     $jInput = $app->input;
     $templateId = $jInput->post->getInt("value");
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('parent_id');
     $query->from('#__judirectory_templates');
     $query->where('id = ' . $templateId);
     $db->setQuery($query);
     $templateParentId = $db->loadResult();
     $query = $db->getQuery(true);
     $query->select('*');
     $query->select('title AS text');
     $query->select('id AS value');
     $query->from('#__judirectory_template_styles');
     $query->where('template_id =' . $templateParentId);
     $query->order('lft ASC');
     $db->setQuery($query);
     $styleObjectList = $db->loadObjectList();
     $html = "";
     $html .= "<option value=\"\">" . JText::_('COM_JUDIRECTORY_SELECT_PARENT_TEMPLATE') . "</option>";
     if (!empty($styleObjectList)) {
         foreach ($styleObjectList as $styleObject) {
             $html .= "<option value=\"" . $styleObject->value . "\">" . $styleObject->text . "</option>";
         }
     }
     JUDirectoryHelper::obCleanData();
     echo $html;
     exit;
 }
Exemple #2
0
 public function rebuildCommentTree()
 {
     $model = $this->getModel();
     JUDirectoryHelper::obCleanData();
     echo $model->rebuildCommentTree();
     exit;
 }
Exemple #3
0
 public static function captchaSecurityImages($namespace = null)
 {
     $secureImage = JUDirectoryFrontHelperCaptcha::initCaptcha($namespace);
     JUDirectoryHelper::obCleanData();
     $secureImage->show();
     $secureImage->getCode();
 }
 public function listingChangeCategory()
 {
     $model = $this->getModel();
     $data = $model->listingChangeCategory();
     JUDirectoryHelper::obCleanData();
     echo $data;
     exit;
 }
 public function listingChangeCategory()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_judirectory/models/category.php';
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/models');
     $backendCategoryModel = JModelLegacy::getInstance('Category', 'JUDirectoryModel');
     $data = $backendCategoryModel->listingChangeCategory();
     JUDirectoryHelper::obCleanData();
     echo $data;
     exit;
 }
 public function getChartData()
 {
     $app = JFactory::getApplication();
     $type = $app->input->get('type');
     $model = $this->getModel();
     $data = $model->getSubmissionData($type);
     $app = JFactory::getApplication();
     $app->setUserState('com_judirectory.dashboard.chart.type', $type);
     JUDirectoryHelper::obCleanData();
     echo json_encode($data);
     exit;
 }
Exemple #7
0
 public function autoSuggest()
 {
     $app = JFactory::getApplication();
     $field = $app->input->get('field', '', 'string');
     $string = $app->input->get('string', '', 'string');
     $model = $this->getModel();
     $result = $model->getAutoSuggestValues($field, $string);
     if ($result === false) {
         exit;
     }
     JUDirectoryHelper::obCleanData();
     echo json_encode($result);
     exit;
 }
 public static function downloadFile($file, $fileName, $transport = 'php', $speed = 50, $resume = true, $downloadMultiParts = true, $mimeType = false)
 {
     if (ini_get('zlib.output_compression')) {
         @ini_set('zlib.output_compression', 'Off');
     }
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', '1');
     }
     $agent = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : null;
     if ($agent && preg_match('#(?:MSIE |Internet Explorer/)(?:[0-9.]+)#', $agent) && (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')) {
         header('Pragma: ');
         header('Cache-Control: ');
     } else {
         header('Pragma: no-store,no-cache');
         header('Cache-Control: no-cache, no-store, must-revalidate, max-age=-1');
         header('Cache-Control: post-check=0, pre-check=0', false);
     }
     header('Expires: Mon, 14 Jul 1789 12:30:00 GMT');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     if (is_resource($file) && get_resource_type($file) == "stream") {
         $transport = 'php';
     } elseif (!JFile::exists($file)) {
         return JText::sprintf("COM_JUDIRECTORY_FILE_NOT_FOUND_X", $fileName);
     }
     if ($transport != 'php') {
         header('Content-Description: File Transfer');
         header('Date: ' . @gmdate("D, j M m Y H:i:s ") . 'GMT');
         if ($resume) {
             header('Accept-Ranges: bytes');
         } elseif (isset($_SERVER['HTTP_RANGE'])) {
             exit;
         }
         if (!$downloadMultiParts) {
             header('Accept-Ranges: none');
         }
         header('Content-Type: application/force-download');
         header('Content-Disposition: attachment; filename="' . $fileName . '"');
     }
     switch ($transport) {
         case 'apache':
             $modules = apache_get_modules();
             if (in_array('mod_xsendfile', $modules)) {
                 header('X-Sendfile: ' . $file);
             }
             break;
         case 'ngix':
             $path = preg_replace('/' . preg_quote(JPATH_ROOT, '/') . '/', '', $file, 1);
             header('X-Accel-Redirect: ' . $path);
             break;
         case 'lighttpd':
             header('X-LIGHTTPD-send-file: ' . $file);
             header('X-Sendfile: ' . $file);
             break;
         case 'php':
         default:
             JLoader::register('JUDownload', JPATH_ADMINISTRATOR . '/components/com_judirectory/helpers/judownload.class.php');
             JUDirectoryHelper::obCleanData();
             $download = new JUDownload($file);
             $download->rename($fileName);
             if ($mimeType) {
                 $download->mime($mimeType);
             }
             if ($resume) {
                 $download->resume();
             }
             $download->speed($speed);
             $download->start();
             if ($download->error) {
                 return $download->error;
             }
             unset($download);
             break;
     }
     return true;
 }
Exemple #9
0
 public function testPhpCode()
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $field_id = $app->input->post->getInt('field_id', 0);
     $plugin_id = $app->input->post->getInt('plugin_id', 0);
     $php_code = $app->input->post->get('php_predefined_values', '', 'raw');
     if (trim($php_code)) {
         if ($plugin_id) {
             $db = JFactory::getDbo();
             $query = "SELECT folder FROM #__judirectory_plugins WHERE id = " . $plugin_id;
             $db->setQuery($query);
             $folder = $db->loadResult();
             $fieldClassName = 'JUDirectoryField' . $folder;
             if ($field_id) {
                 $fieldObj = new $fieldClassName($field_id);
             } else {
                 $fieldObj = new $fieldClassName();
             }
         } else {
             echo 'No plugin selected';
             exit;
         }
         $fieldObj->php_predefined_values = $php_code;
         JUDirectoryHelper::obCleanData(true);
         $result = $fieldObj->getPredefinedFunction();
         echo '<div class="return">';
         var_dump($result);
         echo '</div>';
     }
     exit;
 }
Exemple #10
0
 public function checkInheritedDataWhenChangeParentCat()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $jInput = $app->input;
     $data = array();
     $data['id'] = $jInput->post->getInt('id');
     $data['parent_id'] = $jInput->post->getInt('parent_id');
     $data['selected_fieldgroup'] = $jInput->post->getInt('selected_fieldgroup');
     $data['selected_criteriagroup'] = $jInput->post->getInt('selected_criteriagroup');
     $data['style_id'] = $jInput->post->getInt('style_id');
     $result = $model->checkInheritedDataWhenChangeParentCat($data);
     JUDirectoryHelper::obCleanData();
     $result = json_encode($result);
     echo $result;
     exit;
 }
if (JUDirectoryHelper::isJoomla3x()) {
    JHtml::_('script', 'system/core.js', false, true);
}
$app = JFactory::getApplication();
$task = $app->input->get('task');
switch ($task) {
    case 'captcha':
        $namespace = $app->input->getString('captcha_namespace', '');
        JUDirectoryFrontHelperCaptcha::captchaSecurityImages($namespace);
        exit;
        break;
    case 'rawdata':
        $field_id = $app->input->getInt('field_id', 0);
        $listing_id = $app->input->getInt('listing_id', 0);
        $fieldObj = JUDirectoryFrontHelperField::getField($field_id, $listing_id);
        JUDirectoryHelper::obCleanData();
        $fieldObj->getRawData();
        exit;
        break;
    case 'cron':
        JUDirectoryFrontHelperMail::sendMailq();
        exit;
        break;
    default:
        $controller = JControllerLegacy::getInstance('judirectory');
        $controller->execute($app->input->get('task'));
        $controller->redirect();
        break;
}
$params = JUDirectoryHelper::getParams();
if ($params->get('send_mailqs_on_pageload', 0)) {
Exemple #12
0
 public function changeBLVorder()
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $value = $app->input->getInt('value', 0);
     $data = array(0, 1, 2);
     $value = JArrayHelper::getValue($data, $value, 0, 'int');
     if (!$id) {
         die;
     }
     $model = $this->getModel();
     $result = $model->changeBLVorder($id, $value);
     JUDirectoryHelper::obCleanData();
     if ($result) {
         echo $result;
     }
     exit;
 }
Exemple #13
0
 public function checkDeleteTemplateHasChild()
 {
     $app = JFactory::getApplication();
     $jInput = $app->input;
     $result = array('status' => 0, 'message' => '');
     $data = $jInput->post->get("pluginIDs", array(), 'array');
     $dataTemplateId = array();
     $dataTemplateTree = array();
     foreach ($data as $pluginId) {
         $templateId = $this->getTemplateId($pluginId);
         if ($templateId) {
             $dataTemplateId[] = $templateId;
         }
     }
     $dataTemplateId = array_unique($dataTemplateId);
     foreach ($dataTemplateId as $templateId) {
         $dataTemplateTree = array_merge($dataTemplateTree, $this->getChildTemplateIdByTree($templateId));
         $dataTemplateTree = array_unique($dataTemplateTree);
     }
     $dataTemplateTree = array_unique($dataTemplateTree);
     if (!empty($dataTemplateId) && !empty($dataTemplateTree)) {
         if (implode(',', $dataTemplateId) != implode(',', $dataTemplateTree)) {
             $result['status'] = 1;
             $dataMessage = array();
             if (is_array($dataTemplateTree) && count($dataTemplateTree)) {
                 $dataTemplateTreeString = implode(',', $dataTemplateTree);
                 $dataMessage = $this->orderTemplateTreeBeforeDelete($dataTemplateTreeString);
             }
             $html = '<div class="alert alert-warning">' . JText::_('COM_JUDIRECTORY_DELETE_TEMPLATE_WARNING_MESSAGE') . '</div>';
             $html .= '<table class="table table-condensed">';
             $html .= '<thead>';
             $html .= '<tr>';
             $html .= '<th>' . JText::_('COM_JUDIRECTORY_TEMPLATE_ID') . '</th>';
             $html .= '<th>' . JText::_('COM_JUDIRECTORY_TEMPLATE_TITLE') . '</th>';
             $html .= '</tr>';
             $html .= '</thead>';
             $html .= '<tbody>';
             foreach ($dataMessage as $element) {
                 $html .= '<tr>';
                 $html .= '<td>' . $element->id . '</td>';
                 $html .= '<td>' . str_repeat('<span class="gi">&mdash;</span>', $element->level - 1) . ' ' . ucfirst($element->title) . '</td>';
                 $html .= '</tr>';
             }
             $html .= '</tbody>';
             $html .= '</table>';
             $result['message'] = $html;
         }
     }
     JUDirectoryHelper::obCleanData();
     $result = json_encode($result);
     echo $result;
     exit;
 }
Exemple #14
0
 public function voteComment($commentId)
 {
     $commentObj = JUDirectoryFrontHelperComment::getCommentObject($commentId);
     if (!$commentObj) {
         return;
     }
     $vote_up = JFactory::getApplication()->input->getInt('vote_up', 0);
     $helpful_votes = intval($commentObj->helpful_votes);
     $total_votes = intval($commentObj->total_votes);
     $params = JUDirectoryHelper::getParams(null, $commentObj->listing_id);
     $allow_vote_down_comment = $params->get('allow_vote_down_comment', 1);
     if (!$allow_vote_down_comment) {
         $like_system = true;
         if ($vote_up != 1) {
             $voteType = 0;
             $reference = 'unlike';
             $total_votes--;
             $helpful_votes--;
         } else {
             $voteType = 1;
             $reference = 'like';
             $total_votes++;
             $helpful_votes++;
         }
     } else {
         $like_system = false;
         if ($vote_up != 1) {
             $voteType = -1;
             $reference = 'vote_down';
             $total_votes++;
         } else {
             $voteType = 1;
             $reference = 'vote_up';
             $total_votes++;
             $helpful_votes++;
         }
     }
     $votedValue = $this->getCommentVotedValue($commentObj->id);
     if ($allow_vote_down_comment && $votedValue || $votedValue == $voteType) {
         $return = array();
         $return['message'] = JText::_('COM_JUDIRECTORY_VOTING_ERROR');
         $return['like_system'] = $like_system;
         $return['vote_type'] = null;
         JUDirectoryHelper::obCleanData();
         echo json_encode($return);
         exit;
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_comments')->set('helpful_votes = ' . $helpful_votes)->set('total_votes = ' . $total_votes)->where('id = ' . $commentObj->id);
     $db->setQuery($query);
     if ($db->execute()) {
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('judirectory');
         $dispatcher->trigger('onVoteComment', $commentObj, $like_system, $voteType);
         $user = JFactory::getUser();
         $userId = $user->id;
         $logData = array('user_id' => $user->id, 'event' => 'comment.vote', 'item_id' => $commentObj->id, 'listing_id' => $commentObj->listing_id, 'value' => $voteType, 'reference' => $reference);
         JUDirectoryFrontHelperLog::addLog($logData);
         if ($userId > 0) {
             $cookieName = 'judir-comment-vote-' . $commentObj->id . '_' . $userId;
         } else {
             $ipAddress = JUDirectoryFrontHelper::getIpAddress();
             $ipAddress = str_replace('.', '_', $ipAddress);
             $cookieName = 'judir-comment-vote-' . $commentObj->id . '_' . $ipAddress;
         }
         $config = JFactory::getConfig();
         $cookie_domain = $config->get('cookie_domain', '');
         $cookie_path = $config->get('cookie_path', '/');
         setcookie($cookieName, $voteType, time() + 60 * 60 * 24 * 30, $cookie_path, $cookie_domain);
         $return = array();
         $return['message'] = JText::sprintf('COM_JUDIRECTORY_N_HELPFUL_VOTES_N_TOTAL_VOTES', $helpful_votes, $total_votes);
         $return['like_system'] = $like_system;
         $return['vote_type'] = $voteType;
     } else {
         $return = array();
         $return['message'] = JText::_('COM_JUDIRECTORY_VOTING_ERROR');
         $return['like_system'] = $like_system;
         $return['vote_type'] = null;
     }
     JUDirectoryHelper::obCleanData();
     echo json_encode($return);
     exit;
 }
 public function export()
 {
     $app = JFactory::getApplication();
     $filter = $app->input->post->get('jform', array(), 'array');
     $exportColumns = $app->input->post->get('col', array(), 'array');
     $file_name = $filter['csv_export_file_name'] ? $filter['csv_export_file_name'] : "Export_";
     $data = $this->getExportData($exportColumns, $filter);
     JUDirectoryHelper::obCleanData();
     $file_name = str_replace(' ', '_', $file_name) . "-" . date("Y-m-d") . ".csv";
     $this->downloadSendHeaders($file_name);
     echo chr(239) . chr(187) . chr(191);
     $csv_data = $this->array2csv($data);
     echo $csv_data;
     exit;
 }
Exemple #16
0
 public function updateComment()
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $data = $app->input->getArray($_POST);
     $listingId = $data['listing_id'];
     $commentId = $data['comment_id'];
     $canEditComment = JUDirectoryFrontHelperPermission::canEditComment($commentId);
     $redirectUrl = JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingId) . '#comment-item-' . $commentId);
     if (!$canEditComment) {
         $this->setMessage(JText::_('COM_JUDIRECTORY_UPDATE_COMMENT_ERROR'));
         $this->setRedirect($redirectUrl);
         return false;
     }
     $params = JUDirectoryHelper::getParams(null, $listingId);
     $ratingValue = $this->validateCriteria($data);
     if ($ratingValue) {
         $data = array_merge($data, $ratingValue);
     } else {
         $this->setMessage(JText::_('COM_JUDIRECTORY_UPDATE_COMMENT_ERROR'));
         $this->setRedirect($redirectUrl);
         return false;
     }
     JUDirectoryHelper::obCleanData();
     if ($model->updateComment($data, $params)) {
         $logData = array('user_id' => $user->id, 'event' => 'comment.edit', 'item_id' => $commentId, 'listing_id' => $listingId, 'value' => 0, 'reference' => '');
         JUDirectoryFrontHelperLog::addLog($logData);
         $this->setMessage(JText::_('COM_JUDIRECTORY_UPDATE_COMMENT_SUCCESSFULLY'));
         $this->setRedirect($redirectUrl);
         return true;
     } else {
         $this->setMessage(JText::_('COM_JUDIRECTORY_UPDATE_COMMENT_ERROR'));
         $this->setRedirect($redirectUrl);
         return false;
     }
 }
 public function importProcessing()
 {
     $model = $this->getModel();
     $result = $model->import();
     JUDirectoryHelper::obCleanData();
     echo json_encode($result);
     exit;
 }