Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • BuildTask
  • CliDebugView
  • ConvertFrom26Task
  • Debug
  • DebugView
  • DeleteUnusedCustomerFilesTask
  • DevelopmentAdmin
  • FillLinkTrackingTask
  • FillOldLogDataTask
  • FindBadLinksTask
  • ImportTestContentTask
  • MigrationTask
  • MySQLDatabaseConfigurationHelper
  • PhotoGalleryMigrationTask
  • SapphireREPL
  • SS_Backtrace
  • SS_Cli
  • SS_Log
  • SS_LogEmailWriter
  • SS_LogErrorEmailFormatter
  • SS_LogErrorFileFormatter
  • SS_LogFileWriter
  • SS_ZendLog
  • TaskRunner
 1 <?php
 2 /*
 3  * Задача поиска выпавших с сайта при конвертации (2.6 -> 3.1) ссылок
 4  * Сохраняет выпавшие ссылки в файл bad_urls.txt во временной папке конвертации
 5  *
 6  * @author menedem
 7  */
 8 class FindBadLinksTask extends BuildTask {  
 9     function run($request) {
10         if (!Director::is_cli() && !Permission::check("ADMIN") ) {
11             print "Permission denied";
12             return;
13         }
14         $siteName = $request->getVar('site');
15         $oldSiteMap = simplexml_load_file("http://" . $siteName . '/sitemap.cgi');      
16         $handle = @fopen(ConvertFrom26Task::base_dir() . '/url_map.txt', "r");
17         $map = array();
18         if ($handle) {
19             while (($buffer = fgets($handle)) !== false) {
20                 $map[] = explode(' ', $buffer);
21             }
22             if (!feof($handle)) {
23                 die("Error: unexpected fgets() fail\n");
24             }
25             fclose($handle);
26         }
27         
28         $lines = "";        
29         foreach($oldSiteMap->url as $url) {
30             $urlData = parse_url($url->loc);
31             foreach($map as $entry) {
32                 $urlPath = $urlData['path'];
33                 if ($entry[0] == $urlPath) {
34                     $urlPath = $entry[1];
35                     break;
36                 }
37             }
38             if (!@file_get_contents(Director::absoluteURL(trim($urlPath)))) {
39                 $lines .= Director::absoluteURL(trim($urlPath)) . " \n";
40             }
41         }
42         if ($lines) {
43             file_put_contents(ConvertFrom26Task::base_dir() . '/bad_urls.txt', $lines);
44         }
45     }
46 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0