salut
Question bête : pourquoi tu mets des anti-slash avant chaque déclaration string

?
C'est là en tout cas que ça ne va pas.
Ca m'étonne même que ton ancien serveur ait accepté ce genre de choses...
L'anti-slash ne sert (à ma connaissance) qu'à échapper des caractères à l'interieur d'une chaîne... Mais s'il sont en dehors de la chaîne, forcément ça provoque une erreur...
Donc si tu remplaces tout les
\" par
" et
\' par
' tout va bien... enfin je n'ai pas testé le script mais ça m'a l'air beaucoup mieux déjà

Voilà le résultat (qui a déjà une meilleure tête

) :
<?php
// ***** LAYOUT OPTIONS *****
// an IFRAME is necessary to keep the page "within" your site
// width and height of the IFRAME in your center block
$cp_width = "100%";
$cp_height = 2000;
// ***** SECURITY CONFIGURATION *****
// Groups allowed to select and set their custom page
// This is in the form of their Group ID - example: array('3', '6', '9');
$cp_allowed_groups = array('');
// individual members not allowed to use even if in an allowed group
// uses the member ID - example: array('91', '16');
$cp_disallowed_members = array('');
// whether or not to allow users to make their site public
$cp_allow_public = false;
// ***** DEFAULT STUFF *****
// if the user is not allowed, or doesn't have a custom page yet, what
// page do you want to display to them in the IFRAME?
$cp_default_page = "http://manuel.xbmc.fr/index.php?title=Accueil";
// whether to display the default page if not allowed or no page yet (set to a true value)
// or to not display any page in the block, only the form (set to a false value)
$cp_display_default = 1;
// if $cp_display_default = 0 (or some false value), and user doesn't have a page set,
// display this default text where the IFRAME would have been
$cp_default_text = "You currently do not have a custom page selected.<br />
Please use the form below to select a page.<br />
If you do not see the form below, it is because you do not have access to create a custom page.";
// you can set the tablename to other than custompage if you like
$cp_tablename = "Manuel";
// and the title displayed
$cp_title = "";
// add some descriptive text here if you like to display under title
$cp_desc = "Le Manuel Français de Xbmc est un travail collaboratif éffectué par des bénévoles et bien antérieur à Passion Xbmc. Nous n'avons pas voulu nous l'attribuer, mais vous le faire connaître car c'est une documentation fort utile. Des contributeurs sont bienvenus pour le compléter.";
// if user's browser does not support IFRAMEs, display this where it would be
$cp_no_iframe = "<h1>Custom Page!</h1>
Your browser does not support IFRAMEs. You should get a better browser to see what you are missing!<br />
Check out Mozilla or Firefox, they are great!<br />";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $cp_title . '</b></center><br />';
echo '<font size=1>' . $cp_desc . '</font><p />';
//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;
// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}
$cp_id = $ID_MEMBER;
$cp_admin = false;
// set up all our functions ahead of time
// function to create table if not already there
function CustomPageCreateTable($cp_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $cp_tablename (id INT UNSIGNED NOT NULL PRIMARY KEY,
url TEXT, public tinyint(1) NOT NULL default '0', selected_user INT UNSIGNED);";
if (!mysql_query($dbquery)) {
die("Query Failed! Table NOT Created!<br />\\n");
}
}
// function to modify table to add "public" and "selected_user" columns
function CustomPageModifyTable($cp_tablename) {
// set up the query that will modify the table appropriately
$dbquery = "ALTER TABLE $cp_tablename ADD (public tinyint(1) NOT NULL default '0', selected_user INT UNSIGNED);";
if (!mysql_query($dbquery)) {
if (mysql_errno() == 1060){
// just a double precaution as part of the NULL fix :)
} else {
die("Query Failed! Table NOT Modified!<br />\\n" . mysql_errno() . ": " . mysql_error());
}
}
}
// function to add/edit a user and their custom page to/in the table
function CustomPageAdd($cp_tablename, $cp_id, $cp_url, $cp_selected_user, $cp_public=0) {
if ($cp_url != ''){
if (strtolower(substr($cp_url, 0, 7)) != "http://"){
$cp_url = "http://" . $cp_url;
}
}
// only add user if they do not already exist
$dbquery = "SELECT * FROM $cp_tablename
WHERE id = '" . $cp_id . "'";
$dbresult = mysql_query($dbquery);
if ($dbresult){
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this user in table, edit instead
CustomPageEdit($cp_tablename, $cp_id, $cp_url, $cp_selected_user, $cp_public);
return;
}
}
$dbquery = "INSERT INTO $cp_tablename VALUES ($cp_id, \\"$cp_url\\", $cp_public, $cp_selected_user);";
if (!mysql_query($dbquery)) {
die("Query Failed! Custom Page NOT Inserted into database!<br />\\n");
}
}
// function to edit a user's custom page in the table
function CustomPageEdit($cp_tablename, $cp_id, $cp_url, $cp_selected_user, $cp_public=0) {
// start our dbquery
$dbquery = "UPDATE $cp_tablename ";
// if no URL supplied, don't edit the URL
if ($cp_url != ''){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if (strtolower(substr($cp_url, 0, 7)) != "http://"){
$cp_url = "http://" . $cp_url;
}
// since an url was entered, add it to the update
$dbquery .= "SET url = \\"$cp_url\\", public = $cp_public, selected_user = $cp_selected_user
WHERE id = $cp_id;";
} else {
// update all but the URL
$dbquery .= "SET public = $cp_public, selected_user = $cp_selected_user
WHERE id = $cp_id;";
}
if (!mysql_query($dbquery)) {
die("Query Failed! Custom Page NOT Modified in database!<br />\\n");
}
}
// function to delete Custom Page from the table
function CustomPageDel($cp_tablename, $cp_selected_user) {
// delete Custom Page with $cp_id
$dbquery = "DELETE FROM $cp_tablename WHERE id = $cp_selected_user;";
if (!mysql_query($dbquery)) {
die("Query Failed! Custom Page NOT Deleted from database!<br />\\n");
}
}
/////////// MAIN CODE HERE ////////////
// Admins are always allowed to create a custom page
if ($context['user']['is_admin']){
$cp_admin = 1;
}
// convert $_POST vars to prevent undefined index errors
$cp_save = empty($_POST['cp_save']) ? '' : $_POST['cp_save'];
$cp_del = empty($_POST['cp_del']) ? '' : $_POST['cp_del'];
$cp_urlbox = empty($_POST['cp_urlbox']) ? '' : $_POST['cp_urlbox'];
$cp_public = empty($_POST['cp_public']) ? 0 : $_POST['cp_public'];
$cp_selected_user = empty($_POST['cp_selected_user']) || (!$cp_allow_public && !$cp_admin) ? $ID_MEMBER : $_POST['cp_selected_user'];
// get our script url including parameters (like ?page=6)
$myself = $_SERVER['REQUEST_URL'];
// put the SMF table prefix in front of your tablename from above
$cp_tablename = $tp_prefix . $cp_tablename;
// do same for SMF Members table
$smf_members_table = $db_prefix . 'members';
//////////////// Security Checks ////////////////
// check if user is in a group that is allowed to set a custom page
$cp_allowed = array_intersect($cp_allowed_groups, $user_info['groups']);
// don't let guests set page - would set default for all guests if they did
// also check if user is in the disallow array
if ($context['user']['is_guest'] || @in_array($ID_MEMBER, $cp_disallowed_members)){
$cp_allowed = false;
}
// Admins are always allowed to create a custom page
if ($cp_admin){
$cp_allowed = 1;
}
//////////////////////////////////////////////
// if someone just clicked Save, post info to database
if (!empty($cp_save) && $cp_allowed){
// if the urlbox had info in it, trim it
if (!empty($cp_urlbox)){
$cp_urlbox = trim($cp_urlbox);
} else {
$cp_urlbox = '';
}
CustomPageAdd($cp_tablename, $cp_id, $cp_urlbox, $cp_selected_user, $cp_public);
}
// if someone just deleted a page, remove it from database
if ($cp_del && $cp_admin){
CustomPageDel($cp_tablename, $cp_del);
}
//////////// MAIN DISPLAY CODE HERE ///////////////
// set query to select all data for all users
$dbquery = "SELECT * FROM $cp_tablename;";
$dbresult = mysql_query($dbquery);
if ($dbresult){
// table exists - does it need an upate?
$row = mysql_fetch_assoc($dbresult);
if (in_array("public", array_keys($row))){
// no update needed here!
mysql_data_seek($dbresult, 0);
} else {
// YES! then create the columns!
mysql_free_result($dbquery);
CustomPageModifyTable($cp_tablename);
// re-query the modified table
$dbresult = mysql_query($dbquery);
if (!$dbresult){
die("Unexpected error: " . mysql_error());
}
}
} else {
// no result, is it because table doesn't exist?
if (mysql_errno() == 1146){
// table doesn't exist, create it!
CustomPageCreateTable($cp_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}
$cp_page = '';
$cp_selected_user = $ID_MEMBER;
$cp_selected_page = '';
// cycle through all rows
while ($row = mysql_fetch_assoc($dbresult)){
// add to public pages array if they have set to public (but not ourselves)
// or if the current user is an admin
if (($row["public"] != 0 || $cp_admin) && $row["id"] != $ID_MEMBER){
$cp_public_pages[$row["id"]] = $row["url"];
}
// if our row, get our public status, url, and our selected user
if ($row["id"] == $ID_MEMBER){
$cp_public = $row["public"];
$cp_page = $row["url"];
$cp_urlbox = $cp_page;
$cp_selected_user = $row["selected_user"];
}
}
$cp_public == 0 ? $cp_checked = '' : $cp_checked = "CHECKED";
// free previous result set
mysql_free_result($dbresult);
// if there were some public pages in table, setup the public users array
if (!empty($cp_public_pages)){
$dbquery = "SELECT ID_MEMBER, memberName FROM $smf_members_table
WHERE ID_MEMBER IN (" . implode(",", array_keys($cp_public_pages)) . ");";
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
$cp_public_users = array();
while ($row = mysql_fetch_assoc($dbresult)){
$cp_public_users[$row["ID_MEMBER"]] = $row["memberName"];
}
// free the result for good measure
mysql_free_result($dbresult);
}
// get our selected user's page
if (!empty($cp_public_pages) && @in_array($cp_selected_user, @array_keys($cp_public_pages))){
$cp_selected_page = $cp_public_pages[$cp_selected_user];
}
// if the selected page is null "" then select our own page if it not ""
if (empty($cp_selected_page)){
if (!empty($cp_page)){
$cp_selected_page = $cp_page;
} else {
$cp_display_default ? $cp_selected_page = $cp_default_page : $cp_selected_page = '';
}
}
// display the $cp_selected_page to the user
if (!empty($cp_selected_page)){
echo '<center><IFRAME NAME="CustomPage" ALIGN=middle SRC="' . $cp_selected_page . '" WIDTH=' . $cp_width . ' HEIGHT=' . $cp_height . '>
' . $cp_no_iframe . '
</IFRAME></center>';
} else {
if ($cp_display_default){
echo '<center><IFRAME id="CustomPageID" NAME="CustomPage" ALIGN=middle SRC="' . $cp_default_page . '" WIDTH=' . $cp_width . ' HEIGHT=' . $cp_height . '>
' . $cp_no_iframe . '
</IFRAME></center>';
} else {
echo '<br />' . $cp_default_text . '<p />';
}
}
// only show form if user is allowed to add/edit their custom page
if ($cp_allowed){
//////////////////////////////////////////////////////////////////
///////////// Javascript area /////////////
//////////////////////////////////////////////////////////////////
// write out our javascript stuff
echo '
<script type="text/javascript">
<!--
// create our main array first
var jarray = new Array(); // list of member ids from pull down
var jarray2 = new Array(); // public page user ids
var jarray3 = new Array(); // public page urls
var jarray4 = new Array(); // array of public page user ids => public page urls
jarray[0] = '.$ID_MEMBER.';
jarray4['.$ID_MEMBER.'] = "'.$cp_page.'";
';
if (!empty($cp_public_pages)){
// create a list of public page user ids
$cp_public_user_list = implode(",", array_keys($cp_public_users));
$cp_page_ids = implode(",", array_keys($cp_public_pages));
foreach($cp_public_pages AS $key => $value){
if (empty($cp_page_urls)){
$cp_page_urls = '"' . $value . '"';
} else {
$cp_page_urls .= ',"' . $value . '"';
}
}
echo '
jarray.push('.$cp_public_user_list.');
// if our javascript is huge, big bandwidth waster, save some bandwidth here
jarray2.push('.$cp_page_ids.');
jarray3.push('.$cp_page_urls.');
y = jarray2.length;
for (x=0;x<y;x++){
page_id = jarray2[x];
jarray4[page_id] = jarray3[x];
}
';
}
echo '
function selectedChanged(){
s_id = jarray[document.cp_form.cp_selected_user.selectedIndex];
s_url = jarray4[s_id];
window.frames.CustomPage.location.href = s_url;
}
//-->
</script>
';
// start our form and table
echo '
<p /><form name="cp_form" action="' . $myself . '" method=post>
<table width="100%" border=0>
<tr>
<td width="40%">My Custom Page info:</td>
<td width="10%"></td>
<td width="40%">Public Member Pages</td>
<td width="10%"></td>
</tr>
<tr>
<td width="40%">URL: <input type=text name=cp_urlbox size="50" value="' . $cp_urlbox . '" /></td>
<td width="10%"></td>
<td width="40%" align="left">
<select name=cp_selected_user onChange="selectedChanged()">';
if ($cp_selected_user == $ID_MEMBER){
echo '
<option value="'.$ID_MEMBER.'" SELECTED>' . $user_info["username"] . '</option>
';
} else {
echo '
<option value="'.$ID_MEMBER.'">' . $user_info["username"] . '</option>
';
}
if (!empty($cp_public_users)){
foreach ($cp_public_users as $key => $value){
echo '
';
if ($cp_selected_user == $key){
echo '
<option value="'.$key.'" SELECTED>' . $value . '</option>
';
} else {
echo '
<option value="'.$key.'">' . $value . '</option>
';
}
}
}
echo '
</select>
</td>
<td width="10%"></td>
</tr>
<tr>
<td width="40%"><label><input type=checkbox name=cp_public value="1" ' . $cp_checked . ' />Make my page public</label></td>
<td width="10%"></td>
<td width="40%"></td>
<td width="10%"></td>
</tr>
<tr>
<td colspan="4" align="center"><input type=submit name=cp_save value="Save" /></td>
</tr>
</table>
</form>
';
}
?>