Ejemplo n.º 1
0
 public function indexAction()
 {
     $this->view->title = "Contact";
     $this->view->host = $this->_host;
     $db = Zend_Registry::get('db');
     $template = $db->fetchAll("SELECT output FROM templates where defaultTemplate = '1'");
     $content = "aaaa";
     //$this->view->hits = $hits;
     if (!empty($template)) {
         $out = ViewController::_templatePrepare($template[0]['output'], $content);
         $this->view->output = $out;
     }
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     $translator = Zend_Registry::get('Zend_Translate');
     $langCode = $this->_sesija->lang;
     $values = $this->_request->getParams();
     $db = Zend_Registry::get('db');
     $page = $db->fetchAll("SELECT output, title, description, keywords, template_id FROM pages_{$langCode}  WHERE id = ?", array($values['pid']));
     $template = $db->fetchAll("SELECT output FROM templates_{$langCode} where id = ?", array($page[0]['template_id']));
     //Form
     $form = self::commentsForm($values['pid']);
     $formErrors = array();
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $values = $this->_request->getParams();
         //print_r($values);
         $pageId = $values['pid'];
         $contentType = 'page';
         $commentatorName = $values['commentatorName'];
         $commentatorEmail = $values['commentatorEmail'];
         $comment = $values['comment'];
         $status = '2';
         $replyToComment = '0';
         $rating = $values['star0'];
         //Do query
         $this->_db->query("INSERT INTO comments (pageId, contentType, commentatorName, commentatorEmail, comment, status, replyToComment) VALUES (?, ?, ?, ?, ?, ?, ?)", array($pageId, $contentType, $this->_sesija->user, $commentatorEmail, $comment, $status, $replyToComment));
         //rating
         if (isset($values['pid']) && isset($values['star0'])) {
             $ip = $_SERVER['REMOTE_ADDR'];
             $data = array('commentatorName' => $this->_sesija->user, 'commentatorIp' => $ip, 'rating' => $values['star0'] + 1, 'pageId' => $values['pid']);
             $check = $this->_db->fetchAll("SELECT count(id) as ratings FROM comments_ratings WHERE commentatorIp = ? AND pageId = ?", array($ip, $values['pid']));
             if ($check[0]['ratings'] == 0) {
                 $this->_db->insert('comments_ratings', $data);
                 $resTotal = $this->_db->fetchAll("SELECT round(AVG(rating)) as rating from comments_ratings WHERE pageId = ?", array($values['pid']));
                 $resTotalCount = $this->_db->fetchAll("SELECT COUNT(id) AS totalCount FROM comments_ratings WHERE pageId = ?", array($values['pid']));
                 //echo $resTotal[0]['rating'] . '|' . $resTotalCount[0]['totalCount'];
             } else {
                 //echo $translator->_("You already rated this article!");
             }
         }
         //$this->_db->query("INSERT INTO comments_ratings (pageId, contentType, commentatorName, commentatorEmail, comment, status, replyToComment) VALUES (?, ?, ?, ?, ?, ?, ?)", array($pageId, $contentType, $commentatorName, $commentatorEmail, $comment, $status, $replyToComment) );
         $content = $translator->_('<h2>Thank You for Your comment!</h2>');
         if (!empty($template)) {
             $out = ViewController::_liveBlocksPrepare(ViewController::_templatePrepare($template[0]['output'], $content . $page[0]['output']));
             $this->view->output = $out;
         }
     } else {
         $content = $form;
         if (!empty($template)) {
             $out = ViewController::_liveBlocksPrepare(ViewController::_templatePrepare($template[0]['output'], $content));
             $this->view->output = $out;
         }
     }
 }
Ejemplo n.º 3
0
 public function indexAction()
 {
     $this->_sesija = new Zend_Session_Namespace('net');
     $this->checkApplication();
     //check if update of the encoded files is needed
     $db = Zend_Registry::get('db');
     //$this->changeLang("sr");
     $langCode = $this->_sesija->lang;
     $values = $this->_request->getParams();
     $commentsAuto = Zend_Registry::get('commentsAuto');
     //should comments be auto added to each page
     $resID = $db->fetchAll("SELECT id, check_access FROM pages_{$langCode}  WHERE homepage = '1' ");
     //get which is the home page
     if (empty($resID)) {
         $this->_helper->layout->setLayoutPath(NET_PATH . 'layouts/scripts/errorPages')->setLayout('underConstruction');
         return;
     }
     @($id = $resID[0]['id']);
     $translator = $this->translator;
     if (!($result = $this->_cache->load("q_View_index_{$langCode}" . "_{$id}"))) {
         //caching this query
         //do required queries for the page and template
         $res = $db->fetchAll("SELECT output, title, description, keywords, template_id, published, unbounded FROM pages_{$langCode}  WHERE id = ?", array($id));
         $resTemplate = $db->fetchAll("SELECT output, bodyBg FROM templates_{$langCode} WHERE id = ?", array($res[0]['template_id']));
         $cachedresult = array('res' => $res, 'resTemplate' => $resTemplate);
         $this->_cache->save($cachedresult, "q_View_index_{$langCode}" . "_{$id}");
     } else {
         $res = $result['res'];
         $resTemplate = $result['resTemplate'];
     }
     //if {html:} then turn the htmlawed off
     $mystring = $res[0]['output'];
     $mystring2 = @$resTemplate[0]['output'];
     $findme = '{html:';
     $pos = strpos($mystring, $findme);
     $pos2 = strpos($mystring2, $findme);
     if ($pos === false && $pos2 === false) {
         $htmlawedFeature = 1;
     } else {
         $htmlawedFeature = 0;
     }
     //$this->view->templateBodyBackground = "url(" . $this->_host . "images/templates/" . $res[0]['template_id'] . "/bodyBg.jpg)";
     $this->view->templateBodyBackground = @$resTemplate[0]['bodyBg'];
     $bodyBG = @$resTemplate[0]['bodyBg'];
     $this->view->bg = @$resTemplate[0]['bodyBg'];
     require_once NET_PATH . 'includes/htmLawed/htmLawed.php';
     //require htmlLawed
     $config = array('comments' => 0, 'cdata' => 0, 'lc_std_val' => 0, 'deny_attribute' => 'on*', 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto,skype , news, nntp, sftp, ssh, telnet; style: *; *:file, http, https');
     //config for htmLawed
     //ACL
     $acl = Zend_Registry::get('acl');
     $curRole = Zend_Registry::get('currentRole');
     $allowArray = Zend_Registry::get('aclAllow');
     if ($resID[0]['check_access'] == '1') {
         //ACL in relation to page
         if (!$acl->has('page:' . $resID[0]['id'])) {
             $acl->add(new Zend_Acl_Resource('page:' . $resID[0]['id']));
             //make sure resource exists
         }
         if (@in_array('page:' . $resID[0]['id'], $allowArray[$curRole])) {
             $acl->allow($curRole, 'page:' . $resID[0]['id']);
             //allow resource access if it is in allow array
         }
         if (!$acl->isAllowed($curRole, 'page:' . $resID[0]['id'])) {
             // no permission, move along now
             $output = $translator->_("<b><h2>You dont have permission to access this content!</h2></b>");
             $outputTemplate = ViewController::_templatePrepare($resTemplate[0]['output'], $output);
             $out = ViewController::_liveBlocksPrepare($outputTemplate);
             //if htmlawed
             if ($htmlawedFeature == 1) {
                 $this->view->output = htmLawed($out, $config);
             } else {
                 $this->view->output = $out;
             }
             return;
         }
     }
     //ACL END
     //if ($alias != '' ) {
     //    Zend_Registry::set('page' . utf8_encode($alias), $cache);
     //} else {
     Zend_Registry::set('page' . $id . "_" . $langCode, $this->_cache);
     $this->_sesija->_urlCurrent = $this->_host . "pages/" . $id;
     //self::$urlCurrent = $this->_sesija->_urlCurrent;
     // }
     //if there is a page cached, load it
     if (!($results = $this->_cache->load('page' . $id . "_" . $langCode . "_" . $this->_sesija->currentRole))) {
         if (!$res || $res[0]['published'] != '1') {
             Zend_Registry::set('pageTitle', "404");
             $outputDB = '<b>404</b>';
             $outputDBtemplate = '';
             $title = '404';
             $meta_description = '404';
             $meta_keywords = '404';
             $this->_helper->layout->setLayoutPath(NET_PATH . 'layouts/scripts/errorPages')->setLayout('404');
             return;
         } else {
             Zend_Registry::set('pageTitle', $res[0]['title']);
             $outputDB = $res[0]['output'];
             $outputDBtemplate = @$resTemplate[0]['output'];
             $title = $res[0]['title'];
             $meta_description = $res[0]['description'];
             $meta_keywords = $res[0]['keywords'];
             //if description empty input default description
             if ($meta_description == "") {
                 $defDecr = Zend_Registry::get('defaultDescription');
                 $meta_description = $defDecr;
             }
             //if keywords empty input default keywords
             if ($meta_keywords == "") {
                 $defKW = Zend_Registry::get('defaultKeywords');
                 $meta_keywords = $defKW;
             }
         }
         $comments = '<div id="commentsDivWrapper" style="">{liveblock:comments:display:' . $id . '}</div>';
         $output = ViewController::_templatePrepare($outputDB);
         if ($commentsAuto == "1") {
             $output = str_replace('{liveblock:comments:display:' . $id . '}', '', $output);
             //if there is defined auto display of the comments, remove manually entered ones
         }
         if ($res[0]['unbounded'] == '0') {
             //position in content
             $this->_insideContentArea = true;
         } else {
             //absolute position
             $this->_insideContentArea = false;
             $comments = '<div id="commentsDivWrapper" style="position:absolute;display:none;">{liveblock:comments:display:' . $id . '}</div>';
             //comments disabled if absolute positioning for now
             //$comments = '';
         }
         //if automatic comments display is set to 0, dont display comments
         if ($commentsAuto == "0") {
             $comments = '';
         } else {
             //str_replace('{liveblock:comments:display:' . $id . '}', '', $output);//if there is defined auto display of the comments, remove manually entered ones
         }
         $_insideContentArea = $this->_insideContentArea;
         //if not supposed to be absolute positioning
         if ($_insideContentArea == true) {
             //handling the output for the content area
             $output = str_replace("position: absolute;", "position: absolute;", $output);
             //$output = str_replace('<div id="templateMask"/>', "" , $output);
             $output = '<div id="contentDivWrapper" style="position:relative;">' . $output . "</div><br /><br />";
             $outputTemplate = ViewController::_templatePrepare($outputDBtemplate, $output . $comments);
             $out = ViewController::_liveBlocksPrepare($outputTemplate);
             //if htmlawed
             if ($htmlawedFeature == 1) {
                 $this->view->output = htmLawed($out, $config);
             } else {
                 $this->view->output = $out;
             }
             //$this->view->output = htmLawed($out, $config) ;
             $cachedOutput = $outputTemplate;
         } else {
             $outputTemplate = ViewController::_templatePrepare($outputDBtemplate);
             $output = '<div class="contentArea">' . $output . "</div>";
             $out = ViewController::_liveBlocksPrepare($outputTemplate . $output . $comments);
             //if htmlawed
             if ($htmlawedFeature == 1) {
                 $this->view->output = htmLawed($out, $config);
             } else {
                 $this->view->output = $out;
             }
             //$this->view->output = htmLawed($out, $config );
             $cachedOutput = $outputTemplate . $output . $comments;
         }
         $this->view->translate = $translator;
         $this->view->title = $title;
         $this->view->meta_description = $meta_description;
         $this->view->meta_keywords = $meta_keywords;
         $cacheResult = array('output' => $cachedOutput, 'title' => $title, 'metaDesc' => $meta_description, 'metaKeywords' => $meta_keywords);
         $cacheEnabled = $this->_cacheEnabled;
         if ($cacheEnabled == 1) {
             $this->_cache->save($cacheResult, 'page' . $id . "_" . $langCode . "_" . $this->_sesija->currentRole);
         }
     } else {
         //display page from cache
         //if htmlawed
         if ($htmlawedFeature == 1) {
             $this->view->output = htmLawed(ViewController::_liveBlocksPrepare($results['output']), $config);
         } else {
             $this->view->output = ViewController::_liveBlocksPrepare($results['output']);
         }
         //$this->view->output = htmLawed(ViewController::_liveBlocksPrepare($results['output'] ), $config);
         $this->view->title = $results['title'];
         $this->view->meta_description = $results['metaDesc'];
         $this->view->meta_keywords = $results['metaKeywords'];
         $this->view->translate = $translator;
     }
 }
Ejemplo n.º 4
0
 public function indexAction()
 {
     $db = Zend_Registry::get('db');
     $langCode = $this->_sesija->lang;
     //$langCode = "sr";
     $values = $this->_request->getParams();
     if (@$values['page'] == "" && (!isset($values['what']) || $values['what'] == "")) {
         //die("No search string!");
         $content = $this->_translate->_("No search string!");
         //$template = $db->fetchAll("SELECT output FROM templates_$langCode where defaultTemplate = '1'");
         $template = $db->fetchAll("SELECT output, bodyBg FROM templates_{$langCode} RIGHT JOIN modules ON modules.templateId = templates_{$langCode}.id ");
         if (!empty($template)) {
             $out = ViewController::_templatePrepare($template[0]['output'], $content);
             $this->view->output = $out;
             $this->view->templateBodyBackground = $template[0]['bodyBg'];
         }
         return;
     }
     $what = $values['what'];
     // This cache doesn't expire, needs to be cleaned manually.
     $frontendOptions = array('caching' => true, 'lifetime' => null, 'ignore_user_abort' => true, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => NET_PATH . 'searchIndex/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Registry::set('pagesAll_' . $langCode, $cache);
     //ACL
     $acl = Zend_Registry::get('acl');
     $curRole = Zend_Registry::get('currentRole');
     $allowArray = Zend_Registry::get('aclAllow');
     if (!($results = $cache->load('pagesAll_' . $langCode))) {
         $pages = $db->fetchAll("SELECT output, title, alias, id, check_access FROM pages_{$langCode} WHERE published = '1'");
         $cache->save($pages, 'pagesAll_' . $langCode);
     } else {
         $pages = $results;
     }
     //print_r($pages);
     $i = 0;
     foreach ($pages as $page) {
         if ($page['check_access'] == '1') {
             //ACL in relation to page
             if (!$acl->has('page:' . $page['id'])) {
                 $acl->add(new Zend_Acl_Resource('page:' . $page['id']));
                 //make sure resource exists
             }
             if (@in_array('page:' . $page['id'], $allowArray[$curRole])) {
                 $acl->allow($curRole, 'page:' . $page['id']);
                 //allow resource access if it is in allow array
             }
             if (!$acl->isAllowed($curRole, 'page:' . $page['id'])) {
                 // no permission, move along now
                 continue;
             }
         }
         //ACL END
         //load page from search index if it is there
         if (!($resultsSearch = $cache->load('page' . $page['id'] . "_" . $langCode . "_" . $curRole))) {
             $out = ViewController::_templatePrepare($page['output']);
             //compile output
             $cache->save($out, 'page' . $page['id'] . "_" . $langCode . "_" . $curRole);
             //save to search index
         } else {
             $out = $resultsSearch;
             //it is in index , use it
         }
         //echo $what;
         if (preg_match("/{$what}/i", strip_tags($out))) {
             @($pos = stripos(strip_tags($out), $what));
             //if (preg_match("/$what/i",strip_tags($page['title']) )  ) {
             //   $hits[$i]['title'] =  '<b class="searchHitsBG"><i>' . $page['title'] . "</i></b>";
             //} else {
             $hits[$i]['title'] = $page['title'];
             //}
             $lengthOfWhat = strlen($what);
             $hits[$i]['teaser'] = '...<b class="searchHitsBG"><i>' . substr(strip_tags($out), $pos, $lengthOfWhat) . "</i></b>" . substr(strip_tags($out), $pos + $lengthOfWhat, 350) . "...";
             $hits[$i]['url'] = "pages/" . $page['id'];
             $hits[$i]['url'] = $page['alias'] . ".html";
         }
         if (preg_match("/{$what}/i", strip_tags($page['title']))) {
             @($pos = stripos(strip_tags($page['title']), $what));
             $lengthOfWhat = strlen($what);
             $hits[$i]['title'] = substr(strip_tags($page['title']), 0, $pos) . '<b class="searchHitsBG"><i>' . substr(strip_tags($page['title']), $pos, $lengthOfWhat) . "</i></b>" . substr(strip_tags($page['title']), $pos + $lengthOfWhat, 150);
             $hits[$i]['teaser'] = "..." . substr(strip_tags($out), 0, 350) . "...";
             $hits[$i]['url'] = "pages/" . $page['id'];
             $hits[$i]['url'] = $page['alias'] . ".html";
         }
         $i++;
     }
     if (isset($hits)) {
         $content = $this->_renderSearch(@$hits, $what);
     } else {
         $content = "<h3>" . $this->_translate->_("No results for ") . '"' . $what . '"!</h3>';
     }
     //$template = $db->fetchAll("SELECT output FROM templates_$langCode where defaultTemplate = '1'");
     $template = $db->fetchAll("SELECT output, bodyBg FROM templates_{$langCode} RIGHT JOIN modules ON modules.templateId = templates_{$langCode}.id ");
     if (!empty($template)) {
         $out = ViewController::_templatePrepare($template[0]['output'], $content);
         $this->view->output = ViewController::_liveBlocksPrepare($out);
         $this->view->templateBodyBackground = $template[0]['bodyBg'];
     }
 }
Ejemplo n.º 5
0
 /**
  *Render menu
  *
  *
  *@author NT
  *
  */
 public static function displayMenu($menuQ, $orientation = null, $lC = null)
 {
     $db = Zend_Registry::get('db');
     $urlRewrite = Zend_Registry::get('urlRewrite');
     $translator = Zend_Registry::get('Zend_Translate');
     $acl = Zend_Registry::get('acl');
     $curRole = Zend_Registry::get('currentRole');
     $allowArray = Zend_Registry::get('aclAllow');
     $themePath = NET_PATH . "widgets/";
     $host = NetActionController::$host;
     $view = new Zend_View();
     $view->addScriptPath($themePath . "templates/");
     //$view->addHelperPath(OZIMBO_PATH . 'framework/Ozimbo/View/Helper', 'Ozimbo_View_Helper');
     foreach ($menuQ as $menuQR) {
         //ACL PART
         /*
                         $acl->add(new Zend_Acl_Resource('menu_item:' . $menuQR['item_id'] ));//make sure resource exists
                         if(@in_array('menu_item:' . $menuQR['item_id'], $allowArray[$curRole] ) ){
                             $acl->allow($curRole, 'menu_item:' . $menuQR['item_id'] );
                         }
                             
                         if($menuQR['chkAccess'] == '1') {
                             if (!$acl->isAllowed($curRole, 'menu_item:' . $menuQR['item_id'] )) {
                                 // no permission, move along now
                                 continue;
                             }
                         }
         */
         //acl in relation to page
         if (!$acl->has('page:' . $menuQR['cid'])) {
             $acl->add(new Zend_Acl_Resource('page:' . $menuQR['cid']));
             //make sure resource exists
         }
         if (@in_array('page:' . $menuQR['cid'], $allowArray[$curRole])) {
             $acl->allow($curRole, 'page:' . $menuQR['cid']);
         }
         if ($menuQR['check_access'] == '1') {
             if (!$acl->isAllowed($curRole, 'page:' . $menuQR['cid'])) {
                 // no permission, move along now
                 continue;
             }
         }
         //ACL END
         if ($menuQR['parent_id'] == 0) {
             $data['menus'][$menuQR['item_id']] = $menuQR;
             if ($orientation == "slide") {
                 $data['menus'][$menuQR['item_id']]['output'] = ViewController::_templatePrepare($data['menus'][$menuQR['item_id']]['output']);
             }
             $hasItems = true;
         } else {
             if ($menuQR['parent_id'] != 0) {
                 $data['menu_items'][$menuQR['parent_id']][$menuQR['item_id']] = $menuQR;
                 $hasItems = true;
             }
         }
     }
     if ($orientation == null) {
         $scriptName = "jdMenu.phtml";
     } elseif ($orientation == "vertical") {
         $scriptName = "jdMenuVertical.phtml";
     } elseif ($orientation == "tree") {
         $front = Zend_Controller_Front::getInstance();
         $req = $front->getRequest();
         $treeVals = $req->getParams();
         //print_r($treeVals);
         if (@$treeVals['creatorAct'] == 'true') {
             $data['langC'] = "_" . $treeVals['langC'];
         }
         $scriptName = "treeView.phtml";
     } elseif ($orientation == "slide") {
         $scriptName = "slide.phtml";
     }
     $Menu['menu'] = $menuQ;
     $data['host'] = str_replace('/quickstart/public/', "/", $host);
     $data['host'] = str_replace('/public/', "/", $data['host']);
     $data['translate'] = $translator;
     $data['urlRewrite'] = $urlRewrite;
     //$view->assign($host);
     //$view->assign($Menu);
     $view->assign($data);
     $partialOutput = $view->render($scriptName);
     return $partialOutput;
 }
Ejemplo n.º 6
0
 /**
  *Function for building search index
  */
 public function buildSearchIndexAction()
 {
     $this->_checkAccess();
     // turn off layout and ViewRenderer
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $roles = $this->getRoles();
     $i = 0;
     //$langCode = $this->_sesija->langAdmin;
     $langs = $this->getLanguages();
     // This cache doesn't expire, needs to be cleaned manually.
     $frontendOptions = array('caching' => true, 'lifetime' => null, 'ignore_user_abort' => true, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => NET_PATH . 'cache/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     foreach ($langs as $langCode) {
         $pages = $this->_db->fetchAll("SELECT " . $this->_tblprefix . "pages_{$langCode}.output as outputPage, " . $this->_tblprefix . "pages_{$langCode}.description, " . $this->_tblprefix . "templates_{$langCode}.output as outputTemplate, " . $this->_tblprefix . "pages_{$langCode}.title, " . $this->_tblprefix . "pages_{$langCode}.alias, " . $this->_tblprefix . "pages_{$langCode}.id, " . $this->_tblprefix . "pages_{$langCode}.template_id FROM " . $this->_tblprefix . "pages_{$langCode} LEFT JOIN " . $this->_tblprefix . "templates_{$langCode} ON " . $this->_tblprefix . "pages_{$langCode}.template_id = " . $this->_tblprefix . "templates_{$langCode}.id");
         foreach ($pages as $page) {
             $output = $page['outputPage'];
             $outputTemplate = $page['outputTemplate'];
             $id = $page['id'];
             foreach ($roles as $role) {
                 if (!($results = $cache->load('page' . $id . "_" . $langCode . "_" . $role))) {
                     continue;
                 }
                 //if this cache exists already , dont do unrequired queries
                 $i++;
                 $out = ViewController::_templatePrepare($output . $outputTemplate);
                 $cacheResult = array('output' => $out, 'title' => $page['title'], 'metaDesc' => $page['description']);
                 $cache->save($cacheResult, 'page' . $id . "_" . $langCode . "_" . $role);
             }
         }
     }
     //print_r($pages);
     echo $i;
 }
Ejemplo n.º 7
0
 /**
  * Function for displaying contact index
  *
  * @author Nebojsa Tomic
  *
  */
 public function indexAction()
 {
     $translator = Zend_Registry::get('Zend_Translate');
     $langCode = $this->_sesija->lang;
     $values = $this->_request->getParams();
     $db = Zend_Registry::get('db');
     $formQ = $db->fetchAll("SELECT * FROM mod_forms where id = ? ", array($values['formID']));
     //ovde treba da dodje selectovanje za TO iz baze
     $contactEmail = $db->fetchAll("SELECT email FROM contacts WHERE id = ?", array($formQ[0]['contact']));
     $to = $contactEmail[0]['email'];
     if ($to == "") {
         $to = '*****@*****.**';
     }
     //$template = $db->fetchAll("SELECT output FROM templates where defaultTemplate = '1'");
     $template = $db->fetchAll("SELECT output FROM templates_{$langCode} where id = ?", array($formQ[0]['templateId']));
     //Form
     $form = $this->__contactForm($formQ[0]['name']);
     //$form = $this->__contactForm("contact");
     $formErrors = array();
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $values = $this->_request->getParams();
         //print_r($values);
         $thankPage = '';
         foreach ($values as $key => $value) {
             //@$body .=   "<b>" . str_replace("_", " ", ucwords($key)) . "</b>:" . strip_tags($value) ."<br />\n";
             if ($key == "module") {
                 //continue;
             } else {
                 if ($key == "controller") {
                     //continue;
                 } else {
                     if ($key == "action") {
                         //continue;
                     } else {
                         if ($key == "to") {
                             //continue;
                         } else {
                             if ($key == "formID") {
                                 //continue;
                             } else {
                                 if ($key == "submitbut") {
                                     //continue;
                                 } elseif ($key == "first_name" && $value == '') {
                                     $formErrors[] = $translator->_("First name is missing!");
                                     //die("First name is missing!");
                                 } elseif ($key == "last_name" && $value == '') {
                                     $formErrors[] = $translator->_('Last name is missing!');
                                 } elseif ($key == "email_address" && $value == '' && !$this->_validEmail($value)) {
                                     $formErrors[] = $translator->_('Email is missing!');
                                 } elseif ($key == "thank_page" && $value != '') {
                                     $thankPage = $value;
                                     unset($values['thank_page']);
                                 } else {
                                     @($body .= "<b>" . $translator->_(str_replace("_", " ", ucwords($key))) . "</b>:" . strip_tags($value) . "<br />\n");
                                 }
                             }
                         }
                     }
                 }
             }
             //@$body .= $formErrors;
             //$this->view->formErrors = $formErrors;
         }
         /*
          * Send email
          */
         $mail = new Zend_Mail();
         $mail->setFrom($values['email_address'], $values['first_name'] . ' ' . $values['last_name']);
         $mail->addTo($to);
         if (isset($_FILES)) {
             foreach ($_FILES as $file => $k) {
                 if (isset($k)) {
                     $tmpFile = file_get_contents($k['tmp_name'], FILE_BINARY);
                     $at = $mail->createAttachment($tmpFile);
                     $at->type = $k['type'];
                     $at->filename = $k['name'];
                 }
             }
         }
         $mail->setSubject($translator->_('Contact Form - ') . $formQ[0]['name']);
         $mail->setBodyText($body);
         $mail->setBodyHtml($body);
         $pathSep = PATH_SEPARATOR;
         if ($pathSep == ";") {
             //ako je windows platforma koristi SMTP
             //require_once 'Zend/Config/Ini.php';
             //$configIni = new Zend_Config_Ini('quickstart.ini', 'default');
             $config = $this->_smtpMailConfig;
             //$config =  $configIni->smtpmail;
             //$server = $configIni->smtpmailserver;
             //$tr = new Zend_Mail_Transport_Smtp($server, $config);
             $tr = new Zend_Mail_Transport_Smtp($this->_smtpMailServer, $config);
             Zend_Mail::setDefaultTransport($tr);
         }
         $mail->send();
         //ALL IS WELL -> flush()OUTPUT
         $content = "<h1>" . $translator->_("Message sent :<br />") . "</h1>" . $body . "<h2>" . $translator->_("<br />Mail has been sent! Thank you.") . "</h2>" . "<br />";
         if (!empty($template)) {
             $out = ViewController::_liveBlocksPrepare(ViewController::_templatePrepare($template[0]['output'], $content));
             $this->view->output = $out;
         }
     } else {
         $content = $form;
         if (!empty($template)) {
             $out = ViewController::_liveBlocksPrepare(ViewController::_templatePrepare($template[0]['output'], $content, $this->_sesija->lang));
             $this->view->output = $out;
         }
         //$this->view->contactForm = $form;
     }
 }
Ejemplo n.º 8
0
 public function myAccountAction()
 {
     $langCode = $this->_sesija->lang;
     $template = Zend_Registry::get('defaultTemplate_' . $langCode);
     $form = $this->_myAccountForm();
     $formError = "";
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $values = $this->_request->getParams();
         //password validation
         if ($values['newpassword1'] != $values['newpassword2']) {
             $formError = $this->translator->_("The supplied passwords don't match.");
         }
         $content = $form . "<br />" . $formError;
         if ($formError == "") {
             $updateData = array($values['fullName'], $values['email']);
             $additionalSql = '';
             if (!empty($values['newpassword1'])) {
                 $updateData[] = $values['newpassword1'];
                 $additionalSql = ', password = SHA1(?)';
             }
             $updateData[] = $this->_sesija->user;
             $this->_db->query("UPDATE users SET fullname = ?, email = ? {$additionalSql} WHERE username = ?", $updateData);
             $content = $this->translator->_("Your account has been updated.") . $form;
         }
         if (!empty($template)) {
             $out = ViewController::_templatePrepare($template[0]['output'], $content);
             $this->view->output = ViewController::_liveBlocksPrepare($out);
         }
     } else {
         //if request is not post
         $content = $form;
         if (!empty($template)) {
             $out = ViewController::_templatePrepare($template[0]['output'], $content);
             $this->view->output = ViewController::_liveBlocksPrepare($out);
         }
     }
 }