bonjour a tous
mon probleme est simple pour vous et difficile pour moi
voila ce code est un plugin de mon portail .
j ai deux champs
champ 1 title
champ 2 description
je voudrai utiliser ma fonction qui est en bas pour traiter les carcteres .
function verification($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);
}
je ne sais pas comment et ou l inserer j ai fais des essais à
// Validation checks
à
//Get details from DB if Edit, otherwise set from POST data
ça ne marche pas . merci pour votre aide
[code]
<?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."atoll/language/".e_LANGUAGE.".php")){
require_once(e_PLUGIN."atoll/language/".e_LANGUAGE.".php");
}
$debug = false;
$configtitle = ATOLL_ADMIN_00;
$atolltable = "atoll";
$categorytable = "atoll_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.
$fieldcapt[] = ATOLL_ADMIN_MEDIA_00_0;
$fieldname[] = "title";
$fieldtype[] = "text";
$fieldvalu[] = ",96%,100";
$fieldmand[] = "*";
$fieldcapt[] = ATOLL_ADMIN_MEDIA_01_0;
$fieldname[] = "description";
$fieldtype[] = "textarea";
$fieldvalu[] = ",96%,500px";
$fieldmand[] = "";
$fieldcapt[] = ATOLL_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_".$atolltable;
}
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 ".ATOLL_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($atolltable, "0, $inputstr", $debug))
{
$message = ATOLL_ADMIN_MEDIA_06;
unset($_POST['add']);
}
else
{
$message = ATOLL_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($atolltable, "$inputstr WHERE $primaryid='".$_POST[$primaryid]."'", $debug))
{
$message = ATOLL_ADMIN_MEDIA_04;
unset($_POST['update']);
}
else
{
if ($debug) print "<br>".mysql_error()."<br>";
$message = ATOLL_ADMIN_MEDIA_05;
} }
//$fieldname
// Get details from DB if Edit, otherwise set from POST data
if (isset($_POST['edit'])) {
$sql -> db_Select($atolltable, "*", " $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($atolltable, "$primaryid='".$_POST['existing']."' ")) ? ATOLL_ADMIN_MEDIA_08 : ATOLL_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($atolltable, "*", " order by id asc", "");
if (!$table_total) {
$text .= ATOLL_ADMIN_MEDIA_10;
} else {
$text .= "<span class='defaulttext'>".ATOLL_ADMIN_MEDIA_00.":</span><select name='existing' class='tbox'>";
while (list($id, $title, $description, $rest) = $sql-> db_Fetch()) {
$sql2->db_Select($atolltable, "*", "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='".ATOLL_ADMIN_MEDIA_01."' />
<input class='button' type='submit' name='delete' value='".ATOLL_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='".ATOLL_ADMIN_MEDIA_02."' />
<input type='hidden' name='$primaryid' value='".$row[$primaryid]."'>";
} else {
$text .= "<input class='button' type='submit' id='add' name='add' value='".ATOLL_ADMIN_MEDIA_03."' />";
}
$text .= "</td></tr></table></form></div>";
$ns->tablerender($configtitle, $text);
require_once(e_ADMIN."footer.php");
?>
[/code]