public function feedAction() { $woeid = $this->_request->getParam('woeid'); $ad_type = $this->_request->getParam('ad_type'); $status = $this->_request->getParam('status'); $modelAd = new Model_Ad(); $this->ads = $modelAd->getAdList($woeid, $ad_type, $status, 35); $rss['title'] = $this->view->translate($ad_type) . ' ' . $this->view->translate((string) $status) . ' - ' . $this->_helper->woeid->name($woeid, $this->lang) . ' | nolotiro.org'; $rss['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/rss/feed/woeid/' . $woeid . '/ad_type/' . $ad_type . '/status/' . $status; $rss['charset'] = 'utf-8'; $rss['description'] = 'nolotiro.org - ' . $this->_helper->woeid->name($woeid, $this->lang); $rss['language'] = $this->lang; $rss['generator'] = 'nolotiro.org'; $rss['entries'] = array(); foreach ($this->ads as $value) { $entry = array(); $entry['title'] = $value['title']; $entry['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/ad/' . $value['id'] . '/' . $this->view->slugTitle($value['title']); $entry['description'] = $this->view->escapeEmail($value['body']); $entry['lastUpdate'] = strtotime($value['date_created']); $rss['entries'][] = $entry; } $feedObj = Zend_Feed::importArray($rss, 'rss'); return $feedObj->send(); }
public function indexAction() { $this->_helper->layout()->setLayout('home'); $this->view->suggestIP = $this->_helper->getLocationGeoIP->suggest(); //check if user is locked $locked = $this->_helper->checkLockedUser->check(); if ($locked == 1) { $this->_redirect('/' . $this->view->lang . '/auth/logout'); } //if user is logged the redir to proper location, if not stand on not logged home view (index) $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give'); } //check if request is / redir to /lang $langIndex = $this->getRequest()->getParam('language'); if ($langIndex == null) { //add meta robots to not index the page without language param but allow follow-crawl all the rest //$this->view->metaRobots = 'noindex,follow'; //force redirect with language $this->_redirect('/es', array('code' => 301)); } else { $this->view->metaRobots = 'index,follow'; } //add link rel canonical , better seo $this->view->canonicalUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang; $modelAd = new Model_Ad(); $this->view->allGives = $modelAd->getAdListAllHome(1, null); $this->view->rankingWoeid = $modelAd->getRankingWoeid($limit = 40); $this->view->rankingUsers = $modelAd->getRankingUsers($limit = 80); //add meta description to head $this->view->metaDescription = $this->view->translate('nolotiro.org is a website where you can give away things you no longer want or no longer need to pick them up other people who may serve or be of much use.'); }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc'); $ads = $ads->limit($this->ads_limit)->find_all(); $this->ads = $ads; }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); $ads = $ads->limit($this->ads_limit)->cached()->find_all(); $this->ads = $ads; }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ad = new Model_Ad(); $ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find(); if ($ad->loaded()) { $this->id_ad = $ad->id_ad; } }
public function action_user_contact() { $ad = new Model_Ad($this->request->param('id')); //message to user if ($ad->loaded() and $this->request->post()) { $user = new Model_User($ad->id_user); //require login to contact if ((core::config('advertisement.login_to_contact') == TRUE or core::config('general.messaging') == TRUE) and !Auth::instance()->logged_in()) { Alert::set(Alert::INFO, __('Please, login before contacting')); HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))); } if (captcha::check('contact')) { //check if user is loged in if (Auth::instance()->logged_in()) { $email_from = $this->user->email; $name_from = $this->user->name; } else { $email_from = core::post('email'); $name_from = core::post('name'); } //akismet spam filter if (!core::akismet($name_from, $email_from, core::post('message'))) { if (core::config('general.messaging')) { //price? $price = (core::post('price') !== NULL and is_numeric(core::post('price'))) ? core::post('price') : NULL; $ret = Model_Message::send_ad(core::post('message'), $this->user, $ad->id_ad, $price); } else { if (isset($_FILES['file'])) { $file = $_FILES['file']; } else { $file = NULL; } //contact email is set use that one if (isset($ad->cf_contactemail) and Valid::email($ad->cf_contactemail)) { $to = $ad->cf_contactemail; } else { $to = NULL; } $ret = $user->email('user-contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from, '[URL.AD]' => Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))), $email_from, $name_from, $file, $to); } //if succesfully sent if ($ret) { Alert::set(Alert::SUCCESS, __('Your message has been sent')); // we are updating field of visit table (contact) Model_Visit::contact_ad($ad->id_ad); } else { Alert::set(Alert::ERROR, __('Message not sent')); } HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))); } else { Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.')); } } else { Alert::set(Alert::ERROR, __('Captcha is not correct')); HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))); } } }
/** * is favorite? * @param Model_User $user user * @param Model_Ad $ad ad * @return boolean */ public static function is_favorite(Model_User $user, Model_Ad $ad) { if ($user->loaded() and $ad->loaded()) { $fav = new Model_Favorite(); $fav->where('id_user', '=', $user->id_user)->where('id_ad', '=', $ad->id_ad)->find(); if ($fav->loaded()) { return TRUE; } } return FALSE; }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ad = new Model_Ad(); $user_ads = clone $ad; //get current ad do not filter by user since admin also can see $ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find(); if ($ad->loaded() and Auth::instance()->logged_in()) { $user = Auth::instance()->get_user(); if ($user->id_role == Model_Role::ROLE_ADMIN or $user->id_user == $ad->id_user) { $this->ad = $ad; $this->user_ads = $user_ads->where('id_user', '=', $ad->id_user)->find_all(); } } }
public function action_create() { try { if (!is_numeric(core::request('id_ad')) or !is_numeric(core::request('id_product')) or !is_numeric(core::request('id_user'))) { $this->_error(__('Missing parameters'), 501); } else { $user = new Model_User(core::request('id_user')); $ad = new Model_Ad(core::request('id_ad')); if ($user->loaded() and $ad->loaded()) { $id_product = core::request('id_product'); $amount = core::request('amount'); //in case not set by request if (!is_numeric($amount)) { //get original price for the product switch ($id_product) { case Model_Order::PRODUCT_CATEGORY: $amount = $ad->category->price; break; case Model_Order::PRODUCT_TO_TOP: $amount = core::config('payment.pay_to_go_on_top'); break; case Model_Order::PRODUCT_TO_FEATURED: $amount = Model_Order::get_featured_price(core::request('featured_days')); break; case Model_Order::PRODUCT_AD_SELL: $amount = $ad->price; break; default: $plan = new Model_Plan($id_product); $amount = $plan->loaded() ? $plan->price : 0; break; } } $order = Model_Order::new_order($ad, $user, $id_product, $amount, core::request('currency'), Model_Order::product_desc(core::request('id_product')), core::request('featured_days')); $order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id')); $order->save(); $this->rest_output(array('order' => self::get_order_array($order))); } else { $this->_error(__('User or Ad not loaded'), 501); } } } catch (Kohana_HTTP_Exception $khe) { $this->_error($khe); } }
public function action_index() { $this->before('/pages/maps'); $this->template->title = __('Map'); $this->template->height = Core::get('height', '100%'); $this->template->width = Core::get('width', '100%'); $this->template->zoom = Core::get('zoom', core::config('advertisement.map_zoom')); $this->template->height_thumb = Core::config('image.height_thumb') / 4; $this->template->width_thumb = Core::config('image.width_thumb') / 4; if (Model_User::get_userlatlng()) { $this->template->center_lon = $_COOKIE['mylng']; $this->template->center_lat = $_COOKIE['mylat']; } else { $this->template->center_lon = Core::get('lon', core::config('advertisement.center_lon')); $this->template->center_lat = Core::get('lat', core::config('advertisement.center_lat')); } $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('address', 'IS NOT', NULL)->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL); //filter by category if (core::get('category') !== NULL) { $category = new Model_Category(); $category->where('seoname', '=', core::get('category'))->cached()->limit(1)->find(); if ($category->loaded()) { $ads->where('id_category', 'IN', $category->get_siblings_ids()); } } //filter by location if (core::get('location') !== NULL) { $location = new Model_location(); $location->where('seoname', '=', core::get('location'))->cached()->limit(1)->find(); if ($location->loaded()) { $ads->where('id_location', 'IN', $location->get_siblings_ids()); } } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } //if only 1 ad if (is_numeric(core::get('id_ad'))) { $ads = $ads->where('id_ad', '=', core::get('id_ad')); } $ads = $ads->order_by('published', 'desc')->limit(Core::config('advertisement.map_elements'))->find_all(); $this->template->ads = $ads; }
public function action_index() { if (core::config('general.auto_locate')) { Theme::$scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7'; Theme::$scripts['footer'][] = '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js'; } //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; if (core::config('general.site_description') != '') { $this->template->meta_description = core::config('general.site_description'); } else { $this->template->meta_description = core::config('general.site_name') . ' ' . __('official homepage, get your post listed now.'); } //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); $ads_in_home = core::config('advertisement.ads_in_home'); //in case we do not count visits we cant show popular if (core::config('advertisement.count_visits') == 0 and $ads_in_home == 2) { $ads_in_home = 0; } switch ($ads_in_home) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by('featured', 'desc'); break; case 4: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by(DB::expr('RAND()')); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $categs = Model_Category::get_category_count(); $locats = Model_Location::get_location_count(); $auto_locats = NULL; if (core::config('general.auto_locate') and Model_User::get_userlatlng()) { $auto_locats = new Model_Location(); $auto_locats = $auto_locats->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL)->having('distance', '<=', '100')->order_by('distance', 'desc')->find_all()->as_array(); } $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs, 'locats' => $locats, 'auto_locats' => $auto_locats)); }
public function action_user_contact() { $ad = new Model_Ad($this->request->param('id')); //message to user if ($ad->loaded() and $this->request->post()) { $user = new Model_User($ad->id_user); if (captcha::check('contact')) { //akismet spam filter if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) { if (isset($_FILES['file'])) { $file = $_FILES['file']; } else { $file = NULL; } $ret = $user->email('user.contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.FROM]' => core::post('email')), core::post('email'), core::post('name'), $file); //if succesfully sent if ($ret) { Alert::set(Alert::SUCCESS, __('Your message has been sent')); // we are updating field of visit table (contact) $visit_contact_obj = new Model_Visit(); $visit_contact_obj->where('id_ad', '=', $this->request->param('id'))->order_by('created', 'desc')->limit(1)->find(); try { $visit_contact_obj->contacted = 1; $visit_contact_obj->save(); } catch (Exception $e) { //throw 500 throw new HTTP_Exception_500($e->getMessage()); } } else { Alert::set(Alert::ERROR, __('Message not sent')); } Request::current()->redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))); } else { Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.')); } } else { Alert::set(Alert::ERROR, __('You made some mistake')); } } }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } switch ($this->ads_type) { case 'popular': $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 'featured': $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc'); break; case 'latest': default: $ads->order_by('published', 'desc'); break; } $ads = $ads->limit($this->ads_limit)->cached()->find_all(); //die(print_r($ads)); $this->ads = $ads; }
public function action_get() { try { if (is_numeric($id_ad = $this->request->param('id'))) { $ad = new Model_Ad(); //get distance to the ad if (isset($this->_params['latitude']) and isset($this->_params['longitude'])) { $ad->select(array(DB::expr('degrees(acos(sin(radians(' . $this->_params['latitude'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $this->_params['latitude'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $this->_params['longitude'] . ' - `longitude`))))) * 69.172'), 'distance')); } $ad->where('id_ad', '=', $id_ad)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->cached()->find(); if ($ad->loaded()) { $a = $ad->as_array(); $a['price'] = i18n::money_format($ad->price); $a['images'] = array_values($ad->get_images()); $a['category'] = $ad->category->as_array(); $a['location'] = $ad->location->as_array(); $a['user'] = Controller_Api_Users::get_user_array($ad->user); $a['customfields'] = Model_Field::get_by_category($ad->id_category); //sorting by distance, lets add it! if (isset($ad->distance)) { $a['distance'] = i18n::format_measurement($ad->distance); } $a['url'] = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)); $this->rest_output(array('ad' => $a)); } else { $this->_error(__('Advertisement not found'), 404); } } else { $this->_error(__('Advertisement not found'), 404); } } catch (Kohana_HTTP_Exception $khe) { $this->_error($khe); return; } }
public function action_index() { //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; $this->template->meta_description = Core::config('general.site_description'); //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); switch (core::config('advertisement.ads_in_home')) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()')); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $this->ads = $ads; $categs = Model_Category::get_category_count(); $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs)); }
/** * returns the current location * @return Model_Location */ public static function current() { //we don't have so let's retrieve if (self::$_current === NULL) { self::$_current = new self(); if (Model_Ad::current() != NULL and Model_Ad::current()->loaded() and Model_Ad::current()->location->loaded()) { self::$_current = Model_Ad::current()->location; } elseif (Request::current()->param('location') != NULL || Request::current()->param('location') != URL::title(__('all'))) { self::$_current = self::$_current->where('seoname', '=', Request::current()->param('location'))->limit(1)->cached()->find(); } } return self::$_current; }
public function action_info() { //try to get the info from the cache $info = Core::cache('action_info', NULL); //not cached :( if ($info === NULL) { $ads = new Model_Ad(); $total_ads = $ads->count_all(); $last_ad = $ads->select('published')->order_by('published', 'desc')->limit(1)->find(); $last_ad = $last_ad->published; $ads = new Model_Ad(); $first_ad = $ads->select('published')->order_by('published', 'asc')->limit(1)->find(); $first_ad = $first_ad->published; $views = new Model_Visit(); $total_views = $views->count_all(); $users = new Model_User(); $total_users = $users->count_all(); $info = array('site_url' => Core::config('general.base_url'), 'site_name' => Core::config('general.site_name'), 'site_description' => Core::config('general.site_description'), 'created' => $first_ad, 'updated' => $last_ad, 'email' => Core::config('email.notify_email'), 'version' => Core::VERSION, 'theme' => Core::config('appearance.theme'), 'theme_mobile' => Core::config('appearance.theme_mobile'), 'charset' => Kohana::$charset, 'timezone' => Core::config('i18n.timezone'), 'locale' => Core::config('i18n.locale'), 'currency' => '', 'ads' => $total_ads, 'views' => $total_views, 'users' => $total_users); Core::cache('action_info', $info); } $this->response->headers('Content-type', 'application/javascript'); $this->response->body(json_encode($info)); }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); switch ($this->ads_type) { case 'popular': $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 'featured': $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); break; case 'latest': default: $ads->order_by('published', 'desc'); break; } $ads = $ads->limit($this->ads_limit)->cached()->find_all(); //die(print_r($ads)); $this->ads = $ads; }
/** * 广告支付 */ public function adAction() { // 判断广告主是否已登录 $aCurrUser = $this->getCurrUser(Model_User::TYPE_AD); if (empty($aCurrUser)) { return $this->showMsg('请先登录', false); } $iAdID = intval($this->getParam('id')); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd)) { return $this->showMsg('推广计划不存在', false); } if ($aAd['iPayStatus'] == 1) { return $this->showMsg('该推广计划已付款', false); } $paypass = $this->getParam('paypass'); $usmoney = intval($this->getParam('usmoney')); $paytype = $this->getParam('paytype'); $aUser = Model_User::getDetail($aCurrUser['iUserID']); $iPayMoney = $aAd['iTotalMoney']; if ($usmoney == 1) { if ($aUser['sPayPass'] != Model_User::makePassword($paypass)) { return $this->showMsg('支付密码错误', false); } if ($aUser['iMoney'] >= $iPayMoney) { $iPayID = Model_Finance::payAd($aUser, $aAd, 0); if ($iPayID == 0) { return $this->showMsg('支付失败,请稍后再试', false); } $iPayMoney = 0; } else { $iPayMoney = $iPayMoney - $aUser['iMoney']; } } if ($iPayMoney == 0) { return $this->showMsg('/payment/pay/success/id/' . $iPayID . '.html', 1); } $aParam = array('orderid' => Model_Finance::ORDER_AD . $iAdID, 'subject' => '51wom', 'body' => '在线支付', 'total_fee' => $iPayMoney); switch ($paytype) { case 'alipay': return $this->showMsg('/payment/alipay/pay.html?' . http_build_query($aParam), 2); break; case 'weixin': return $this->showMsg('/payment/weixin/pay.html?' . http_build_query($aParam), 3); break; } return false; }
public function action_home() { $ads = Model_Ad::search(array('search_string' => arr::get($_GET, 's'), 'limit' => $this->config['feed']['limit'], 'telecommute' => arr::get($_GET, 'telecommute'), 'jobtype_id' => arr::get($_GET, 'jobtype_id'), 'category_id' => arr::get($_GET, 'category_id'), 'fields' => array('id', 'title', 'telecommute', 'jobtype_id', 'company_name', 'highlight', 'location', 'created_at', 'description', 'jobboard_id'))); // Formats some field for better viewing foreach ($ads['rows'] as $key => $ad) { $ads['rows'][$key]['link'] = $ads['rows'][$key]['url']; $ads['rows'][$key]['title'] = HTML::chars($ads['rows'][$key]['title'], true); $ads['rows'][$key]['description'] = HTML::chars($ads['rows'][$key]['description'], true); unset($ads['rows'][$key]['url']); } // Sets thje info text for the RSS feed $info = array('title' => arr::get($_GET, 's') . 'Gowork@: IT Jobs board', 'link' => arr::get($_SERVER, 'SCRIPT_NAME'), 'description' => 'Recent Jobs posted', 'language' => 'en-US', 'generator' => '', 'ttl' => 60); $content = Kohana_Feed::create($info, $ads['rows']); header('Content-Type: text/xml'); echo $content; die; }
/** * 执行Action后的操作 * * @see Yaf_Controller::actionAfter() */ public function actionAfter() { if ($this->autoRender() == true) { $aDebug = Util_Common::getDebugData(); if ($aDebug) { $this->assign('__showDebugInfo__', 'showDebugInfo(' . json_encode($aDebug) . ');'); } $this->assign('_iMediaTotal', Model_Media::getCnt(array('where' => array('iStatus' => 1)))); $this->assign('_iYAdTotal', Model_Ad::getYesterdayAdCnt()); $this->assign('_iYUserTotal', Model_Ad::getYesterdayUserCnt()); if (empty($this->aCurrUser)) { $this->aCurrUser = $this->getCurrUser(Model_User::TYPE_AD, false); if (empty($this->aCurrUser)) { $this->aCurrUser = $this->getCurrUser(Model_User::TYPE_MEDIA, false); } } $this->assign('_aCurrUser', $this->aCurrUser); } else { } }
/** * 推广详情 */ public function adAction() { $iAdID = (int) $this->getParam('id', 0); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd)) { return $this->show404(); } $aSetting = Model_Ad::getSetting($aAd); if (!empty($aSetting) && isset($aSetting['sForwardImg'])) { $aSetting['aForwardImg'] = explode(',', $aSetting['sForwardImg']); } $aList = Model_AdMedia::getAll(array('iAdID' => $iAdID, 'iChoose' => 1, 'iStatus >' => 0)); foreach ($aList as $k => &$aRow) { $aRow['aAd'] = Model_Ad::getDetail($aRow['iAdID']); $aRow['aMedia'] = Model_Media::getDetail($aRow['iMediaID']); } $this->assign('aStatus', Model_AdMedia::$aStatus); $this->assign('aTitle', Model_Media::$aPos[$aAd['iMediaType']]); $this->assign('aSetting', $aSetting); $this->assign('aAd', $aAd); $this->assign('aList', $aList); $this->assign('iType', $this->getParam('type', 1)); $this->setMeta('ad_add', array('sTitle' => '添加推广计划 - 支付详情')); }
/** * creates an ad from a row of import * @param class adsimport $adi * @return boolean */ private function create_ad($adi) { //new advertisement $ad = new Model_Ad(); //create user? if ($adi->id_user == NULL or !is_numeric($adi->id_user)) { //create the user $user = Model_User::create_user($adi->user_email, $adi->user_name); //check if in the table other users with same email set the id_user, then gets faster ;) try { DB::update('adsimport')->set(array('id_user' => $user->id_user))->where('user_email', '=', $adi->user_email)->execute(); } catch (Exception $e) { } //set id user to the new ad $ad->id_user = $user->id_user; } else { $ad->id_user = $adi->id_user; } //create category? if ($adi->id_category == NULL or !is_numeric($adi->id_category)) { //create the category $cat = Model_Category::create_name($adi->category); //check if in the table other cats with same name set the id_category, then gets faster ;) try { DB::update('adsimport')->set(array('id_category' => $cat->id_category))->where('category', '=', $adi->category)->execute(); } catch (Exception $e) { } //set id user to the new ad $ad->id_category = $cat->id_category; } else { $ad->id_category = $adi->id_category; } //create location? if (isset($adi->location) and !empty($adi->location) and ($adi->id_location == NULL or !is_numeric($adi->id_location))) { //create the location $loc = Model_Location::create_name($adi->location); //check if in the table other cats with same name set the id_location, then gets faster ;) try { DB::update('adsimport')->set(array('id_location' => $loc->id_location))->where('location', '=', $adi->location)->execute(); } catch (Exception $e) { } //set id user to the new ad $ad->id_location = $loc->id_location; } elseif (is_numeric($adi->id_location)) { $ad->id_location = $adi->id_location; } $ad->title = $adi->title; $ad->seotitle = $ad->gen_seo_title($adi->title); $ad->description = Text::html2bb($adi->description); $ad->published = $adi->date; $ad->created = $adi->date; $ad->price = $adi->price; $ad->address = $adi->address; $ad->phone = $adi->phone; $ad->website = $adi->website; $ad->status = Model_Ad::STATUS_PUBLISHED; try { $ad->save(); } catch (Exception $e) { return FALSE; } //save images if (($has_images = $this->process_images($ad, $adi)) > 0) { $ad->has_images = $has_images; try { $ad->save(); } catch (Exception $e) { return FALSE; } } //mark it as done try { DB::update('adsimport')->set(array('processed' => 1))->where('id_import', '=', $adi->id_import)->execute(); return TRUE; } catch (Exception $e) { return FALSE; } }
/** * creates an order * @param Model_Ad $ad * @param Model_User $user * @param integer $id_product * @param numeric $amount * @param string $currency * @param string $description * @return Model_Order */ public static function new_order(Model_Ad $ad = NULL, $user, $id_product, $amount, $currency = NULL, $description = NULL, $featured_days = NULL) { if ($currency === NULL) { $currency = core::config('payment.paypal_currency'); } if ($description === NULL) { $description = Model_Order::product_desc($id_product); } //get if theres an unpaid order for this product and this ad $order = new Model_Order(); if ($ad !== NULL and $ad->loaded()) { $order->where('id_ad', '=', $ad->id_ad); } $order->where('id_user', '=', $user->id_user)->where('status', '=', Model_Order::STATUS_CREATED)->where('id_product', '=', $id_product)->where('amount', '=', $amount)->where('currency', '=', $currency)->limit(1)->find(); //if no unpaid create order if (!$order->loaded()) { //add coupon ID and discount only if not AD_SELL if (Model_Coupon::valid($id_product)) { $amount = Model_Coupon::price($id_product, $amount); $order->id_coupon = Model_Coupon::current()->id_coupon; } //create order $order = new Model_Order(); $order->id_user = $user->id_user; if ($ad !== NULL and $ad->loaded()) { $order->id_ad = $ad->id_ad; } $order->id_product = $id_product; $order->currency = $currency; $order->amount = $amount; $order->description = $description; // check product if ($order->id_product == Model_Order::PRODUCT_AD_SELL) { // check if ad has VAT if (isset($order->ad->cf_vatnumber) and $order->ad->cf_vatnumber and isset($order->ad->cf_vatcountry) and $order->ad->cf_vatcountry) { $order->VAT_country = $order->ad->cf_vatcountry; $order->VAT_number = $order->ad->cf_vatnumber; $order->VAT = euvat::vat_by_country($order->ad->cf_vatcountry); } elseif (isset($order->user->cf_vatnumber) and $order->user->cf_vatnumber and isset($order->user->cf_vatcountry) and $order->user->cf_vatcountry) { $order->VAT_country = $order->user->cf_vatcountry; $order->VAT_number = $order->user->cf_vatnumber; $order->VAT = euvat::vat_by_country($order->user->cf_vatcountry); } } else { if (core::config('payment.vat_country') and core::config('payment.vat_number')) { $order->VAT_country = core::config('payment.vat_country'); $order->VAT_number = core::config('payment.vat_number'); $order->VAT = euvat::vat_by_country(core::config('payment.vat_country')); } } //store how many days the ad is featured if ($featured_days !== NULL and is_numeric($featured_days)) { $order->featured_days = $featured_days; } try { $order->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } //send email to user with link to pay $url_checkout = $user->ql('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)); $replace = array('[ORDER.ID]' => $order->id_order, '[ORDER.DESC]' => $order->description, '[URL.CHECKOUT]' => $url_checkout); //$user->email('new-order',$replace); } return $order; }
?> "/> <meta property="logbee:addr" content="<?php echo Model_Ad::current()->address; ?> "/> <meta property="logbee:email" content="<?php echo Model_Ad::current()->user->email; ?> "/> <meta property="logbee:phone" content="<?php echo Model_Ad::current()->phone; ?> "/> <meta property="logbee:price" content="<?php echo i18n::money_format(Model_Ad::current()->price); ?> "/> <meta property="logbee:imgurl" content="<?php echo Controller::$image; ?> "/> <?php } ?> <link rel="shortcut icon" href="<?php echo Theme::get('favicon_url') != '' ? Theme::get('favicon_url') : core::config('general.base_url') . 'images/favicon.ico'; ?> ">
/** * creates a new ad * @param array $data * @param model_user $user * @return array */ public static function new_ad($data, $user) { $return_message = ''; $checkout_url = ''; //akismet spam filter if (isset($data['title']) and isset($data['description']) and core::akismet($data['title'], $user->email, $data['description']) == TRUE) { // is user marked as spammer? Make him one :) if (core::config('general.black_list')) { $user->user_spam(); } return array('error' => __('This post has been considered as spam! We are sorry but we can not publish this advertisement.'), 'error_type' => Alert::ALERT); } //akismet $ad = new Model_Ad(); $ad->id_user = $user->id_user; $ad->values($data); $ad->seotitle = $ad->gen_seo_title($ad->title); $ad->created = Date::unix2mysql(); try { $ad->save(); } catch (ORM_Validation_Exception $e) { return array('validation_errors' => $e->errors('ad')); } catch (Exception $e) { return array('error' => $e->getMessage(), 'error_type' => Alert::ALERT); } /////////// NOTIFICATION Emails,messages to user and Status of the ad // depending on user flow (moderation mode), change usecase $moderation = core::config('general.moderation'); //calculate how much he needs to pay in case we have payment on if ($moderation == Model_Ad::PAYMENT_ON or $moderation == Model_Ad::PAYMENT_MODERATION) { // check category price, if 0 check parent if ($ad->category->price == 0) { $cat_parent = new Model_Category($ad->category->id_category_parent); //category without price if ($cat_parent->price == 0) { //swapping moderation since theres no price :( if ($moderation == Model_Ad::PAYMENT_ON) { $moderation = Model_Ad::POST_DIRECTLY; } elseif ($moderation == Model_Ad::PAYMENT_MODERATION) { $moderation = Model_Ad::MODERATION_ON; } } else { $amount = $cat_parent->price; } } else { $amount = $ad->category->price; } } //where and what we say to the user depending ont he moderation switch ($moderation) { case Model_Ad::PAYMENT_ON: case Model_Ad::PAYMENT_MODERATION: $ad->status = Model_Ad::STATUS_NOPUBLISHED; $order = Model_Order::new_order($ad, $user, Model_Order::PRODUCT_CATEGORY, $amount, NULL, Model_Order::product_desc(Model_Order::PRODUCT_CATEGORY) . ' ' . $ad->category->name); // redirect to invoice $return_message = __('Please pay before we publish your advertisement.'); $checkout_url = Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)); break; case Model_Ad::EMAIL_MODERATION: case Model_Ad::EMAIL_CONFIRMATION: $ad->status = Model_Ad::STATUS_UNCONFIRMED; $url_ql = $user->ql('oc-panel', array('controller' => 'myads', 'action' => 'confirm', 'id' => $ad->id_ad)); $user->email('ads-confirm', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title)); $return_message = __('Advertisement is posted but first you need to activate. Please check your email!'); break; case Model_Ad::MODERATION_ON: $ad->status = Model_Ad::STATUS_NOPUBLISHED; $url_ql = $user->ql('oc-panel', array('controller' => 'myads', 'action' => 'update', 'id' => $ad->id_ad)); $user->email('ads-notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title)); // email to notify user of creating, but it is in moderation currently $return_message = __('Advertisement is received, but first administrator needs to validate. Thank you for being patient!'); break; case Model_Ad::POST_DIRECTLY: default: $ad->status = Model_Ad::STATUS_PUBLISHED; $ad->published = $ad->created; $url_cont = $user->ql('contact'); $url_ad = $user->ql('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)); $user->email('ads-user-check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $ad->title)); Model_Subscribe::notify($ad); $return_message = __('Advertisement is posted. Congratulations!'); break; } //save the last changes on status $ad->save(); //notify admins new ad $ad->notify_admins(); return array('message' => $return_message, 'checkout_url' => $checkout_url, 'ad' => $ad); }
public function action_stats() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My ads'))->set_url(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Stats'))); Controller::$full_width = TRUE; $this->template->scripts['footer'] = array('js/chart.min.js', 'js/chart.js-php.js', 'js/oc-panel/stats/dashboard.js'); $this->template->title = __('Stats'); $this->template->bind('content', $content); $content = View::factory('oc-panel/profile/stats'); $list_ad = array(); $advert = new Model_Ad(); //single stats for 1 ad if (is_numeric($id_ad = $this->request->param('id'))) { $advert = new Model_Ad($id_ad); if ($advert->loaded()) { //if admin or moderator user is the advert user ;) hack!! if ($this->user->id_role == Model_Role::ROLE_ADMIN or $this->user->id_role == Model_Role::ROLE_MODERATOR) { $user = $advert->user; } else { $user = $this->user; } if ($user->id_user !== $advert->id_user) { Alert::set(Alert::ALERT, __("This is not your advertisement.")); HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index'))); } Breadcrumbs::add(Breadcrumb::factory()->set_title($advert->title)); // make a list of 1 ad (array), and than pass this array to query (IN).. To get correct visits $list_ad[] = $id_ad; } } //we didnt filter by ad, so lets get them all! if (empty($list_ad)) { $ads = new Model_Ad(); $collection_of_user_ads = $ads->where('id_user', '=', $this->user->id_user)->find_all(); $list_ad = array(); foreach ($collection_of_user_ads as $key) { // make a list of ads (array), and than pass this array to query (IN).. To get correct visits $list_ad[] = $key->id_ad; } } // if user doesn't have any ads if (empty($list_ad)) { $list_ad = array(NULL); } $content->advert = $advert; //Getting the dates and range $from_date = Core::post('from_date', strtotime('-1 month')); $to_date = Core::post('to_date', time()); //we assure is a proper time stamp if not we transform it if (is_string($from_date) === TRUE) { $from_date = strtotime($from_date); } if (is_string($to_date) === TRUE) { $to_date = strtotime($to_date); } //mysql formated dates $my_from_date = Date::unix2mysql($from_date); $my_to_date = Date::unix2mysql($to_date); //dates range we are filtering $dates = Date::range($from_date, $to_date, '+1 day', 'Y-m-d', array('date' => 0, 'count' => 0), 'date'); //dates displayed in the form $content->from_date = date('Y-m-d', $from_date); $content->to_date = date('Y-m-d', $to_date); /////////////////////CONTACT STATS//////////////////////////////// //visits created last XX days $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute(); $contacts_dates = $query->as_array('date'); //Today $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute(); $contacts = $query->as_array(); $content->contacts_today = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0; //Yesterday $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute(); $contacts = $query->as_array(); $content->contacts_yesterday = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0; // //Last 30 days contacts $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute(); $contacts = $query->as_array(); $content->contacts_month = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0; //total contacts $query = DB::select(DB::expr('COUNT(contacted) count'))->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->from('visits')->execute(); $contacts = $query->as_array(); $content->contacts_total = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0; /////////////////////VISITS STATS//////////////////////////////// //visits created last XX days $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute(); $visits = $query->as_array('date'); $stats_daily = array(); foreach ($dates as $date) { $count_contants = isset($contacts_dates[$date['date']]['count']) ? $contacts_dates[$date['date']]['count'] : 0; $count_visits = isset($visits[$date['date']]['count']) ? $visits[$date['date']]['count'] : 0; $stats_daily[] = array('date' => $date['date'], 'views' => $count_visits, 'contacts' => $count_contants); } $content->stats_daily = $stats_daily; //Today $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute(); $visits = $query->as_array(); $content->visits_today = isset($visits[0]['count']) ? $visits[0]['count'] : 0; //Yesterday $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute(); $visits = $query->as_array(); $content->visits_yesterday = isset($visits[0]['count']) ? $visits[0]['count'] : 0; //Last 30 days visits $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute(); $visits = $query->as_array(); $content->visits_month = isset($visits[0]['count']) ? $visits[0]['count'] : 0; //total visits $query = DB::select(DB::expr('COUNT(id_visit) count'))->where('id_ad', 'in', $list_ad)->from('visits')->execute(); $visits = $query->as_array(); $content->visits_total = isset($visits[0]['count']) ? $visits[0]['count'] : 0; }
/** * thanks for publish * @return [type] [description] */ public function action_thanks() { $ad = new Model_Ad($this->request->param('id')); if ($ad->loaded()) { $page = Model_Content::get_by_title(Core::config('advertisement.thanks_page')); //template header $this->template->title = $page->loaded() ? $page->title : __('Thanks'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title($ad->title)->set_url(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)))); Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title)); $this->template->bind('content', $content); $this->template->content = View::factory('pages/ad/thanks', array('ad' => $ad, 'page' => $page)); } else { //throw 404 throw HTTP_Exception::factory(404, __('Page not found')); } }
public function action_favorites() { $user = Auth::instance()->get_user(); //favs or unfavs if (is_numeric($id_ad = $this->request->param('id'))) { $this->auto_render = FALSE; $this->template = View::factory('js'); $ad = new Model_Ad($id_ad); //ad exists if ($ad->loaded()) { //if fav exists we delete if (Model_Favorite::unfavorite($user->id_user, $id_ad) === TRUE) { //fav existed deleting $this->template->content = __('Deleted'); } else { //create the fav Model_Favorite::favorite($user->id_user, $id_ad); $this->template->content = __('Saved'); } } else { $this->template->content = __('Ad Not Found'); } } else { $this->template->title = __('My Favorites'); Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title)); Controller::$full_width = TRUE; $this->template->styles = array('//cdn.jsdelivr.net/sweetalert/1.1.3/sweetalert.css' => 'screen'); $this->template->scripts['footer'][] = '//cdn.jsdelivr.net/sweetalert/1.1.3/sweetalert.min.js'; $this->template->scripts['footer'][] = 'js/oc-panel/favorite.js'; $favorites = new Model_Favorite(); $favorites = $favorites->where('id_user', '=', $user->id_user)->order_by('created', 'desc')->find_all(); $this->template->bind('content', $content); $this->template->content = View::factory('oc-panel/profile/favorites', array('favorites' => $favorites)); } }
/** * Wrapper for checking category_id * * @param Integer $id * @return Boolean */ public function jobtype_id_exists($id) { return Model_Ad::table_id_exists($id, 'jobtype'); }