public static function testHeaderRequest() { $tmp = new Tmp(TMP_PATH); $tmp->addTmp('test.common.cookie', false); $url = 'http://localhost/ForeShadowAlpha/script/AnCommonTest.php'; $content = self::curlSingle($url, null, $tmp->getTmpFile('test.common.cookie')); echo $url . '<br>'; echo $content; }
protected function getCatalog() { /* Украсть католог с http://www.carexpert.ru/ /* С концептами, но без ранее выпускавшихся моделей */ $brands = Brand::model()->findAll(); foreach ($brands as $brand) { $brand_title = $brand->title; $brand_alias = $brand->alias; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, 'http://www.carexpert.ru/' . $brand->alias . '.htm'); #d('http://www.carexpert.ru/'.$brand->alias.'.htm'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $html = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $html = iconv('windows-1251', 'UTF-8', $html); preg_match_all('|(/models/(.*)\\.htm)(:?[^"]*)>(.*)</a|Ui', $html, $out, PREG_PATTERN_ORDER); foreach ($out[1] as $i => $m) { $model_title = $out[4][$i]; $model_alias = $out[2][$i]; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, 'http://www.carexpert.ru' . $m); #d('http://www.carexpert.ru'.$m); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $html = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $html = iconv('windows-1251', 'UTF-8', $html); preg_match_all('|(/models/tech/(.*)\\.htm)(:?[^"]*)>(.*)</a|Ui', $html, $out1, PREG_PATTERN_ORDER); #d($brand_title.' '.$brand_alias); #d($model_title.' '.$model_alias); #d($out1, true); foreach ($out1[1] as $i1 => $t) { $mod_title = $out1[4][$i1]; $mod_alias = $out1[2][$i1]; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, 'http://www.carexpert.ru' . $t); d('http://www.carexpert.ru' . $t); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $html = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $html = iconv('windows-1251', 'UTF-8', $html); preg_match_all("|Общие данные(.*)</table>|siU", $html, $out3, PREG_PATTERN_ORDER); $tmp = new Tmp(); $tmp->brand = trim($brand_title); $tmp->brand_alias = trim($brand_alias); $tmp->model = trim($model_title); $tmp->model_alias = trim($model_alias); $tmp->mod = trim($mod_title); $tmp->mod_alias = trim($mod_alias); $tmp->techs_table = '<table><tr><td>' . $out3[0][0]; $tmp->url = 'http://www.carexpert.ru' . $t; if (!Tmp::model()->exists('url=:url', array(':url' => $tmp->url))) { $tmp->save(); } $tmp->save(); } } } }
<?php die; include '../inc.common.php'; $files = glob('/var/www/frontend/demo/art/*'); class Tmp extends Transform_Upload_Abstract_Image { protected function test_file() { } protected function get_max_size() { } protected function process() { global $key; $newthumb = '/var/www/frontend/demo/art/_' . $key . '.jpg'; $this->worker = Transform_Image::get_worker($this->file); $this->animated = $this->is_animated($this->file); $this->scale(array(150, 150), $newthumb); $this->set(array()); } } foreach ($files as $key => $file) { $worker = new Tmp($file, basename($file)); $worker->process_file(); unlink($file); }
<?php require_once "../zombie-core/util/util.php"; require_once "../zombie-core/util/autoload.php"; function notFound() { class Tmp extends Controller { public function init() { $this->allowFormat("json"); $this->allowFormat("xml"); $this->allowFormat("serial"); } } $c = new Tmp(); $c->run(); } if (isset($_GET['app'])) { // sanitize the app name: only letters, numbers, and underscores $app = preg_replace('/[^0-9a-zA-Z_]/', '', $_GET['app']); $app_file = "../apps/{$app}/{$app}.php"; if (file_exists($app_file)) { require_once $app_file; $app_class = underscoreToClass($app); if (class_exists($app_class)) { $app = new $app_class(); $app->run(); } else { notFound(); }
public static function testTmp() { $t = new Tmp(TMP_PATH); $p = CommonInfo::GetFileName(__FILE__); $t->addTmp($p, false); //$t->newTmpFile($p); $t->putTmpContent($p, "null", FILE_APPEND); echo $t->getTmpContent($p); }