public function responseAction() { $id = $this->_request->getParam('id', 0); if (!$id) { $this->_redirect('/ads/categories-list/'); } $ads = new Ads(); $ad = $ads->find($id)->current(); if (!$ad) { $this->_redirect('/ads/categories-list/'); } $form = new AdsResponseForm(); $form->getSubForm('ads_responses')->getElement('ad_id')->setValue($id); if (Standart_Main::buttonPressed('doResponse')) { if ($form->isValid($_POST)) { $values = $form->getValues(); $akismetData = array('user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_type' => 'comment', 'comment_author' => $values['ads_responses']['name'], 'comment_author_email' => $values['ads_responses']['email'], 'comment_content' => $values['ads_responses']['content']); $akismet = new Zend_Service_Akismet(Zend_Registry::get('config')->akismet->apiKey, Zend_Registry::get('config')->host->default); if ($akismet->isSpam($akismetData)) { $values['ads_responses']['is_spam'] = 1; $this->view->message(Standart_Main::translate('adsResponseIsSpam'), 'error'); } $adsResponses = new Ads_Responses(); $adsResponses->insert($values['ads_responses']); $this->_redirect('/ads/response/id/' . $id . '/'); } else { $this->view->message(Standart_Main::translate('invalidFormData'), 'error'); } } $this->view->form = $form; }
private function renderHtml() { $smarty = $this->getSmarty(); if ($this->render['ads']) { $ads = Ads::find('all', array('conditions' => array('start_date' => array('$between' => array(0, time())), '$or' => array('end_date' => array('$gte' => time(), '$is' => 0)), 'active' => 1))); $smarty->assign("ads", $ads); // assign ads } $smarty->assign("title", $this->render['title']); // assign current user object if ($this->uid) { $smarty->assign("user", $this->profile); } // assign current user object if (!empty($this->render['data'])) { // assign data foreach ($this->render['data'] as $k => $v) { $smarty->assign($k, $v); } } $smarty->assign("body", $smarty->fetch($this->getTemplate())); $smarty->display($this->getBase()); }
public function actionAdmin() { $this->setHeaderTitle('Advertisement'); $this->layout = 'admin'; if (Rays::isPost()) { if (isset($_POST['checked_ads'])) { $selected = $_POST['checked_ads']; if (is_array($selected)) { $operation = $_POST['operation_type']; foreach ($selected as $id) { $ad = Ads::get($id); if ($ad == null) { break; } switch ($operation) { case "block": $ad->status = Ads::BLOCKED; $ad->save(); break; case "active": $ad->status = Ads::APPROVED; $ad->save(); break; } } } } } $curPage = $this->getPage('page'); $pageSize = $this->getPageSize("pagesize", 10); $filterStr = Rays::getParam('search', null); $query = Ads::find()->join("publisher"); if ($name = trim($filterStr)) { $names = preg_split("/[\\s]+/", $name); foreach ($names as $key) { $query = $query->like("name", $key); } } $count = $query->count(); $ads = $query->order_desc("id")->range($pageSize * ($curPage - 1), $pageSize); $data = ['ads' => $ads, 'count' => $count]; $url = RHtml::siteUrl('ads/admin'); if ($filterStr != null) { $url .= '?search=' . urlencode(trim($filterStr)); } $pager = new RPager('page', $count, $pageSize, $url, $curPage); $data['pager'] = $pager->showPager(); $this->render('admin', $data, false); }
/** * Post ads * * @return Response */ public function post_ads() { $files = Input::file(); $b = Ads::find(1); $b->link = Input::get('box-text1'); $b->save(); $b = Ads::find(2); $b->link = Input::get('box-text2'); $b->save(); $b = Ads::find(3); $b->link = Input::get('box-text3'); $b->save(); $b = Ads::find(4); $b->link = Input::get('box-text4'); $b->save(); $b = Ads::find(5); $b->link = Input::get('box-text5'); $b->save(); foreach ($files as $i => $f) { $name = $i; $location = storage_path() . "/ads/"; if (Input::hasFile($name)) { $file = Input::file($name)->getRealPath(); Image::make($file)->resize(256, 180)->save($location . $name . ".png"); } } return Redirect::to('admin/ads'); }