public function run($args)
 {
     mysql_connect("localhost", "world_news_admin", "7TVzoANC");
     mysql_select_db("yii_travel_db");
     mysql_query("DELETE FROM catalog_upload WHERE ste='proavto.uz' ORDER BY id LIMIT 20") or die(mysql_error());
     $newCache = CatalogCache::fetchBySlug("proavto.uz");
     $newCache->description = "";
     $newCache->date = 1;
     if (!$newCache->save()) {
         print_r($newCache->getErrors());
     }
     $newCache2 = CatalogCache::fetchBySlug("proavto_uz_page");
     $newCache2->description = 1;
     $newCache2->date = 1;
     if (!$newCache2->save()) {
         print_r($newCache2->getErrors());
     }
 }
 public function run($args)
 {
     $link = "http://webgazeta.uz";
     $listPages = array();
     $cacheTopCategory = CatalogCache::fetchBySlug("webgazeta_uz_top_category");
     if ($cacheTopCategory->date == 0 || $cacheTopCategory->date <= time()) {
         $text = file_get_contents("http://webgazeta.uz/gazeta-45.html");
         //$arr = explode( "id='sidemenu'", $text );
         echo $text . "#";
         die;
         $arr = explode('</ul', $arr[1]);
         $arr = explode('<a', $arr[0]);
         echo sizeof($arr);
         $listTopCategory = array();
         for ($i = 5; $i < sizeof($arr); $i++) {
             $arr2 = explode("href='", $arr[$i]);
             $arr2 = explode("'", $arr2[1]);
             $listTopCategory[] = $link . $arr2[0];
         }
         print_r($listTopCategory);
         die;
         $cacheTopCategory->description = serialize($listTopCategory);
         $cacheTopCategory->date = time() + 60 * 60 * 24 * 7 * 4;
         //$cacheTopCategory->save();
     } else {
         $listTopCategory = unserialize($cacheTopCategory->description);
     }
     /*
     
     
     
             // Начинаем ходить по категориям и выстаскивать объявления
             $cacheCategory = CatalogCache::fetchBySlug( "yp_uz_current_category" );
             if( $cacheCategory->description )$currentCategory = $listSubCategory[$cacheCategory->description];
             else
             {
                 // Сохраняем текщую категорию
                 $currentCategory = $listSubCategory[0];
                 $cacheCategory->description = 0;
                 $cacheCategory->date = time();
                 $cacheCategory->save();
             }
     
             // Определяем текущую страницу данной категории
             $page = CatalogCache::fetchBySlug( "yp_uz_page" );
             if( $page->description >0 )$currentPage = $page->description;
     
             for( $n=0;$n<30;$n++ )
             {
                 if( $currentPage == 1  )$loadPage = $currentCategory;
                 else $loadPage = $currentCategory."?page=".$currentPage."&pagesize=10";
     
                 echo $loadPage."<br/>";
                 $text = file_get_contents( $loadPage );
                 $arr = explode( 'id="ov"', $text );
                 $arr = explode( 'class="header2">', $arr[1] );
     
                 echo sizeof( $arr )."*";
     
                 // Значит кончались страницы в этой категории
                 if( sizeof( $arr ) == 1 )
                 {
                     // Скидываем страницу до первой
                     $page = CatalogCache::fetchBySlug( "yp_uz_page" );
                     $page->description = 1;
                     $page->date = time();
                     $page->save();
     
                     // Сохраняем новую категорию
                     $currentCategory = CatalogCache::fetchBySlug( "yp_uz_current_category" );
                     $currentCategory->description = $currentCategory->description + 1;
                     $currentCategory->save();
     
                     // Выходим из цикла
                     break;
                 }
     
                 for( $i=1;$i<sizeof( $arr );$i++ )
                 {
                     if( strpos( $arr[$i], "Email" ) !== false )
                     {
                         $arr2 = explode( '</a>', $arr[$i] );
                         $name = trim( strip_tags( $arr2[0] ) );
                         $arr2 = explode( 'mailto:', $arr2[1] );
                         $arr2 = explode( '"', $arr2[1] );
     
                         $check = CatalogUsersSubscribe::findByAttributes( array( "email"=>$arr2[0] ) );
                         if( sizeof( $check ) ==0 )
                         {
                             $user = new CatalogUsersSubscribe();
                             $user->name = $name;
                             $user->email = $arr2[0];
                             $user->save();
                         }
                     }
                 }
     
                 // Сохраняем текущую страницу
                 $currentPage++;
                 $page->description = $currentPage;
                 $page->date = time();
                 $page->save();
             }*/
 }
Example #3
0
 public function run($args)
 {
     $link = "http://olx.uz";
     $listPages = array();
     $newCache = CatalogCache::fetchBySlug("torg_uz");
     if (!$newCache->description) {
         $newCache1 = CatalogCache::fetchBySlug("torg_uz_page");
         if ($newCache1->description == 1) {
             $text = file_get_contents("http://www.olx.uz/ru/all");
         } else {
             $text = file_get_contents("http://www.olx.uz/ru/all/page/" . $newCache1->description);
         }
         $arr = explode("offers blue offers", $text);
         //echo $arr[0]."###";
         //echo $arr[1];
         //die;
         if (empty($arr[1])) {
             echo "Oy";
             echo $arr[0];
             die;
         }
         $arr = explode("/ru/changeview", $arr[1]);
         $arr = explode("</tr>", $arr[0]);
         for ($i = 1; $i < sizeof($arr) - 1; $i++) {
             $arr1 = explode('href="', $arr[$i]);
             $arr1 = explode('"', $arr1[1]);
             $listPages[] = trim($link . $arr1[0]);
         }
         $newCache->description = serialize($listPages);
         $newCache->date = time();
         if (!$newCache->save()) {
             print_r($newCache->getErrors());
         }
     } else {
         $listPages = unserialize($newCache->description);
     }
     $countPage = 0;
     for ($i = 0; $i < sizeof($listPages); $i++) {
         $checkModel = CatalogUpload::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("name='" . $listPages[$i] . "'")->setCache(0));
         if (sizeof($checkModel) == 0) {
             $countPage++;
             $text = file_get_contents($listPages[$i]);
             if (strpos($text, "mailto") !== false) {
                 $arr = explode("Имя:", $text);
                 $arr = explode("</table>", $arr[1]);
                 $arrE = explode("mailto:", $arr[0]);
                 $arrE = explode('"', $arrE[1]);
                 $email = trim($arrE[0]);
                 $arrN = explode("</tr>", $arr[0]);
                 $arrN = explode("<td", $arrN[0]);
                 $name = strip_tags("<p" . $arrN[1]);
                 echo "##" . $email . "-" . $name;
                 //.;
                 $chechEmail = CatalogUsersSubscribe::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("email='" . $email . "'")->setCache(0));
                 if (sizeof($chechEmail) == 0) {
                     echo "N0";
                     //.;
                     $newSubscribe = new CatalogUsersSubscribe();
                     $newSubscribe->name = trim($name);
                     $newSubscribe->email = trim($email);
                     if (!$newSubscribe->save()) {
                         print_r($newSubscribe->getErrors());
                     }
                 }
                 //break;
             }
             $newPage = new CatalogUpload();
             $newPage->name = $listPages[$i];
             if (!$newPage->save()) {
                 print_r($newPage->getErrors());
             }
         }
     }
     // Если не нашол не одной новой стринцы то скидываем кеш, и устанавливаем текущей следующую страницу
     if ($countPage == 0) {
         $newCache = CatalogCache::fetchBySlug("torg_uz");
         $newCache->description = "";
         $newCache->save();
         $newCache1 = CatalogCache::fetchBySlug("torg_uz_page");
         $newCache1->description = (int) $newCache1->description + 1;
         $newCache1->save();
     }
 }
 public function run($args)
 {
     echo "*";
     $link = "http://proavto.uz";
     $listPages = array();
     $newCache = CatalogCache::fetchBySlug("proavto.uz");
     if (!$newCache->description) {
         echo "*";
         $newCache1 = CatalogCache::fetchBySlug("proavto_uz_page");
         if ($newCache1->description == 1) {
             $text = file_get_contents("http://proavto.uz/ru/ads/search?sortby=datenew&pageSize=10");
         } else {
             $text = file_get_contents("http://proavto.uz/ru/ads/search?sortby=datenew&pageSize=10&page=" . $newCache1->description);
         }
         $arr = explode('class="foot"', $text);
         $arr = explode('class="adcell"', $arr[0]);
         for ($i = 1; $i < sizeof($arr) - 1; $i++) {
             $arr1 = explode('class="add_wish', $arr[$i]);
             $arr1 = explode('href="', $arr1[0]);
             $arr1 = explode('"', $arr1[1]);
             $listPages[] = trim($link . $arr1[0]);
         }
         $newCache->description = serialize($listPages);
         $newCache->date = time();
         if (!$newCache->save()) {
             print_r($newCache->getErrors());
         }
         print_r($listPages);
     } else {
         $listPages = unserialize($newCache->description);
     }
     die("&");
     $countPage = 0;
     for ($i = 0; $i < sizeof($listPages); $i++) {
         $checkModel = CatalogUpload::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("name='" . $listPages[$i] . "'")->setCache(0));
         if (sizeof($checkModel) == 0) {
             $countPage++;
             $text = file_get_contents($listPages[$i]);
             if (strpos($text, "mailto") !== false) {
                 $arrE = explode("mailto:", $text);
                 $arrE = explode('"', $arrE[1]);
                 $email = trim($arrE[0]);
                 $arrE = explode("@", $email);
                 $name = $arrE[0];
                 echo "##" . $email . "-" . $name;
                 //.;
                 $chechEmail = CatalogUsersSubscribe::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("email='" . $email . "'")->setCache(0));
                 if (sizeof($chechEmail) == 0) {
                     $newSubscribe = new CatalogUsersSubscribe();
                     $newSubscribe->name = trim($name);
                     $newSubscribe->email = trim($email);
                     if (!$newSubscribe->save()) {
                         print_r($newSubscribe->getErrors());
                     }
                 }
                 //break;
             }
             $newPage = new CatalogUpload();
             $newPage->name = $listPages[$i];
             $newPage->site = "proavto.uz";
             if (!$newPage->save()) {
                 print_r($newPage->getErrors());
             }
         }
     }
     // Если не нашол не одной новой стринцы то скидываем кеш, и устанавливаем текущей следующую страницу
     if ($countPage == 0) {
         $newCache = CatalogCache::fetchBySlug("proavto.uz");
         $newCache->description = "";
         $newCache->date = 0;
         $newCache->save();
         $newCache1 = CatalogCache::fetchBySlug("proavto_uz_page");
         $newCache1->description = (int) $newCache1->description > 0 ? (int) $newCache1->description + 1 : ($newCache1->description = 2);
         $newCache1->date = 0;
         if (!$newCache1->save()) {
             $newCache1->getErrors();
         }
     }
 }
Example #5
0
 public function run($args)
 {
     $link = "http://yp.uz/";
     $listPages = array();
     $cacheTopCategory = CatalogCache::fetchBySlug("yp_uz_top_category");
     if ($cacheTopCategory->date == 0 || $cacheTopCategory->date <= time()) {
         $text = file_get_contents("http://yp.uz/");
         $arr = explode("content2", $text);
         $arr = explode("header", $arr[1]);
         $arr = explode('class="chapter"', $arr[0]);
         $listTopCategory = array();
         for ($i = 1; $i < sizeof($arr); $i++) {
             $arr2 = explode("<div", $arr[$i]);
             $arr2 = explode('href="', $arr2[0]);
             $arr2 = explode('"', $arr2[1]);
             $listTopCategory[] = "http://yp.uz" . $arr2[0];
         }
         $cacheTopCategory->description = serialize($listTopCategory);
         $cacheTopCategory->date = time() + 60 * 60 * 24 * 7 * 4;
         $cacheTopCategory->save();
     } else {
         $listTopCategory = unserialize($cacheTopCategory->description);
     }
     // Вытаскиваем все внутренине категории
     $cacheCategory = CatalogCache::fetchBySlug("yp_uz_inner_category");
     if ($cacheCategory->date == 0 || $cacheCategory->date <= time()) {
         $listSubCategory = array();
         for ($i = 0; $i < sizeof($listTopCategory); $i++) {
             // echo $listTopCategory[$i]."<br/>";
             $text = file_get_contents($listTopCategory[$i]);
             $arr = explode('border="0px"', $text);
             $arr = explode('class="header"', $arr[1]);
             $arr = explode('href="', $arr[0]);
             for ($n = 1; $n < sizeof($arr); $n++) {
                 $arr2 = explode('"', $arr[$n]);
                 $listSubCategory[] = substr($link, 0, -1) . $arr2[0];
                 //echo substr( $link, 0, -1 ).$arr2[0]."<br/>";
             }
         }
         $cacheCategory->description = serialize($listSubCategory);
         $cacheCategory->date = time() + 60 * 60 * 24 * 7 * 4;
         $cacheCategory->save();
     } else {
         $listSubCategory = unserialize($cacheCategory->description);
     }
     // Начинаем ходить по категориям и выстаскивать объявления
     $cacheCategory = CatalogCache::fetchBySlug("yp_uz_current_category");
     if ($cacheCategory->description) {
         $currentCategory = $listSubCategory[$cacheCategory->description];
     } else {
         // Сохраняем текщую категорию
         $currentCategory = $listSubCategory[0];
         $cacheCategory->description = 0;
         $cacheCategory->date = time();
         $cacheCategory->save();
     }
     // Определяем текущую страницу данной категории
     $page = CatalogCache::fetchBySlug("yp_uz_page");
     if ($page->description > 0) {
         $currentPage = $page->description;
     }
     for ($n = 0; $n < 30; $n++) {
         if ($currentPage == 1) {
             $loadPage = $currentCategory;
         } else {
             $loadPage = $currentCategory . "?page=" . $currentPage . "&pagesize=10";
         }
         echo $loadPage . "<br/>";
         $text = file_get_contents($loadPage);
         $arr = explode('id="ov"', $text);
         $arr = explode('class="header2">', $arr[1]);
         echo sizeof($arr) . "*";
         // Значит кончались страницы в этой категории
         if (sizeof($arr) == 1) {
             // Скидываем страницу до первой
             $page = CatalogCache::fetchBySlug("yp_uz_page");
             $page->description = 1;
             $page->date = time();
             $page->save();
             // Сохраняем новую категорию
             $currentCategory = CatalogCache::fetchBySlug("yp_uz_current_category");
             $currentCategory->description = $currentCategory->description + 1;
             $currentCategory->save();
             // Выходим из цикла
             break;
         }
         for ($i = 1; $i < sizeof($arr); $i++) {
             if (strpos($arr[$i], "Email") !== false) {
                 $arr2 = explode('</a>', $arr[$i]);
                 $name = trim(strip_tags($arr2[0]));
                 $arr2 = explode('mailto:', $arr2[1]);
                 $arr2 = explode('"', $arr2[1]);
                 $check = CatalogUsersSubscribe::findByAttributes(array("email" => $arr2[0]));
                 if (sizeof($check) == 0) {
                     $user = new CatalogUsersSubscribe();
                     $user->name = $name;
                     $user->email = $arr2[0];
                     $user->save();
                 }
             }
         }
         // Сохраняем текущую страницу
         $currentPage++;
         $page->description = $currentPage;
         $page->date = time();
         $page->save();
     }
 }