Dotclear

Changeset 1745:326b3deaffd0 for admin


Ignore:
Timestamp:
09/07/13 00:42:21 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add warning about URL of blog if it's ATOM feed is not reachable, fixes #1113.
Might be enhanced.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_pref.php

    r1719 r1745  
    321321          echo 
    322322          '<p><label for="blog_url" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog URL:').'</label>'. 
    323           form::field('blog_url',30,255,html::escapeHTML($blog_url)).'</p>'. 
     323          form::field('blog_url',50,255,html::escapeHTML($blog_url)).'</p>'. 
    324324           
    325325          '<p><label for="url_scan">'.__('URL scan method:').'</label>'. 
    326           form::combo('url_scan',$url_scan_combo,$blog_settings->system->url_scan).'</p>'. 
    327            
     326          form::combo('url_scan',$url_scan_combo,$blog_settings->system->url_scan).'</p>'; 
     327           
     328          # Test URL of blog by testing it's ATOM feed 
     329          $file = $blog_url.'feed/atom'; 
     330          $path = ''; 
     331          $status = '404'; 
     332          $content = ''; 
     333          $client = netHttp::initClient($file,$path); 
     334          if ($client !== false) { 
     335               $client->setTimeout(4); 
     336               $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 
     337               $client->get($path); 
     338               $status = $client->getStatus(); 
     339               $content = $client->getContent(); 
     340          } 
     341          if ($status != '200') { 
     342               // Might be 404 (URL not found), 670 (blog not online), ... 
     343               echo 
     344               '<p class="form-note warn">'. 
     345               sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'), 
     346                         $file,$status). 
     347               '</p>'; 
     348          } else { 
     349               if (substr($content,0,6) != '<?xml ') { 
     350                    // Not well formed XML feed 
     351                    echo 
     352                    '<p class="form-note warn">'. 
     353                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'), 
     354                              $file). 
     355                    '</p>'; 
     356               } 
     357          } 
     358 
     359          echo 
    328360          '<p><label for="blog_status">'.__('Blog status:').'</label>'. 
    329361          form::combo('blog_status',$status_combo,$blog_status).'</p>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map