28                 define(
'SOCKET_TIMEOUT',5);
 
   35                 $this->validate_all = $a_validate_all;
 
   40                 $this->period = $a_period;
 
   49                 $this->mail_status = (bool) $a_status;
 
   58                 $this->type = $a_type;
 
   67                 return $this->page_id = $a_page_id;
 
   76                 return $this->validate_all ? 
true : 
false;
 
   81                 return $this->log_messages ? $this->log_messages : array();
 
   86                 return $this->invalid_links ? $this->invalid_links : array();
 
   93                 $query = 
"SELECT * FROM link_check ".
 
   94                         "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
'integer').
" ";
 
   99                         $invalid[] = array(
'page_id' => 
$row->page_id,
 
  103                 return $invalid ? $invalid : array();
 
  112                         $query = 
"SELECT MAX(last_check) last_check FROM link_check ";
 
  116                         $query = 
"SELECT MAX(last_check) last_check FROM link_check ".
 
  117                                 "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
'integer').
" ";
 
  122                 return $row->last_check ? 
$row->last_check : 0;
 
  136                         foreach($invalid as $invalid_item)
 
  138                                 $this->
__appendLogMessage(
'LinkChecker: found invalid link: '.$invalid_item[
'complete']);
 
  164                         echo 
"ilLinkChecker::checkLinks() No Page id given";
 
  170                         $query = 
"SELECT * FROM page_object ".
 
  171                                 "WHERE parent_id = ".$ilDB->quote($this->
getObjId()).
" ".
 
  172                                 "AND parent_type = 'lm'";
 
  177                                 $pages[] = array(
'page_id' => 
$row->page_id,
 
  178                                                                  'content' => 
$row->content,
 
  179                                                                  'type'  => 
$row->parent_type);
 
  184                         $query = 
"SELECT * FROM page_object ".
 
  185                                 "WHERE parent_type = 'lm'";
 
  190                                 $pages[] = array(
'page_id' => 
$row->page_id,
 
  191                                                                  'content' => 
$row->content,
 
  192                                                                  'type'  => 
$row->parent_type);
 
  197                 foreach($pages as $page)
 
  201                                 foreach($invalid as $invalid_item)
 
  203                                         $this->
__appendLogMessage(
'LinkChecker: found invalid link: '.$invalid_item[
'complete']);
 
  219                 if(!@include_once(
'HTTP/Request.php'))
 
  228         function __txt($language,$key,$module = 
'common')
 
  232                 include_once 
'./Services/Language/classes/class.ilLanguage.php';
 
  240                 $query = 
"SELECT email FROM usr_data WHERE usr_id = ".$ilDB->quote($a_usr_id).
"";
 
  246                 $set = $ilDB->query(
"SELECT * FROM usr_pref ".
 
  247                         "WHERE usr_id = ".$ilDB->quote($a_usr_id, 
"integer").
" ".
 
  248                         "AND keyword = ".$ilDB->quote(
'language', 
"text"));
 
  250                 $row = $ilDB->fetchObject($set);
 
  261                 $query = 
"SELECT title FROM object_data ".
 
  262                         "WHERE obj_id = ".$ilDB->quote($a_lm_obj_id ,
'integer').
" ";
 
  284                 include_once 
'./classes/class.ilLinkCheckNotify.php';
 
  295                         foreach($obj_ids as $obj_id)
 
  297                                 if(!isset($notify[$obj_id]))
 
  306                                                 $body .= $this->
__txt($tmp_user->getLanguage(),
'obj_webr');
 
  311                                                 $body .= $this->
__txt($tmp_user->getLanguage(),
'lo');
 
  319                                 foreach($notify[$obj_id] as 
$data)
 
  321                                         $body .= $data[
'url'].
"\r\n";
 
  327                                 include_once 
"Services/Mail/classes/class.ilFormatMail.php";
 
  330                                 $subject = $this->
__txt($tmp_user->getLanguage(),
'link_check_subject');
 
  332                                 $umail->sendMail($tmp_user->getLogin(),
"",
"",$subject,$body,array(),array(
"normal"));
 
  343                 return $this->notify ? $this->notify : array();
 
  349                 $this->invalid_links = array();
 
  353                 $this->invalid_links[] = $a_link;
 
  359                 $this->log_messages[] = $a_string;
 
  363                 return $this->log_messages = array();
 
  370                 $pattern_complete = 
'/<ExtLink Href="([^"]*)">/';
 
  371                 if(preg_match_all($pattern_complete,$a_page[
'content'],$matches))
 
  373                         for($i = 0;$i < count($matches[0]); ++$i)
 
  375                                 $url_data = @parse_url($matches[1][$i]);
 
  377                                 if($url_data[
'scheme'] == 
'mailto')
 
  383                                 if(!$url_data[
'scheme'])
 
  385                                         $matches[1][$i] = 
'http://'.$matches[1][$i];
 
  389                                 $link[] = array(
'page_id'  => $a_page[
'page_id'],
 
  391                                                                 'type'     => $a_page[
'type'],
 
  392                                                                 'complete' => $matches[1][$i],
 
  393                                                                 'scheme'   => isset($url_data[
'scheme']) ? $url_data[
'scheme'] : 
'http',
 
  394                                                                 'host'     => isset($url_data[
'host']) ? $url_data[
'host'] : $url_data[
'path']);
 
  398                 return $link ? $link : array();
 
  403                 include_once 
'Modules/WebResource/classes/class.ilLinkResourceItems.php';
 
  407                 foreach($check_links = $link_res_obj->getCheckItems($this->getCheckPeriod()) as $item_data)
 
  409                                 $url_data = @parse_url($item_data[
'target']);
 
  412                                 if(!$url_data[
'scheme'])
 
  414                                         $item_data[
'target'] = 
'http://'.$item_data[
'target'];
 
  417                                 $link[] = array(
'page_id'  => $item_data[
'link_id'],
 
  420                                                                 'complete' => $item_data[
'target'],
 
  421                                                                 'scheme'   => isset($url_data[
'scheme']) ? $url_data[
'scheme'] : 
'http',
 
  422                                                                 'host'     => isset($url_data[
'host']) ? $url_data[
'host'] : $url_data[
'path']);
 
  424                 return $link ? $link : array();
 
  433                 if(!@include_once(
'HTTP/Request.php'))
 
  435                         $this->
__appendLogMessage(
'LinkChecker: Pear HTTP_Request is not installed. Aborting');
 
  440                 foreach($a_links as $link)
 
  442                         if(gethostbyname($link[
'host']) == $link[
'host'])
 
  448                         if($link[
'scheme'] !== 
'http' and $link[
'scheme'] !== 
'https')
 
  453                         require_once 
'classes/class.ilProxySettings.php';
 
  465                         $req = 
new HTTP_Request($link[
'complete'], $options);
 
  468                         switch($req->getResponseCode())
 
  478                                         $link[
'http_status_code'] = $req->getResponseCode();
 
  483                 return $invalid ? $invalid : array();
 
  488                 $query = 
"SELECT lm_id FROM lm_data ".
 
  489                         "WHERE obj_id = '".$a_page_id.
"'";
 
  493                 return $row->lm_id ? 
$row->lm_id : 0;
 
  500                         if($link[
'page_id'] == $a_page_id and
 
  501                            substr($link[
'complete'],0,255) == $a_url)
 
  522                         $query = 
"INSERT INTO link_check (obj_id,page_id,url,parent_type,http_status_code,last_check) ".
 
  524                                 $ilDB->quote($link[
'obj_id'],
'integer').
", ".
 
  525                                 $ilDB->quote($link[
'page_id'],
'integer').
", ".
 
  526                                 $ilDB->quote(substr($link[
'complete'],0,255),
'text').
", ".
 
  527                                 $ilDB->quote($link[
'type'],
'text').
", ".
 
  528                                 $ilDB->quote($link[
'http_status_code'] ? $link[
'http_status_code'] : 0,
'integer').
", ".
 
  529                                 $ilDB->quote(time(),
'integer').
" ".
 
  541                         $query = 
"SELECT * FROM link_check ".
 
  542                                 "WHERE page_id = ".$ilDB->quote($link[
'page_id'],
'integer').
" ".
 
  543                                 "AND url = ".$ilDB->quote(substr($link[
'complete'],0,255),
'text').
" ";
 
  548                                 $this->notify[$link[
"obj_id"]][] = array(
'page_id' => $link[
'page_id'],
 
  549                                                                                                                  'url'     => $link[
'complete']);
 
  561                         $query = 
"DELETE FROM link_check";
 
  565                         $query = 
"DELETE FROM link_check ".
 
  566                                 "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
'integer');