| Server IP : 104.21.17.213 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/gotofindhomes.com/components/Page/Controllers/ |
Upload File : |
<?php
/**
* Documentation
* @author
* @category
* @package
* @subpackage
* @copyright Copyright (c) 2005-2012 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
* @license
*/
class Page_OptionController extends System_Controller_Db_Table
{
/**
* Enter description here ...
*/
public function getAction()
{
$strTemplate = $this->getRequest()->getParam('template');
//echo $this->getRequest()->getPathInfo();
$Uri = $this->getRequest()->getParam('Uri', Zend_Controller_Front::getInstance()->getRequest()->getServer('REQUEST_URI'));
$CompanyID = $this->getRequest()->getParam('companyid', System_Company::getID());
if (System_User::getRoleID() == User_Role::ADMIN) {
User::checkAccess($CompanyID);
}
if (System_Company::getID()) {
if (strpos($Uri, '/'.System_Company::getItemRoute().'/') !== false) {
$Uri = '/'.System_Company::getItemRoute();
}
// $arrCategories = Classified_Category::getList(System_Company::getID());
// if (is_array($arrCategories) && count($arrCategories)) {
// foreach ($arrCategories as $Category) {
// if (strpos($Uri, '/'.System_Company::getCategoryRoute().'/'.$Category['SEID']) !== false) {
// $Uri = '/'.System_Company::getCategoryRoute().'/'.$Category['SEID'];
// continue;
// }
// }
// }
}
$this->_select->where('Uri = ?', $Uri)->where('Company_ID = ?', $CompanyID);
if (System_Company::getID()) {
$this->_select->where('Published = ?', true);
}
$object = $this->_model->fetchRow($this->_select);
if (System_Company::getID() == 0) {
if (!is_object($object)) {
$this->_select->reset();
$this->_select->where('Uri = ?', '/')->where('Company_ID = ?', $CompanyID);
$object = $this->_model->fetchRow($this->_select);
}
}
//$object = $this->_model->fetchRow($this->_model->select()->where('Uri = ?', $uri)->where('Published = ?', true));
$this->view->row = (is_object($object)) ? $object->toArray() : false;
$this->render('get' . (($strTemplate != '') ? '-' : '') . $strTemplate);
}
public function editAction()
{
$CompanyID = $this->getRequest()->getParam('ID', $this->getRequest()->getParam('companyid'));
if (!$CompanyID) {
throw new Zend_Exception('Can\'t find pages options by provided CompanyID');
}
$strTemplate = $this->getRequest()->getParam('template');
User::checkAccess($CompanyID);
if ($this->getRequest()->isPost()) {
$Uri = trim($this->getRequest()->getParam('Uri', ''));
$PageName = trim($this->getRequest()->getParam('PageName', ''));
if (!$Uri) {
$this->addErrorMessage('Please choose page');
}
$objPageOption = $this->_model->fetchRow($this->_model->select()->where('Uri = ?', $Uri)->where('Company_ID = ?', $CompanyID));
$isNewPageOptions = false;
if (!is_object($objPageOption)) {
$objPageOption = $this->_model->createRow();
$isNewPageOptions = true;
}
$objPageOption->Uri = $Uri;
$objPageOption->Title = trim($this->getRequest()->getParam('Title', ''));
$objPageOption->Keywords = trim($this->getRequest()->getParam('Keywords', ''));
$objPageOption->Description = trim($this->getRequest()->getParam('Description', ''));
$objPageOption->H1 = trim($this->getRequest()->getParam('H1', ''));
$objPageOption->TextTop = trim($this->getRequest()->getParam('TextTop', ''));
$objPageOption->TextBottom = trim($this->getRequest()->getParam('TextBottom', ''));
$objPageOption->Published = intval($this->getRequest()->getParam('Published', 0));
if (!$objPageOption->Uri) {
//$this->addErrorMessage('Please type uri');
}
if (!$objPageOption->Title) {
$this->addErrorMessage('Please type title');
}
if (!$objPageOption->Keywords) {
$this->addErrorMessage('Please type keywords');
}
if (!$objPageOption->Description) {
$this->addErrorMessage('Please type description');
}
if (!$objPageOption->H1) {
$this->addErrorMessage('Please type H1');
}
if (!$objPageOption->TextTop) {
$this->addErrorMessage('Please type textTop');
}
/*if (!$objPageOption->TextBottom) {
$this->addErrorMessage('Please type textBottom');
}*/
// save
if (!$this->isErrorMessages()) {
$objPageOption->Company_ID = $CompanyID;
$objPageOption->save();
// $tableCompany = new Company_Table();
// $QBlankPageOpt = Page_Option::getDifference($CompanyID);
// $tableCompany->update(array('QBlankPOpt' => $QBlankPageOpt), $tableCompany->getAdapter()->quoteInto('ID = ?', $CompanyID));
$this->view->row = $objPageOption->toArray();
$this->addOkMessage('Page Options has been successfully '.(($isNewPageOptions)?'added':'updated'));
$this->render('edit' . (($strTemplate != '') ? '-' : '') . $strTemplate . '-success');
return;
}
$this->view->row = $objPageOption->toArray();
$this->view->PageName = $PageName;
}
$this->view->CompanyID = $CompanyID;
$this->render('edit' . (($strTemplate != '') ? '-' : '') . $strTemplate);
}
public function addAction()
{
$ID = $this->getRequest()->getParam('ID');
$objPageOption = $this->_model->find($ID)->current();
if (!is_object($objPageOption)) {
throw new Zend_Exception('Can\'t find page options by provided ID');
}
if ($this->getRequest()->isPost()) {
$objPageOption->Uri = trim($this->getRequest()->getParam('Uri', ''));
$objPageOption->Title = trim($this->getRequest()->getParam('Title', ''));
$objPageOption->Keywords = trim($this->getRequest()->getParam('Keywords', ''));
$objPageOption->Description = trim($this->getRequest()->getParam('Description', ''));
$objPageOption->H1 = trim($this->getRequest()->getParam('H1', ''));
$objPageOption->TextTop = trim($this->getRequest()->getParam('TextTop', ''));
$objPageOption->TextBottom = trim($this->getRequest()->getParam('TextBottom', ''));
$objPageOption->Published = intval($this->getRequest()->getParam('Published', 0));
if (!$objPageOption->Uri) {
$this->addErrorMessage('Please type uri');
}
if (!$objPageOption->Title) {
$this->addErrorMessage('Please type title');
}
if (!$objPageOption->Keywords) {
$this->addErrorMessage('Please type keywords');
}
if (!$objPageOption->Description) {
$this->addErrorMessage('Please type description');
}
if (!$objPageOption->H1) {
$this->addErrorMessage('Please type H1');
}
if (!$objPageOption->TextTop) {
$this->addErrorMessage('Please type textTop');
}
/*if (!$objPageOption->TextBottom) {
$this->addErrorMessage('Please type textBottom');
}*/
// save
if (!$this->isErrorMessages()) {
$objPageOption->save();
//$this->addOkMessage('Page Options has been successfully updated.');
$this->view->row = $objPageOption->toArray();
$this->render('add-success');
return;
}
}
$this->view->row = $objPageOption->toArray();
}
/**
*
* @author keeper
* @return mixed
*/
public function getlistAction()
{
//$this->getRequest()->setParam('sort', $this->getRequest()->getParam('sort', 'GUID'));
//$this->getRequest()->setParam('dir', $this->getRequest()->getParam('dir', 'ASC'));
$CompanyID = $this->getRequest()->getParam('ID', $this->getRequest()->getParam('companyid'));
if (System_User::getRoleID() == User_Role::ADMIN) {
User::checkAccess($CompanyID);
}
$this->getRequest()->setParam('results', $this->getRequest()->getParam('results', 20));
$this->_select->setIntegrityCheck(false);
$Filter = $this->getFilter();
$Filter->Uri = $this->getRequest()->getParam('Uri', $Filter->Uri);
$Filter->Title = $this->getRequest()->getParam('Title', $Filter->Title);
$Filter->Keywords = $this->getRequest()->getParam('Keywords', $Filter->Keywords);
$Filter->Company = $this->getRequest()->getParam('Company', $Filter->Company);
if ($CompanyID) {
$this->_select->where('Company_ID = ?', $CompanyID);
$this->_selectCount->where('Company_ID = ?', $CompanyID);
}
if ($Filter->Uri) {
$this->_select->where('Uri LIKE ?', '%' . $Filter->Uri . '%');
$this->_selectCount->where('Uri LIKE ?', '%' . $Filter->Uri . '%');
}
if ($Filter->Title) {
$this->_select->where('Title LIKE ?', '%'.$Filter->Title.'%');
$this->_selectCount->where('Title LIKE ?', '%'.$Filter->Title.'%');
}
if ($Filter->Keywords) {
$this->_select->where('Keywords LIKE ?', '%'.$Filter->Keywords.'%');
$this->_selectCount->where('Keywords LIKE ?', '%'.$Filter->Keywords.'%');
}
if ($Filter->Company) {
$this->_select->where('Company_ID = ?', $Filter->Company);
$this->_selectCount->where('Company_ID = ?', $Filter->Company);
}
$this->view->CompanyID = $CompanyID;
parent::getlistAction();
}
public function addrefererAction()
{
$this->_helper->layout()->disableLayout();
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'google')) {
$tblReferer = new Page_Referer_Table();
$objReferer = $tblReferer->createRow();
$ref = $_SERVER['HTTP_REFERER'];
$url_array = parse_url($ref);
parse_str($url_array['query'], $params);
$objReferer->Url = urldecode($params['url']);
parse_str($url_array['query'], $params);
$objReferer->Keywords = $params['q'];
$objReferer->AddedDate = date("Y-m-d H:i:s");
$objReferer->save();
}
}
public function getlistReferersAction()
{
$tblReferer = new Page_Referer_Table();
$objPagesReferers = $tblReferer->fetchAll($tblReferer->select()->where('Url <> ?', '')->order(array('AddedDate DESC'))->limit(50));
$this->view->rows = $objPagesReferers->toArray();
}
public function generateKeywordsAction()
{
$CategoryID = $this->getRequest()->getParam('categoryid');
$ProductID = $this->getRequest()->getParam('productid');
if (!$CategoryID) return false;
if (!$ProductID) return false;
$tableProduct = new Product_Table();
$objProduct = $tableProduct->find($ProductID)->current();
$arrH2 = array('Sales 70% off:', 'Discount:', 'Best price 2012! :');
$arrB = array();
$textBottom = '';
$strB = '';
if (file_exists(Zend_Registry::get('AppFolder').'/seo/categories-keywords/'.$CategoryID.'.txt')) {
$arrB = file(Zend_Registry::get('AppFolder').'/seo/categories-keywords/'.$CategoryID.'.txt');
} else {
return false;
}
if (is_array($arrB) && count($arrB)) {
$textBottom .= '<h2 class="textBottom-h2">' . $arrH2[array_rand($arrH2)] . '</h2> ';
$strB .= $objProduct->Name;
$arrRand = array_rand($arrB, 4);
$keywordInTitle = $arrB[$arrRand[0]];
foreach ($arrRand as $str) {
$strB .= ', ' . trim($arrB[$str]);
}
$textBottom .= '<b class="textBottom-b">' . $strB . '</b>';
$this->view->keywordInTitle = $keywordInTitle;
}
$this->view->textBottom = $textBottom;
//$this->getResponse()->setBody($textBottom);
}
}