function getFileCache($location, $expire = false) { if (is_bool($expire)) { $expire = 60 * 30; } $hash = sha1($location); $file = "./cache/{$hash}"; if (file_exists($file)) { $file_content = file_get_contents($file); $unserialize_file = unserialize($file_content); $file_expire = $unserialize_file['expire']; if ($file_expire > time()) { // error_log('Returning Cache', E_NOTICE); return base64_decode($unserialize_file['content']); } else { // error_log('Cache Expired', E_NOTICE); } } $content = CURL($location); if (!$content || !$content['output']) { return false; } $store = array('date' => time(), 'expire' => time() + $expire, 'content' => base64_encode($content['output'])); $serialize = serialize($store); file_put_contents($file, $serialize); // error_log('Writing Cache', E_NOTICE); return $content['output']; }
include_once 'hal.php'; if (!isset($error)) { if (isset($_POST['resize']) and $_POST['resize'] == true and $_POST['width'] + $_POST['height'] == 0) { $error[] = 'Выбрана опция изменения размера, но не установлена ни ширина ни высота!'; } elseif (isset($_POST['thumb']) and $_POST['thumb'] == true and $_POST['thumb_width'] + $_POST['thumb_height'] == 0) { $error[] = 'Выбрана опция "Создать превью", но не установлена ни ширина ни высота!'; } else { if (isset($_POST['web_uploadfile'])) { $_POST['web_uploadfile'] = preg_replace("/\\s/", '', $_POST['web_uploadfile']); //вырезаем переносы строк preg_match_all('#(https?://[\\w-]+[\\.\\w-]+/((?!https?://)[\\w- ./?%&=])+)#', $_POST['web_uploadfile'], $out); $web_links_quantity = count($out['0']); if ($web_links_quantity > 0) { foreach ($out['0'] as $up) { if (CURL($up)) { $partes = explode('/', $up); $filename = $partes[count($partes) - 1]; list($final_filename, $returned_error) = check_and_move($filename); make_img_code($final_filename, false, false, $returned_error); } } } } if (isset($_FILES['local_uploadfile'])) { $local_up = $_FILES['local_uploadfile']; foreach ($local_up['name'] as $key => $check) { if (empty($check)) { foreach ($local_up as $type => $value) { unset($local_up[$type][$key]); }
<?php function CURL($URL, $DS = array(), $MET = "GET") { $DS = json_encode($DS); $CH = CURL_INIT(); CURL_SETOPT($CH, CURLOPT_URL, $URL); CURL_SETOPT($CH, CURLOPT_CUSTOMREQUEST, $MET); if (!empty($DS)) { CURL_SETOPT($CH, CURLOPT_POSTFIELDS, $DS); } CURL_SETOPT($CH, CURLOPT_RETURNTRANSFER, 1); CURL_SETOPT($CH, CURLOPT_CONNECTTIMEOUT, 1); CURL_SETOPT($CH, CURLOPT_USERPWD, "Cellwiz:cpr12345"); CURL_SETOPT($CH, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); $CON = CURL_EXEC($CH); CURL_CLOSE($CH); return $CON; } echo '<pre>'; print_r(json_decode(CURL('https://api.github.com/repos/Nvenom/cellwiz/issues', array("bio" => "This is my bio")), true));