DLE Замена url на leech для всех старый новостей

было дело, начал писать свой скрипт,
хотя оказалось что скрипт уже написан

 query ( "SELECT * FROM " . PREFIX . "_post" );

    $parse = new ParseFilter(Array(), Array(), 1, 1);

    while ( $row = $db->get_row ( $sql_result ))
    {

        $short_story = $parse->decodeBBCodes( $row['short_story'], false );
        $full_story  = $parse->decodeBBCodes( $row['full_story'],  false );


        $short_story = str_replace ( "[url=", "[leech=", $short_story );
        $full_story  = str_replace ( "[url=", "[leech=", $full_story );

         $short_story = str_replace ( "[/url]", "[/leech]", $short_story );
         $full_story     = str_replace ( "[/url]", "[/leech]", $full_story );

          $short_story = $db->safesql ( $parse->BB_Parse( $parse->process( $short_story ), false));
          $full_story     = $db->safesql ( $parse->BB_Parse( $parse->process( $full_story ), false));

          $db->query ( "UPDATE " . PREFIX . "_post SET short_story = '{$short_story}', full_story = '{$full_story}' WHERE id = '{$row['id']}'" );


    }

    $db->free();

?>

а вот что я хотел написать, 99% готово

 
query ( "SELECT id FROM " . PREFIX . "_post WHERE 1" );
$all_id = array ();
while ( $row = $db->get_row () ) {
	$all_id[] = $row['id'];
}

echo (sizeof($all_id));
$n = intval($_GET['id']);
echo "#$n#

"; $once = 5; $_p1=''; foreach ($all_id as $k=>$id) { if ($k>=$n && $k<($n+$once) ){ $_p1[] = (int) $id; } } if(!strlen($_p1)) exit; $_p1 = implode(',', $_p1); $db->query ( "SELECT * FROM " . PREFIX . "_post WHERE id in ($_p1)" ); $data = array (); while ( $row = $db->get_row () ) { $data[] = $row; } foreach ($data as $k=>$row) { echo "
({$row['id']})"; $row["short_story"] = addLeach($row["short_story"]); $row["full_story"] = addLeach($row["full_story"]); $db->query ( " UPDATE " . PREFIX . "_post SET `full_story` = '{$db->safesql($row["full_story"])}', `short_story` = '{$db->safesql($row["short_story"])}' WHERE id = {$row['id']}" ); } sleep (1); #header ('Location: /leech_conv.php?id='. $n + $once); $url = '/leech_conv.php?id='. ($n + $once); echo ''; function addLeach($html) { // BEGIN function addLeach $html = preg_replace( "#(.+?)#ie", "\make_leech('\\1\\2', '\\3')", $html ); return $html; } // END function addLeach function make_leech($url = "", $show = "") { GLOBAL $config; $show = stripslashes( $show ); $url_html = $config['http_home_url'] . "engine/go.php?url=" . rawurlencode( base64_encode( $url ) ); $target = 'target="_blank" ' ; $pos = strpos("$url" ,"engine/go.php?url="); if ($pos === false) { return "" . $show . ""; }else{ return "" . $show . ""; } } ?>

Добавить комментарий

Ваш e-mail не будет опубликован.