"; if($var) { var_dump($debug); } else { print_r($debug); } echo ""; } function getImageByName($folder) { $name = explode('/', $folder); if(is_dir($folder)) { preg_match_all("/S[0-9]+/", $name[sizeof($name) - 1], $output); if(sizeof($output[0]) > 0) { return "posters/" . $name[3] . "_" . ltrim(str_replace('S', '', $name[sizeof($name) - 1]), "0") . ".jpg"; } return "posters/" . $name[3] . ".jpg"; } else { // ([a-zA-Z.]*).(S[0-9]*E[0-9]*).([a-zA-Z0-9.-]*) : $1-$2-$3 // ([a-zA-Z ]*) - (S([0-9]+)E([0-9]+)) - ([a-zA-Z ]*) : $1-$2-$5 // ([a-zA-Z]*) - ([0-9]*x[0-9]*) - ([a-zA-Z0-9]*) : $1-$2-$3 // old regex: ([a-zA-Z.*]+)-S([0-9]+)E([0-9]+)-([a-zA-Z0-9.-]+).([a-zA-Z*]+) // ([a-zA-Z.*]+)-[S|s]([0-9]+)[E|e]([0-9]+)-([a-zA-Z0-9.-]+)\.([a-zA-Z0-9*]+) // ([a-zA-Z0-9.*]+)-[S|s]([0-9]+)[E|e]([0-9]+)-([a-zA-Z0-9.-]+)\.([a-zA-Z0-9\(\).*\w\,]+) preg_match_all("/([a-zA-Z0-9.*]+)-[S|s]([0-9]+)[E|e]([0-9]+)-([a-zA-Z0-9äöüÄÖÜß\-\.\,\w]+)\.([a-zA-Z0-9\(\).*\w\,]+)/", $folder, $output); if(sizeof($output[0]) > 0) { if((string) $output[3][0] != "0") { $output[3][0] = ltrim((string) $output[3][0], "0"); } if((string) $output[2][0] != "0") { $output[2][0] = ltrim((string) $output[2][0], "0"); } return "posters/" . $name[3] . "_" . $output[2][0] . "_" . $output[3][0] . ".jpg"; } else { $movieName = explode('/', $folder); $movieName = explode('.', $movieName[3]); unset($movieName[sizeof($movieName) - 1]); unset($movieName[sizeof($movieName) - 1]); $movieName = implode(' ', $movieName); $movieName = str_replace(" Directors Cut", "", $movieName); return "posters/" . $movieName . ".jpg"; } } } function curl_download($Url){ // is cURL installed yet? if (!function_exists('curl_init')){ die('Sorry cURL is not installed!'); } // OK cool - then let's create a new cURL resource handle $ch = curl_init(); // Now set some options (most are optional) // Set URL to download curl_setopt($ch, CURLOPT_URL, $Url); // Set a referer //curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); // User agent curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"); // Include header in result? (0 = yes, 1 = no) curl_setopt($ch, CURLOPT_HEADER, 0); // Should cURL return or print out the data? (true = return, false = print) curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Timeout in seconds curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Download the given URL, and return output $output = curl_exec($ch); // Close the cURL resource, and free system resources curl_close($ch); return $output; } ?>