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 80 81 82 83 84 85 86 87 88 89 90
| <?
include('verify.php');
$title = $_POST['title'];
$bigline = $_POST['bigline'];
$text = $_POST['text'];
$categorie = $_POST['categorie'];
$categorie_name = $_POST['categorie_name'];
$author = $_POST['author'];
// Call for the name of categorie
$queryd = "SELECT * FROM $table_d WHERE id_cat=$categorie";
$resultd = mysql_query($queryd);
$mycat = @mysql_fetch_object($resultd);
$categorie_name = $mycat->categorie_name;
// LAST INCREMENTATION
$queryz = "SELECT last FROM $table_g";
$resultz = mysql_query($queryz);
$incr = @mysql_fetch_object($resultz);
$nrowss = $incr->last;
// NEW ID
$id= $nrowss+1;
umask(0000);
mkdir('../blog/'.$id.'', 0777);
// Folder blog + id of the new article
$uploadDir = '../blog/'.$id.'/';
// Image file data
$fileName = $_FILES['preview']['name'];
$tmpName = $_FILES['preview']['tmp_name'];
// File extension extraction
$ext = substr(strrchr($fileName, "."), 1);
// File extension verification
if ($ext != "jpg" ) {
echo alert("Only jpg file are accepted (extension .jpg) Thanks !");
exit;
}
// Generate random name
$randName = md5(rand() * time());
// Creation of path
$filePath = $uploadDir . $fileName;
$newfilename = $fileName;
// UPLOAD IMAGE
// If something wrong.... we stop ! or we upload.
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error during upload... Please read the help doc.";
exit;
}
$date_post = date("Y-m-d H:i:s");
$insert = mysql_query("INSERT INTO $table_b
(
title,
bigline,
text,
preview,
categorie,
categorie_name,
author,
date_post
)
VALUES
(
'$title',
'$bigline',
'$text',
'$newfilename',
'$categorie',
'$categorie_name',
'$author',
'$date_post'
)") or die(mysql_error());
if(!$insert) echo alert("Error during insert...");
$update = mysql_query("UPDATE $table_g SET last='$id'");
if(!$update) echo alert("Error during update...");
header("location:update_rss.php");
?> |
Partager