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
|
<?php
//$dir = '/new/editable/';
//c'est un ajout
if(isset($_GET['action']) && $_GET['action'] =='ajouter')
{
if(isset($_POST['module_content']) && !empty($_POST['module_content']))
{
if(file_exists(realpath($_POST['filename']))){
$ressource_fichier = fopen(realpath($_POST['filename']),'w+');
if($ressource_fichier)
{
fputs($ressource_fichier, $_POST['module_content']);
fclose($ressource_fichier);
}
else
{
echo "ecriture impossible.";
}
}
$ressource_fichier = fopen(realpath($_POST['filename']),'w+');
fputs($ressource_fichier, $_POST['module_content']);
fclose($ressource_fichier);
require_once('../../Connections/connexion_ipcube.php');
mysql_select_db($database_connexion_ipcube, $connexion_ipcube);
$requete = "INSERT INTO pages_module
VALUES ('','".$_POST['module_title']."','http://localhost/new/editable/".$_POST['filename']."','".$_POST['cat_module']."');";
echo $requete;
$resultat = mysql_query($requete, $connexion_ipcube) or die(mysql_error());
}
}
//c'est une modification
if(isset($_GET['action']) && $_GET['action'] =='modifier')
{
if(file_exists('http://localhost/new/editable/'.$_POST['filename'])){
$file = file_get_contents('http://localhost/new/editable/'.$_POST['filename']);
$ressource_fichier = fopen('http://localhost/new/editable/'.$_POST['filename'],'w+');
if($ressource_fichier && is_writable('http://localhost/new/editable/'.$_POST['filename']))
{
fputs($ressource_fichier, $_POST['module_content']);
fclose($ressource_fichier);
}
else
{
echo "ecriture impossible.";
}
}
$ressource_fichier = fopen('http://localhost/new/editable/'.$_POST['filename'],'w');
fputs($ressource_fichier, $_POST['module_content']);
fclose($ressource_fichier);
require_once('../../Connections/connexion_ipcube.php');
mysql_select_db($database_connexion_ipcube, $connexion_ipcube);
$requete = "UPDATE pages_module
SET module_title = '".$_POST['module_title']."',
module_content = 'http://localhost/new/editable/".$_POST['filename']."',
module_cat = '".$_POST['cat_module']."'
WHERE module_id = '".$_POST['module_id']."'";
echo $requete;
$resultat = mysql_query($requete, $connexion_ipcube) or die(mysql_error());
}
?> |
Partager