Example #1
0
 public function run()
 {
     $this->controller->layout = false;
     //rss创建
     $obj = new Sitemap();
     $rss = $obj->show();
     $this->controller->render('sitemap', array('rss' => $rss));
 }
Example #2
0
 function addSitemap(Sitemap $sitemap, $lastmod = null)
 {
     $url = array('loc' => $sitemap->getSitemapUrl());
     if ($lastmod) {
         $url['lastmod'] = $lastmod;
     }
     $this->addUrl($url);
 }
Example #3
0
 public function addSitemap(Sitemap $sitemap)
 {
     if (!$sitemap->getUrl()) {
         throw new Exception('Sitemaps needs to have an URL to be indexable');
     }
     if ($this->maxUrls && count($sitemap) > $this->maxUrls) {
         throw new OutOfBoundsException('Sitemap has more than ' . $this->maxUrls . ' URLs and needs to be spitted');
     }
     $this->sitemaps[] = $sitemap;
 }
Example #4
0
 /**
  * @covers itseo\test\Humans::test
  * @todo   Implement testTest().
  */
 public function testTest()
 {
     $dummy_target = "http://www.google.es/";
     $result = $this->object->test($dummy_target);
     $this->assertArrayHasKey("name", $result);
     $this->assertArrayHasKey("score", $result);
     $this->assertArrayHasKey("total_score", $result);
     $this->assertArrayHasKey("result", $result);
     $this->assertEquals("humans", $result['name']);
 }
Example #5
0
 public function index()
 {
     // load sitemap.php
     if (file_exists(APP . DS . 'Config' . DS . 'Sitemap.php')) {
         App::import('Config', 'Sitemap');
     } else {
         App::import('Trois.Config', 'Sitemap');
     }
     $sitemap = new Sitemap($this->request, $this->response);
     $sitemap->constructClasses();
     $this->set('data', $sitemap->get_sitemap_array());
 }
 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;
 }
Example #7
0
 public function action_index()
 {
     $cache_key = 'sourcemap-sitemap';
     $ttl = 60 * 60 * 24;
     if ($cached = Cache::instance()->get($cache_key)) {
         $xml = $cached;
     } else {
         // Sitemap instance.
         $sitemap = new Sitemap();
         // basics
         $urls = array('home' => array('', 0.9, 'daily', time()), 'register' => array('register/', 0.6, 'yearly'), 'browse' => array('browse/', 0.7, 'daily', time()), 'login' => array('auth/login', 0.5, 'yearly'), 'about' => array('info/', 0.7, 'monthly'), 'api' => array('info/api', 0.7, 'monthly'), 'contact' => array('info/contact', 0.8, 'monthly'));
         // categories
         $cats = Sourcemap_Taxonomy::arr();
         $nms = array();
         foreach ($cats as $i => $cat) {
             $slug = Sourcemap_Taxonomy::slugify($cat->name);
             $urls['browse-' . $cat->name] = array('browse/' . $slug . '/', 0.7);
         }
         // public maps
         $o = 0;
         $l = 100;
         while (($results = Sourcemap_Search::find(array('o' => $o, 'l' => $l))) && $results->hits_ret) {
             foreach ($results->results as $i => $r) {
                 $urls['sc-' . $r->id] = array('view/' . $r->id, 0.5, 'daily', $r->modified);
             }
             $o += $l;
         }
         $defaults = array(false, 0.5, 'daily', false);
         foreach ($urls as $k => $urld) {
             foreach ($defaults as $i => $d) {
                 if (!isset($urld[$i])) {
                     $urld[$i] = $d;
                 }
             }
             list($loc, $priority, $freq, $lastmod) = $urld;
             $new_url = new Sitemap_URL();
             $new_url->set_loc(URL::site($loc, true))->set_priority($priority)->set_change_frequency($freq);
             if ($lastmod) {
                 $new_url->set_last_mod($lastmod);
             }
             $sitemap->add($new_url);
         }
         $xml = $sitemap->render();
         Cache::instance()->set($cache_key, $xml, $ttl);
     }
     header('Content-Type: application/xml');
     $this->response = $xml;
     die($this->response);
 }
Example #8
0
 /**
  * @test
  * @group sitemap
  */
 public function test_root()
 {
     // Base Sitemap
     $sitemap = new Sitemap();
     // Create basic Mobile Sitemap
     $instance = new Sitemap_URL(new Sitemap_Geo());
     $instance->set_loc('http://google.com');
     $sitemap->add($instance);
     // Load the end XML
     $xml = new SimpleXMLElement($sitemap->render());
     // Namespaces.
     $namespaces = $xml->getDocNamespaces();
     $this->assertSame(TRUE, isset($namespaces['geo']));
     $this->assertSame('http://www.google.com/geo/schemas/sitemap/1.0', $namespaces['geo']);
 }
 public function getAllMediaMerge($paginate = false)
 {
     //dc($this->model->getMediaTypes());
     $merged_collection = collect();
     foreach ($this->model->getMediaTypes() as $mediaType) {
         $col = $this->getAllMediaByActiveLocaleAndType($mediaType);
         $merged_collection = $merged_collection->merge($col);
     }
     //$merged_collection = $merged_collection->toArray();
     //$merged_collection = collect($merged_collection);
     //dc($merged_collection);
     // dc($merged_collection);
     /*
             $projects = \App\Project::all();
             $news = \App\Post::all();
             $foo = \App\Foo::all();
     
             $all = $projects->merge($news)->merge($foo);
     */
     //   dc($all_sorted);
     //$merged_collection = $merged_collection->sortBy('translations[0].name');
     //dc($merged_collection);
     //$user->exams()->orderBy('date', 'asc')->get()
     if (is_int($paginate)) {
         //order key values and use for paginate() item counter
         //Reset the keys on the underlying array.
         $merged_collection = $merged_collection->values();
         //dc($merged_collection);
         $merged_collection = $this->getPaginator($merged_collection->all(), $paginate);
         //dc($merged_collection);
     }
     return $merged_collection;
 }
Example #10
0
 public static function getInstance()
 {
     if (!self::$instance && !is_object(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #11
0
 public function show($id)
 {
     // Получаем ряд
     $id = intval($id);
     $this->nId = $id;
     try {
         // Получаем детей
         $aChild = Sitemap::selectChild($id);
         if ($id != 0) {
             $aRow = Sitemap_Sample::get($id);
         } else {
             $aRow = null;
         }
         /*$aData = array();
         		foreach ($aChild as $row)
         		{
         			$aData[] = $row['id'];
         		}*/
         $aData = $aChild;
         //
         $this->formatDesign($aRow);
         // Выводим форму сортировки
         print UParser::parsePHPFile(LIB_PATH . 'sitemap/controller/tpl/order.tpl', array('szTitle' => $this->szTitle, 'aBegin' => $this->aBegin, 'id' => $id, 'back' => $this->back, 'aData' => $aData));
         $this->output();
     } catch (SiteMapException $e) {
         $this->addError(_msg('Ряд не найден в бд'));
         $this->jump('./');
     }
 }
 /**
  * create an instance of Sitemap_Base using sitemap
  *
  * @return void
  * @author Andy Bennett
  */
 public static function instance()
 {
     if (self::$instance == NULL) {
         self::$instance = Sitemap_Base::factory('sitemap');
     }
     return self::$instance;
 }
 /**
  * Create sitemap
  */
 public static function create()
 {
     // Get pages list
     $pages_list = Pages::getPages();
     // Create sitemap content
     $map = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     $map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     foreach ($pages_list as $page) {
         if ($page['parent'] != '') {
             $parent = $page['parent'] . '/';
             $priority = '0.5';
         } else {
             $parent = '';
             $priority = '1.0';
         }
         $map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . $parent . $page['slug'] . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", (int) $page['date']) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>' . $priority . '</priority>' . "\n\t" . '</url>' . "\n";
     }
     // Get list of components
     $components = Sitemap::getComponents();
     // Add components to sitemap
     if (count($components) > 0) {
         foreach ($components as $component) {
             $map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . Text::lowercase($component) . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", time()) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>1.0</priority>' . "\n\t" . '</url>' . "\n";
         }
     }
     // Close sitemap
     $map .= '</urlset>';
     // Save sitemap
     return File::setContent(ROOT . DS . 'sitemap.xml', $map);
 }
Example #14
0
 /**
  * @covers Sitemap::gzip
  */
 public function testGzip()
 {
     $result = $this->object->gzip();
     // Check return value
     $this->assertEquals(NULL, $result);
     // Check valid returnd value
     $this->expectOutputRegex('/<urlset xmlns=/');
 }
Example #15
0
 public function actionIndex()
 {
     if (!$this->isXml) {
         Sitemap::publishAssets();
     }
     $map = $this->generateMap($this->isXml);
     $this->render('index', array('map' => $map));
 }
Example #16
0
 public static function generate()
 {
     //@TODO: Implemet your own  logic here
     $path = $_SERVER['DOCUMENT_ROOT'];
     $xmlDateFormat = "Y-m-d";
     $changeFreq = "weekly";
     $timeZoneInst = new DateTimeZone(CURRENT_TIMEZONE);
     $dateTime = new DateTime("now", $timeZoneInst);
     $sitemapGenInst = new Sitemap("http://" . $_SERVER['SERVER_NAME']);
     $sitemapGenInst->setPath($path . "/");
     $dateTime->setTimestamp(time());
     $sitemapGenInst->addItem('/', 1.0, $changeFreq, $dateTime->format($xmlDateFormat));
     $dateTime->setTimestamp(time());
     $sitemapGenInst->addItem('/contacts', 0.5, $changeFreq, $dateTime->format($xmlDateFormat));
     $sitemapGenInst->createSitemapIndex("http://" . $_SERVER['SERVER_NAME'] . "/");
     return true;
 }
Example #17
0
 /**
  * Gets a page and children based on it's ID
  * @param  string $id The page ID
  * @return object     A JSON tree
  */
 private static function _getPage($id)
 {
     self::$_result = null;
     self::_getPageHelper(self::$_data->pages, $id);
     if (!isset(self::$_result)) {
         throw new \Exception('Sitemap: Page not found.');
     }
     return self::$_result;
 }
Example #18
0
 public function sitemap()
 {
     if ($_POST) {
         Sitemap::save();
         $this->redirect('/tools/sitemap/');
     } else {
         View::render('tools/sitemap/list', array('list' => Sitemap::getList()));
     }
 }
Example #19
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']);
         }
     }
 }
Example #20
0
 public static function createXMLSiteMap()
 {
     $domain = str_ireplace('www.', '', $_SERVER["HTTP_HOST"]);
     if (!file_exists("../sitemap.xml") && file_exists("../robots.txt")) {
         $file = '../robots.txt';
         $siteMapLine = "\n\nSitemap: http://" . $domain . '/sitemap.xml';
         file_put_contents($file, $siteMapLine, FILE_APPEND);
     }
     $siteMap = new Sitemap('http://' . $domain . '/');
     $siteMap->setPath('../');
     $blogData = new BlogData();
     $postPageName = $blogData->getPostPageName();
     $siteMap->addItem('', '1', 'daily');
     $pagesData = new PagesData();
     $pages = $pagesData->getData();
     foreach ($pages as $page) {
         if ($page != $postPageName && $page != 'error' && $page != 'index') {
             $siteMap->addItem($page . '/', '0.5', 'daily');
         }
     }
     $blogList = $blogData->getBlogList();
     if (!empty($blogList)) {
         foreach ($blogList as $blog) {
             if (isset($blog['published'])) {
                 $siteMap->addItem($postPageName . '/' . $blog['external'] . '/', '1', 'monthly');
             }
         }
     }
     $siteMap->createSitemapIndex('http://' . $domain . '/', 'Today');
 }
Example #21
0
 public function action_index()
 {
     $this->auto_render = FALSE;
     // Sitemap instance.
     $sitemap = new Sitemap();
     // New basic sitemap.
     $sitemap_url = new Sitemap_URL();
     // Set base url
     $base_url = "http://{$this->config['global']['server_domain']}/";
     // Config urls
     $urls = array(array('url' => $base_url, 'frequency' => 'daily'), array('url' => $base_url . 'contact', 'frequency' => 'yearly'), array('url' => $base_url . 'about', 'frequency' => 'yearly'), array('url' => $base_url . 'contact', 'frequency' => 'yearly'));
     // Adds categories urls
     $categories = ORM::factory('category')->find_all();
     foreach ($categories as $category) {
         $urls[] = array('url' => $base_url . '?&category_id=' . $category->id, 'frequency' => 'daily');
     }
     // Adds jobtypes urls
     $jobtypes = ORM::factory('jobtype')->find_all();
     foreach ($jobtypes as $jobtype) {
         $urls[] = array('url' => $base_url . '?&jobtype_id=' . $jobtype->id, 'frequency' => 'daily');
     }
     // Get all active ads
     $ads = ORM::factory('ad');
     $ads = $ads->where('active', '=', 1)->limit(500)->offset(0)->order_by('id', 'DESC')->find_all()->as_array('id', 'title');
     foreach ($ads as $id => $title) {
         $urls[] = array('url' => Helper_Utils::get_ad_url($title, $id), 'frequency' => 'yearly');
     }
     // Adds each url to the sitemap xml structure
     foreach ($urls as $url) {
         $sitemap_url->set_loc($url['url'])->set_last_mod(time())->set_change_frequency($url['frequency'])->set_priority(1);
         $sitemap->add($sitemap_url);
     }
     // Render the output.
     $output = $sitemap->render();
     // __toString is also supported.
     header('Content-Type: text/xml');
     echo $sitemap;
     die;
 }
 /**
  * Specific controller action for displaying a particular list of links
  * for a class
  */
 public function sitemap($request)
 {
     $class = $this->request->param('Class');
     $page_num = $this->request->param('PageNum');
     $page_num = is_numeric($page_num) && $page_num > 0 ? $page_num : 1;
     $this->Items = Sitemap::get_items($class, $page_num);
     if (!$this->Items || $this->Items->Count() == 0) {
         return new SS_HTTPResponse('Page not found', 404);
     }
     $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
     $this->getResponse()->addHeader('X-Robots-Tag', 'noindex');
     return $this->renderWith('Sitemap');
 }
    /**
     * simple test to show navigation
     *
     * @return void
     * @author Andy Bennett
     */
    public function index()
    {
        echo '<style type="text/css" media="screen">
			    ul { clear: left; background: #ccc; height: 30px; }
			    li { list-style: none; float: left; line-height: 30px; height: 30px; }
			    li.current { background: white; color: red; }
			    li span { margin-top: 5px; display: block; border-right: 1px solid red; line-height: 16px; padding: 2px 1em; }
			    li.last span { border-right: none; }
			    li a { color: black; text-decoration: none; }
			    li a:hover { text-decoration: underline; }
			</style>';
        echo Sitemap::instance()->navigation(2, 0);
    }
 /**
  * get a list of pages
  *
  * @return void
  * @author Andy Bennett
  */
 public function get_pages()
 {
     $map = Sitemap::instance()->get_sitemap();
     $pages = $map->xpath('/root//item');
     $arr = array();
     foreach ($pages as $page) {
         $tmp = new stdClass();
         $tmp->id = (string) $page->name;
         $tmp->title = (string) $page->title;
         $arr[] = $tmp;
     }
     return $arr;
 }
Example #25
0
 public function xml()
 {
     $sitemap = new Sitemap();
     //create new sitemap
     $www = $_SERVER['SERVER_NAME'];
     $pages = ORM::factory('page')->where('status_id', 2)->find_all();
     foreach ($pages as $page) {
         if ($page->seoURL == "") {
             $url = 'http://' . $www . "/";
         } else {
             $url = 'http://' . $www . "/" . $page->seoURL . ".html";
         }
         $sitemap->add_url($url, date('Y-m-d'), 'weekly', 1);
         //url, last modified, change frequency, priority
     }
     $sitemap->location = 'http://' . $www . '/sitemap.xml';
     //not necessary really since this url is assumed
     echo $sitemap->render();
     //will output the sitemap and add an xml header
     $sitemap->ping_google();
     //tell Google about the sitemap
     $this->auto_render = false;
 }
Example #26
0
 protected function _execute(array $params)
 {
     $categories = ORM::factory('Category')->fetchActive();
     $products = ORM::factory('Product')->fetchActive();
     $pages = ORM::factory('Page')->fetchActive();
     $sitemap = new Sitemap();
     $url = new Sitemap_URL();
     $page = ORM::factory('Page')->where('url', '=', '')->find();
     $url->set_loc("http://cosm.by")->set_last_mod(strtotime($page->updated_at))->set_priority(1);
     $sitemap->add($url);
     foreach ($pages as $page) {
         if ($page->url) {
             $url->set_loc("http://cosm.by/page/" . $page->url)->set_last_mod(strtotime($page->updated_at))->set_change_frequency('monthly')->set_priority(0.2);
             $sitemap->add($url);
         }
     }
     $PDO = ORM::factory('Brand')->PDO();
     $brandsQuery = "SELECT br.id, br.url FROM brand br\r\n\t\t\t\t\t\tLEFT JOIN product pr ON pr.brand_id = br.id\r\n\t\t\t\t\t\tWHERE pr.active = 1\r\n\t\t\t\t\t\tGROUP BY br.id\r\n\t\t\t\t\t\tHAVING COUNT(pr.id) > 0";
     $brands = $PDO->query($brandsQuery)->fetchAll(PDO::FETCH_ASSOC);
     foreach ($brands as $brand) {
         $url->set_loc("http://cosm.by/brand/" . $brand['url'])->set_change_frequency('monthly')->set_priority(0.5);
         $sitemap->add($url);
     }
     foreach ($brands as $brand) {
         $query = "SELECT line.url, line.name, product.updated_at FROM categories\r\n\t\t\t\t\tLEFT JOIN product ON product.category_id = categories.id\r\n\t\t\t\t\tLEFT JOIN line ON line.id = product.line_id\r\n\t\t\t\t\tWHERE product.brand_id = {$brand['id']}\r\n\t\t\t\t\tAND product.active = 1\r\n\t\t\t\t\tGROUP BY line.id\r\n\t\t\t\t\tHAVING COUNT(product.id) > 0\r\n\t\t\t\t\tORDER BY line.name ASC";
         $brandCategories = $PDO->query($query)->fetchAll(PDO::FETCH_ASSOC);
         foreach ($brandCategories as $category) {
             $url->set_loc("http://cosm.by/brand/" . $brand['url'] . "/" . $category['url'])->set_last_mod(strtotime($category['updated_at']))->set_change_frequency('weekly');
             $sitemap->add($url);
         }
     }
     foreach ($categories as $category) {
         $url->set_loc("http://cosm.by/" . $category->url)->set_last_mod(strtotime($category->updated_at))->set_change_frequency('weekly');
         $sitemap->add($url);
     }
     foreach ($products as $product) {
         $url->set_loc("https://cosm.by" . $product->getSiteUrl())->set_last_mod(strtotime($product->updated_at))->set_change_frequency('daily')->set_priority(1);
         $sitemap->add($url);
     }
     $response = $sitemap->render();
     file_put_contents('sitemap.xml', $response);
 }
Example #27
0
 function getList()
 {
     $data = array();
     $xml = Sitemap::getSitemapXML();
     //$site=Control::getSite(Funcs::$siteDB);
     $sql = 'SELECT * FROM {{tree}} WHERE visible=1 ORDER BY mdate DESC, cdate DESC';
     $list = DB::getAll($sql);
     foreach ($list as $item) {
         $info = Tree::getInfo($item['id']);
         if ($info['id2'] != 0 && $info['params'] != '') {
             $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id'], $info['params']);
         } else {
             $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id']);
         }
         $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path, 'mdate' => date('Y-m-d', strtotime($item['mdate'])), 'changefreq' => $xml[str_replace('/', '_', $path)]['changefreq'], 'priority' => $xml[str_replace('/', '_', $path)]['priority'], 'checked' => is_array($xml[str_replace('/', '_', $path)]) ? 'checked' : '');
     }
     return $data;
 }
Example #28
0
    /**
     * Осуществляет сортировку по определенному полю у конкретного документа
     */
    public static function sortByField($nId, $szDocumentName, $szFieldName, $bAsc = true)
    {
        //
        $nId = IntegerHelper::toNatural($nId);
        $szDocumentName = \Faid\DB::escape($szDocumentName);
        $szFieldName = \Faid\DB::escape($szFieldName);
        $bAsc = intval($bAsc);
        //
        // Получаем всех детей элемента, которые имеют указанный документ в кач. имени
        //
        $szTable = call_user_func([$szDocumentName, 'getTableName']);
        $sql = <<<SQL
\tSELECT `sitemap`.id,`sitemap`.document_id
\tFROM `%s` as `sitemap` 
\tINNER JOIN `%s` as `document` 
\tON `sitemap`.`parent` = %d and `sitemap`.document_id = `document`.id and `sitemap`.document_name = "%s" 
\tORDER BY `document`.%s %s
SQL;
        $sql = sprintf($sql, SITEMAP_TABLE, $szTable, $nId, $szDocumentName, $szFieldName, $bAsc ? ' ASC' : ' DESC');
        $aDocumentsData = DB::query($sql);
        // Получаем всех остальных детей
        $sql = 'SELECT * FROM `%s` WHERE `parent`="%d" and STRCMP(`document_name`,"%s") <> 0 ORDER by `order`';
        $sql = sprintf($sql, SITEMAP_TABLE, $nId, $szDocumentName);
        $aOtherData = DB::query($sql);
        // Выстраиваем детей совмещаем массивы, неотсортированные элементы остаются на своих местах
        $aResult = array();
        $nOrder = 0;
        while (sizeof($aDocumentsData) > 0 || sizeof($aOtherData) > 0) {
            if (!empty($aOtherData) && $aOtherData[0]['order'] == $nOrder) {
                $aElement = array_shift($aOtherData);
                $aResult[] = $aElement['id'];
            } else {
                //
                $aElement = array_shift($aDocumentsData);
                $aResult[] = $aElement['id'];
            }
            $nOrder++;
        }
        //
        Sitemap::manualOrder($nId, $aResult);
    }
Example #29
0
 public function action_query($domain)
 {
     $domain = strtolower($domain);
     $index_alpha = Sitemap::get_filters();
     Log::write('check', 'whois: ' . $domain);
     //Cache::forget('whois.'.$domain);
     $whois = Cache::remember('whois.' . $domain, function () use($domain) {
         return new Whois\Whois($domain);
     }, 60 * 24);
     $data = $whois->get_all_data();
     if ($data === 0) {
         $valid = 0;
     } else {
         $valid = $data[0]->valid();
     }
     if (!$valid) {
         return View::make('whois.index')->with('valid', 0)->with('type', 'whois')->with('title', 'WHOIS Search')->with('index_alpha', $index_alpha);
     }
     $data = $whois->email_mask($data);
     $available = $whois->available();
     $domain = $data[sizeof($data) - 1];
     $domain = $domain->get_query_domain();
     $meta = array('title' => '', 'ip' => '');
     if ($valid && !$available) {
         if (!Domain::where('name', '=', $domain)->first()) {
             @Domain::create(array('name' => $domain));
         }
         $meta['title'] = Domain::get_domain_title($domain);
         $ip = gethostbyname($domain);
         if ($ip != $domain) {
             $meta['ip'] = $ip;
         }
     }
     $expires_on = $whois->expires_on();
     $created_on = $whois->created_on();
     $updated_on = $whois->updated_on();
     if (is_numeric(end($data)->get_body())) {
         Cache::forget('whois.' . $domain);
     }
     return View::make('whois.query', array('i' => 1, 'data' => $data, 'meta' => $meta, 'type' => 'whois', 'valid' => $valid, 'domain' => $domain, 'available' => $available, 'expires_on' => $expires_on, 'created_on' => $created_on, 'updated_on' => $updated_on, 'index_alpha' => $index_alpha, 'title' => $domain . '\'s whois info'));
 }
Example #30
0
 function index()
 {
     $arrTmp = $this->product->findall();
     $products = $arrTmp['rpta'] == true ? $arrTmp['array'] : array();
     unlink(APPPATH . "../tmp/sitemap.xml");
     unlink(APPPATH . "../tmp/sitemap-index.xml");
     $sitemap = new Sitemap("https://www.lifeleg.com");
     $sitemap->setPath('tmp/');
     $sitemap->setFilename('sitemap');
     ///AGREGAR ITEMS AL XML CON LAS RUTAS DE LAS PAGINAS WEB
     $sitemap->addItem('/', '1.0', 'daily', 'Today');
     $hoy = getdate();
     $sitemap->addItem('/index.php/Petshop', '0.8', 'weekly', $hoy['month'] . " " . $hoy['mday']);
     foreach ($products as $key => $value) {
         $sitemap->addItem('/index.php/Petshop/detail/' . $value['url'], '0.8', 'weekly', $hoy['month'] . " " . $hoy['mday']);
     }
     /// SE CREA EL ARCHIVO
     $sitemap->createSitemapIndex('https://www.lifeleg.com/tmp/', 'Today');
 }