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"));
 
  261                $query = 
"SELECT title FROM object_data ".
 
  262                        "WHERE obj_id = ".$ilDB->quote($a_lm_obj_id ,
'integer').
" ";
 
  284                include_once 
'./Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
 
  297                        foreach($obj_ids as $obj_id)
 
  299                                if(!isset($notify[$obj_id]))
 
  308                                                $obj_name = $this->
__txt($tmp_user->getLanguage(),
'obj_webr');
 
  312                                                $obj_name = $this->
__txt($tmp_user->getLanguage(),
'lo');
 
  315                                $body .= $obj_name.
': '.$this->
__getTitle($obj_id).
"\r\n";
 
  316                                $body .= $this->
__txt($tmp_user->getLanguage(),
'link_check_perma_link', 
"mail"). 
": " .
 
  318                                $body .= $this->
__txt($tmp_user->getLanguage(),
"link_check_affected_links", 
"mail"). 
":\r\n";
 
  321                                foreach($notify[$obj_id] as 
$data)
 
  323                                        $body .= 
$data[
'url'].
"\r\n";
 
  329                                include_once 
"./Services/Notification/classes/class.ilSystemNotification.php";
 
  331                                $ntf->setLangModules(array(
"mail", 
"common"));
 
  332                                $ntf->setSubjectLangId(
"link_check_subject");
 
  333                                $ntf->setIntroductionLangId(
"link_check_introduction");
 
  334                                $ntf->setReasonLangId(
"link_check_reason");
 
  335                                $ntf->addAdditionalInfo(
"additional_info", $body,
true);
 
  336                                $ntf->sendMail(array($tmp_user->getId()));
 
  357                foreach((array) $ref_ids as $id)
 
  359                        if($ilAccess->checkAccessOfUser($a_usr_id, 
"read", 
"", $id, $a_obj_type, $a_obj_id))
 
  370                include_once 
'./Services/Link/classes/class.ilLink.php';
 
  376                return $this->notify ? $this->notify : array();
 
  382                $this->invalid_links = array();
 
  386                $this->invalid_links[] = $a_link;
 
  392                $this->log_messages[] = $a_string;
 
  396                return $this->log_messages = array();
 
  403                $pattern_complete = 
'/<ExtLink Href="([^"]*)">/';
 
  404                if(preg_match_all($pattern_complete,$a_page[
'content'],$matches))
 
  406                        for($i = 0;$i < count($matches[0]); ++$i)
 
  408                                $url_data = @parse_url($matches[1][$i]);
 
  410                                if($url_data[
'scheme'] == 
'mailto')
 
  416                                if(!$url_data[
'scheme'])
 
  418                                        $matches[1][$i] = 
'http://'.$matches[1][$i];
 
  422                                $link[] = array(
'page_id'  => $a_page[
'page_id'],
 
  424                                                                'type'     => $a_page[
'type'],
 
  425                                                                'complete' => $matches[1][$i],
 
  426                                                                'scheme'   => isset($url_data[
'scheme']) ? $url_data[
'scheme'] : 
'http',
 
  427                                                                'host'     => isset($url_data[
'host']) ? $url_data[
'host'] : $url_data[
'path']);
 
  431                return $link ? $link : array();
 
  436                global $objDefinition;
 
  438                include_once 
'Modules/WebResource/classes/class.ilLinkResourceItems.php';
 
  442                foreach($check_links = $link_res_obj->getCheckItems($this->getCheckPeriod()) as $item_data)
 
  445                        if(strpos($item_data[
'target'], 
'|'))
 
  447                                $parts = explode(
'|', $item_data[
'target']);
 
  448                                if(
sizeof($parts) == 2 &&
 
  449                                        is_numeric($parts[1]) &&
 
  450                                        $objDefinition->isAllowedInRepository($parts[0]))
 
  452                                        $link[] = array(
'page_id'  => $item_data[
'link_id'],
 
  455                                                                'complete' => $item_data[
'target'],
 
  456                                                                'scheme'   => 
'internal',
 
  457                                                                'obj_type' => $parts[0],
 
  458                                                                'ref_id'   => $parts[1]);                       
 
  464                        $url_data = @parse_url($item_data[
'target']);
 
  467                        if(!$url_data[
'scheme'])
 
  469                                $item_data[
'target'] = 
'http://'.$item_data[
'target'];
 
  472                        $link[] = array(
'page_id'  => $item_data[
'link_id'],
 
  475                                                'complete' => $item_data[
'target'],
 
  476                                                'scheme'   => isset($url_data[
'scheme']) ? $url_data[
'scheme'] : 
'http',
 
  477                                                'host'     => isset($url_data[
'host']) ? $url_data[
'host'] : $url_data[
'path']);                                                                                
 
  479                return $link ? $link : array();
 
  488                if(!@include_once(
'HTTP/Request.php'))
 
  490                        $this->
__appendLogMessage(
'LinkChecker: Pear HTTP_Request is not installed. Aborting');
 
  495                foreach($a_links as $link)
 
  498                        if($link[
'scheme'] == 
'internal')
 
  503                                        $tree->isDeleted($link[
'ref_id']))
 
  511                                if(gethostbyname($link[
'host']) == $link[
'host'])
 
  517                                if($link[
'scheme'] !== 
'http' and $link[
'scheme'] !== 
'https')
 
  522                                require_once 
'./Services/Http/classes/class.ilProxySettings.php';
 
  537                                switch($req->getResponseCode())
 
  547                                                $link[
'http_status_code'] = $req->getResponseCode();
 
  553                return $invalid ? $invalid : array();
 
  558                $query = 
"SELECT lm_id FROM lm_data ".
 
  559                        "WHERE obj_id = '".$a_page_id.
"'";
 
  563                return $row->lm_id ? 
$row->lm_id : 0;
 
  570                        if($link[
'page_id'] == $a_page_id and
 
  571                           substr($link[
'complete'],0,255) == $a_url)
 
  592                        $query = 
"INSERT INTO link_check (obj_id,page_id,url,parent_type,http_status_code,last_check) ".
 
  594                                $ilDB->quote($link[
'obj_id'],
'integer').
", ".
 
  595                                $ilDB->quote($link[
'page_id'],
'integer').
", ".
 
  596                                $ilDB->quote(substr($link[
'complete'],0,255),
'text').
", ".
 
  597                                $ilDB->quote($link[
'type'],
'text').
", ".
 
  598                                $ilDB->quote($link[
'http_status_code'] ? $link[
'http_status_code'] : 0,
'integer').
", ".
 
  599                                $ilDB->quote(time(),
'integer').
" ".
 
  611                        $query = 
"SELECT * FROM link_check ".
 
  612                                "WHERE page_id = ".$ilDB->quote($link[
'page_id'],
'integer').
" ".
 
  613                                "AND url = ".$ilDB->quote(substr($link[
'complete'],0,255),
'text').
" ";
 
  618                                $this->notify[$link[
"obj_id"]][] = array(
'page_id' => $link[
'page_id'],
 
  619                                                                                                                 'url'     => $link[
'complete']);
 
  631                        $query = 
"DELETE FROM link_check";
 
  635                        $query = 
"DELETE FROM link_check ".
 
  636                                "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
'integer');
 
const DB_FETCHMODE_OBJECT
static _lookupEntry($a_lang_key, $a_mod, $a_id)
class for checking external links in page objects Normally used in Cron jobs, but should be extensibl...
__fetchUserData($a_usr_id)
setCheckPeriod($a_period)
__txt($language, $key, $module='common')
__getObjIdByPageId($a_page_id)
ilLinkChecker(&$db, $a_validate_all=true)
__isInvalid($a_page_id, $a_url)
createPermanentLink($a_obj_id, $a_usr_id, $a_obj_type)
creates a permanent link
__validateLinks($a_links)
__appendInvalidLink($a_link)
__appendLogMessage($a_string)
Class ilObjLinkResourceGUI.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Getter for unique instance.
Wrapper classes for system notifications.
if(!is_array($argv)) $options