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     Frederic Schneider
 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:  * Repair common mistakes in links
17:  *
18:  * @author frederic.schneider
19:  */
20: class cLinkcheckerRepair
21: {
22:     /**
23:      * Typical link misstakes
24:      *
25:      * @var array
26:      */
27:     private $errorTypes = [
28:         'htp://',
29:         'htttp://',
30:         'htps://',
31:         'htttps://',
32:         'ww',
33:         'www',
34:         'wwww',
35:     ];
36: 
37:     /**
38:      * Fixed link misstakes
39:      * Keys are equivalent to $errorTypes
40:      *
41:      * @var array
42:      */
43:     private $correctTypes = [
44:         'http://',
45:         'http://',
46:         'https://',
47:         'https://',
48:         'http://www',
49:         'http://www',
50:         'http://www',
51:     ];
52: 
53:     /**
54:      * Checks link and generate a repaired version
55:      *
56:      * @param string $link
57:      *
58:      * @return string|bool
59:      */
60:     public function checkLink($link)
61:     {
62:         foreach ($this->errorTypes as $errorTypeKey => $errorType) {
63:             if (cString::getPartOfString($link, 0, cString::getStringLength($errorType)) == $errorType) {
64:                 $repaired_link = str_replace($errorType, $this->correctTypes[$errorTypeKey], $link);
65:                 if ($this->_pingRepairedLink($repaired_link) == true) {
66:                     return $repaired_link;
67:                 } else {
68:                     return false;
69:                 }
70:             }
71:         }
72:     }
73: 
74:     /**
75:      * Test repaired link
76:      *
77:      * @param string $repaired_link
78:      *
79:      * @return  bool  true or false
80:      */
81:     private function _pingRepairedLink($repaired_link)
82:     {
83:         $repaired_link = cSecurity::escapeString($repaired_link);
84: 
85:         return @fopen($repaired_link, 'r');
86:     }
87: }
88: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0