protected function _check_local_urls()
 {
     $this->page->prefer_relative_urls = false;
     $local_url = $this->context->get_icon_url('{icons}/buttons/blank', Sixteen_px);
     $local_url_with_domain = $this->env->resolve_file($local_url, Force_root_on);
     $local_path = url_to_file_name($local_url_with_domain);
     $img = new IMAGE();
     $this->_set_image($img, $local_url_with_domain);
     $this->_check_equal($local_url_with_domain, $img->properties->url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $this->_set_image($img, $local_url_with_domain, true);
     $this->_check_equal($local_url_with_domain, $img->properties->url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $this->_set_image($img, $local_path);
     $relative_image_url = path_between($img->properties->url, $local_url, global_url_options());
     $this->_check_equal($local_url, $relative_image_url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $relative_image_url = path_between($img->properties->url, $local_url, global_url_options());
     $this->_set_image($img, $local_path, true);
     $this->_check_equal($local_url, $relative_image_url);
     $this->_check_equal($local_path, $img->properties->file_name);
     /* Check non-existent local file. */
     $this->_set_image($img, $local_url_with_domain . '.does.not_exist');
     $this->_check_equal($local_url_with_domain . '.does.not_exist', $img->properties->url);
     $this->_check_equal('', $img->properties->file_name);
 }
 /**
  * Syntax-highlight the contents of the current url.
  * @see file_as_html()    
  * @return  string
  */
 public function current_as_html()
 {
     $this->file_as_html(url_to_file_name($this->env->url(Url_part_no_args)));
 }
 /**
  * Return the size of the object.
  * @param PICTURE $obj
  * @return integer
  * @access private
  */
 protected function _size_of($obj)
 {
     return @filesize(url_to_file_name($obj->full_file_name(true)));
 }
Beispiel #4
0
/**
 * Convert a url to a local folder.
 * Automatically removes the domain name and will only work for the server file system.
 * Useful for calculating paths for uploaded files.
 * @see UPLOADER
 * @param string $f
 * @param URL_OPTIONS $opts
 * @param boolean $create_if_not_found Creates the folder if it doesn't exist.
 * @return string
 * @see ensure_path_exists()
 */
function url_to_folder($f, $opts = null, $create_if_not_found = true)
{
    $Result = url_to_file_name($f, $opts);
    if ($Result && $create_if_not_found && !is_dir($Result)) {
        ensure_path_exists($Result);
    }
    return $Result;
}
earthli WebCore is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with earthli WebCore; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

For more information about the earthli WebCore, visit:

http://www.earthli.com/software/webcore

****************************************************************************/
$page_name = read_array_index($_GET, 'page_name');
$file_name = url_to_file_name($page_name);
define('Start_of_template', 'webcore/pages');
define('End_of_template', '.php');
function draw_source($source_text)
{
    echo "<div class=\"log-box\">{$source_text}</div>\n";
}
$Page->title->subject = 'View source';
$Page->template_options->title = 'Source';
$Page->template_options->icon = '{icons}buttons/source';
$Page->location->add_root_link();
$Page->location->append('View source');
$Page->add_style_sheet($Env->logger_style_sheet);
$Page->start_display();
?>
<div class="main-box">
 /**
  * Fully resolved server-local path to the file.
  * @return string
  */
 public function full_file_name()
 {
     $Result = $this->file_name;
     if (!$Result || !file_exists($this->file_name)) {
         $Result = url_to_file_name($this->full_url(Force_root_on));
     }
     return $Result;
 }
 /**
  * Called after fields are validated.
  * @param PICTURE $obj
  * @access private
  */
 protected function _post_validate($obj)
 {
     parent::_post_validate($obj);
     $file_name = $this->_selected_file_name();
     if (!$this->value_for('use_upload')) {
         $old_file_name = $obj->file_name;
         $obj->file_name = $file_name;
         $file_name = url_to_file_name($obj->full_file_name());
         $obj->file_name = $old_file_name;
     }
     if ($this->value_for('read_exif')) {
         $url_is_empty = $this->value_is_empty('file_name');
         $use_upload = $this->value_for('use_upload');
         if ($use_upload && !$this->num_errors('upload_file', Form_first_control_for_field) || !$url_is_empty) {
             $class_name = $this->context->final_class_name('IMAGE', 'webcore/util/image.php');
             /** @var IMAGE $img */
             $img = new $class_name();
             $img->set_file($file_name, true);
             if ($img->properties->exists() && $img->properties->time_created->is_valid()) {
                 $this->_exif_date = $img->properties->time_created;
             } else {
                 $this->record_error('day', 'Could not extract date information from the picture.');
             }
         }
     }
     if (!$this->value_for('read_exif') && $this->value_is_empty('day')) {
         $this->record_error('day', 'Please set a date.');
     }
 }
 /**
  * Outputs the object as plain text.
  * @param object $obj
  * @access private
  */
 protected function _display_as_plain_text($obj)
 {
     $this->_echo_plain_text_user_information($obj);
     $file_url = $obj->full_url();
     $file_name = url_to_file_name($file_url);
     $file_url = htmlentities($file_url);
     echo $this->line('[Name]: ' . $obj->original_file_name);
     echo $this->line('[Size]: ' . file_size_as_text($obj->size));
     echo $this->line('[Type]: ' . $obj->mime_type);
     echo $this->par(' [URL]: <' . $file_url . '>');
     $this->_echo_plain_text_description($obj);
     if ($obj->is_archive) {
         $this->_draw_text_archive($obj, $file_name);
     } else {
         if ($obj->mime_type == 'text/plain') {
             if ($this->_options->preferred_text_length) {
                 $handle = fopen($file_name, 'r+');
                 echo fread($handle, $this->_options->preferred_text_length);
             } else {
                 readfile($file_name);
             }
         }
     }
 }
Beispiel #9
0
 /**
  * Load image properties form the given file.
  * @param string $name Full path to the file to load. May be a URL or local file.
  * @param boolean $include_exif Load EXIF digital camera information from the file?
  */
 public function load_from_file($name, $include_exif)
 {
     $this->php_type = null;
     if (is_file($name)) {
         $name = ensure_has_full_path($name);
         $this->file_name = $name;
         $this->url = file_name_to_url($name);
     } else {
         $this->url = $name;
         $name_as_file = url_to_file_name($name);
         if ($name_as_file) {
             /* File is local. Only attempt loading if it exists (this avoids trying to
              * load through a loopback URL because the file isn't on the server).
              */
             if (@is_file($name_as_file)) {
                 $name = $name_as_file;
                 $this->file_name = $name_as_file;
             } else {
                 $name = '';
                 $this->file_name = null;
             }
         } else {
             $name = str_replace(' ', '%20', $name);
         }
     }
     if ($name) {
         if ($include_exif) {
             $this->_read_exif($name);
             if (!$this->php_type) {
                 $this->_read_image_info($name);
             }
         } else {
             $this->_read_image_info($name);
         }
         if (!$this->exists()) {
             $this->file_name = null;
         }
     }
 }
Beispiel #10
0
 /**
  * @param PURGE_OPTIONS $options
  * @access private
  */
 protected function _purge($options)
 {
     if ($options->remove_resources) {
         $url = $this->location(true);
         $file_name = url_to_file_name($url->as_text());
         if ($file_name) {
             @unlink($file_name);
         }
         $url = $this->thumbnail_location(true);
         $file_name = url_to_file_name($url->as_text());
         if ($file_name) {
             @unlink($file_name);
         }
     }
     parent::_purge($options);
 }
 /**
  * Perform the actual process actions.
  * This is task- and application-specific.
  * @access private
  */
 protected function _execute()
 {
     $class_name = $this->app->final_class_name('ARCHIVE', 'webcore/util/archive.php');
     $archive = new $class_name($this->archive_file_name);
     log_open_block('Extracting files from archive...');
     $this->_target_directory = url_to_file_name($this->_folder->picture_folder_url(Force_root_on));
     $this->_num_pictures_imported = 0;
     $archive->for_each(new CALLBACK_METHOD('process_image', $this), new CALLBACK_METHOD('show_error', $this));
     log_close_block();
     $php_errormsg = null;
     @unlink($this->archive_file_name);
     if (isset($php_errormsg)) {
         $this->_log("Could not delete archive: " . $php_errormsg, Msg_type_warning);
     } else {
         $this->_log("Deleted archive.", Msg_type_info);
     }
 }