If et variable

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : If et variable

par Mathieu68 » 28 nov. 2008, 11:11

// Reverse the effect of register_globals
unregister_globals();
tant miex pour toi :D

par contre je sais pas du tout quoi sert cette fonction!

par Nicost » 27 nov. 2008, 22:52

merci beaucoup pour ton aide Mathieu68 :D
toujours pareil, rien ne s' affiche :(
le chemin pour le fichier common.php est bon, aucune erreur, j'ai fait la modif comme tu a dis, idem pas d' erreur.

Dans le fichier : common.php
// Enable DEBUG mode by removing // from the following line
//define('PUN_DEBUG', 1);

// This displays all executed queries in the page footer.
// DO NOT enable this in a production environment!
//define('PUN_SHOW_QUERIES', 1);

if (!defined('PUN_ROOT'))
	exit('The constant PUN_ROOT must be defined and point to a valid PunBB installation root directory.');


// Load the functions script
require PUN_ROOT.'include/functions.php';

// Reverse the effect of register_globals
unregister_globals();


@include PUN_ROOT.'config.php';

// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
	exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run <a href="install.php">install.php</a> to install PunBB first.');


// Record the start time (will be used to calculate the generation time for the page)
list($usec, $sec) = explode(' ', microtime());
$pun_start = ((float)$usec + (float)$sec);

// Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
error_reporting(E_ALL ^ E_NOTICE);

// Turn off magic_quotes_runtime
set_magic_quotes_runtime(0);

// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
if (get_magic_quotes_gpc())
{
	function stripslashes_array($array)
	{
		return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
	}

	$_GET = stripslashes_array($_GET);
	$_POST = stripslashes_array($_POST);
	$_COOKIE = stripslashes_array($_COOKIE);
}

// Seed the random number generator (PHP <4.2.0 only)
if (version_compare(PHP_VERSION, '4.2.0', '<'))
	mt_srand((double)microtime()*1000000);

// If a cookie name is not specified in config.php, we use the default (punbb_cookie)
if (empty($cookie_name))
	$cookie_name = 'punbb_cookie';

// Define a few commonly used constants
define('PUN_UNVERIFIED', 32000);
define('PUN_ADMIN', 1);
define('PUN_MOD', 2);
define('PUN_GUEST', 3);
define('PUN_MEMBER', 4);


// Load DB abstraction layer and connect
require PUN_ROOT.'include/dblayer/common_db.php';

// Start a transaction
$db->start_transaction();

// Load cached config
@include PUN_ROOT.'cache/cache_config.php';
if (!defined('PUN_CONFIG_LOADED'))
{
	require PUN_ROOT.'include/cache.php';
	generate_config_cache();
	require PUN_ROOT.'cache/cache_config.php';
}


// Enable output buffering
if (!defined('PUN_DISABLE_BUFFERING'))
{
	// For some very odd reason, "Norton Internet Security" unsets this
	$_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '';

	// Should we use gzip output compression?
	if ($pun_config['o_gzip'] && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
		ob_start('ob_gzhandler');
	else
		ob_start();
}


// Check/update/set cookie and fetch user info
$pun_user = array();
check_cookie($pun_user);

// Attempt to load the common language file
@include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
if (!isset($lang_common))
	exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.');

// Check if we are to display a maintenance message
if ($pun_config['o_maintenance'] && $pun_user['g_id'] > PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT'))
	maintenance_message();


// Load cached bans
@include PUN_ROOT.'cache/cache_bans.php';
if (!defined('PUN_BANS_LOADED'))
{
	require_once PUN_ROOT.'include/cache.php';
	generate_bans_cache();
	require PUN_ROOT.'cache/cache_bans.php';
}

// Check if current user is banned
check_bans();


// Update online list
update_users_online();

Si j'enleve tout le code et que je laisse juste le code du debut ça fonctionne
// Enable DEBUG mode by removing // from the following line
//define('PUN_DEBUG', 1);

// This displays all executed queries in the page footer.
// DO NOT enable this in a production environment!
//define('PUN_SHOW_QUERIES', 1);

if (!defined('PUN_ROOT'))
	exit('The constant PUN_ROOT must be defined and point to a valid PunBB installation root directory.');


// Load the functions script
require PUN_ROOT.'include/functions.php';
Je pense que cela viens donc de :
// Reverse the effect of register_globals
unregister_globals();
J' ai remis tout le code comme avant, et j' ai enlever juste le code : unregister_globals();
Et ça fonctionne

par Mathieu68 » 27 nov. 2008, 22:17

Si un fichier d'inclusion est manquant alors php interrompt le script. ce qui est bizarre c'est que tu n'est pas d'erreur, alors dans un premier temps sois sur du chemin et que common.php existe bien.

et ensuite essaye de remplacer require par include qui n'interrompt pas le script
<?php 
define('PUN_ROOT', './forum/'); 
include PUN_ROOT.'include/common.php'; 

?>

par Nicost » 27 nov. 2008, 20:46

apres recherche, aucun variable avec $rub et $index

:cry:

par Mathieu68 » 27 nov. 2008, 20:25

regarde dans les fichiers que tu inclus que tu n'a pas le même nom d'une variable $rub ou $index qui est déjà utilisé

par Nicost » 27 nov. 2008, 20:15

merci Mathieu68, j' ai régler l'erreur pour la sécuriter.
Sinon ben voila, quand je place mon code pour afficher mon texte :
<?php 
if ( $index == "news" ) { 
echo "Vous êtes dans la section news"; 
} 
if ( $rub == "test" ) { 
echo "rubrique test"; 
} 
?>
Mon code fonctionne.

Quand j'ajoute le code de punbb :
<?php 
define('PUN_ROOT', './forum/'); 
require PUN_ROOT.'include/common.php'; 

?>
Le code de mon texte ne fonctionne plus.

par Mathieu68 » 27 nov. 2008, 18:13

include($_GET['page'].".php"); 
j'ai un peu de mal à comprendre ton problème mais en tout cas je te déconseille vraiment de ne pas avoir des bouts de codes comme celui ci!

http://www.zataz.com/images/documentati ... 823d1f.pdf

http://www.vulgarisation-informatique.c ... es-php.php un peu plus facile à comprendre :D

If et variable

par Nicost » 27 nov. 2008, 00:31

bonsoir, j'utilise le forum punbb sur mon site de test.
dans ma page principal du site : index.php
j'ai placer le code de punbb pour avoir quelque fonction en dehor du forum.

mon site fonctionne parfaitement en local et le forum aussi.

malheureusement j'utilise une fonction qui permet d'afficher un texte different quand l'on est dans une page.

exemple quand je suis dans la page : test
index.php?rub=test
jusque la pas de problème mon texte s'affiche.

mais des lors que je place le code de punbb dans l'index.php, mon code de texte ne s'affiche plus.
apparament cela viens du faite que je donne pas de variable pour : $rub

Mon code de ma page index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
</head>

<body>
<table width="100%" border="0">
  <tr>
    <td colspan="2" bgcolor="#BCBCBC"><div align="center">
    <?php
if ( $index == "news" ) {
echo "Vous êtes dans la section news";
}
if ( $rub == "test" ) {
echo "rubrique test";
}
?></div></td>
  </tr>
  <tr>
    <td width="20%" height="223" valign="top" bgcolor="#BCBCBC"><p><a href="index.php">Accueil</a></p>
    <p><a href="index.php?rub=test">Rubrique test</a> </p></td>
    <td width="80%" valign="top" bgcolor="#BCBCBC">
    <?php
/*if (!isset($_GET['page'])) {
include("news.php");
} else {
include($_GET['page'].".php");
}*/

if (isset($_GET['page'])) {
include ("rubrique/".$_GET['rub']."/".$_GET['page'].".php") ;
} elseif (isset($_GET['rub'])) {
include ("rubrique/".$_GET['rub']."/index.php") ;
} else {
include ("news.php") ;
}

?>
</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#BCBCBC"><div align="center">Copyrigth 2008 </div></td>
  </tr>
</table>
</body>
</html>
avec le code si dessus, pas de problème mon texte s'affiche.

par contre maintenant si je mes le même code avec le code de punbb
punbb : define('PUN_ROOT', './forum/');
require PUN_ROOT.'include/common.php';

se qui donne :
<?php
define('PUN_ROOT', './forum/');
require PUN_ROOT.'include/common.php';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
</head>

<body>
<table width="100%" border="0">
  <tr>
    <td colspan="2" bgcolor="#BCBCBC"><div align="center">
    <?php
if ( $index == "news" ) {
echo "Vous êtes dans la section news";
}
if ( $rub == "test" ) {
echo "rubrique test";
}
?></div></td>
  </tr>
  <tr>
    <td width="20%" height="223" valign="top" bgcolor="#BCBCBC"><p><a href="index.php">Accueil</a></p>
    <p><a href="index.php?rub=test">Rubrique test</a> </p></td>
    <td width="80%" valign="top" bgcolor="#BCBCBC">
    <?php
/*if (!isset($_GET['page'])) {
include("news.php");
} else {
include($_GET['page'].".php");
}*/

if (isset($_GET['page'])) {
include ("rubrique/".$_GET['rub']."/".$_GET['page'].".php") ;
} elseif (isset($_GET['rub'])) {
include ("rubrique/".$_GET['rub']."/index.php") ;
} else {
include ("news.php") ;
}

?>
</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#BCBCBC"><div align="center">Copyrigth 2008 </div></td>
  </tr>
</table>
</body>
</html>
et la super j'ai plus mon texte qui s'affiche.
je voi pas comment je peu ecrire la variable pour $rub, et je dirai même quand faite je comprend pas pourquoi ça n'affiche plus rien juste parce que j'ai ajouter le code de punbb.
merci de votre aide.