1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
header("Content-Type: image/jpg");
#---------------------------------------
#on se connecte à la base de données
#---------------------------------------
function bdd_connect() {
$link=@mysql_connect("localhost","root",""); // sql's params here
if ($link && @mysql_select_db("nom_base")) // here database's name
return ($link);
return (FALSE);
}
$link=bdd_connect();
if (!$link) die("SQL connexion failed");
#---------------------------------------------
#choisir la table et prendre la colonne thumbs
#----------------------------------------------
function recup_images($chemin, $sponsor){
$i='';
$j='';
switch($spnsor){
case 'XP,pp':
$SQL_THUMBS = "xp_videos";
$SQL_COLUMN = "thumbs";
$NB_THUMBS = 10;
$sql_recup_thumbs = mysql_query("SELECT $SQL_COLUMN FROM $SQL_THUMBS") or die(mysql_error());
$row = mysql_fetch_row($sql_recup_thumbs) or die(mysql_error());
$NUM_ROWS = mysql_num_rows($sql_recup_thumbs) or die(mysql_error());
$URL_IMG = "http://img$i.domaine.com/rep/$row[$j]/$i.jpg";
break;
}
for($j=0;$j<=$NUM_ROWS;$j++){
for($i=1;$i<=$NB_THUMBS;$i++){
$destination = $chemin.$row[$j].','.$i.'.jpg';
$reponse = file_get_contents($URL_IMG);
echo $URL_IMG;
copy($URL_IMG,$destination);
}
}
}
recup_images('STORAGE/','XP,pp');
#fermer la connexion à la base de données
@mysql_close($link);
?> |