$uniq_session=$_SESSION["uniq_session"]=session_id(); if($_SERVER["HTTP_HOST"]=='localhost') { $main_url="http://localhost/ayoub-auto/"; $main_path="D:/wamp/www/ayoub-auto/"; } else { $domain_url="http://ayoubauto.com.eg/"; $main_url="http://ayoubauto.com.eg/"; $main_path="/home/ayoubeg/public_html/"; } define( 'API_ACCESS_KEY', 'AIzaSyBCM7rKWh9NeIREt32xB8PpM6GHVkmypWg' ); $G_API_KEY="AIzaSyAG8fv6oTsrBI5rggPdr3IzFay-W6oGeAQ"; $item_id=(int)$_GET["item_id"]; ?> if($_SERVER["HTTP_HOST"]=='localhost') { $db = new PDO('mysql:host=localhost;dbname=ayoub;charset=utf8mb4', 'root', ''); } else { $db = new PDO('mysql:host=localhost;dbname=ayoubeg_db;charset=utf8mb4', 'ayoubeg_deep', 'Egypt#2018'); } ?> class ClassUpload { ///////////////////////////////////////////////////////////// function update_images($inserted_id,$hash_id) { global $db; $sql="update images set `ItemID`='{$inserted_id}' where `ItemID`='{$hash_id}' "; $query=$db->query($sql); return true; } ///////////////////////////////////////////////////////////// function get_extention($file) { $mimes = array( 'application/msword' =>'doc' , 'application/x-zip-compressed' =>'rar' , 'application/octet-stream' => 'docx', 'application/pdf' => 'pdf' , 'application/x-shockwave-flash' => 'swf' , 'application/x-tar' =>'tar', 'application/x-tar' =>'tgz' , 'application/xhtml+xml' => 'xhtml', 'application/zip' => 'zip' , 'audio/midi' => 'mid', 'audio/mpeg' => 'mp3' , 'audio/x-aiff' => 'aif', 'audio/mpeg' => 'mpga', 'audio/x-aiff' => 'aiff' , 'audio/x-pn-realaudio' => 'ram' , 'audio/x-pn-realaudio-plugin' => 'rpm' , 'audio/x-realaudio' => 'ra' , 'video/vnd.rn-realvideo' => 'rv' , 'audio/x-wav' => 'wav' , 'image/bmp' => 'bmp' , 'image/gif' => 'gif' , 'image/jpeg' => 'jpg' , 'image/pjpeg' => 'jpg' , 'image/png' => 'png' , 'image/x-png' => 'png' , 'image/tiff' => 'tiff' , 'text/css' => 'css' , 'text/html' => 'html' , 'text/plain' => 'text' , 'text/rtf' => 'rtf' , 'text/xml' => 'xsl' , 'video/mpeg' => 'mpg' , 'video/quicktime' => 'mov' , 'video/x-msvideo' => 'avi' , 'video/x-ms-wmv' => 'avi' , 'video/avi' => 'avi' , 'video/x-sgi-movie' => 'movie' , 'application/msword' => 'doc' , 'application/excel' => 'xl' , 'application/vnd.openxmlformats-office' => 'docx' , 'document.wordprocessingml.document' => 'docx' , 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx' ); $file_type=$_FILES[$file]["type"]; if(!empty($mimes[$file_type])) { return $mimes[$file_type]; } else echo ($file_type); return false; } ///////////////////////////////////////////////////////////// function gen_name($length){ $password=""; srand((double)microtime()*1000000); $vowels = array("a", "e", "i", "o", "u"); $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl"); $num_vowels = count($vowels); $num_cons = count($cons); for($i = 0; $i < $length; $i++){ $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; } return substr($password, 0, $length); } ///////////////////////////////////////////////////////////// function gen_pass($length){ $l=rand(0,$length); $s=rand(0,$length); $x=rand(0,$length); $y=rand(0,$length); $chosen=array($l,$s,$x,$y); $password=""; srand((double)microtime()*1000000); $vowels = array("A","E","I","O","U"); $chars = array("@","#","$","!","^","*","_"); $cons = array("b","c","d","g","h","j","k","l","m","n","p","r","s","t","u","v","w","tr","cr","br","fr","th","dr","ch","ph","wr","st","sp","sw","pr","sl","cl"); $num_vowels = count($vowels); $num_chars = count($chars); $num_cons = count($cons); for($i = 0; $i < $length; $i++){ if($i==$l || !in_array($i,$chosen) && $i%2==0) $password .= $cons[rand(0,$num_cons-1)]; if($i==$s) $password .= $chars[rand(0,$num_chars-1)]; if($i==$x || !in_array($i,$chosen) && $i%2==1) $password .= rand(1,7); if($i==$y ) $password .= $vowels[rand(0, $num_vowels - 1)]; } return $password; } ///////////////////////////////////////////////////////////// function checkExtensions($this_extension,$type) { global $main_url; if($type=="images") $allowedExtensions=array("gif", "jpg", "jpe", "jpeg","png","bmp"); if($type=="word") $allowedExtensions=array('doc','docx','rtf','word','pdf','avi','wmv','mov','mp4'); if($type=="ads") $allowedExtensions=array("gif", "jpg", "jpe", "jpeg","png","bmp","swf"); if($type=="video") $allowedExtensions=array('ram','mpeg','mp3','mp4','3gp','mov','avi'); if($type=="pdf") $allowedExtensions=array("pdf"); if($type=="file") $allowedExtensions=array("pdf","gif", "jpg", "jpe", "jpeg","png","bmp",'doc','docx','rtf','word','pdf','avi','wmv','mov','mp4','ram','mpeg','mp3','mov','avi'); foreach ($allowedExtensions as $key => $extension) { if (strtolower($extension) == strtolower($this_extension)) { return true; } } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// function upload($file1,$type='images') { global $main_path; $randname=$this->gen_name(4).time(); $extinsion=explode('.',$_FILES[$file1]['name']); $ext=$extinsion[(count($extinsion)-1)]; if($this->checkExtensions($ext,$type)) { $src_path='image'.$randname.'.'.$ext; move_uploaded_file($_FILES[$file1]['tmp_name'],$main_path."uploaded/".$src_path); if(!is_file($main_path."uploaded/".$src_path)) { ?> exit(); } else { return $src_path; } } else { $this->alert("sorry this extension is not allowed".$ext); } } function multi_upload($upload_type,$uid) { ?>