Files
Testing/include/seantest1.php

279 lines
7.5 KiB
PHP
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
<?php
//require("header.php");
use Aws\Exception\MultipartUploadException;
use Aws\S3\MultipartUploader;
use Aws\S3\ObjectUploader;
use Aws\S3\S3Client;
//ini_set('display_errors', true);
//set_time_limit(0);
//error_reporting(E_ALL^E_NOTICE^E_WARNING);
//if(!SE_DEBUG1){exit;}
$query=$database->database_query("SELECT * FROM se_users WHERE user_photo LIKE '%.%' LIMIT 1");
$x=0;
while($row=$database->database_fetch_array($query)){echo $x." ";
$width=null;
$height=null;
$size=null;
$imageData=null;
$photo=explode(".", $row["user_photo"]);
$imageUrl = "https://cloudcdn.bateworld.com/".str_replace("./", "", $url->url_userdir($row["user_id"])).$photo[0]."_thumb.".$photo[1];
$imageUrl1 = "https://cloudcdn.bateworld.com/".str_replace("./", "", $url->url_userdir($row["user_id"])).$photo[0].".".$photo[1];
$destination=str_replace("./", "", $url->url_userdir($row["user_id"])).$photo[0]."_thumb.".$photo[1];
echo " ".$destination." ";
// Local path to save the processed image
$localPath = 'temp_uploads/new/'.$photo[0].".".$photo[1];
$thumb = 'temp_uploads/new/'.$photo[0]."_thumb.".$photo[1];
// cURL initialization
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $imageUrl);
// Set the referrer
curl_setopt($ch, CURLOPT_REFERER, 'https://bateworld.com');
// Set the return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, false); // Only fetch headers
// Execute cURL and get the image data
$imageData = curl_exec($ch);
// Close cURL
curl_close($ch);
//if ($imageData)
{
//echo $localPath." ";
// Save the image data to a local file
//
$size=getimagesizefromstring($imageData);
$width=$size[0];
$height=$size[1];
echo $width;
if($width<300||$width==""){
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $imageUrl1);
// Set the referrer
curl_setopt($ch, CURLOPT_REFERER, 'https://bateworld.com');
// Set the return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Execute cURL and get the image data
$imageData = curl_exec($ch);
// Close cURL
curl_close($ch);
file_put_contents($localPath, $imageData);
$size=getimagesize($localPath);
$width=$size[0];
$height=$size[1];
//if($width==""){$width=$width1;}
//if($height==""){$height=$height1;}
//if(SE_DEBUG){mail("leprakhauns@gmail.com", "ccc",$exact);}
/*if($height>300){
$div=$height/300;
$newwidth=$width/$div;
$newheight=$height/$div;
$foo="change";
}
if($newwidth>300){
$div=$newwidth/300;
$newwidth=$newwidth/$div;
$newheight=$newheight/$div;
$foo="change";
}*/
if($width>300||$height>300)
{
if($width>300)
{$newheight="x300";}
elseif($height>300)
{
$newheight="300x";
}
else{$newheight=$width."x".$height;
}
$change=1;
}
// if($foo=="change"){
// Process the image with ImageMagick
$command = escapeshellcmd("/usr/bin/convert -auto-orient '{$localPath}' '{$thumb}'");
exec($command, $output, $return_var);
//var_dump($output);
system(escapeshellcmd("/usr/bin/convert -strip -size {$width}x{$height} '". $thumb."' -resize {$newheight} '". $thumb."'"), $array);
//var_dump($array);
$client = new MyS3Wrapper([
'region' => 'us-north-1',
'version' => 'latest',
'endpoint' => ENDPOINT,
'credentials' => [
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY
],
// Set the S3 class to use objects.dreamhost.com/bucket
// instead of bucket.objects.dreamhost.com
'use_path_style_endpoint' => true
]);
//$source = fopen(str_replace("./", "",$photo_dest), 'rb');
if(file_exists("temp_uploads/".str_replace("/", "", str_replace("./", "", $thumb)))){
$source = fopen($thumb, 'rb');
$uploader = new ObjectUploader(
$client,
'bateworld',
$destination,
$source
);
do {
try {
$result = $uploader->upload();
if ($result["@metadata"]["statusCode"] == '200') {
$database->database_query("UPDATE se_users SET thumbchecked=1 WHERE user_id='".$row["user_id"]."'");
}
//print($result);
// If the SDK chooses a multipart upload, try again if there is an exception.
// Unlike PutObject calls, multipart upload calls are not automatically retried.
} catch (MultipartUploadException $e) {
rewind($source);
$uploader = new MultipartUploader($client, $source, [
'state' => $e->getState(),
]);
}
} while (!isset($result));
fclose($source);
//$database->database_query();
}
}else{$database->database_query("UPDATE se_users SET thumbchecked=1 WHERE user_id='".$row["user_id"]."'");}
}
echo "<br>";
$x++;
}
exit;
$client = new MyS3Wrapper([
'region' => 'us-north-1',
'version' => 'latest',
'endpoint' => ENDPOINT,
'credentials' => [
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY
],
// Set the S3 class to use objects.dreamhost.com/bucket
// instead of bucket.objects.dreamhost.com
'use_path_style_endpoint' => true
]);
$objects = $client->getIterator('ListObjects', [
'Bucket' => "bateworld"
//'Prefix' => "bate_videos"
]);
$x=0;
foreach ($objects as $object) {
if($x>100){exit;}
var_export($object);
$x++;
}
exit;
$url = "https://cloudcdn.bateworld.com/uploads_user/448000/447417/2104332_thumb.jpg";
$referer = "https://bateworld.com";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_NOBODY, false); // Only fetch headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Referer: $referer"));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
$imageData = curl_exec($ch);
//echo $imageData;
// Get headers as an associative array
//$headers = curl_getinfo($ch);
//print_r($headers);
if ($imageData) {
// Get the dimensions from the image data
$imageInfo = getimagesizefromstring($imageData);
if ($imageInfo) {
$width = $imageInfo[0]; // Image width
$height = $imageInfo[1]; // Image height
echo "Width: " . $width . "px\n";
echo "Height: " . $height . "px\n";
} else {
echo "Failed to determine image dimensions.";
}
} else {
echo "Failed to fetch the image.";
}
curl_close($ch);
exit;
$query=$database->database_query("SELECT * FROM se_users LEFT JOIN se_profilevalues ON profilevalue_user_id=user_id WHERE user_verified=0 AND user_photo='' AND (profilevalue_13='' AND profilevalue_27='' AND profilevalue_29='') AND user_signupdate>='".strtotime("12AM 2 days ago")."' AND user_signupdate<='".strtotime("11:59:59PM 2 days ago")."'");
while($row=$database->database_fetch_array($query))
{
echo $row["user_username"]."<br>";
}
echo strtotime("12AM 2 days ago")."<br>";
echo strtotime("11:59:59PM 2 days ago")."<br>";
exit;
$query=$database->database_query("SELECT * FROM se_he_user_note WHERE viewer_id=0");
while($row=$database->database_fetch_array($query)){
$database->database_query("INSERT INTO bateworldcom_wall.notes SET user_id='".$database->database_real_escape_string($row["user_id"])."', note='".$database->database_real_escape_string($row["note"])."', date='".time()."'");
}
exit;