Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SIWECOS
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cLinkcheckerCategoryHelper
  • cLinkcheckerRepair
  • cLinkcheckerSearchLinks
  • cLinkcheckerTester

Functions

  • linksort
  • url_is_image
  • url_is_uri
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * @package    Plugin
  5:  * @subpackage Linkchecker
  6:  * @author     Mario Diaz
  7:  * @copyright  four for business AG <www.4fb.de>
  8:  * @license    http://www.contenido.org/license/LIZENZ.txt
  9:  * @link       http://www.4fb.de
 10:  * @link       http://www.contenido.org
 11:  */
 12: 
 13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 14: 
 15: /**
 16:  * Class searchLinks
 17:  */
 18: class cLinkcheckerSearchLinks
 19: {
 20:     /**
 21:      * @var string
 22:      */
 23:     private $mode = '';
 24: 
 25:     /**
 26:      * cLinkcheckerSearchLinks constructor.
 27:      */
 28:     public function __construct()
 29:     {
 30:         $this->setMode("text");
 31:     }
 32: 
 33:     /**
 34:      * Setter method for mode
 35:      *
 36:      * mode:
 37:      * - text (standard)
 38:      * - redirect
 39:      *
 40:      * @param $mode
 41:      *
 42:      * @return mixed
 43:      */
 44:     public function setMode($mode)
 45:     {
 46:         return $this->mode = cSecurity::toString($mode);
 47:     }
 48: 
 49:     /**
 50:      * Searchs extern and intern links.
 51:      *
 52:      * @todo Optimize this function!
 53:      * @todo Do not use global!
 54:      *
 55:      * @param string $value
 56:      * @param int    $idart
 57:      * @param string $nameart
 58:      * @param int    $idcat
 59:      * @param string $namecat
 60:      * @param int    $idlang
 61:      * @param int    $idartlang
 62:      * @param int    $idcontent
 63:      *
 64:      * @return array
 65:      */
 66:     public function search($value, $idart, $nameart, $idcat, $namecat, $idlang, $idartlang, $idcontent = 0)
 67:     {
 68:         global $aUrl, $aSearchIDInfosNonID, $aWhitelist;
 69: 
 70:         // Extern URL
 71:         if (preg_match_all('~(?:(?:action|data|href|src)=["\']((?:file|ftp|http|ww)[^\s]*)["\'])~i', $value, $aMatches)
 72:             && $_GET['mode'] != 1
 73:         ) {
 74:             for ($i = 0; $i < count($aMatches[1]); $i++) {
 75:                 if (!in_array($aMatches[1][$i], $aWhitelist)) {
 76:                     $aSearchIDInfosNonID[] = [
 77:                         "url"       => $aMatches[1][$i],
 78:                         "idart"     => $idart,
 79:                         "nameart"   => $nameart,
 80:                         "idcat"     => $idcat,
 81:                         "namecat"   => $namecat,
 82:                         "idcontent" => $idcontent,
 83:                         "idartlang" => $idartlang,
 84:                         "lang"      => $idlang,
 85:                         "urltype"   => "extern",
 86:                     ];
 87:                 }
 88:             }
 89:         }
 90: 
 91:         // Redirect
 92:         if ($this->mode == "redirect"
 93:             && (preg_match('!(' . preg_quote($aUrl['cms']) . '[^\s]*)!i', $value, $aMatches)
 94:                 || (preg_match('~(?:file|ftp|http|ww)[^\s]*~i', $value, $aMatches) && $_GET['mode'] != 1))
 95:             && (cString::findFirstPosCI($value, 'front_content.php') === false)
 96:             && !in_array($aMatches[0], $aWhitelist)
 97:         ) {
 98:             $aSearchIDInfosNonID[] = [
 99:                 "url"       => $aMatches[0],
100:                 "idart"     => $idart,
101:                 "nameart"   => $nameart,
102:                 "idcat"     => $idcat,
103:                 "namecat"   => $namecat,
104:                 "idcontent" => 0,
105:                 "idartlang" => $idartlang,
106:                 "lang"      => $idlang,
107:                 "urltype"   => "unknown",
108:                 "redirect"  => true,
109:             ];
110:         }
111: 
112:         // Intern URL
113:         if (preg_match_all(
114:                 '~(?:(?:action|data|href|src)=["\'])(?!file://)(?!ftp://)(?!http://)(?!https://)(?!ww)(?!mailto)(?!\#)(?!/\#)([^"\']+)(?:["\'])~i',
115:                 $value,
116:                 $aMatches
117:             )
118:             && $_GET['mode'] != 2
119:         ) {
120:             for ($i = 0; $i < count($aMatches[1]); $i++) {
121:                 if (cString::findFirstPos($aMatches[1][$i], "front_content.php") === false
122:                     && !in_array(
123:                         $aMatches[1][$i],
124:                         $aWhitelist
125:                     )
126:                 ) {
127:                     $aSearchIDInfosNonID[] = [
128:                         "url"       => $aMatches[1][$i],
129:                         "idart"     => $idart,
130:                         "nameart"   => $nameart,
131:                         "idcat"     => $idcat,
132:                         "namecat"   => $namecat,
133:                         "idcontent" => $idcontent,
134:                         "idartlang" => $idartlang,
135:                         "lang"      => $idlang,
136:                         "urltype"   => "intern",
137:                     ];
138:                 }
139:             }
140:         }
141: 
142:         return $aSearchIDInfosNonID;
143:     }
144: }
145: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0