Gd: Intel Dual Xeon e5-2670v2 | 128 GB of DDR3 | 2 x 500 GB SSD | Dallas

George Datacenter LLC

******Properties*******

– 1GBPS port speed is included.
– We all own our own hardware
– Data Center Dallas | Colocation Chicago
– 100% SLA for network uptime
– Free basic DDoS mitigation
– rDNA available
– Full root access
– 99.99% availability guarantee
– Payments by Paypal

Our main goal is to provide the best quality to small customers

Today we have our offer of the day

**** DEDICATED SERVER BASIC ****

INTEL DUAL XEON E5-2670V2
Unmeasured bandwidth
1Gigabit port
128 GB RAM
2 x 500 GB SSD
05 IPS IPV4

$ 250.00

assignment

**** DEDICATED SERVER STANDARD ****

INTEL XEON E5-2620
10 TB bandwidth
1Gigabit port
64 GB RAM
4 x 1 TB SSD
05 IPS IPV4

299.00 USD

assignment

Limited number.

If you have questions about our services, please contact sales@georgedatacenter.com.

php – upload image with GD library

First of all, I just started learning OOP.

My priority is to create a secure code. I think my code is safe because I use GD to make a copy of the uploaded image, and use an image proxy to make sure no one can directly access the uploaded file and upload it outside the webroot, but if 100% was sure it was safe, I did not post it here haha. I'm not sure how to check the MIME type and what the DG is about.

I have done some tests and it works fine, but what do you think? Suggestions are welcome. Even if you have any doubt about the code, just ask me in the comments.

Class Img:

class Img
{
private static $ folder, $ file, $ ext, $ w, $ h;

upload public static function ($ file, $ new_size) {
self :: $ ext = pathinfo ($ file["name"], PATHINFO_EXTENSION);
list (self :: $ w, self :: $ h) = ($ size = getimagesize ($ file["tmp_name"]));

if (! $ size ||! in_array (self :: $ ext, ['png', 'jpeg', 'jpg'])) the (json_encode (['error' => 'Invalid file']));
if (file size ($ file["tmp_name"])> 2700000) the (json_encode (['error' => 'File is too big']));

self :: $ folder = dirname (__ DIR __). & # 39; / .. / .. / uploads / profile /'.$_ SESSION['user_folder'];
self :: $ file = $ file["tmp_name"];

$ _SESSION['avatar'] = ($ name = mt_rand (100, 100000). & # 39; - & # 39; time (). & 39 ;. self :: $ ext);
self :: resize_image ($ name, $ new_size, $ new_size);

$ user_id = $ _SESSION['user_id'];
$ conn =  lib  Db :: instance ();
$ query = $ conn-> query ("UPDATE user SET avatar = # {$ name} # WHERE user_ID = # {user ID} #);
$ conn = NULL;

the (json_encode ([#39;avatar'=$>_SESSION['Avatar'=$>_SESSION['avatar'=>$_SESSION['avatar'=>$_SESSION['avatar']]));
}

private static function resize_image ($ name, $ width, $ height) {
if (self :: $ ext === & # 39; jpeg & # 39;) self :: $ ext = & # 39; jpg & # 39 ;;

if (self :: $ ext === & # 39; jpg & # 39;) $ img = imagecreatefromjpeg (self :: $ file);
elseif (self :: $ ext === & # 39; png & # 39;) $ img = imagecreatefrompng (self :: $ file);

$ ratio = max ($ width / self :: $ w, $ height / self :: $ h);
$ x = (self :: $ w - $ width / $ ratio) / 2;
self :: $ h = $ height / $ ratio;
self :: $ w = $ width / $ ratio;

$ new = imagecreatetruecolor ($ width, $ height);

// Preserve transparency
if (self :: $ ext === "png"):
imagecolortransparent ($ new, imagecolorallocatealpha ($ new, 0, 0, 0, 127));
imagealphablending ($ new, false);
imagesavealpha ($ new, true);
endif;

imagecopyresampled ($ new, $ img, 0, 0, $ x, 0, $ width, $ height, self :: $ w, self :: $ h);

if (self :: $ ext === & # 39; jpg & # 39;) imagejpeg ($ new, self :: $ folder. $ name);
elseif (self :: $ ext === & # 39; png & # 39;) imagepng ($ new, self :: $ folder. $ name);
Imagedestroy ($ new);
}
}

avatar_upload.php:

require_once dirname (__ DIR __). & # 39; / .. / .. / vendor / autoload.php & # 39 ;;

if (! isset ($ _ SESSION)) session_start ();
if ($ _ SERVER['REQUEST_METHOD'] ! = & # 39; POST & # 39; || empty ($ _ SESSION['user_id'])) the (header (& # 39; HTTP / 1.1 404 Not Found & # 39;);
if (! empty ($ _ FILES['avatar']['size']))  lib  Img :: upload ($ _ FILES["avatar"]150);

Buy / Sell Target, Best Buy, Apple, Itunes, Amazon, Ebay, All kinds of Walmart, Gd; All In

Buy / Sell the following quantities daily:
Immediate fast and reliable exchange.
Best price & immediate exchange!

Amazon Gift Cards
Itunes gift cards
Ebay gift cards
Apple Store Gift Cards
Google plays gift cards
Best Buy Gift Cards
GameStop gift cards
Target Gift Cards
Macy's Gift Card
Hotels.com gift card
Playstation Network Gift Cards
Xbox gift cards
Walmart
| steam
Moneypak
Onevanilla
Northern Storm gift cards
Gobank
GameStop gift cards
AMEX gift card
HOME DEPOT GIFT CARDS
ALIPAY (CNY)
Neosurf EUR, GBP

* Rate is negotiated in the chat!
* Looking for a long-term cooperation!
* If you want to communicate with me, contact me via my Icq Whatsapp Telegram.

* ICQ> 689899989
* Whatsapp +37258946164
* Telegram @Maxkovnik
* Skype aarongood25

This post has been edited by Armivanbuuren: Today, 2:00 pm