12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- require_once __DIR__.'/../global.inc.php';
- api_protect_course_script(true);
- $action = $_REQUEST['a'];
- switch ($action) {
- case 'check_url':
- if (api_is_allowed_to_edit(null, true)) {
- $url = $_REQUEST['url'];
-
- if (!in_array('curl', get_loaded_extensions())) {
- echo '';
- exit;
- }
-
- $defaults = array(
- CURLOPT_URL => $url,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_HEADER => 0,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_TIMEOUT => 4
- );
-
- $ch = curl_init();
- curl_setopt_array($ch, $defaults);
-
- ob_start();
- $result = curl_exec($ch);
- ob_get_clean();
-
- curl_close($ch);
- if ($result) {
- echo Display::return_icon(
- 'check-circle.png',
- get_lang('Ok'),
- null,
- ICON_SIZE_TINY
- );
- } else {
- echo Display::return_icon(
- 'closed-circle.png',
- get_lang('Wrong'),
- null,
- ICON_SIZE_TINY
- );
- }
- }
- break;
- default:
- echo '';
- }
- exit;
|