| Server IP : 172.67.178.83 / 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/gotofindhomes.com/ |
Upload File : |
<pre>
<?php
require_once "lib/dbmysql.class.php";
// if($_SERVER['REMOTE_ADDR']!='204.12.241.146'){
// exit;
// }
error_reporting(E_ALL);
$db = new DbMySQL("localhost", "corbizrealestate", "corbizrealestate", "WAotraUcM5M8aA");
if(!$db->connect()){
header('HTTP/1.0 500 Internal Server Error');
exit;
}
$objClient = new MongoClient("mongodb://dsh7.crimeaonline.net:27017");
$objDb = $objClient->selectDB('rrestated_production');
$objCollectionHouses = $objDb->selectCollection('houses');
//print_r($house);
?>
<?php
//print_r($house['image_ids']);
$objCollectionImages = $objDb->selectCollection('images');
$sql = "SELECT count(*) as houses_count FROM houses WHERE ID not in (select AssignID from images where Active=1 and Assign='House') and `Source`<>13";
//$sql = "SELECT count(*) as houses_count FROM houses WHERE ID=1005103";
$houses_count = $db->select_row($sql);
echo "HOUSES for UPDATE:".$houses_count['houses_count']."\n";
$processing = 10;
echo $iterations_number = ceil($houses_count['houses_count'] / $processing);
echo "\n";
$i=0;
for ($iteration = 0; $iteration < $iterations_number; $iteration++) {
$sql = "SELECT * FROM houses WHERE ID not in (select AssignID from images where Active=1 and Assign='House') and `Source`<>13 order by ID desc LIMIT ".($iteration * $processing).",".$processing;
//$sql = "SELECT * FROM houses WHERE ID=1005103";
$houses = $db->select($sql);
foreach($houses as $key=>$house){
$house1 = $objCollectionHouses->findOne(array('_id' => new MongoId($house['ExternalID'])));
if(isset($house1['image_ids'])){
echo "HOUSE images:".$house['ID']." im count - ".(count($house1['image_ids']))."\n";
foreach ($house1['image_ids'] as $key=>$image){
$image1 = $objCollectionImages->findOne(array('_id' =>$image));
if (isset($image1['url'])){
exec("mkdir -m 755 -p /home/corbizrealestate/public_html/images/upload2/".$house['State']."/".$house['Zip']."/".encodeID($house['ID']));
//proxy 144.76.33.130 12001 - 12070
$primary =0;
if ($key==0) {
$primary = 1;
}
usleep(rand(1000,300000));
echo("wget -o/home/corbizrealestate/public_html/images/upload2/wget.log.txt -e use_proxy=yes -e http_proxy=http://144.76.33.130:".rand(12001, 12070)." -O/home/corbizrealestate/public_html/images/upload2/".$house['State']."/".$house['Zip']."/".encodeID($house['ID'])."/".($key+1).".jpg \"".$image1['url']."\"\n");
exec("wget -o/home/corbizrealestate/public_html/images/upload2/wget.log.txt -e use_proxy=yes -e http_proxy=http://144.76.33.130:".rand(12001, 12070)." -O/home/corbizrealestate/public_html/images/upload2/".$house['State']."/".$house['Zip']."/".encodeID($house['ID'])."/".($key+1).".jpg \"".$image1['url']."\"");
echo $image_path = "/images/upload2/".$house['State']."/".$house['Zip']."/".encodeID($house['ID'])."/";
$file_name = ($key+1).".jpg";
echo "\n";
$mongo_id = $image1['_id']->{'$id'};
$img_info = getimagesize("/home/corbizrealestate/public_html".$image_path.$file_name);
//print_r($img_info);
if($img_info){
$db->insert("INSERT IGNORE INTO houses_simages (house_id,house_image_path,status,mongo_id) values('".$house['ID']."','$image_path.$file_name',1,'$mongo_id')");
$imageid = $db->insert("INSERT IGNORE INTO images (`Name`, `Assign`, `AssignID`, `File`, `Path`, `Primary`, `Active`, `ExternalSourceID`,`Width`,`Height`, `ExternalImageID`)
values('".mysql_escape_string($house['Address'])." image #".($key+1)."',
'House',
'".$house['ID']."',
'$file_name',
'$image_path',
'$primary',
1,
2,
'".$img_info[0]."',
'".$img_info[1]."',
'$mongo_id')");
if($key==0){
$myimage = resizeImage("/home/corbizrealestate/public_html".$image_path.$file_name, '140', '105');
imagejpeg($myimage,"/home/corbizrealestate/public_html".$image_path."/".($key+1)."-140x105.jpg");
$db->insert("INSERT IGNORE INTO images_thumbs (`Name`, `File`, `Path`,`Width`,`Height`,`ExternalSourceID`,`Image_ID`)
values('".mysql_escape_string($house['Address'])." image #".($key+1)."',
'".($key+1).'-140x105.jpg'."',
'$image_path',
'140',
'105',
2,
$imageid)");
}
if($house['ID']==1005103){
echo ("INSERT IGNORE INTO images (`Name`, `Assign`, `AssignID`, `File`, `Path`, `Primary`, `Active`, `ExternalSourceID`,`Width`,`Height`, `ExternalImageID`)
values('".mysql_escape_string($house['Address'])." image #".($key+1)."',
'House',
'".$house['ID']."',
'$file_name',
'$image_path',
'$primary',
1,
2,
'".$img_info[0]."',
'".$img_info[1]."',
'$mongo_id')");
}
}
if($key==4){
break;
}
usleep(rand(1000,300000));
}
}
}else{
echo "\nNo images:".$house['ID']."\n";
}
}
}
?>
</pre>
<?php
function encodeID($ID, $CompanyID = null) {
$CompanyID = 9;
$md5 = md5($CompanyID + $ID);
$sum = ord($md5[0]) + ord($md5[5]) * ord($md5[15]) + ord($md5[25]);
$strSum = (string) $sum;
if (strlen($strSum) > 3) {
$strSum = substr($strSum, 0, 3);
} else {
$strSum = str_pad($strSum, 3, '0', STR_PAD_BOTH);
}
$strCompany = (string) $CompanyID;
if (strlen($strCompany) > 4) {
$strCompany = substr($strCompany, 0, 4);
} else {
$strCompany = str_pad($strCompany, 4, '0', STR_PAD_BOTH);
}
return $strCompany . $ID . $strSum;
}
function resizeImage($filename, $max_width, $max_height)
{
list($orig_width, $orig_height) = getimagesize($filename);
$width = $orig_width;
$height = $orig_height;
# taller
if ($height > $max_height) {
$width = ($max_height / $height) * $width;
$height = $max_height;
}
# wider
if ($width > $max_width) {
$height = ($max_width / $width) * $height;
$width = $max_width;
}
$image_p = imagecreatetruecolor($width, $height);
switch(substr($filename,strrpos($filename,".")+1))
{
case 'png':
$iTmp = imagecreatefrompng($filename);
break;
case 'gif':
$iTmp = imagecreatefromgif($filename);
break;
case 'jpeg':
case 'jpg':
$iTmp = imagecreatefromjpeg($filename);
break;
}
imagecopyresampled($image_p, $iTmp, 0, 0, 0, 0,$width, $height, $orig_width, $orig_height);
return $image_p;
}
?>