Overview

Packages

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

Classes

  • LinkcheckerRepair

Functions

  • cCatPerm
  • checkLinks
  • getGroupIDs
  • linksort
  • searchFrontContentLinks
  • searchLinks
  • url_is_image
  • url_is_uri
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: /**
 3:  * Repair common mistakes in links
 4:  *
 5:  * @package Plugin
 6:  * @subpackage Linkchecker
 7:  * @version SVN Revision $Rev:$
 8:  *
 9:  * @author Frederic Schneider
10:  * @copyright four for business AG <www.4fb.de>
11:  * @license http://www.contenido.org/license/LIZENZ.txt
12:  * @link http://www.4fb.de
13:  * @link http://www.contenido.org
14:  */
15: 
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17: 
18: /**
19:  * Repair common mistakes in links
20:  *
21:  * @author frederic.schneider
22:  *
23:  */
24: class LinkcheckerRepair {
25: 
26:     /**
27:      * Typical link misstakes
28:      *
29:      * @var string
30:      */
31:     private $errorTypes = array(
32:         'htp://',
33:         'htttp://',
34:         'htps://',
35:         'htttps://',
36:         'ww',
37:         'www',
38:         'wwww'
39:     );
40: 
41:     /**
42:      * Fixed link misstakes
43:      * Keys are equivalent to $errorTypes
44:      *
45:      * @var string
46:      */
47:     private $correctTypes = array(
48:         'http://',
49:         'http://',
50:         'https://',
51:         'https://',
52:         'http://www',
53:         'http://www',
54:         'http://www'
55:     );
56: 
57:     /**
58:      * Checks link and generate a repaired version
59:      *
60:      * @return string|bool
61:      */
62:     public function checkLink($link) {
63: 
64:         foreach ($this->errorTypes as $errorTypeKey => $errorType) {
65:             if (substr($link, 0, strlen($errorType)) == $errorType) {
66:                 $repaired_link = str_replace($errorType, $this->correctTypes[$errorTypeKey], $link);
67:                 if ($this->pingRepairedLink($repaired_link) == true) {
68:                     return $repaired_link;
69:                 } else {
70:                     return false;
71:                 }
72:             }
73:         }
74: 
75:     }
76: 
77:     /**
78:      * Test repaired link
79:      *
80:      * @param string $repaired_link
81:      * @return  bool  true or false
82:      */
83:     private function pingRepairedLink($repaired_link) {
84:         return @fopen($repaired_link, 'r');
85:     }
86: 
87: }
88: ?>
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0