?
Path : /home/admin/public_html/old/ |
Current File : /home/admin/public_html/old/updatecode.php |
<?php $host="localhost:8889"; $user="root"; $pw="root"; $dbname="happytokorea"; $connect=mysql_connect($host,$user,$pw); mysql_select_db($dbname,$connect)or die("can not connect database"); mysql_query("set NAMES utf8"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>File update sql by php</title> </head> <body> <? $sql = "SELECT * FROM `jos_content` WHERE `catid`=20 or `catid`=21 and `images`='' order by `id` desc"; $result = mysql_query($sql); while($row= mysql_fetch_array($result)) { $id=$row["id"]; $images = $row["images"]; $introtext = $row["introtext"]; preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i',$introtext, $i); echo $id."<br>"; if(!stristr($i[src],"http://www.happytokorea.com/")) $i[src]="http://www.happytokorea.com/".$i[src]; $i[src]=str_replace("/", "\/",$i[src]); $change="{\"image_intro\":\"".$i[src]."\",\"float_intro\":\"\",\"image_intro_alt\":\"\",\"image_intro_caption\":\"\",\"image_fulltext\":\"\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"\",\"image_fulltext_caption\":\"\"}"; echo $change."<br>"; } ?> </body> </html>