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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?php
function Addpic() {
include('connexion.php');
if(isset($_POST['ligne']))
{
$ligne=$_POST['ligne'];
$ligne++;
}
else
{
$ligne=1;
}
$ouvre=fopen('/Applications/MAMP/htdocs/wordpress/wp-content/plugins/pluginimage/moto.txt', 'r+'); // ouverture du fichier
while (!feof ($ouvre))
{
$lecture = fgets($ouvre, 4096);
$donnee=explode(" ",$lecture); // parsing)
$nb=count($donnee)-1; // nbre d'éléments séparés
for ($ligne=1;$ligne<=$nb;$ligne++)
{
if (ereg("http.+\.(jpg|png|gif|jpeg)",$donnee[$ligne]))
{
$url=stripslashes($donnee[$ligne]);
}
}
}
fclose($ouvre);// fermeture du fichier txt
if ($_POST['add'])
{
$content = $_POST['describe'].' <br><img class="alignnone" title="img" src="'.$url.'" width="400" height="400" />';
$my_post = array();
$my_post['post_title'] = $_POST['title'];
$my_post['post_content'] =$content;
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(8,39);
// Insert the post into the database
wp_insert_post( $my_post );
}
?>
<div class="wrap">
<form method="post" action="">
<p><H2>Ajout de photos</H2></p>
<ul>
<table>
<tr>
<td valign="top">Titre de l'image:<br> <input type="text" name="title" /><br>
Description:<br> <textarea name="describe" rows="3" id="describe"></textarea><br>
<td valign="top"><?php echo '<img src="'.$url.'" width="200" height="200">'; ?> </td>
<input type="hidden" name="ligne" value="<?php echo $ligne ?>" />
</tr><br>
</table>
<p>
<input type="submit" name="add" value="Ajouter l'image"/>
</p>
<p>
<input type="submit" name="ignore" value="Ignorer l'image"/>
</p>
<p>
<input type="submit" name="exit" value="Quitter l'ajout de photo"/>
</p>
</form>
</div>
<?php
}
?> |
Partager