| Server IP : 104.21.17.213 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/findnextproperty.com/console/controllers/ |
Upload File : |
<?php
namespace console\controllers;
use common\models\Image;
use console\parsers\Main;
use Yii;
class ImageController extends \yii\console\Controller
{
function init()
{
if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
ini_set('display_errors', 'On');
ini_set('max_execution_time', 60000);
ini_set('memory_limit', '128M');
}
public function actionTest()
{
for ($i = 1; $i <= 10000000000; $i++) {
$imageModel = Image::getOneNotDownloadingPictureYet();
if ($imageModel) {
$i = 0;
foreach ($imageModel as $image) {
$i++;
$agent = Main::getRandomAgent();
$proxi = Main::getRandomProxi();
$url = str_replace(" ", "%20", trim($image->url));
if (strripos($url, "Mobile-Homes/ShowThumbnail.php")) {
$url = str_replace("Mobile-Homes/ShowThumbnail", "GetPhoto", $url);
}
$path = trim($image->state) . '/' . trim($image->zip) . '/' . trim($image->house_id);
$timeout = rand(1, 3);
$Unicname = uniqid() . '.' . 'jpg';
$newUnicfilename = 'frontend/web/static/images/' . $path . '/' . $Unicname;
$newUnicfilenameShot = $path . '/' . $Unicname;
if (!file_exists('frontend/web/static/images/' . $path . '/')) {
mkdir('frontend/web/static/images/' . $path . '/', 0777, true);
}
echo "Waiting " . $timeout . " seconds...", PHP_EOL;
sleep($timeout);
echo "#ImageDownload..", PHP_EOL;
$out = '';
$result = '';
echo "download..", PHP_EOL;
$command = 'wget --no-check-certificate --timeout=15 -nc -c --tries=1 --user-agent="' . $agent . '" -O' . $newUnicfilename . ' "' . $url . '" -e use_proxy=yes -e http_proxy=' . $proxi;
echo $command;
exec($command, $out, $result);
if ($result == 0) {
Image::markImageAsDone($image->id, $newUnicfilenameShot);
} else {
echo "error code= " . $result, PHP_EOL;
if($result == 8){
// �������� ��� ���������
Image::markImageAsDone($image->id, $newUnicfilenameShot);
echo "Marked as downloaded", PHP_EOL;
}
}
}
echo "Downloaded " . $i . " images.", PHP_EOL;
} else {
echo "All images are downloaded allready.", PHP_EOL;
}
}
}
public function actionDownload()
{
$imageModel = Image::getNotDownloadingPicturesYet();
if ($imageModel) {
$i = 0;
foreach ($imageModel as $image) {
$i++;
$agent = Main::getRandomAgent();
$proxi = Main::getRandomProxi();
$url = str_replace(" ", "%20", trim($image->url));
if (strripos($url, "Mobile-Homes/ShowThumbnail.php")) {
$url = str_replace("Mobile-Homes/ShowThumbnail", "GetPhoto", $url);
}
$path = trim($image->state) . '/' . trim($image->zip) . '/' . trim($image->house_id);
$timeout = rand(1, 3);
$Unicname = uniqid() . '.' . 'jpg';
$newUnicfilename = 'frontend/web/static/images/' . $path . '/' . $Unicname;
$newUnicfilenameShot = $path . '/' . $Unicname;
if (!file_exists('frontend/web/static/images/' . $path . '/')) {
mkdir('frontend/web/static/images/' . $path . '/', 0777, true);
}
echo "Waiting " . $timeout . " seconds...", PHP_EOL;
sleep($timeout);
echo "#ImageDownload..", PHP_EOL;
$out = '';
$result = '';
echo "download..", PHP_EOL;
$command = 'wget --no-check-certificate --timeout=15 -nc -c --tries=1 --user-agent="' . $agent . '" -O' . $newUnicfilename . ' "' . $url . '" -e use_proxy=yes -e http_proxy=' . $proxi;
echo $command;
exec($command, $out, $result);
if ($result == 0) {
Image::markImageAsDone($image->id, $newUnicfilenameShot);
} else {
echo "error code= " . $result, PHP_EOL;
}
}
echo "Downloaded " . $i . " images.", PHP_EOL;
} else {
echo "All images are downloaded allready.", PHP_EOL;
}
}
}