Войти

Показать полную графическую версию : Скрипт для DLE


Weblack
16-04-2011, 00:12
Здрасьте! Т.к в php не знаю, то попрошу Вас помочь. В этом коде:
<?php

class image_controller
{
var $images = array ();
var $prefix = 'dl';
var $upload_images = array ();

function reset_url($url)
{
$value = str_replace("http://", "", $url);
$value = str_replace("www.", "", $value);
return reset(explode("/", $value));
}
function get_images ($content)
{
preg_match_all ('#\\[img\\](.+?)\\[/img\\]#ie', $content, $preg_array);
if (count ($preg_array[1]) != 0)
{
foreach ($preg_array[1] as $item)
{
if ($this->reset_url($_SERVER['HTTP_HOST'])!=$this->reset_url($item))
{
if (!(in_array ($item, $this->images)))
{
$this->images[] = $item;
continue;
}
}
}
}

}

function download ($image_url)
{
global $config;
$image_name = basename ($image_url);
$image_arr = explode ('_', $image_name);
if (count ($image_arr) != 0)
{
$image_name = end ($image_arr);
}

$image_name = $this->prefix . '_' . $image_name;

$serv_image_url = $config['http_home_url'] . 'uploads/posts/' . $image_name;
$this->source = str_replace ($image_url, $serv_image_url, $this->source);
@copy ($image_url, UPLOAD_PATH . $image_name);
if (!(in_array (basename ($serv_image_url), $this->upload_images)))
{
$this->upload_images[] = basename ($serv_image_url);
}

}

function process ($parse)
{
$source = preg_replace( "'\[thumb\]([^\[]*)([/\\\\])(.*?)\[/thumb\]'ie", "\$this->build_thumb('\$1\$2\$3', '\$1\$2thumbs\$2\$3')", $source );
$source = preg_replace( "'\[thumb=(.*?)\]([^\[]*)([/\\\\])(.*?)\[/thumb\]'ie", "\$this->build_thumb('\$2\$3\$4', '\$2\$3thumbs\$3\$4', '\$1')", $source );

$this->source = $parse->decodeBBCodes($this->source);
$this->prefix = time ();

if (trim ($this->source) != '')
{
$this->get_images ($this->source);
}

foreach ($this->images as $image_url)
{
$this->download ($image_url);
}



}
}

define ('UPLOAD_PATH', ROOT_DIR . '/uploads/posts/');

?>

...мне нужно, чтобы скрипт искал не и , а <img src=(какая-нить ссылка)>. Если что, то этот скрипт для DLE.

Dimchik
17-04-2011, 14:32
зделай нормальний просмотр ....тогда может кто и откликнется а так...... :unsure:

Sham
21-04-2011, 14:31
preg_match_all*('#\\[img\\](.+?)\\[/img\\]#ie',*$content,*$preg_array); »
preg_match_all ('#\<img\s[^\>]*src\=[\"\']?([^\'\"\>\s]+)[\"\']?[^\>]*\>#ie', $content, $preg_array);




© OSzone.net 2001-2012