Ecshop remote product details Image localization php code
";}Exit () ;}sleep (1 ); $ SQL = "select 'goods _ desc' from 'p _ goods 'where 'goods _ id' =' $ ID' limit 1 "; $ res = mysql_fetch_array (mysql_query ($ SQL); preg_match_all ('/src = [\' | "] ([^" | ^ \ '] +) [\ '| "]/I', $ res [0], $ picurl); $ urlArr = $ picurl [1];/* print_r ($ urlArr ); die (); $ urlArr [] = "http://static.oschina.net/uploads/user/129/258733_50.jpg"; $ urlArr [] = "http://static.oschina.net/uploads/img/201302/16195715_kPci.png"; */$ num = is Set ($ _ GET ['num'])? $ _ GET ['num']: 1; $ all = count ($ urlArr); $ url = $ urlArr [$ num-1]; if (! Preg_match ('/(http: \/)/I', $ url) {if ($ num> = $ all) {exit ('
All done! ');} Echo $ url ."
Processed "; echo" script location. href = '? Id = {$ id} & num = ". ($ num + 1 ). "'script"; exit () ;}$ array = @ get_headers ($ url, 1); echo $ url."
"; If (preg_match ('/ 200/', $ array [0]) {ob_start (); readfile ($ url); $ img = ob_get_contents (); ob_end_clean (); $ dir = "images/goods_desc"; if (! File_exists ($ dir) {mkdir ($ dir, 0777);} $ filename = $ dir. "/". mt_rand (11111,9999999999 ). time (). ". jpg "; $ f = fopen ($ filename, 'A'); $ fres = fwrite ($ f, $ img); fclose ($ f); if ($ fres! = False) {$ goods_desc = str_replace ($ url ,"/". $ filename, $ res [0]); $ SQL = "update 'p _ goods 'set 'goods _ desc' =' $ goods_desc 'Where 'goods _ id' = '$ ID' limit 1 "; mysql_query ($ SQL) ;}} echo $ num. "/". $ all; if ($ num >=$ all) {exit ('
All done! ');} Else {echo "script location. href = '? Id = {$ id} & num = ". ($ num + 1)." 'script ";}?>