/** * check if its valid or not * @param string $name for the session * @return boolean */ public static function check($name = '', $ajax = FALSE) { //d(strtolower(core::post('captcha'))); //d(Session::instance()->get('captcha_'.$name)); //d(Session::instance()->get('captcha_'.$name) == strtolower(core::post('captcha'))); //for OC if (core::config('advertisement.captcha') != NULL and core::config('advertisement.captcha') == FALSE) { // Captcha disabled on OC return TRUE; } //for OE if (core::config('general.captcha') != NULL and core::config('general.captcha') == FALSE) { // Captchas disabled on OE return TRUE; } // verify with recaptcha if enabled if (Core::config('general.recaptcha_active')) { if (self::recaptcha_verify()) { return TRUE; } else { return FALSE; } } if (Session::instance()->get('captcha_' . $name) == strtolower(core::post('captcha'))) { if ($ajax === FALSE) { Session::instance()->set('captcha_' . $name, ''); } return TRUE; } else { return FALSE; } }
/** * Function to notify subscribers */ public static function notify(Model_Ad $ad) { $subscribers = new Model_Subscribe(); if ($ad->price > 0) { $subscribers->where_open()->where(DB::EXPR((int) $ad->price), 'BETWEEN', array('min_price', 'max_price'))->or_where('max_price', '=', 0)->where_close(); } //location is set if (is_numeric($ad->id_location)) { $subscribers->where('id_location', 'in', array($ad->id_location, 0)); } //filter by category, 0 means all the cats, in case was not set $subscribers->where('id_category', 'in', array($ad->id_category, 0)); $subscribers = $subscribers->find_all(); $subscribers_id = array(); // array to be filled with user emails foreach ($subscribers as $subs) { // do not repeat same users. if (!in_array($subs->id_user, $subscribers_id)) { $subscribers_id[] = $subs->id_user; } } // query for getting users, transform it to array and pass to email function if (count($subscribers_id) > 0) { $query = DB::select('email')->select('name')->from('users')->where('id_user', 'IN', $subscribers_id)->where('status', '=', Model_User::STATUS_ACTIVE)->execute(); $users = $query->as_array(); // Send mails like in newsletter, to multiple users simultaneously if (count($users) > 0) { $url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)); $replace = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $ad->title); Email::content($users, '', core::config('email.notify_email'), core::config('general.site_name'), 'ads-subscribers', $replace); } } }
public function action_index() { //if they want to see a single post $seotitle = $this->request->param('seotitle', NULL); if ($seotitle !== NULL) { return $this->action_view($seotitle); } //template header $this->template->title = __('Blog'); $this->template->meta_description = core::config('general.site_name') . ' ' . __('blog section.'); $posts = new Model_Post(); $posts->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', 'IS', NULL); if (($search = Core::get('search')) !== NULL and strlen(Core::get('search')) >= 3) { $posts->where_open()->where('title', 'like', '%' . $search . '%')->or_where('description', 'like', '%' . $search . '%')->where_close(); } $res_count = clone $posts; $res_count = $res_count->count_all(); // check if there are some post if ($res_count > 0) { // pagination module $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->current_page)); //we sort all ads with few parameters $posts = $posts->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); } else { $posts = NULL; $pagination = NULL; } $this->template->bind('content', $content); $this->template->content = View::factory('pages/blog/listing', array('posts' => $posts, 'pagination' => $pagination, 'user' => Auth::instance()->get_user())); }
/** * [action_buy] Pay for ad, and set new order * */ public function action_buy() { if (Core::config('general.subscriptions') == FALSE) { throw HTTP_Exception::factory(404, __('Page not found')); } //getting the user that wants to buy now if (!Auth::instance()->logged_in()) { Alert::set(Alert::INFO, __('To buy this product you need to register first.')); $this->redirect(Route::url('oc-panel')); } //check plan exists $plan = new Model_Plan(); $plan->where('seoname', '=', $this->request->param('id'))->where('status', '=', 1)->find(); //loaded published and with stock if we control the stock. if ($plan->loaded() and $plan->status == 1) { //free plan can not be renewed if ($plan->price == 0 and $this->user->subscription()->id_plan == $plan->id_plan) { Alert::set(Alert::WARNING, __('Free plan can not be renewed, before expired')); HTTP::redirect(Route::url('pricing')); } $order = Model_Order::new_order(NULL, $this->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name); //free plan no checkout if ($plan->price == 0) { $order->confirm_payment('cash'); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { $this->redirect(Route::url('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order))); } } else { throw HTTP_Exception::factory(404, __('Page not found')); } }
public function action_index() { //if they want to see a single post $seotitle = $this->request->param('seotitle', NULL); if ($seotitle !== NULL) { return $this->action_view($seotitle); } //template header $this->template->title = __('Blog'); $this->template->meta_description = __('Blog'); $posts = new Model_Post(); $posts->where('status', '=', 1); $res_count = $posts->count_all(); // check if there are some post if ($res_count > 0) { // pagination module $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->current_page)); //we sort all ads with few parameters $posts = $posts->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); } else { $posts = NULL; $pagination = NULL; } $this->template->bind('content', $content); $this->template->content = View::factory('pages/blog/listing', array('posts' => $posts, 'pagination' => $pagination, 'user' => Auth::instance()->get_user())); }
static function url() { $args= href::processArgs(func_get_args()); $hash=''; if (isset($args['request']['#'])) { $hash= '#'.$args['request']['#']; unset($args['request']['#']); } $args= href::required($args); if (core::config('rewrite-encode') && (!core::config('no-cache') || !in_array($args['template'],core::$config['no-cache']))) { $url= call_user_func(core::$config['rewrite-encode'],$args['module'],$args['request'],$hash); } else { if (isset(core::$config['index.php'])) $url= core::$config['index.php']; else $url= ''; $pairs= array(); if ($args['module']!=core::$config['default-module']) $pairs[]= core::$config['module-var'].'='.$args['module']; foreach ($args['request'] as $name=>$val) if(!is_null($val)) $pairs[]= $name.'='.urlencode($val); if ($pairs) $url.= '?'.implode('&',$pairs); if (!$url && !isset($args['current'])) $url= (isset($_SERVER['HTTPS '])?'https':'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['SCRIPT_NAME'],0,-9); // cut off "index.php" } $url= $url.$hash; return $url; }
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)); }
/** * [action_form] generates the form to pay at paypal */ public function action_form() { $this->auto_render = FALSE; $order_id = $this->request->param('id'); $order = new Model_Order(); $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // dependant on product we have different names if ($order->id_product == Paypal::to_featured) { $item_name = __('Advertisement to featured'); } else { if ($order->id_product == Paypal::to_top) { $item_name = __('Advertisement to top'); } else { $item_name = $order->description . __(' category'); } } $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway; $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name); $this->template = View::factory('paypal', $paypal_data); $this->response->body($this->template->render()); } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->request->redirect(Route::url('default')); } }
/** * validates the data at paypal c&p from https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623 * @note impossible to test on sandbox, paypal wont work. * I really dislike this code but seems to work... * @return boolean */ public static function validate_ipn() { if (core::config('payment.sandbox')) { $ipn_url = self::ipn_sandbox_url; } else { $ipn_url = self::ipn_url; } // STEP 1: Read POST data // reading posted data from directly from $_POST causes serialization // issues with array data in POST // reading raw POST data from input stream instead. $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode('=', $keyval); if (count($keyval) == 2) { $myPost[$keyval[0]] = urldecode($keyval[1]); } } // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&{$key}={$value}"; } // STEP 2: Post IPN data back to paypal to validate $ch = curl_init($ipn_url); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); if (!($res = curl_exec($ch))) { // error_log("Got " . curl_error($ch) . " when processing IPN data"); curl_close($ch); exit; } curl_close($ch); // STEP 3: Inspect IPN validation result and act accordingly if (strcmp($res, "VERIFIED") == 0) { return TRUE; } elseif (strcmp($res, "INVALID") == 0) { Kohana::$log->add(Log::ERROR, 'Paypal invalid payment error. Result: ' . $res . ' Data: ' . json_encode($_POST)); return FALSE; } else { Kohana::$log->add(Log::ERROR, 'Unknown result from IPN verification. Result: ' . $res . ' Data: ' . json_encode($_POST)); return FALSE; } }
public function action_index() { //template header $this->template->title = __('Contact Us'); $this->template->meta_description = __('Contact') . ' ' . core::config('general.site_name'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us'))); if ($this->request->post()) { //captcha check if (captcha::check('contact')) { //check if user is loged in if (Auth::instance()->logged_in()) { $email_from = Auth::instance()->get_user()->email; $name_from = Auth::instance()->get_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'))) { $replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from); if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), $email_from, $name_from, 'contact-admin', $replace)) { Alert::set(Alert::SUCCESS, __('Your message has been sent')); } else { Alert::set(Alert::ERROR, __('Message not sent')); } } else { Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.')); } } else { Alert::set(Alert::ERROR, __('Wrong captcha')); } } $this->template->content = View::factory('pages/contact'); }
public function action_index() { //template header $this->template->title = __('Contact Us'); $this->template->meta_description = __('Contact Us'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us'))); if ($this->request->post()) { //captcha check if (captcha::check('contact')) { //akismet spam filter if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) { $replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.FROM]' => core::post('email')); if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::post('email'), core::post('name'), 'contact.admin', $replace)) { Alert::set(Alert::SUCCESS, __('Your message has been sent')); } else { Alert::set(Alert::ERROR, __('Message not sent')); } } 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, __('Check the form for errors')); } } $this->template->content = View::factory('pages/contact'); }
function send($message, $data = false) { if (!is_array($this->devices) || count($this->devices) == 0) { $this->error("No devices set"); } if (strlen($this->serverApiKey) < 8) { $this->error("Server API Key not set"); } $fields = array('registration_ids' => $this->devices, 'data' => array("message" => $message), 'notification' => array("title" => core::config('general.site_name'), "message" => $message, "body" => $message)); if (is_array($data)) { foreach ($data as $key => $value) { $fields['data'][$key] = $value; } } $headers = array('Authorization: key=' . $this->serverApiKey, 'Content-Type: application/json'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // Avoids problem with https certificate curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); return $result; }
/** * [action_form] generates the form to pay at paypal */ public function action_pay() { $this->auto_render = FALSE; $order_id = $this->request->param('id'); $order = new Model_Order(); $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // case when selling advert if ($order->id_product == Model_Order::PRODUCT_AD_SELL) { $paypal_account = $order->ad->paypal_account(); $currency = i18n::get_intl_currency_symbol(); if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) { $order->amount = $order->amount + $order->ad->cf_shipping; } } else { $paypal_account = core::config('payment.paypal_account'); $currency = core::config('payment.paypal_currency'); } $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway; $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description); $this->template = View::factory('paypal', $paypal_data); $this->response->body($this->template->render()); } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default')); } }
/** * Initialize properties before running the controller methods (actions), * so they are available to our action. * @param string $template view to use as template * @return void */ public function before($template = NULL) { Theme::checker(); $this->maintenance(); if ($this->auto_render === TRUE) { // Load the template $this->template = $template === NULL ? 'oc-panel/main' : $template; $this->template = View::factory($this->template); // Initialize empty values $this->template->title = __('Panel') . ' - ' . core::config('general.site_name'); $this->template->meta_keywords = ''; $this->template->meta_description = ''; $this->template->meta_copywrite = 'Open Classifieds ' . Core::version; $this->template->header = View::factory('oc-panel/header'); $this->template->content = ''; $this->template->footer = View::factory('oc-panel/footer'); $this->template->styles = array(); $this->template->scripts = array(); $this->template->user = Auth::instance()->get_user(); //other color if (Theme::get('admin_theme') != 'bootstrap' and Theme::get('admin_theme') != '') { Theme::$styles = array('http://netdna.bootstrapcdn.com/bootswatch/3.0.0/' . Theme::get('admin_theme') . '/bootstrap.min.css' => 'screen', 'http://cdn.jsdelivr.net/bootstrap/2.3.2/css/bootstrap-responsive.min.css' => 'screen', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', 'http://cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css' => 'screen', 'css/admin-styles.css' => 'screen'); } else { Theme::$styles = array('http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css' => 'screen', 'http://cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css' => 'screen', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', 'css/admin-styles.css' => 'screen'); } Theme::$scripts['footer'] = array('http://code.jquery.com/jquery-1.10.2.min.js', 'js/jquery.sceditor.min.js', 'http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.jquery.min.js', 'js/oc-panel/theme.init.js?v=2.1', 'js/oc-panel/sidebar.js'); } }
/** * 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; }
/** * 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() { // get all categories if ($this->advanced != FALSE) { $this->cat_items = Model_Category::get_as_array(); $this->cat_order_items = Model_Category::get_multidimensional(); $this->selected_category = NULL; if (core::request('category')) { $this->selected_category = core::request('category'); } elseif (Model_Category::current()->loaded()) { $this->selected_category = core::config('general.search_multi_catloc') ? array(Model_Category::current()->seoname) : Model_Category::current()->seoname; } // get all locations $this->loc_items = Model_Location::get_as_array(); $this->loc_order_items = Model_Location::get_multidimensional(); $this->selected_location = NULL; if (core::request('location')) { $this->selected_location = core::request('location'); } elseif (Model_Location::current()->loaded()) { $this->selected_location = core::config('general.search_multi_catloc') ? array(Model_Location::current()->seoname) : Model_Location::current()->seoname; } } if ($this->custom != FALSE) { $fields = Model_Field::get_all(); $this->custom_fields = $fields; } }
/** * expired featured ads * @return void */ public static function renew() { if (Core::config('general.subscriptions') == TRUE) { //get expired subscription that are active $subscriptions = new Model_Subscription(); $subscriptions = $subscriptions->where('status', '=', 1)->where('expire_date', '<=', Date::unix2mysql())->order_by('created', 'desc')->find_all(); foreach ($subscriptions as $s) { //disable the plan $s->status = 0; try { $s->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $plan = $s->plan; if ($plan->loaded() and $plan->status == 1) { //generate a new order $order = Model_Order::new_order(NULL, $s->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name); //free plan no checkout if ($plan->price == 0) { $order->confirm_payment('cash'); } else { $checkout_url = $s->user->ql('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order)); $s->user->email('plan-expired', array('[PLAN.NAME]' => $plan->name, '[URL.CHECKOUT]' => $checkout_url)); } } //if plan loaded } //end foreach } //if subscription active }
/** * Initialize properties before running the controller methods (actions), * so they are available to our action. * @param string $template view to use as template * @return void */ public function before($template = NULL) { Theme::checker(); $this->maintenance(); $this->private_site(); if ($this->auto_render === TRUE) { // Load the template $this->template = $template === NULL ? 'oc-panel/main' : $template; //if its and ajx request I want only the content if (Core::get('rel') == 'ajax') { $this->template = 'oc-panel/content'; } $this->template = View::factory($this->template); // Initialize empty values $this->template->title = __('Panel') . ' - ' . core::config('general.site_name'); $this->template->meta_keywords = ''; $this->template->meta_description = ''; $this->template->meta_copyright = 'Open Classifieds ' . Core::VERSION; $this->template->header = ''; $this->template->content = ''; $this->template->footer = ''; $this->template->styles = array(); $this->template->scripts = array(); $this->template->user = Auth::instance()->get_user(); //non ajax request if (Core::get('rel') != 'ajax') { $this->template->header = View::factory('oc-panel/header'); $this->template->footer = View::factory('oc-panel/footer'); /** * custom options for the theme * @var array */ Theme::$options = Theme::get_options(); //we load earlier the theme since we need some info Theme::load(); if (Theme::get('cdn_files') == FALSE) { //other color if (Theme::get('admin_theme') != 'bootstrap' and Theme::get('admin_theme') != '') { $theme_css = array('css/' . Theme::get('admin_theme') . '-bootstrap.min.css' => 'screen'); } else { $theme_css = array('css/style.css' => 'screen'); } $common_css = array('css/other.css' => 'screen'); Theme::$styles = array_merge($common_css, $theme_css); Theme::$scripts['footer'] = array('js/jquery.min.js', 'js/jquery.cookie.min.js', 'js/iconPicker.min.js', 'js/jquery.sceditor.bbcode.min.js', 'js/summernote.min.js', 'js/bootstrap.min.js', 'js/chosen.jquery.min.js', 'js/mousetrap.min.js', 'js/bootstrap-tour.min.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'bstour')), 'js/oc-panel/tour.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'chosen')), 'http://' . (Kohana::$environment !== Kohana::DEVELOPMENT ? 'market.' . Core::DOMAIN . '' : 'eshop.lo') . '/embed.js', 'js/sweet-alert.min.js', 'js/favico.min.js', '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7', '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js', 'js/bootstrap-colorpicker.min.js', 'js/jquery.bootgrid.min.js', 'js/query.bootgrid.fa.min.js', 'js/oc-panel/metismenu.min.js', 'js/oc-panel/fastclick.min.js', 'js/oc-panel/theme.init.js?v=' . Core::VERSION, 'js/oc-panel/sidebar.js?v=' . Core::VERSION); } else { //other color if (Theme::get('admin_theme') != 'bootstrap' and Theme::get('admin_theme') != '') { $theme_css = array('//cdn.jsdelivr.net/bootswatch/3.3.6/' . Theme::get('admin_theme') . '/bootstrap.min.css' => 'screen'); } else { $theme_css = array('css/style.css' => 'screen'); } $common_css = array('css/other.css' => 'screen'); Theme::$styles = array_merge($theme_css, $common_css); Theme::$scripts['footer'] = array('//cdn.jsdelivr.net/jquery/1.12.3/jquery.min.js', '//cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js', 'js/iconPicker.min.js', 'js/jquery.sceditor.bbcode.min.js', '//cdn.jsdelivr.net/summernote/0.8.1/summernote.min.js', '//cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js', '//cdn.jsdelivr.net/chosen/1.0.0/chosen.jquery.min.js', '//cdn.jsdelivr.net/mousetrap/1.6.0/mousetrap.min.js', 'js/bootstrap-tour.min.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'bstour')), 'js/oc-panel/tour.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'chosen')), 'http://' . (Kohana::$environment !== Kohana::DEVELOPMENT ? 'market.' . Core::DOMAIN . '' : 'eshop.lo') . '/embed.js', 'js/sweet-alert.min.js', 'js/favico.min.js', '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3', '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js', 'js/bootstrap-colorpicker.min.js', 'js/jquery.bootgrid.min.js', 'js/query.bootgrid.fa.min.js', 'js/oc-panel/metismenu.min.js', 'js/oc-panel/fastclick.min.js', 'js/oc-panel/theme.init.js?v=' . Core::VERSION, 'js/oc-panel/sidebar.js?v=' . Core::VERSION); } } } }
public static function get() { $menus = json_decode(core::config('general.menu'), TRUE); if (!is_array($menus)) { $menus = array(); } return $menus; }
/** * 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; }
/** * generates HTML for apy buton * @param Model_Order $order * @return string */ public static function button_connect(Model_Order $order) { if (!empty($order->ad->user->stripe_user_id) and Core::config('payment.stripe_connect') == TRUE and Core::config('payment.stripe_private') != '' and Core::config('payment.stripe_public') != '' and Theme::get('premium') == 1) { if ($order->ad->price != NULL and $order->ad->price > 0 and (core::config('payment.stock') == 0 or $order->ad->stock > 0 and core::config('payment.stock') == 1)) { return View::factory('pages/stripe/button_connect', array('order' => $order)); } } return ''; }
public function action_bstour() { $this->auto_render = FALSE; $this->template = View::factory('js'); $bstour_basepath = explode('/', core::config('general.base_url')); $bstour_basepath = array_slice($bstour_basepath, 3); $bstour_basepath = '/' . implode('/', $bstour_basepath); $localization_rules = 'function getTourLocalization(text) { switch (text) { case "step1_title": return "' . __('Hey!') . '"; break; case "step1_content": return "' . __('You are now viewing your admin panel, where you can control almost everything in your classifieds site.') . '"; break; case "step2_content": return "' . __('Get started by creating and editing categories and locations for your site here.') . '"; break; case "step3_content": return "' . __('Put your website on maintenance mode until you want to launch it, manage other general settings and create custom fields through this tab.') . '"; break; case "step4_content": return "' . __('Customize your website look and feel by choosing one of the many available themes and changing theme options.') . '"; break; case "step5_content": return "' . __('When there is something you want to know type your question here or check the full list of our <a href=\'http://docs.yclas.com/\'>guides and faqs</a>.') . '"; break; case "step6_title": return "' . __('Hey!') . '"; break; case "step6_content": return "' . sprintf(__('You are now viewing the back panel at %s here you can manage your ads, favorites, payments and more.'), core::config('general.site_name')) . '"; break; case "step7_content": return "' . __('Manage ads you published and edit them through this tab, you can also ask to feature or place your ad to top here.') . '"; break; case "step8_content": return "' . __('Customize your profile, upload a photo, description and change your password.') . '"; break; case "step9_content": return "' . __('You can check payments you made and see your favorites list here') . '"; break; case "step10_content": return "' . sprintf(__('To continue your experience with %s you can get back to the main website by clicking here.'), core::config('general.site_name')) . '"; break; } }'; $localization_rules .= 'function getTourBasePath() { return "' . $bstour_basepath . '"; } '; $this->template->content = $localization_rules; }
public function action_image() { if (Core::post('photo_delete') and Auth::instance()->get_user()->delete_image() == TRUE) { Alert::set(Alert::SUCCESS, __('Photo deleted.')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } // end of photo delete //get image $image = $_FILES['profile_image']; //file post if (!Upload::valid($image) or !Upload::not_empty($image) or !Upload::type($image, explode(',', core::config('image.allowed_formats'))) or !Upload::size($image, core::config('image.max_image_size') . 'M')) { if (Upload::not_empty($image) && !Upload::type($image, explode(',', core::config('image.allowed_formats')))) { Alert::set(Alert::ALERT, $image['name'] . ' ' . __('Is not valid format, please use one of this formats "jpg, jpeg, png"')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } if (!Upload::size($image, core::config('image.max_image_size') . 'M')) { Alert::set(Alert::ALERT, $image['name'] . ' ' . __('Is not of valid size. Size is limited on ' . core::config('general.max_image_size') . 'MB per image')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } Alert::set(Alert::ALERT, $image['name'] . ' ' . __('Image is not valid. Please try again.')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } else { if ($image != NULL) { $user = Auth::instance()->get_user(); // saving/uploadng zip file to dir. $root = DOCROOT . 'images/users/'; //root folder $image_name = $user->id_user . '.png'; $width = core::config('image.width'); // @TODO dynamic !? $height = core::config('image.height'); // @TODO dynamic !? $image_quality = core::config('image.quality'); // if folder does not exist, try to make it if (!is_dir($root) and !@mkdir($root, 0775, TRUE)) { // mkdir not successful ? Alert::set(Alert::ERROR, __('Image folder is missing and cannot be created with mkdir. Please correct to be able to upload images.')); return FALSE; // exit function } // save file to root folder, file, name, dir if ($file = Upload::save($image, $image_name, $root)) { // resize uploaded image Image::factory($file)->orientate()->resize($width, $height, Image::AUTO)->save($root . $image_name, $image_quality); // update category info $user->has_image = 1; $user->last_modified = Date::unix2mysql(); $user->save(); Alert::set(Alert::SUCCESS, $image['name'] . ' ' . __('Image is uploaded.')); } else { Alert::set(Alert::ERROR, $image['name'] . ' ' . __('Icon file could not been saved.')); } $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } } }
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_index() { // validation active Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List'))); $this->template->title = __('Translations'); //scan project files and generate .po $parse = $this->request->query('parse'); if ($parse) { //scan script require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php'); $obj = new POTCreator(); $obj->set_root(DOCROOT); $obj->set_exts('php'); $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i'); $obj->set_base_path('..'); $obj->set_read_subdir(true); $obj->write_pot(i18n::get_language_path()); Alert::set(Alert::SUCCESS, 'File regenerated'); } //change default site language if ($this->request->param('id')) { //save language $locale = new Model_Config(); $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find(); if (!$locale->loaded()) { $locale->group_name = 'i18n'; $locale->config_key = 'locale'; } $locale->config_value = $this->request->param('id'); try { $locale->save(); Alert::set(Alert::SUCCESS, __('Translations regenarated')); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations'))); } //create language if (Core::post('locale')) { $language = $this->request->post('locale'); $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/'; // if folder does not exist, try to make it if (!file_exists($folder) and !@mkdir($folder, 0775, true)) { // mkdir not successful ? Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.')); HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations'))); } // write an empty .po file for $language $out = 'msgid ""' . PHP_EOL; $out .= 'msgstr ""' . PHP_EOL; File::write($folder . 'messages.po', $out); Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved')); } $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale'))); }
static function loginCheck($user,$pass) { $users= core::config('cms-users'); if (!isset($users[$user])) return false; if ($users[$user]['password']===$pass) { if (isset($users[$user]['attr'])) return $users[$user]['attr']; return true; } return false; }
/** * Receives a description as a string to replace all baned word * with replacement provided. * array of baned words and replacement is get fromconfig * @param string text * @return string */ public static function banned_words($text) { if (core::config('advertisement.banned_words') != NULL and core::config('advertisement.banned_words') != '') { $banned_words = explode(',', core::config('advertisement.banned_words')); $banned_words = array_map('trim', $banned_words); // with provided array of baned words, replacement and string to be replaced // returns string with replaced words return str_replace($banned_words, core::config('advertisement.banned_words_replacement'), $text); } else { return $text; } }
static function log() { if (!core::config('log-file')) return; $args= func_get_args(); $line= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; foreach ($args as $arg) { if (is_array($arg)) $arg=jason_encode($arg); $line.= '; '.$arg; } file_put_contents(core::config('log-file'),$line."\n",FILE_APPEND); }
/** * remember the user his ad is about to expire * @param integer days num of days before to notify * @return void */ public static function to_expire($days = 2) { //feature expire ads from yesterday if (core::config('advertisement.expire_date') > 0) { $ads = new Model_Ad(); $ads = $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where(DB::expr('DATE(DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY))'), '=', Date::format('+' . $days . ' days', 'Y-m-d'))->find_all(); foreach ($ads as $ad) { $edit_url = $ad->user->ql('oc-panel', array('controller' => 'myads', 'action' => 'update', 'id' => $ad->id_ad)); $ad->user->email('ad-to-expire', array('[AD.NAME]' => $ad->title, '[URL.EDITAD]' => $edit_url)); } } }
/** * Validate the domain of an email address by checking if the domain has a * valid MX record and is nmot blaklisted as a temporary email * * @link http://php.net/checkdnsrr not added to Windows until PHP 5.3.0 * * @param string $email email address * @return boolean */ public static function email_domain($email) { if (!Valid::not_empty($email)) { return FALSE; } // Empty fields cause issues with checkdnsrr() $domain = preg_replace('/^[^@]++@/', '', $email); if (core::config('general.black_list') == TRUE and in_array($domain, self::get_banned_domains())) { return FALSE; } // Check if the email domain has a valid MX record return (bool) checkdnsrr($domain, 'MX'); }