ÿØÿà JFIF ÿÛ „ ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/sharefilefree/jqu/ |
<?php require '../vendor/autoload.php'; function getClient() { $client = new Google_Client(); $client->setApplicationName('Google Drive API PHP Quickstart'); $client->setScopes(Google_Service_Drive::DRIVE); $client->setAuthConfig('../giangnn30.json'); $client->setAccessType('offline'); $client->setPrompt('select_account consent'); // Load previously authorized token from a file, if it exists. // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. $tokenPath = '../data/token.json'; if (file_exists($tokenPath)) { $accessToken = json_decode(file_get_contents($tokenPath), true); $client->setAccessToken($accessToken); } // If there is no previous token or it's expired. if ($client->isAccessTokenExpired()) { // Refresh the token if possible, else fetch a new one. if ($client->getRefreshToken()) { $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); } else { // Request authorization from the user. /*$authUrl = $client->createAuthUrl(); printf("Open the following link in your browser:\n%s\n", $authUrl); print 'Enter verification code: '; exit();*/ //$authCode = trim(fgets(STDIN)); $authCode = '4/0AX4XfWg5Mx2kEr55X7P77sd_upRb0MVZoyIQdaHMyk3g5TiP7xIgvk5V1UiM4mezBuEjoQ'; //$authCode = $_GET['code']; // Exchange authorization code for an access token. $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); $client->setAccessToken($accessToken); // Check to see if there was an error. if (array_key_exists('error', $accessToken)) { throw new Exception(join(', ', $accessToken)); } } // Save the token to a file. if (!file_exists(dirname($tokenPath))) { mkdir(dirname($tokenPath), 0777, true); } file_put_contents($tokenPath, json_encode($client->getAccessToken())); } return $client; } include_once("../config.php"); include("../classes/sfs.class.php"); $SFS = new SFS($config); $config = $SFS->config; include_once("../functions.php"); /*if (!preg_match("|^" . $config->instUrl . '/|', $_SERVER["HTTP_REFERER"])) { exit("illegal access"); }*/ $client = getClient(); $service = new Google_Service_Drive($client); //Insert a file error_reporting(E_ALL | E_STRICT); //SFS PHP ERROR CHECKS [+] $numFiles = isset($_FILES["files"]) ? count($_FILES["files"]["name"]) : 0; //multiple file upload not allowed if (!$config->multiUpload && $numFiles > 1) { exit("Files Count Error: You are only allowed to upload one single file at once!"); } //maximum number exceeded elseif ($numFiles > $config->maxMultiFiles) { exit("Files Count Error: Only " . $config->maxMultiFiles . " files can be uploaded at once."); } //file size and extension error checks $sizeErrorFiles = $extDeniedFiles = array(); $folderId = $drive_folder_id; for ($i=0;$i<$numFiles;$i++) { if ($_FILES["files"]["size"][$i]/1024/1024 > $config->maxFileSize) $sizeErrorFiles[] = $_FILES["files"]["name"][$i]; //extensions check $matches = array(); preg_match('/\.([^\.]*)$/',$_FILES["files"]["name"][$i],$matches); $ext = null; if (isset($matches[1])) { $ext = strtolower($matches[1]); } else { $ext = "unknown"; } //denied extensions if ($config->extDeniedArray && in_array($ext, $config->extDeniedArray)) $extDeniedFiles[] = $_FILES["files"]["name"][$i]; //not allowed extension elseif ($config->extAllowedArray && !in_array($ext, $config->extAllowedArray)) $extDeniedFiles[] = $_FILES["files"]["name"][$i]; } //file size errors found if ($sizeErrorFiles) { exit ("At least one of the files exceeds the maximum allowed filesize of " . $config->maxFileSize . " MB! Affected file(s): " . implode(", ",$sizeErrorFiles)); } if ($extDeniedFiles) { exit ("At least one of the files has a not allowed file extension! Affected file(s): " . implode(", ",$extDeniedFiles)); } for ($i=0;$i<$numFiles;$i++) { $v_tmp_file_size = $_FILES["files"]["size"][$i]; $v_tmp_file_type = $_FILES["files"]["type"][$i]; $v_tmp_file_name = $_FILES["files"]["name"][$i]; //extensions check $matches = array(); preg_match('/\.([^\.]*)$/',$_FILES["files"]["name"][$i],$matches); $ext = null; if (isset($matches[1])) { $ext = strtolower($matches[1]); } else { } $v_file_name = str_replace(".".$ext,"",$v_tmp_file_name); $v_file_name = convert_utf8_to_kd($v_file_name); $v_file_name = remove_invailid_char($v_file_name); $v_file_name = strtolower($v_file_name); $v_file_name = $v_file_name."_".uniqid().".".$ext; $v_file_name = substr($v_file_name,-199); $fileMetadata = new Google_Service_Drive_DriveFile(array( //Set the Random Filename 'name' => $v_file_name, //Set the Parent Folder 'parents' => array($folderId) // this is the folder id )); $createdFile = $service->files->create($fileMetadata, array( 'data' => file_get_contents($_FILES["files"]["tmp_name"][$i]), 'mimeType' => $v_tmp_file_type, 'uploadType' => 'media' )); $fileId = $createdFile->id; //insert db $sql = "update `" . $SFS->config->tablePrefix . "overall_stats` set uploads = uploads + 1, u_size = u_size + " . intval($v_tmp_file_size) . " where id = 1"; $SFS->dbquery($sql); //generate new short download keys $shortkey = $SFS->getUniqKey(); $fname = $v_file_name; $sql = "insert into `" . $SFS->config->tablePrefix . "files` set uid = '" . get_user_id() . "', fname = " . $SFS->dbquote($fname) . ", ftype = " . $SFS->dbquote($v_tmp_file_type) . ", fsize = '" . intval($v_tmp_file_size) . "', descr = " . $SFS->dbquote($v_tmp_file_name) . ", status = 1, created = now(), last_download = now(), u_key = " . $SFS->dbquote(trim($_REQUEST["u_key"])) . ", shortkey = " . $SFS->dbquote($shortkey)." , drive_id= '".$fileId."' " ; $SFS->dbquery($sql); $id = mysqli_insert_id($SFS->db); $fileKeys = $SFS->genFileKeys($id); $arr_return = array($shortkey,$fileKeys[1]); $arr = array ( 'files' => array ( 0 => array ( 'name' => $fname, 'size' => intval($v_tmp_file_size), 'type' => $v_tmp_file_type, 'niceSize' => fsize(intval($v_tmp_file_size)), 'realName' =>$v_tmp_file_name, 'fileKey' => $shortkey, 'delFileKey' => $fileKeys[1], 'delete_url' => 'https://freesharefile.com/jqu/?file='.$fname, 'delete_type' => 'DELETE', ), ), ); echo json_encode($arr); //echo '{"files":[{"name":"6a2569fc8e63f00df1e15b09cb661cee.jpg","size":889357,"type":"image\/jpeg","niceSize":"868.51 KB","realName":"6111e315495d9_z265715462495982faf4b305815482.jpg","fileKey":"dB9mS","delFileKey":"1d6718078915dbc37f1c403b070c1342","delete_url":"https:\/\/sfs.hom.ac\/jqu\/?file=6a2569fc8e63f00df1e15b09cb661cee.jpg","delete_type":"DELETE"}]}'; //echo json_encode($arr_return); } function get_user_id() { @session_start(); if(!isset($_SESSION['uid']) or intval($_SESSION['uid'])==0){ return 0; } return $_SESSION['uid']; } function convert_utf8_to_kd($str){ $arr_sour_char_code=array(); $arr_dest_char_code=array(); $arr_sour_char_code[1]=chr(195).chr(129); $arr_dest_char_code[1]="a"; $arr_sour_char_code[2]=chr(195).chr(128); $arr_dest_char_code[2]="a"; $arr_sour_char_code[3]=chr(225).chr(186).chr(162); $arr_dest_char_code[3]="a"; $arr_sour_char_code[4]=chr(195).chr(131); $arr_dest_char_code[4]="a"; $arr_sour_char_code[5]=chr(225).chr(186).chr(160); $arr_dest_char_code[5]="a"; $arr_sour_char_code[6]=chr(195).chr(161); $arr_dest_char_code[6]="a"; $arr_sour_char_code[7]=chr(195).chr(160); $arr_dest_char_code[7]="a"; $arr_sour_char_code[8]=chr(225).chr(186).chr(163); $arr_dest_char_code[8]="a"; $arr_sour_char_code[9]=chr(195).chr(163); $arr_dest_char_code[9]="a"; $arr_sour_char_code[10]=chr(225).chr(186).chr(161); $arr_dest_char_code[10]="a"; $arr_sour_char_code[11]=chr(195).chr(130); $arr_dest_char_code[11]="a"; $arr_sour_char_code[12]=chr(225).chr(186).chr(164); $arr_dest_char_code[12]="a"; $arr_sour_char_code[13]=chr(225).chr(186).chr(166); $arr_dest_char_code[13]="a"; $arr_sour_char_code[14]=chr(225).chr(186).chr(168); $arr_dest_char_code[14]="a"; $arr_sour_char_code[15]=chr(225).chr(186).chr(170); $arr_dest_char_code[15]="a"; $arr_sour_char_code[16]=chr(225).chr(186).chr(172); $arr_dest_char_code[16]="a"; $arr_sour_char_code[17]=chr(195).chr(162); $arr_dest_char_code[17]="a"; $arr_sour_char_code[18]=chr(225).chr(186).chr(165); $arr_dest_char_code[18]="a"; $arr_sour_char_code[19]=chr(225).chr(186).chr(167); $arr_dest_char_code[19]="a"; $arr_sour_char_code[20]=chr(225).chr(186).chr(169); $arr_dest_char_code[20]="a"; $arr_sour_char_code[21]=chr(225).chr(186).chr(171); $arr_dest_char_code[21]="a"; $arr_sour_char_code[22]=chr(225).chr(186).chr(171); $arr_dest_char_code[22]="a"; $arr_sour_char_code[23]=chr(225).chr(186).chr(173); $arr_dest_char_code[23]="a"; $arr_sour_char_code[24]=chr(196).chr(130); $arr_dest_char_code[24]="a"; $arr_sour_char_code[25]=chr(225).chr(186).chr(174); $arr_dest_char_code[25]="a"; $arr_sour_char_code[26]=chr(225).chr(186).chr(176); $arr_dest_char_code[26]="a"; $arr_sour_char_code[27]=chr(225).chr(186).chr(178); $arr_dest_char_code[27]="a"; $arr_sour_char_code[28]=chr(225).chr(186).chr(180); $arr_dest_char_code[28]="a"; $arr_sour_char_code[29]=chr(225).chr(186).chr(182); $arr_dest_char_code[29]="a"; $arr_sour_char_code[30]=chr(196).chr(131); $arr_dest_char_code[30]="a"; $arr_sour_char_code[31]=chr(225).chr(186).chr(175); $arr_dest_char_code[31]="a"; $arr_sour_char_code[32]=chr(225).chr(186).chr(177); $arr_dest_char_code[32]="a"; $arr_sour_char_code[33]=chr(225).chr(186).chr(179); $arr_dest_char_code[33]="a"; $arr_sour_char_code[34]=chr(225).chr(186).chr(181); $arr_dest_char_code[34]="a"; $arr_sour_char_code[35]=chr(225).chr(186).chr(183); $arr_dest_char_code[35]="a"; $arr_sour_char_code[36]=chr(195).chr(137); $arr_dest_char_code[36]="e"; $arr_sour_char_code[37]=chr(195).chr(136); $arr_dest_char_code[37]="e"; $arr_sour_char_code[38]=chr(225).chr(186).chr(186); $arr_dest_char_code[38]="e"; $arr_sour_char_code[39]=chr(225).chr(186).chr(188); $arr_dest_char_code[39]="e"; $arr_sour_char_code[40]=chr(225).chr(186).chr(184); $arr_dest_char_code[40]="e"; $arr_sour_char_code[41]=chr(195).chr(169); $arr_dest_char_code[41]="e"; $arr_sour_char_code[42]=chr(195).chr(168); $arr_dest_char_code[42]="e"; $arr_sour_char_code[43]=chr(225).chr(186).chr(187); $arr_dest_char_code[43]="e"; $arr_sour_char_code[44]=chr(225).chr(186).chr(189); $arr_dest_char_code[44]="e"; $arr_sour_char_code[45]=chr(225).chr(186).chr(185); $arr_dest_char_code[45]="e"; $arr_sour_char_code[46]=chr(195).chr(138); $arr_dest_char_code[46]="e"; $arr_sour_char_code[47]=chr(225).chr(186).chr(190); $arr_dest_char_code[47]="e"; $arr_sour_char_code[48]=chr(225).chr(187).chr(128); $arr_dest_char_code[48]="e"; $arr_sour_char_code[49]=chr(225).chr(187).chr(130); $arr_dest_char_code[49]="e"; $arr_sour_char_code[50]=chr(225).chr(187).chr(132); $arr_dest_char_code[50]="e"; $arr_sour_char_code[51]=chr(225).chr(187).chr(134); $arr_dest_char_code[51]="e"; $arr_sour_char_code[52]=chr(195).chr(170); $arr_dest_char_code[52]="e"; $arr_sour_char_code[53]=chr(225).chr(186).chr(191); $arr_dest_char_code[53]="e"; $arr_sour_char_code[54]=chr(225).chr(187).chr(129); $arr_dest_char_code[54]="e"; $arr_sour_char_code[55]=chr(225).chr(187).chr(131); $arr_dest_char_code[55]="e"; $arr_sour_char_code[56]=chr(225).chr(187).chr(133); $arr_dest_char_code[56]="e"; $arr_sour_char_code[57]=chr(225).chr(187).chr(135); $arr_dest_char_code[57]="e"; $arr_sour_char_code[58]=chr(195).chr(180); $arr_dest_char_code[58]="o"; $arr_sour_char_code[59]=chr(225).chr(187).chr(145); $arr_dest_char_code[59]="o"; $arr_sour_char_code[60]=chr(225).chr(187).chr(147); $arr_dest_char_code[60]="o"; $arr_sour_char_code[61]=chr(225).chr(187).chr(149); $arr_dest_char_code[61]="o"; $arr_sour_char_code[62]=chr(225).chr(187).chr(151); $arr_dest_char_code[62]="o"; $arr_sour_char_code[63]=chr(225).chr(187).chr(153); $arr_dest_char_code[63]="o"; $arr_sour_char_code[64]=chr(195).chr(148); $arr_dest_char_code[64]="o"; $arr_sour_char_code[65]=chr(225).chr(187).chr(144); $arr_dest_char_code[65]="o"; $arr_sour_char_code[66]=chr(225).chr(187).chr(146); $arr_dest_char_code[66]="o"; $arr_sour_char_code[67]=chr(225).chr(187).chr(148); $arr_dest_char_code[67]="o"; $arr_sour_char_code[68]=chr(225).chr(187).chr(150); $arr_dest_char_code[68]="o"; $arr_sour_char_code[69]=chr(225).chr(187).chr(152); $arr_dest_char_code[69]="o"; $arr_sour_char_code[70]=chr(195).chr(179); $arr_dest_char_code[70]="o"; $arr_sour_char_code[71]=chr(195).chr(178); $arr_dest_char_code[71]="o"; $arr_sour_char_code[72]=chr(225).chr(187).chr(143); $arr_dest_char_code[72]="o"; $arr_sour_char_code[73]=chr(195).chr(181); $arr_dest_char_code[73]="o"; $arr_sour_char_code[74]=chr(225).chr(187).chr(141); $arr_dest_char_code[74]="o"; $arr_sour_char_code[75]=chr(195).chr(147); $arr_dest_char_code[75]="o"; $arr_sour_char_code[76]=chr(195).chr(146); $arr_dest_char_code[76]="o"; $arr_sour_char_code[77]=chr(225).chr(187).chr(142); $arr_dest_char_code[77]="o"; $arr_sour_char_code[78]=chr(195).chr(149); $arr_dest_char_code[78]="o"; $arr_sour_char_code[79]=chr(225).chr(187).chr(140); $arr_dest_char_code[79]="o"; $arr_sour_char_code[80]=chr(195).chr(141); $arr_dest_char_code[80]="i"; $arr_sour_char_code[81]=chr(195).chr(140); $arr_dest_char_code[81]="i"; $arr_sour_char_code[82]=chr(225).chr(187).chr(136); $arr_dest_char_code[82]="i"; $arr_sour_char_code[83]=chr(196).chr(168); $arr_dest_char_code[83]="i"; $arr_sour_char_code[84]=chr(225).chr(187).chr(138); $arr_dest_char_code[84]="i"; $arr_sour_char_code[85]=chr(195).chr(173); $arr_dest_char_code[85]="i"; $arr_sour_char_code[86]=chr(195).chr(172); $arr_dest_char_code[86]="i"; $arr_sour_char_code[87]=chr(225).chr(187).chr(137); $arr_dest_char_code[87]="i"; $arr_sour_char_code[88]=chr(196).chr(169); $arr_dest_char_code[88]="i"; $arr_sour_char_code[89]=chr(225).chr(187).chr(139); $arr_dest_char_code[89]="i"; $arr_sour_char_code[90]=chr(195).chr(186); $arr_dest_char_code[90]="u"; $arr_sour_char_code[91]=chr(195).chr(185); $arr_dest_char_code[91]="u"; $arr_sour_char_code[92]=chr(225).chr(187).chr(167); $arr_dest_char_code[92]="u"; $arr_sour_char_code[93]=chr(197).chr(169); $arr_dest_char_code[93]="u"; $arr_sour_char_code[94]=chr(225).chr(187).chr(165); $arr_dest_char_code[94]="u"; $arr_sour_char_code[95]=chr(195).chr(154); $arr_dest_char_code[95]="u"; $arr_sour_char_code[96]=chr(195).chr(153); $arr_dest_char_code[96]="u"; $arr_sour_char_code[97]=chr(225).chr(187).chr(166); $arr_dest_char_code[97]="u"; $arr_sour_char_code[98]=chr(197).chr(168); $arr_dest_char_code[98]="u"; $arr_sour_char_code[99]=chr(197).chr(168); $arr_dest_char_code[99]="u"; $arr_sour_char_code[100]=chr(225).chr(187).chr(164); $arr_dest_char_code[100]="u"; $arr_sour_char_code[101]=chr(198).chr(176); $arr_dest_char_code[101]="u"; $arr_sour_char_code[102]=chr(225).chr(187).chr(169); $arr_dest_char_code[102]="u"; $arr_sour_char_code[103]=chr(225).chr(187).chr(171); $arr_dest_char_code[103]="u"; $arr_sour_char_code[104]=chr(225).chr(187).chr(173); $arr_dest_char_code[104]="u"; $arr_sour_char_code[105]=chr(225).chr(187).chr(175); $arr_dest_char_code[105]="u"; $arr_sour_char_code[106]=chr(225).chr(187).chr(177); $arr_dest_char_code[106]="u"; $arr_sour_char_code[107]=chr(198).chr(175); $arr_dest_char_code[107]="u"; $arr_sour_char_code[108]=chr(225).chr(187).chr(168); $arr_dest_char_code[108]="u"; $arr_sour_char_code[109]=chr(225).chr(187).chr(170); $arr_dest_char_code[109]="u"; $arr_sour_char_code[110]=chr(225).chr(187).chr(172); $arr_dest_char_code[110]="u"; $arr_sour_char_code[111]=chr(225).chr(187).chr(172); $arr_dest_char_code[111]="u"; $arr_sour_char_code[112]=chr(225).chr(187).chr(174); $arr_dest_char_code[112]="u"; $arr_sour_char_code[113]=chr(225).chr(187).chr(176); $arr_dest_char_code[113]="u"; $arr_sour_char_code[114]=chr(195).chr(157); $arr_dest_char_code[114]="y"; $arr_sour_char_code[115]=chr(225).chr(187).chr(178); $arr_dest_char_code[115]="y"; $arr_sour_char_code[116]=chr(225).chr(187).chr(182); $arr_dest_char_code[116]="y"; $arr_sour_char_code[117]=chr(225).chr(187).chr(184); $arr_dest_char_code[117]="y"; $arr_sour_char_code[118]=chr(225).chr(187).chr(180); $arr_dest_char_code[118]="y"; $arr_sour_char_code[119]=chr(195).chr(189); $arr_dest_char_code[119]="y"; $arr_sour_char_code[120]=chr(225).chr(187).chr(179); $arr_dest_char_code[120]="y"; $arr_sour_char_code[121]=chr(225).chr(187).chr(183); $arr_dest_char_code[121]="y"; $arr_sour_char_code[122]=chr(225).chr(187).chr(185); $arr_dest_char_code[122]="y"; $arr_sour_char_code[123]=chr(225).chr(187).chr(181); $arr_dest_char_code[123]="y"; $arr_sour_char_code[124]=chr(196).chr(144); $arr_dest_char_code[124]="D"; $arr_sour_char_code[125]=chr(196).chr(145); $arr_dest_char_code[125]="d"; $arr_sour_char_code[126]=chr(198).chr(161); $arr_dest_char_code[126]="o"; $arr_sour_char_code[127]=chr(225).chr(187).chr(155); $arr_dest_char_code[127]="o"; $arr_sour_char_code[128]=chr(225).chr(187).chr(157); $arr_dest_char_code[128]="o"; $arr_sour_char_code[129]=chr(225).chr(187).chr(159); $arr_dest_char_code[129]="o"; $arr_sour_char_code[130]=chr(225).chr(187).chr(161); $arr_dest_char_code[130]="o"; $arr_sour_char_code[131]=chr(225).chr(187).chr(163); $arr_dest_char_code[131]="o"; $arr_sour_char_code[132]=chr(198).chr(160); $arr_dest_char_code[132]="o"; $arr_sour_char_code[133]=chr(225).chr(187).chr(154); $arr_dest_char_code[133]="o"; $arr_sour_char_code[134]=chr(225).chr(187).chr(154); $arr_dest_char_code[134]="o"; $arr_sour_char_code[135]=chr(225).chr(187).chr(156); $arr_dest_char_code[135]="o"; $arr_sour_char_code[136]=chr(225).chr(187).chr(158); $arr_dest_char_code[136]="o"; $arr_sour_char_code[137]=chr(225).chr(187).chr(160); $arr_dest_char_code[137]="o"; $arr_sour_char_code[138]=chr(225).chr(187).chr(162); $arr_dest_char_code[138]="o"; for ($i=1;$i<139;$i++){ $str = str_replace($arr_sour_char_code[$i],$arr_dest_char_code[$i],$str); } return($str); } function remove_invailid_char($p_str){ $p_str = trim($p_str); $p_str = str_replace(" ","_",$p_str); $tmp = ""; for ($i=0;$i<strlen($p_str);$i++){ $v_code = ord(substr($p_str,$i,1)); if (($v_code>=48 && $v_code<=57) || ($v_code>=65 && $v_code<=90) || ($v_code>=97 && $v_code<=122) || ($v_code==95)){ $tmp.=substr($p_str,$i,1); } } while (strpos($tmp,"__")!==false){ $tmp = str_replace("__","_",$tmp); } return $tmp; } ?>