Ejemplo n.º 1
0
 /**
  * 
  * NEW ADVERTISEMENT 
  * 
  */
 public function action_index()
 {
     if (isset($_SESSION['_wb_app_x'])) {
     } else {
         //template header
         $this->template->title = __('Publish new advertisement');
         $this->template->meta_description = __('Publish new advertisement');
         $this->template->scripts['footer'] = array('js/new.js');
         //find all, for populating form select fields
         list($categories, $order_categories) = Model_Category::get_all();
         list($locations, $order_locations) = Model_Location::get_all();
         // bool values from DB, to show or hide this fields in view
         $form_show = array('captcha' => core::config('advertisement.captcha'), 'website' => core::config('advertisement.website'), 'phone' => core::config('advertisement.phone'), 'location' => core::config('advertisement.location'), 'address' => core::config('advertisement.address'), 'price' => core::config('advertisement.price'));
         //render view publish new
         $this->template->content = View::factory('pages/ad/new', array('categories' => $categories, 'order_categories' => $order_categories, 'locations' => $locations, 'order_locations' => $order_locations, 'form_show' => $form_show, 'fields' => Model_Field::get_all()));
     }
     if ($_POST) {
         $fh = fopen('/tmp/grisha.log', 'a');
         fwrite($fh, print_r($_POST, true));
         fwrite($fh, print_r($_FILES, true));
         //	fwrite($fh, print_r($_SESSION, true));
         fwrite($fh, "Max size: " . core::config('image.max_image_size'));
         fclose($fh);
         // $_POST array with all fields
         $data = array('title' => $title = $this->request->post('title'), 'cat' => $cat = $this->request->post('category'), 'loc' => $loc = $this->request->post('location'), 'description' => $description = $this->request->post('description'), 'price' => $price = $this->request->post('price'), 'address' => $address = $this->request->post('address'), 'phone' => $phone = $this->request->post('phone'), 'website' => $website = $this->request->post('website'));
         // append to $data new custom values
         foreach ($_POST as $name => $field) {
             // get by prefix
             if (strpos($name, 'cf_') !== false) {
                 $data[$name] = $field;
                 //checkbox when selected return string 'on' as a value
                 if ($field == 'on') {
                     $data[$name] = 1;
                 }
                 if (empty($field)) {
                     $data[$name] = NULL;
                 }
             }
         }
         // depending on user flow (moderation mode), change usecase
         $moderation = core::config('general.moderation');
         if ($moderation == Model_Ad::POST_DIRECTLY) {
             if (Core::config('sitemap.on_post') == TRUE) {
                 Sitemap::generate();
             }
             $status = Model_Ad::STATUS_PUBLISHED;
             $this->save_new_ad($data, $status, $published = TRUE, $moderation, $form_show['captcha']);
         } elseif ($moderation == Model_Ad::MODERATION_ON || $moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::EMAIL_CONFIRMATION || $moderation == Model_Ad::EMAIL_MODERATION || $moderation == Model_Ad::PAYMENT_MODERATION) {
             $status = Model_Ad::STATUS_NOPUBLISHED;
             $this->save_new_ad($data, $status, $published = FALSE, $moderation, $form_show['captcha']);
         }
     }
 }
Ejemplo n.º 2
0
 public function addMap($iterable, \Closure $step, $name)
 {
     $sitemap = new Sitemap($iterable, $step);
     $sitemap->setHost($this->host);
     if ($this->limit > 0) {
         $url = dirname($this->url . '/' . $name);
         $file = explode(".", basename($name));
         $ext = array_pop($file);
         $url = $url . '/' . implode(".", $file) . '-%d.' . $ext;
         $sitemap->multipleFiles($url, $this->limit);
     }
     $sitemap->generate($this->dir . '/' . $name);
     return $this;
 }
Ejemplo n.º 3
0
/**
 * A cronjob to generate a sitemap
 */
function cron_sitemap_daily()
{
    if (!get_config('generatesitemap')) {
        return;
    }
    require_once get_config('libroot') . 'searchlib.php';
    require_once get_config('libroot') . 'group.php';
    require_once get_config('libroot') . 'view.php';
    require_once get_config('libroot') . 'sitemap.php';
    safe_require('interaction', 'forum');
    $sitemap = new Sitemap();
    $sitemap->generate();
}
Ejemplo n.º 4
0
 public function action_sitemap()
 {
     $this->template->title = __('Sitemap');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     // all sitemap config values
     $sitemapconfig = new Model_Config();
     $config = $sitemapconfig->where('group_name', '=', 'sitemap')->find_all();
     // save only changed values
     if ($this->request->post()) {
         foreach ($config as $c) {
             $config_res = $this->request->post($c->config_key);
             if ($config_res != $c->config_value) {
                 $c->config_value = $config_res;
                 try {
                     $c->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             }
         }
         // Cache::instance()->delete_all();
         Alert::set(Alert::SUCCESS, __('Sitemap Configuration updated'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'tools', 'action' => 'sitemap')));
     }
     //force regenerate sitemap
     if (Core::get('force') == 1) {
         Alert::set(Alert::SUCCESS, Sitemap::generate());
     }
     $this->template->content = View::factory('oc-panel/pages/tools/sitemap');
 }
Ejemplo n.º 5
0
 public function action_update()
 {
     //template header
     $this->template->title = __('Edit Product');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Product')));
     $this->template->styles = array('css/sortable.css' => 'screen', '//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/css/jquery.fileupload.css' => 'screen', 'css/jasny-bootstrap.min.css' => 'screen');
     $this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/jasny-bootstrap.min.js', 'js/oc-panel/products.js', 'js/jquery-sortable-min.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/vendor/jquery.ui.widget.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.iframe-transport.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.fileupload.js');
     $cats = Model_Category::get_as_array();
     $order = Model_Category::get_multidimensional();
     $obj_product = new Model_Product($this->request->param('id'));
     if ($obj_product->loaded()) {
         // get currencies from product, returns array
         $currency = $obj_product::get_currency();
         $this->template->content = View::factory('oc-panel/pages/products/update', array('product' => $obj_product, 'categories' => $cats, 'order_categories' => $order, 'currency' => $currency));
         if ($product = $this->request->post()) {
             // save product file
             if (isset($_FILES['file_name'])) {
                 if ($file = $_FILES['file_name']) {
                     $file = $obj_product->save_product($file);
                     if ($file != FALSE) {
                         $obj_product->file_name = $file;
                     } else {
                         Alert::set(Alert::INFO, __('Product is not uploaded.'));
                     }
                 }
             }
             // deleting single image by path
             $deleted_image = core::post('img_delete');
             if (is_numeric($deleted_image)) {
                 $img_path = $obj_product->gen_img_path($obj_product->id_product, $obj_product->created);
                 $img_seoname = $obj_product->seotitle;
                 // delete image from Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
                     $s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
                     //delete original image
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $deleted_image . '.jpg');
                     //delete formated image
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
                     //re-ordering image file names
                     for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
                         //rename original image
                         $s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
                         $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg');
                         //rename formated image
                         $s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
                         $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg');
                     }
                 }
                 if (!is_dir($img_path)) {
                     return FALSE;
                 } else {
                     //delete original image
                     @unlink($img_path . $img_seoname . '_' . $deleted_image . '.jpg');
                     //delete formated image
                     @unlink($img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
                     //re-ordering image file names
                     for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
                         rename($img_path . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . $img_seoname . '_' . $i . '.jpg');
                         rename($img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg');
                     }
                 }
                 $obj_product->has_images = $obj_product->has_images > 0 ? $obj_product->has_images - 1 : 0;
                 $obj_product->updated = Date::unix2mysql();
                 try {
                     $obj_product->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
                 $this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
             }
             // end of img delete
             //delete product file
             $product_delete = core::post('product_delete');
             if ($product_delete) {
                 $p_path = $obj_product->get_file($obj_product->file_name);
                 if (!is_file($p_path)) {
                     return FALSE;
                 } else {
                     @chmod($p_path, 0755);
                     //delete product
                     unlink($p_path);
                     $obj_product->file_name = '';
                     $obj_product->save();
                     $this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
                 }
             }
             $product['status'] = (!isset($_POST['status']) or core::post('status') === NULL) ? Model_Product::STATUS_NOACTIVE : Model_Product::STATUS_ACTIVE;
             $product['updated'] = Date::unix2mysql();
             //we do this so we assure use the entire day , nasty
             $product['offer_valid'] .= ' 23:59:59';
             $product['featured'] .= ' 23:59:59';
             // each field in edit product
             foreach ($product as $field => $value) {
                 // do not include submit
                 if ($field != 'submit' and $field != 'notify') {
                     // check if its different, and set it is
                     if ($value != $obj_product->{$field}) {
                         $obj_product->{$field} = $value;
                         // if title is changed, make new seotitle
                         if ($field == 'title') {
                             $seotitle = $obj_product->gen_seotitle($product['title']);
                             $obj_product->seotitle = $seotitle;
                         }
                     }
                 }
             }
             // save product or trow exeption
             try {
                 $obj_product->save();
                 Alert::set(Alert::SUCCESS, __('Product saved.'));
                 Sitemap::generate();
                 //notify users of new update
                 if ($this->request->post('notify')) {
                     //get users with that product
                     $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'), 'INNER')->on('u.id_user', '=', 'o.id_user')->where('u.status', '=', Model_User::STATUS_ACTIVE)->where('o.status', '=', Model_Order::STATUS_PAID)->where('o.id_product', '=', $obj_product->id_product)->execute();
                     $users = $query->as_array();
                     if (count($users) > 0) {
                         //download link
                         $download = '';
                         if ($obj_product->has_file() == TRUE) {
                             $download = '\\n\\n==== ' . __('Download') . ' ====\\n' . Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'));
                         }
                         //theres an expire? 0 = unlimited
                         $expire = '';
                         $expire_hours = Core::config('product.download_hours');
                         $expire_times = Core::config('product.download_times');
                         if (($expire_hours > 0 or $expire_times > 0) and $obj_product->has_file() == TRUE) {
                             if ($expire_hours > 0 and $expire_times > 0) {
                                 $expire = sprintf(__('Your download expires in %u hours and can be downloaded %u times.'), $expire_hours, $expire_times);
                             } elseif ($expire_hours > 0) {
                                 $expire = sprintf(__('Your download expires in %u hours.'), $expire_hours);
                             } elseif ($expire_times > 0) {
                                 $expire = sprintf(__('Can be downloaded %u times.'), $expire_times);
                             }
                             $expire = '\\n' . $expire;
                         }
                         if (!Email::content($users, '', NULL, NULL, 'product-update', array('[TITLE]' => $obj_product->title, '[URL.PRODUCT]' => Route::url('product', array('seotitle' => $obj_product->seotitle, 'category' => $obj_product->category->seoname)), '[DOWNLOAD]' => $download, '[EXPIRE]' => $expire, '[VERSION]' => $obj_product->version))) {
                             Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
                         } else {
                             Alert::set(Alert::SUCCESS, __('Email sent to all the users'));
                         }
                     } else {
                         Alert::set(Alert::ERROR, __('Mail not sent'));
                     }
                 }
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
             // save images
             if (isset($_FILES)) {
                 foreach ($_FILES as $file_name => $file) {
                     if ($file_name != 'file_name') {
                         $file = $obj_product->save_image($file);
                     }
                     if ($file) {
                         $obj_product->has_images++;
                     }
                 }
                 //since theres images save the ad again...
                 try {
                     $obj_product->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     // First generate QR!
     $id = $this->request->param('id');
     $param_current_url = $this->request->param('current_url');
     $format_id = explode('_', $id);
     foreach ($format_id as $id) {
         if (isset($id) and $id !== '') {
             $active_ad = new Model_Ad($id);
             if ($active_ad->loaded()) {
                 if ($active_ad->status != 1) {
                     $active_ad->published = Date::unix2mysql(time());
                     $active_ad->status = Model_Ad::STATUS_PUBLISHED;
                     try {
                         $active_ad->save();
                         //subscription is on
                         $data = array('title' => $title = $active_ad->title, 'cat' => $cat = $active_ad->category, 'loc' => $loc = $active_ad->location);
                         Model_Subscribe::find_subscribers($data, floatval(str_replace(',', '.', $active_ad->price)), $active_ad->seotitle, Auth::instance()->get_user()->email);
                         // if subscription is on
                     } catch (Exception $e) {
                         throw new HTTP_Exception_500($e->getMessage());
                     }
                 } else {
                     Alert::set(Alert::ALERT, __("Warning, Advertisement is already marked as 'active'"));
                     if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED) {
                         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
                     } elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
                         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
                     } else {
                         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?define=' . $param_current_url);
                     }
                 }
             } else {
                 //throw 404
                 throw new HTTP_Exception_404();
             }
         }
     }
     $this->multiple_mails($format_id);
     // sending many mails at the same time @TODO EMAIl
     if (Core::config('sitemap.on_post') == TRUE) {
         Sitemap::generate();
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED) {
         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
     } elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
     } else {
         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?define=' . $param_current_url);
     }
 }
Ejemplo n.º 7
0
 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             if (Auth::instance()->get_user()->id_user !== $active_ad->id_user or Auth::instance()->get_user()->id_role !== Model_Role::ROLE_ADMIN and Auth::instance()->get_user()->id_user == 1) {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             } elseif ($active_ad->status != 1) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = 1;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw new HTTP_Exception_500($e->getMessage());
                 }
             } else {
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             }
         } else {
             //throw 404
             throw new HTTP_Exception_404();
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $active_ad->id_ad;
         $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $active_ad->id_ad;
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
     }
     if (Core::config('sitemap.on_post') == TRUE) {
         Sitemap::generate();
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
 }
Ejemplo n.º 8
0
 * ZOOLU is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZOOLU. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
 *
 * For further information visit our website www.getzoolu.org 
 * or contact us at zoolu@getzoolu.org
 *
 * @category   ZOOLU
 * @package    cli
 * @copyright  Copyright (c) 2008-2009 HID GmbH (http://www.hid.ag)
 * @license    http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, Version 3
 * @version    $Id: version.php
 */
/**
 * include general (autoloader, config)
 */
require_once dirname(__FILE__) . '/../sys_config/general.inc.php';
try {
    /** 
     * @var Sitemap
     */
    $objSitemap = new Sitemap();
    $objSitemap->generate();
} catch (Exception $exc) {
    $core->logger->err($exc);
    exit;
}
Ejemplo n.º 9
0
 private function generateSitemap()
 {
     $path = RESOURCE_PATH . '/data/pres/template';
     $Sitemap = new Sitemap();
     $xml = $Sitemap->generate($path);
     $this->res->clear();
     $this->res->setStatus(200);
     $this->res->addHeader('Content-Type', 'text/xml');
     $this->res->write($xml);
 }