probleme pour ajouter fonc.. supprimer ts les carac..s spéc
Posté : 06 févr. 2009, 22:01
je ne sais pas comment metre en place ma fonction suppression de tous les caractères spéciaux pour les champs title et description
j'ai essayé a c est balise
// Get details from DB if Edit, otherwise set from POST data
et la
// Data is valid so try and add
et la page je voudrai l integrer
j'ai essayé a c est balise
// Get details from DB if Edit, otherwise set from POST data
et la
// Data is valid so try and add
Code : Tout sélectionner
function verifnomimage($texte)
{
$texte = strtr( $texte,"àáâãäåòóôõöøèéêëçìíîïùúûüÿñÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜÑ","aaaaaaooooooeeeeciiiiuuuuynAAAAAAOOOOOOEEEECIIIIUUUUN");
$texte = strtr($texte," ","_");
$texte = str_replace("'","_",$texte);
$texte = str_replace("\"","_",$texte);
$texte = str_replace("&","",$texte);
$texte = str_replace("(","",$texte);
$texte = str_replace(")","",$texte);
$texte = str_replace("[","",$texte);
$texte = str_replace("]","",$texte);
$texte = str_replace(":","",$texte);
$texte = str_replace("<","",$texte);
$texte = str_replace(">","",$texte);
$texte = str_replace("\\","",$texte);
$texte = str_replace("/","",$texte);
$texte = str_replace("*","",$texte);
$texte = str_replace("?","",$texte);
$texte = str_replace("’","",$texte);
$texte = str_replace("«","",$texte);
$texte = str_replace("»","",$texte);
$texte = str_replace("~","",$texte);
$texte = str_replace("|","",$texte);
$texte = str_replace("`","",$texte);
$texte = str_replace("^","",$texte);
$texte = str_replace("°","",$texte);
$texte = str_replace("=","",$texte);
$texte = str_replace("+","",$texte);
$texte = str_replace("-","",$texte);
$texte = str_replace("¨","",$texte);
$texte = str_replace("$","",$texte);
$texte = str_replace("£","",$texte);
$texte = str_replace("¤","",$texte);
$texte = str_replace("%","",$texte);
$texte = str_replace("µ","",$texte);
$texte = str_replace("§","",$texte);
$texte = str_replace("!","",$texte);
$texte = str_replace(";","",$texte);
$texte = str_replace(".","",$texte);
$texte = str_replace(",","",$texte);
$texte = str_replace("@","",$texte);
$texte = str_replace("²","2",$texte);
$texte = str_replace(" "," ",$texte);
return($texte);
}Code : Tout sélectionner
<?php
require_once("../../class2.php");
if (!getperms("P")) {
header("location:".e_BASE."index.php");
}
require_once(e_ADMIN."auth.php");
if (file_exists(e_PLUGIN."eplayer/language/".e_LANGUAGE.".php")){
require_once(e_PLUGIN."eplayer/language/".e_LANGUAGE.".php");
}
$debug = false;
$configtitle = EPLAYER_ADMIN_00;
$eplayertable = "eplayer";
$categorytable = "eplayer_category";
$primaryid = "id"; // first column of your table.
$e_wysiwyg = ""; // commas seperated list of textareas to use wysiwyg with.
$pageid = "media"; // unique name that matches the one used in admin_menu.php.
$show_preset = FALSE; // allow e107 presets to be saved for use in the form.
$downloads = eplayerGetFiles(e_FILE, $pref["eplayer_media_dir"]);
$fieldcapt[] = EPLAYER_ADMIN_MEDIA_00_0;
$fieldname[] = "title";
$fieldtype[] = "text";
$fieldvalu[] = ",96%,100";
$fieldmand[] = "*";
$fieldcapt[] = EPLAYER_ADMIN_MEDIA_01_0;
$fieldname[] = "description";
$fieldtype[] = "textarea";
$fieldvalu[] = ",96%,500px";
$fieldmand[] = "";
$fieldcapt[] = EPLAYER_ADMIN_MEDIA_09_0;
$fieldname[] = "author";
$fieldtype[] = "text";
$fieldvalu[] = USERNAME.",50,100";
$fieldmand[] = "";
//---------------------------------------------------------------
// END OF CONFIGURATION AREA
//---------------------------------------------------------------
// -------- Presets. ------------ // always load before auth.php
if ($show_preset) {
require_once(e_HANDLER."preset_class.php");
$pst = new e_preset;
$pst->form = "adminform"; // form id of the form that will have it's values saved.
$pst->page = e_SELF; // display preset options on which page(s).
$pst->id = "admin_".$eplayertable;
}
require_once(e_ADMIN."auth.php");
require_once("form_handler.php");
$rs = new form;
// Validation checks
if (isset($_POST['add']) || isset($_POST['update'])) {
if (strlen($_POST['title']) == 0) {
$message .= "Title ".EPLAYER_ADMIN_MEDIA_12;
}
}
// Data is valid so try and add
if (!isset($message) && isset($_POST['add'])) {
if ($debug) print "<br>".print_r($_POST)."<br>";
$count = count($fieldname);
for ($i=0; $i<$count; $i++) {
$inputstr .= " '".$rs->getfieldvalue($fieldname[$i], $fieldtype[$i], $debug)."', ";
}
$inputstr .= time();
if ($sql->db_Insert($eplayertable, "0, $inputstr", $debug)) {
$message = EPLAYER_ADMIN_MEDIA_06;
unset($_POST['add']);
} else {
$message = EPLAYER_ADMIN_MEDIA_07;
}
}
// Data is valid so try and update
if (!isset($message) && isset($_POST['update'])) {
if ($debug) print "<br>".print_r($_POST)."<br>";
$count = count($fieldname);
for ($i=0; $i<$count; $i++) {
$inputstr .= $fieldname[$i]."='".$rs->getfieldvalue($fieldname[$i], $fieldtype[$i], $debug)."', ";
}
$inputstr .= "timestamp=".time();
if ($sql->db_Update($eplayertable, "$inputstr WHERE $primaryid='".$_POST[$primaryid]."'", $debug)) {
$message = EPLAYER_ADMIN_MEDIA_04;
unset($_POST['update']);
} else {
if ($debug) print "<br>".mysql_error()."<br>";
$message = EPLAYER_ADMIN_MEDIA_05;
}
}
// Get details from DB if Edit, otherwise set from POST data
if (isset($_POST['edit'])) {
$sql -> db_Select($eplayertable, "*", " $primaryid='".$_POST['existing']."' ");
$row = $sql->db_Fetch();
} else {
if (isset($_POST['add']) || isset($_POST['update'])) {
$row = $_POST;
}
}
// Try the delete
if (isset($_POST['delete'])) {
if ($debug) print "<br>".print_r($_POST)."<br>";
$message = ($sql -> db_Delete($eplayertable, "$primaryid='".$_POST['existing']."' ")) ? EPLAYER_ADMIN_MEDIA_08 : EPLAYER_ADMIN_MEDIA_09;
}
// Draw the form
$text = "<div style='text-align:center'><form method='post' action='".e_SELF."' id='myexistingform'>
<table style='width:96%;margin-left:auto;margin-right:auto;' class='fborder'>";
if (isset($message)) {
$text .= "<tr><td colspan='2' class='spacer' style='text-align:center'>$message</td></tr>";
if ($debug) print "<br>".mysql_error()."<br>";
}
$text .= "<tr><td colspan='2' class='forumheader' style='text-align:center'>";
$table_total = $sql->db_Select($eplayertable, "*", " order by id asc", "");
if (!$table_total) {
$text .= EPLAYER_ADMIN_MEDIA_10;
} else {
$text .= "<span class='defaulttext'>".EPLAYER_ADMIN_MEDIA_00.":</span><select name='existing' class='tbox'>";
while (list($id, $title, $description, $rest) = $sql-> db_Fetch()) {
$sql2->db_Select($eplayertable, "*", "id=$id order by id");
list($id, $title, $description, $rest) = $sql2->db_Fetch();
$text .= "<option value='$id'>$title ($id)</option>";
}
$text .= "</select><input class='button' type='submit' name='edit' value='".EPLAYER_ADMIN_MEDIA_01."' />
<input class='button' type='submit' name='delete' value='".EPLAYER_ADMIN_MEDIA_11."' /></td></tr>";
}
$text .= "</table></form></div>";
$text .= "<div style='text-align:center'>\n";
$text .= "<form method='post' action='".e_SELF."' id='adminform'><table class='fborder' style='margin-left:auto;margin-right:auto;width:96%'>";
for ($i=0; $i<count($fieldcapt); $i++) {
$form_send = $fieldcapt[$i] . "|" .$fieldtype[$i]."|".$fieldvalu[$i];
$text .="<tr>
<td style='vertical-align:top' class='forumheader3'>".$fieldcapt[$i]." ".$fieldmand[$i]."</td>
<td class='forumheader3'>";
$text .= $rs->user_extended_element_edit($form_send, $row[$fieldname[$i]], $fieldname[$i]);
$text .="</td></tr>";
};
$text .= "<tr style='vertical-align:top'><td colspan='2' style='text-align:center' class='forumheader'>";
if (isset($_POST['edit']) || isset($_POST['update'])){
$text .= "<input class='button' type='submit' id='update' name='update' value='".EPLAYER_ADMIN_MEDIA_02."' />
<input type='hidden' name='$primaryid' value='".$row[$primaryid]."'>";
} else {
$text .= "<input class='button' type='submit' id='add' name='add' value='".EPLAYER_ADMIN_MEDIA_03."' />";
}
$text .= "</td></tr></table></form></div>";
$ns->tablerender($configtitle, $text);
require_once(e_ADMIN."footer.php");
function eplayerGetFiles($prefixdir, $pathdir, $sub=0){
global $t_array, $FILES_DIRECTORY;
if (substr($pathdir, strlen($pathdir)-1, 1) != "/") {
$pathdir .= "/";
}
$dh = opendir($prefixdir.$pathdir);
$size = 0;
$search = array("../", str_replace("../","",$DOWNLOADS_DIRECTORY), $FILES_DIRECTORY, "downloads/", "downloadimages/", "downloadthumbs/");
$replace = array("", "", "", "", "", "");
while ($file = readdir($dh)) {
if ($file != "." and $file != ".." && $file != "index.html" && $file != "null.txt"){
if (is_file($prefixdir.$pathdir.$file)) {
$t_array[] = $prefixdir.$pathdir.$file.":".str_replace($search, $replace, $pathdir.$file);;
} else {
if(!preg_match("#^CVS#", $prefixdir.$patchdir.$file)) {
eplayerGetFiles($prefixdir, $pathdir.$file."/");
}
}
}
}
closedir($dh);
sort($t_array);
for ($i=0; $i<count($t_array); $i++) {
$csv .= $t_array[$i];
if ($i<count($t_array)-1) {
$csv .= ",";
}
}
return $csv;
}
?>