mirror of
https://github.com/pierre42100/comunic
synced 2025-06-20 09:05:21 +00:00
First commit
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* If two personns are friend, this file check
|
||||
* the second one has right to make posts on
|
||||
* the first one page.
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
if($afficher['autoriser_post_amis'] == 1 and detectesilapersonneestamie($_SESSION['ID'], $idPersonn, $bdd))
|
||||
{
|
||||
//Requête de recherche (en fait, on regarde la ligne "ami" du point de vue de l'autre personne...)
|
||||
$sql = "SELECT * FROM amis WHERE (ID_personne = ?) && (ID_amis = ?) && (actif = 1)";
|
||||
|
||||
//Exécution de la requête
|
||||
$requeteamis = $bdd->prepare($sql);
|
||||
$requeteamis->execute(array($idPersonn, $_SESSION['ID']));
|
||||
|
||||
//On renvoi le résultat suivant si la personne est amie ou non
|
||||
if(!$verifierautorisation = $requeteamis->fetch())
|
||||
{
|
||||
//On ne possède pas de droit
|
||||
}
|
||||
else
|
||||
{
|
||||
//On vérifie si l'on a le droit
|
||||
if($verifierautorisation['autoriser_post_page'] == 1)
|
||||
$allowcreatepost = 1; //On l'a!
|
||||
}
|
||||
|
||||
//Fermeture de la requete
|
||||
$requeteamis->closeCursor();
|
||||
}
|
48
inc/pages/homeUser/addPost/controllers/postEvent.inc.php
Normal file
48
inc/pages/homeUser/addPost/controllers/postEvent.inc.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Post an event
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//Exemple d'envoi :
|
||||
// [date] => 16.04.2015
|
||||
// [heure] => 4
|
||||
// [minute] => 4
|
||||
// [nom_evenement] => test
|
||||
// [niveau_visibilite] => 2
|
||||
|
||||
$date = $_POST['date'];
|
||||
//$heure = $_POST['heure']*1;
|
||||
//$minute = $_POST['minute']*1;
|
||||
$nom_evenement = $_POST['nom_evenement'];
|
||||
|
||||
if($date == "")
|
||||
{
|
||||
echo affiche_message_erreur("L'événement n'a pas de date !"); //L'événement doit avoir une date
|
||||
}
|
||||
else
|
||||
{
|
||||
//Décomposition de la date
|
||||
$array_date = explode('|', str_replace('.', '|', $date));
|
||||
|
||||
if(count($array_date) != 3)
|
||||
echo affiche_message_erreur("La date spécifiée est incorrecte."); //La date donnée est invalide
|
||||
elseif($array_date[1] > 31 OR $array_date[1] < 1)
|
||||
echo affiche_message_erreur("Le jour spécifié est incorrect."); //Le jour donné est invalide
|
||||
elseif($array_date[2] < date("Y", time()))
|
||||
echo affiche_message_erreur("L'année donnée est passée."); //L'année donnée est invalide
|
||||
else
|
||||
{
|
||||
//Ajout du texte
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $nom_evenement, $bdd, $niveau_visibilite, "count_down", "", $array_date[2], $array_date[1], $array_date[0]);
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $nom_evenement, $bdd, $niveau_visibilite, "count_down", "", $array_date[2], $array_date[1], $array_date[0]);
|
||||
|
||||
//Message de succès
|
||||
echo "<p><img src='".path_img_asset('succes.png')."' title='Succès' alt='V' /> L'événement a bien été ajouté.</p>";
|
||||
}
|
||||
}
|
72
inc/pages/homeUser/addPost/controllers/postPDF.inc.php
Normal file
72
inc/pages/homeUser/addPost/controllers/postPDF.inc.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a PDF file
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//Enregistrement du texte dans une variable
|
||||
$texte = $_POST['texte_post_with_pdf'];
|
||||
|
||||
if(isset($_FILES['fichier_pdf']))
|
||||
{
|
||||
//Enregistrement des informations du PDF dans une variable
|
||||
$infos_pdf = $_FILES['fichier_pdf'];
|
||||
|
||||
//Contrôle de la présence d'une erreur
|
||||
if($infos_pdf['error'] != 0)
|
||||
{
|
||||
//Une erreur a survenue lors de l'envoi
|
||||
$erreur_ajout_pdf = "Une erreur a survenue lors de l'envoi du PDF. Merci de réssayer.";
|
||||
}
|
||||
elseif($infos_pdf['type'] != "application/pdf")
|
||||
{
|
||||
//Le fichier choisi n'est pas un PDF
|
||||
$erreur_ajout_pdf = "Le fichier envoyé n'est pas un PDF.";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Détermination du nom du pdf
|
||||
$nom_pdf = sha1(time().$_SESSION['ID'].$texte.$_SERVER['REMOTE_ADDR']);
|
||||
|
||||
while(file_exists(relativeUserDataFolder("post_pdf/".$nom_pdf.".pdf")))
|
||||
{
|
||||
$nom_pdf = crypt($nom_pdf);
|
||||
}
|
||||
|
||||
//On vérifie si un dossier a été allouée à la personne, création automatique le cas échéant
|
||||
checkPersonnalFolder(relativeUserDataFolder("post_pdf/"), $_SESSION['ID']);
|
||||
$folder_user_pdf = "post_pdf/".$_SESSION['ID']."/";
|
||||
|
||||
//On finit le nom du PDF
|
||||
$nom_pdf = $folder_user_pdf.$nom_pdf.".pdf";
|
||||
|
||||
//Copie du PDF
|
||||
if(move_uploaded_file($infos_pdf['tmp_name'], relativeUserDataFolder($nom_pdf)))
|
||||
{
|
||||
//Ajout du texte
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $texte, $bdd, $niveau_visibilite, "pdf", $nom_pdf);
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $texte, $bdd, $niveau_visibilite, "pdf", $nom_pdf);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Il y a une erreur lors de la copie
|
||||
$erreur_ajout_pdf = "Une erreur a survenue lors de la copie du PDF vers son emplacement définitif. Merci de réssayer.";
|
||||
}
|
||||
}
|
||||
|
||||
//Si il y a une erreur, on l'affiche
|
||||
if(isset($erreur_ajout_pdf))
|
||||
{
|
||||
?><script>affiche_notification_erreur("<?php echo $erreur_ajout_pdf; ?>");</script><?php
|
||||
}
|
||||
else
|
||||
{
|
||||
//Sinon on affiche un message de succès
|
||||
?><script>affiche_notification_succes("Le PDF a bien été enregistré.");</script><?php
|
||||
}
|
||||
}
|
87
inc/pages/homeUser/addPost/controllers/postSurvey.inc.php
Normal file
87
inc/pages/homeUser/addPost/controllers/postSurvey.inc.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a survey
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//Enregistrement des variables
|
||||
$reponses_sondage = bloquebalise($_POST['reponses_sondage']);
|
||||
$question_sondage = bloquebalise($_POST['question_sondage']);
|
||||
$commentaire_sondage = $_POST['commentaire_sondage'];
|
||||
|
||||
//Choix par défaut pour les réponses au sondage si il n'y en a aucune
|
||||
if(str_replace("\n", "", $reponses_sondage) == "")
|
||||
$reponses_sondage = "None";
|
||||
|
||||
//On commence par enregistrer le texte dans la bdd
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $commentaire_sondage, $bdd, $niveau_visibilite, "sondage");
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $commentaire_sondage, $bdd, $niveau_visibilite, "sondage");
|
||||
|
||||
//Récupération des informations sur le texte précédemment posté
|
||||
$infos_texte = select_sql("texte", "texte = ? AND (ID_personne = ? OR ID_amis = ?) AND niveau_visibilite = ? ORDER BY ID DESC", $bdd, array(
|
||||
$commentaire_sondage,
|
||||
$_SESSION['ID'],
|
||||
$_SESSION['ID'],
|
||||
$niveau_visibilite
|
||||
));
|
||||
|
||||
//On vérifie que l'on a bien notre texte
|
||||
if(count($infos_texte) == 0)
|
||||
{
|
||||
//Rapport d'erreur à l'administration
|
||||
report_error('if(count($infos_texte) == 0)', 'La variable $infos_texte ne compte aucune entrée, alors qu\'elle devrait en contenir au moins une (permet l\'ajout de sondages) dans addpost.php (inc).');
|
||||
|
||||
//Affichage d'un message d'erreur
|
||||
affiche_message_erreur("Nous avons rencontré une erreur en interne. (Err Sondage Inser 1) L'administration a été informée de cette erreur. Nous ferons en sorte de la réparer au plus vite, veuillez réssayer d'envoyer votre sondage.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Poursuite
|
||||
|
||||
//Récupération de l'ID du sondage
|
||||
$idPersonn_texte = $infos_texte[0]['ID'];
|
||||
|
||||
//Création du sondage
|
||||
insert_sql("sondage", "ID_utilisateurs, ID_texte, date_creation, question", "?, ?, NOW(), ?", $bdd, array($_SESSION['ID'], $idPersonn_texte, $question_sondage));
|
||||
|
||||
$infos_sondage = select_sql("sondage", "ID_utilisateurs = ? AND ID_texte = ? AND question = ? ORDER BY ID DESC", $bdd, array(
|
||||
$_SESSION['ID'],
|
||||
$idPersonn_texte,
|
||||
$question_sondage
|
||||
));
|
||||
|
||||
if(count($infos_sondage) == 0)
|
||||
{
|
||||
//Rapport d'erreur à l'administration
|
||||
report_error('if(count($infos_sondage) == 0)', 'La variable $infos_sondage ne compte aucune entrée, alors qu\'elle devrait en contenir au moins une (permet l\'ajout de sondages) dans addpost.php (inc).');
|
||||
|
||||
//Affichage d'un message d'erreur
|
||||
affiche_message_erreur("Nous avons rencontré une erreur en interne. (Err Sondage Inser 2) L'administration a été informée de cette erreur. Nous ferons en sorte de la réparer au plus vite, veuillez réssayer d'envoyer votre sondage.");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
//Récupération de l'ID du sondage
|
||||
$idPersonn_sondage = $infos_sondage[0]['ID'];
|
||||
|
||||
//Ajout des réponses au sondage
|
||||
$array_reponses = explode("\n", $reponses_sondage);
|
||||
foreach($array_reponses as $traiter)
|
||||
{
|
||||
//Vérification de la réponse
|
||||
if($traiter != "" AND $traiter != " ")
|
||||
{
|
||||
//Ajout du choix à la BDD
|
||||
insert_sql("sondage_choix", "ID_sondage, date_creation, choix", "?, NOW(), ?", $bdd, array($idPersonn_sondage, $traiter));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Message de succès
|
||||
?><script>affiche_notification_succes("Le sondage a bien été enregistré.");</script><?php
|
||||
}
|
48
inc/pages/homeUser/addPost/controllers/postTextImage.inc.php
Normal file
48
inc/pages/homeUser/addPost/controllers/postTextImage.inc.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a text or an image
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//An image does not require a valid text
|
||||
if((isset($_FILES['image'])) AND ($_FILES['image']['error'] == 0))
|
||||
$image = true;
|
||||
else
|
||||
$image = false;
|
||||
|
||||
//On vérifie si le texte n'est pas vide
|
||||
if($_POST['texte'] != "" OR $image)
|
||||
{
|
||||
//Vérification de la validité du post
|
||||
if(verifie_validite_ajout($_POST['texte']) OR $image)
|
||||
{
|
||||
|
||||
//On vérifie si une image est incorporée au post
|
||||
if((isset($_FILES['image'])) AND ($_FILES['image']['error'] == 0))
|
||||
{
|
||||
//Envoi de l'image en ligne
|
||||
envoiimage(($_SESSION['ID'] == $idPersonn ? $_SESSION['ID'] : $idPersonn) , $_POST['texte'], $bdd, ($_SESSION['ID'] == $idPersonn ? 0 : $_SESSION['ID']), $niveau_visibilite);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ajout du texte
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $_POST['texte'], $bdd, $niveau_visibilite);
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $_POST['texte'], $bdd, $niveau_visibilite);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//On affiche un message d'erreur
|
||||
?><script type='text/javascript'>affiche_notification_erreur("Votre texte est invalide : pas assez de caractères différents (au minimum 3).", "Erreur", 10);</script><?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//On affiche un message d'erreur
|
||||
?><script type='text/javascript'>affiche_notification_erreur("L'ajout de textes vides est interdit !", "Erreur", 10);</script><?php
|
||||
}
|
35
inc/pages/homeUser/addPost/controllers/postVideo.inc.php
Normal file
35
inc/pages/homeUser/addPost/controllers/postVideo.inc.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a personnal video
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
if($_POST['idvideo'] != "" && $_POST['niveau_visibilite'] != "")
|
||||
{
|
||||
//On vérifie si il faut prendre la dernière vidéo disponible
|
||||
if($_POST['idvideo'] == "last_one")
|
||||
$_POST['idvideo'] = id_video_plus_recente($_SESSION['ID'], $bdd); //Récupération de l'ID de la vidéo la plus récente
|
||||
|
||||
if(isset_video($_POST['idvideo'], $_SESSION['ID'], $bdd))
|
||||
{
|
||||
if($_POST['niveau_visibilite'] <= 3)
|
||||
{
|
||||
//Ajout de la vidéo
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
add_movie($_SESSION['ID'], $_POST['commentaire_video'], $_POST['idvideo'], $bdd, $_POST['niveau_visibilite']);
|
||||
else //Si c'est un amis
|
||||
add_movie($idPersonn, $_POST['commentaire_video'], $_POST['idvideo'], $bdd, $_POST['niveau_visibilite'], $_SESSION['ID']);
|
||||
}
|
||||
else
|
||||
{
|
||||
?><script>affiche_notification_erreur("Il y a une erreur dans votre requête.");</script><?php //Vidéo indisponible
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?><script>affiche_notification_erreur("La vidéo dmandée n'est pas disponible.");</script><?php //Vidéo indisponible
|
||||
}
|
||||
}
|
54
inc/pages/homeUser/addPost/controllers/postWebLink.inc.php
Normal file
54
inc/pages/homeUser/addPost/controllers/postWebLink.inc.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a web link
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//Enregistrement de l'URL
|
||||
$url = $_POST['adresse_page'];
|
||||
$description = ($_POST['texte_lien_page'] != "" ? "<p>".$_POST['texte_lien_page']."</p>" : "");
|
||||
|
||||
//Inclusion de la fonction d'analyse
|
||||
require_once(relativePath_3rdparty('analysing_page/analyser_fr.php'));
|
||||
|
||||
//Contrôle de l'URL
|
||||
if(!preg_match('<http://>', $url) AND !preg_match('<https://>', $url))
|
||||
{
|
||||
echo affiche_message_erreur("L'URL saisie est invalide !"); //L'URL donnée est invalide
|
||||
}
|
||||
else
|
||||
{
|
||||
//On commence par récupérer le code source de l'URL
|
||||
ob_start();
|
||||
$source = file_get_contents($url);
|
||||
ob_end_clean();
|
||||
|
||||
//Contrôle de la source
|
||||
if($source == "")
|
||||
{
|
||||
echo affiche_message_erreur("La page demandée n'a pas été trouvée !"); //Page non trouvée (404)
|
||||
}
|
||||
else
|
||||
{
|
||||
//On peut tenter d'extraire les informations
|
||||
$infos_page = analyse_source_page_extrait_description($source);
|
||||
|
||||
//On prépare l'enregistrement de la page
|
||||
$infos_page['titre'] = ($infos_page['titre'] == null ? "default" : $infos_page['titre']);
|
||||
$infos_page['description'] = ($infos_page['description'] == null ? "default" : $infos_page['description']);
|
||||
$infos_page['image'] = ($infos_page['image'] == null ? "default" : $infos_page['image']);
|
||||
|
||||
//On enregistre la page
|
||||
//Ajout du texte
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $description, $bdd, $niveau_visibilite, "webpage_link", "", 0, 0, 0, $url, $infos_page['titre'], $infos_page['description'], $infos_page['image']);
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $description, $bdd, $niveau_visibilite, "webpage_link", "", 0, 0, 0, $url, $infos_page['titre'], $infos_page['description'], $infos_page['image']);
|
||||
|
||||
//Message de succès
|
||||
echo "<p><img src='".path_img_asset('succes.png')."' title='Succès' alt='V' /> Le lien vers la page a bien été ajouté.</p>";
|
||||
}
|
||||
}
|
53
inc/pages/homeUser/addPost/controllers/postYouTube.inc.php
Normal file
53
inc/pages/homeUser/addPost/controllers/postYouTube.inc.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Post a YouTube video
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
if($_POST['youtube'] != "")
|
||||
{
|
||||
//Exemple d'URL YouTube :
|
||||
// https://www.youtube.com/watch?v=1MBU0yRgBTw
|
||||
|
||||
if(strpbrk($_POST['youtube'], "<https://www.youtube.com/watch?v=>") != false OR strpbrk($_POST['youtube'], "<http://www.youtube.com/watch?v=>") != false)
|
||||
{
|
||||
$adresse = strstr($_POST['youtube'], "watch?v=");
|
||||
|
||||
$adresse = str_replace("watch?v=", "", $adresse);
|
||||
|
||||
if($adresse != "")
|
||||
{
|
||||
//Définition du texte de la vidéo
|
||||
$source = "";
|
||||
|
||||
if($_POST['commentyoutube'] != "")
|
||||
{
|
||||
if(!preg_match('/endof/', $_POST['commentyoutube']))
|
||||
{
|
||||
$source .= $_POST['commentyoutube'];
|
||||
}
|
||||
}
|
||||
|
||||
//Enregistrement de la vidéo
|
||||
//Ajout du texte
|
||||
if($_SESSION['ID'] == $idPersonn)
|
||||
ajouttexte($_SESSION['ID'], $source, $bdd, $niveau_visibilite, "youtube", $adresse);
|
||||
else //Si c'est un amis
|
||||
ajouttexte_amis($_SESSION['ID'], $idPersonn, $source, $bdd, $niveau_visibilite, "youtube", $adresse);
|
||||
|
||||
//Message de succès
|
||||
?><script>affiche_notification_succes("La vidéo a bien été enregistrée.");</script><?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?><script>affiche_notification_erreur("L'adresse de la vidéo YouTube est incorrecte.");</script><?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?><script>affiche_notification_erreur("L'adresse de la vidéo YouTube est incorrecte. Le nom de domaine ou l'URL est incorrecte.");</script><?php
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user