{
parent::setFields();
- $this->addField('fluidbook_id', Integer::class, '',[]);
- $this->addField('page', Integer::class, '',[]);
- $this->addField('link_id', Text::class, '',[]);
- $this->addField('error_code', Text::class, '',[]);
- $this->addField('first_time_error', Text::class, '',['default' => '']);
- $this->addField('last_date_test', Text::class, '',['default' => '']);
- $this->addField('url', Text::class, '',[]);
- $this->addField('new_url', Text::class, '',['default' => '']);
- $this->addField('redirection_code', Text::class, '',[]);
- $this->addField('final_code_url', Text::class, '',['default' => '']);
- $this->addField('final_target', Text::class, '',['default' => '']);
+ $this->addField('fluidbook_id', Integer::class, '', []);
+ $this->addField('page', Integer::class, '', []);
+ $this->addField('link_id', Text::class, '', []);
+ $this->addField('error_code', Text::class, '', []);
+ $this->addField('first_time_error', Text::class, '', ['default' => '']);
+ $this->addField('last_date_test', Text::class, '', ['default' => '']);
+ $this->addField('url', Text::class, '', []);
+ $this->addField('new_url', Text::class, '', ['default' => '']);
+ $this->addField('redirection_code', Text::class, '', []);
+ $this->addField('final_code_url', Text::class, '', ['default' => '']);
+ $this->addField('final_target', Text::class, '', ['default' => '']);
}
- public static function youtubeVideoExist($videoID) {
+ public static function youtubeVideoExist($videoID)
+ {
$headers = get_headers('https://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=' . $videoID);
-
- if(is_array($headers) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$headers[0]) : false){
- // video exists
- } else {
- return false;
- }
- return true;
+ return (is_array($headers) && preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/', $headers[0]));
}
- public static function getHttpCode($url) {
+ public static function getHttpCode($url, $timeout = 30)
+ {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
return ['httpcode' => $httpcode, 'finalurl' => $finalUrl];
}
- public static function getHttpCodeComment($httpcode) {
+ public static function getHttpCodeComment($httpcode)
+ {
switch ($httpcode) {
- case 301: echo " - Moved Permanently: the resource has a new permanent home — update your bookmarks or links."; break;
- case 302: echo " - Found: tells the client to look at (browse to) another URL."; break;
+ case 301:
+ return " - Moved Permanently: the resource has a new permanent home — update your bookmarks or links.";
+ case 302:
+ return " - Found: tells the client to look at (browse to) another URL.";
//case 307:
//case 308:
- case 400: echo " - Bad request: this and all future requests should be directed to the given URI."; break;
+ case 400:
+ return " - Bad request: this and all future requests should be directed to the given URI.";
}
}
}