IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Probleme de GET et SESSION


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 14
    Points : 7
    Points
    7
    Par défaut Probleme de GET et SESSION
    Bonjour a tous.

    Je pense que le sujet a du etre abordé maintes et maintes fois mais dans l'application et malgre apres avoir lu d innombrables tutos/posts je n'arrive pas a resoudre mon probleme.

    Voila le principe: j utilise le CMS Joomla 1.5 pour un de mes sites auquel j ai intégré un script qui n'a rien a voir avec Joomla.

    J appelle ce script au travers de certaines de mes pages via un include du type
    include ('projects.php');

    Cela fonctionne tres bien et me permet de garder mon script au sein de ma page Joomla! ( c est le but).

    Cependant, mes scripts de type projects.php crées des URL de type :
    http://monsite.com/project.php?id=6

    Afin de récuperer ces pages j'ai crée dans mon htacess quelques règles de type:
    RewriteRule ^projects.php$ index.php?option=com_content&view=article&id=124&Itemid=83?id=$ [L]

    Vous l'aurez compris, lorsque une url comportant projects.php se présente, la page affichée est index.php?option=com_content&view=article&id=124&Itemid=83.

    Cette page est une page Joomla! comprenant une copie de mon script pojects.php

    Cela fonctionne tres bien sauf que mon script projects.php appelle des variables GET , SESSION et COOKIE qui, et c est bien la le probleme, sont censées être contenues dans l URL. Or le soucis est que ma vraie URL est index.php?option=com_content&view=article&id=124&Itemid=83 alors que celle qui devrait être utilisée est par exemple http://monsite.com/project.php?id=6


    Le probleme est donc que mon script ne passe plus. Il traite l URL de ma page Joomla.

    J'ai bien pensé a définir toutes les variables pour se passer des GET mais ce n est pas tres propre et bien que cela fonctionne cela reste tres bancal.


    En complement d'information, sachez que mon script de type projects.php apelle un moteur de template chargé de convertir les variable en affichage.

    Ainsi : voici mes codes :

    Celui de la page Joomla ( les tags {php} permettent d ecrire du code directement dans les articles):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    {php} 
    include ('deposit.php');
    {/php}
    Celui de mon script projects.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    <?php
    require_once('includes/config.php');
    require_once('includes/classes/class.template_engine.php');
    require_once('includes/functions/func.global.php');
    session_start();
    $config['lang'] = check_user_lang($config);
    require_once('includes/lang/lang_'.$config['lang'].'.php');
     
    db_connect($config);
     
    check_cookie($_SESSION,$config);
     
    // Get Settings
    $settings = get_settings('index.php',$config);
     
    $count = 0;
    $extra_where = '';
     
    if(isset($_GET['cat']))
    {
    	$categories = get_categories($config,array($_GET['cat']),'selected');
     
    	if(isset($categories[$_GET['cat']]))
    	{
    		if($categories[$_GET['cat']]['ctype'] == '1')
    		{
    			foreach($categories as $catvalue)
    			{
    				if($catvalue['parent_id'] == $_GET['cat'])
    				{
    					 $extra_where.= " OR project_types = '".validate_input($catvalue['id'])."' OR project_types LIKE '".validate_input($catvalue['id']).",%' OR project_types LIKE '%,".validate_input($catvalue['id'])."' OR project_types LIKE '%,".validate_input($catvalue['id']).",%'";
    				}
    			}
     
    		}
    	}
    }
    else
    {
    	$categories = get_categories($config);
    }
     
    $projects = array();
     
    if(!isset($_GET['page']))
    {
    	$_GET['page'] = 1;
    }
     
    if(!isset($_GET['filter']))
    {
    	$_GET['filter'] = '';
    }
     
    if($_GET['filter'] == 'featured')
    {
    	$total[0] = mysql_num_rows(mysql_query("SELECT 1 FROM `".$config['db']['pre']."projects` WHERE project_status='0' AND project_featured='1'"));
     
    	$query = "SELECT project_id,project_title,project_bids,project_start,project_end,project_types,project_subtypes,project_avgbid,project_featured,project_db,project_os FROM `".$config['db']['pre']."projects` WHERE project_status='0' AND project_featured='1' ORDER BY project_id DESC LIMIT ".validate_input(($_GET['page']-1)*20).",20";
    }
    elseif(isset($_GET['cat']))
    {
    	$total[0] = mysql_num_rows(mysql_query("SELECT 1 FROM `".$config['db']['pre']."projects` WHERE project_status='0' AND (project_types = '".validate_input($_GET['cat'])."' OR project_types LIKE '".validate_input($_GET['cat']).",%' OR project_types LIKE '%,".validate_input($_GET['cat'])."' OR project_types LIKE '%,".validate_input($_GET['cat']).",%' ".$extra_where.")"));
     
    	$query = "SELECT project_id,project_title,project_bids,project_start,project_end,project_types,project_subtypes,project_avgbid,project_featured,project_db,project_os FROM `".$config['db']['pre']."projects` WHERE project_status='0' AND (project_types = '".validate_input($_GET['cat'])."' OR project_types LIKE '".validate_input($_GET['cat']).",%' OR project_types LIKE '%,".validate_input($_GET['cat'])."' OR project_types LIKE '%,".validate_input($_GET['cat']).",%' ".$extra_where.") ORDER BY project_id DESC LIMIT ".validate_input(($_GET['page']-1)*20).",20";
    }
    else
    {
    	$total[0] = mysql_num_rows(mysql_query("SELECT 1 FROM `".$config['db']['pre']."projects` WHERE project_status='0'"));
     
    	$query = "SELECT project_id,project_title,project_bids,project_start,project_end,project_types,project_subtypes,project_avgbid,project_featured,project_db,project_os FROM `".$config['db']['pre']."projects` WHERE project_status='0' ORDER BY project_id DESC LIMIT ".validate_input(($_GET['page']-1)*20).",20";
    }
    $query_result = mysql_query ($query) OR error(mysql_error());
    while ($info = mysql_fetch_array($query_result))
    {
    	$types_temp = array();
    	$types_temp2 = array();
    	$types_temp3 = array();
    	unset($types);
     
    	$display=false;
     
    	if(!isset($_GET['cat']))
    	{
    		$display=true;
    	}
    	else
    	{
    		$types=explode(",",$info['project_types']);
    		foreach($types as $typ)
    		{
    			if($_GET['cat']==$typ)
    			{
    				$display=true;
    			}
    		}
     
    		if($display == false)
    		{
    			if(isset($categories[$_GET['cat']]))
    			{
    				if($categories[$_GET['cat']]['ctype'] == '1')
    				{
    					foreach($categories as $catvalue)
    					{
    						if($catvalue['parent_id'] == $_GET['cat'])
    						{
    							$display = true;
    						}
    					}
    				}
    			}
    		}
    	}
     
    	if($display==true)
    	{
    		$types_temp = explode(',', $info['project_types']);
    		foreach ($types_temp as $value) 
    		{
    			if(isset($categories[$value]['title']))
    			{
    				$types_temp2[] = $categories[$value]['title'];
    			}
    		}
     
    		$types_temp3 = implode(', ', $types_temp2);
    		$projects[$count]['title'] = strip_tags(stripslashes(substr($info['project_title'],0,30)));
    		$projects[$count]['id'] = $info['project_id'];
    		$projects[$count]['bids'] = $info['project_bids'];
     
    		if(date('z', $info['project_start']) == date('z'))
    		{
    			$projects[$count]['startdate'] = $lang['TODAY'];
    		}
    		else
    		{
    			$projects[$count]['startdate'] = date("n/j/Y", $info['project_start']);
    		}
     
    		if(($info['project_end'] - $info['project_start']) <= $settings['urgent_time'])
    		{
    			$projects[$count]['urgent'] = 1;
    		}
    		else
    		{
    			$projects[$count]['urgent'] = 0;
    		}
     
    		$projects[$count]['enddate'] = date("n/j/Y", $info['project_end']);
    		$projects[$count]['types'] = $types_temp3;
    		$projects[$count]['avg_bid'] = $info['project_avgbid'];
    		$projects[$count]['featured'] = $info['project_featured'];
    		$projects[$count]['db'] = stripslashes($info['project_db']);
    		$projects[$count]['os'] = stripslashes($info['project_os']);
     
    		if($config['mod_rewrite'] == 0)
    		{
    			$projects[$count]['link'] = 'project.php?id=' . $info['project_id'];
    		}
    		else
    		{
    			$projects[$count]['link'] = 'projects/' . $info['project_id'] . '/'.convert2link(stripslashes($info['project_title'])).'/';
    		}
     
    		$count++;
    	}
    }
     
    $count=0;
     
    foreach(array_keys($categories) as $cat)
    {
    	$category[$count]['id']=$cat;
    	$category[$count]['name']=$categories[$cat]['title'];
    	$category[$count]['selected']=$categories[$cat]['selected'];
    	$category[$count]['ctype']=$categories[$cat]['ctype'];
    	$count++;
    }
     
    $page = new HtmlTemplate ("templates/" . $config['tpl_name'] . "/projects.html");
    $page->SetParameter ('OVERALL_HEADER', create_header($config,$lang,$lang['PROJECTS']));
    $page->SetLoop ('PROJECTS', $projects);
    $page->SetParameter ('SITEURL',$config['site_url']);
    $page->SetLoop ('CATEGORIES', $category);
    if(isset($_GET['cat']))
    {
    	$page->SetParameter('CURRENT_CAT', $_GET['cat']);
    }
    else
    {
    	$page->SetParameter('CURRENT_CAT', '');
    }
    if($_GET['filter'] == 'featured')
    {
    	$page->SetLoop ('PAGES', pagenav($total[0],$_GET['page'],20,$config['site_url'].'projects.php?filter=featured',1));
    }
    elseif(isset($_GET['cat']))
    {
    	$page->SetLoop ('PAGES', pagenav($total[0],$_GET['page'],20,$config['site_url'].'projects.php?cat='.$_GET['cat'],1));
    }
    else
    {
    	$page->SetLoop ('PAGES', pagenav($total[0],$_GET['page'],20,$config['site_url'].'projects.php',0));
    }
    $page->SetParameter ('OVERALL_FOOTER', create_footer($config,$lang));
    $page->CreatePageEcho($lang,$config);
    ?>

    Celui du moteur de template ( je ne sais pas si c est utile a la resolution du probleme) nommé class.template_engine.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    <?php
    /********************************************************
     * Template Engine
     * Class for templatating a script
    ********************************************************
     * @package Template Engine
     * @author Craig Merchant
     * @copyright 2007 Kubelabs
     ********************************************************/
     
    class HtmlTemplate 
    {
    	// The template file being used
    	var $template;
     
    	// The html content of the template
    	var $html;
     
    	// The parameters to be replaced
    	var $parameters = array();
     
     
    	/*************************************************************************
    	* function HtmlTemplate ($template)
    	* Reads the file into a string variable
    	* USAGE example:
    	* $template = 'html/index.html';
    	* $page = new HtmlTemplate ($template);
    	*************************************************************************
    	* $template: The file you want to convert
    	* ***********************************************************************/
    	function HtmlTemplate ($template)
    	{
    		$this->template = $template;
    		$this->html = implode ('', (file($this->template)));
    	}
     
    	/*************************************************************************
    	* function SetLoop ($name, $values)
    	* Outputs an array as an html loop
    	* USAGE example:
    	* $items['0']['title'] = 'A Book';
    	* $items['0']['id'] = '1';
    	* $page->SetLoop ("ITEMS", $items);
    	*************************************************************************
    	* $name: The name of the Loop
    	* $values: The Array
    	* ***********************************************************************/
    	function SetLoop ($name, $values)
    	{
    		$return = '';
    		if(preg_match('/{LOOP: ' . $name . '\}(.*)\{\/LOOP: ' . $name . '\}/s', $this->html, $parts))
    		{
    			if(is_array($values))
    			{
    				foreach ($values as $value) 
    				{
    					$templatestuff = $parts['1'];
    					foreach ($value as $key2 => $value2) 
    					{
    						if(!is_array($value2))
    						{
    							$templatestuff = str_replace('{' . $name . '.' . $key2 . '}', $value2, $templatestuff);			
    						}
    						else
    						{
    							foreach ($value2 as $key3 => $value3) 
    							{
    								if(!is_array($value3))
    								{
    									$templatestuff = str_replace('{' . $name . '.' . $key2 . '/' . $key3 . '}', $value3, $templatestuff);
    								}
    								else
    								{
    									foreach ($value3 as $key4 => $value4) 
    									{
    										if(!is_array($value4))
    										{
    											$templatestuff = str_replace('{' . $name . '.' . $key2 . '/' . $key3 . '/' . $key4 . '}', $value4, $templatestuff);
    										}
    									}
    								}
    							}
    						}
    					}
    					$return.= $templatestuff;
    				}
    			}
    			else
    			{
    				$return = $values;
    			}
    		}
     
    		if(isset($parts['0']))
    		{
    			$this->html = stripslashes(str_replace ($parts['0'], $return, $this->html));
    		}
    	}
     
    	/*************************************************************************
    	* function SetParameter ($variable, $value)
    	* Sets a paramateter to later be replaced in the template
    	* USAGE example:
    	* $page->SetParameter ("TITLE", 'The about page');
    	*************************************************************************
    	* $variable: The parameters name
    	* $value: The paramaters value
    	* ***********************************************************************/
    	function SetParameter ($variable, $value)
    	{
    		$this->parameters[$variable] = $value;
    	}
     
    	/*************************************************************************
    	* function CreatePageEcho () 
    	* Echos the finished template
    	* USAGE example:
    	* $page->CreatePageEcho();
    	* ***********************************************************************/
    	function CreatePageEcho ($lang,$config) 
    	{
    		foreach ($lang as $key => $value) 
    		{
    			$template_name = '{LANG_' . $key . '}';
    			$this->html = str_replace ($template_name, $value, $this->html);
    		}	
    		foreach ($this->parameters as $key => $value) 
    		{
    			$template_name = '{' . $key . '}';
     
    			$this->html = str_replace ($template_name, $value, $this->html);
    		}	
     
    		$this->html = str_replace ('{SITE_URL}', $config['site_url'], $this->html);
    		$this->html = str_replace ('{TPL_NAME}', $config['tpl_name'], $this->html);
    		$this->html = str_replace ('{CURRENCY_SIGN}', $config['currency_sign'], $this->html);
    		$this->html = str_replace ('{CURRENCY_CODE}', $config['currency_code'], $this->html);
    		$this->html = str_replace ('{CURRENCY_POS}', $config['currency_pos'], $this->html);
     
    		if(isset($_SESSION['user']['id']))
    		{
    			$this->html = str_replace ('{LOGGED_IN}', '1', $this->html);
    		}
    		else
    		{
    			$this->html = str_replace ('{LOGGED_IN}', '0', $this->html);
    		}
     
    		if(isset($config['temp_php']))
    		{
    			if($config['temp_php'])
    			{
    				$this->html = preg_replace_callback("/(<\?=)(.*?)\?>/si", array('HtmlTemplate', 'EvalPrintBuffer'),$this->html);
    				$this->html = preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si", array('HtmlTemplate', 'EvalBuffer'),$this->html);
    			}
    		}
     
    		$ifmatches = array();
    		preg_match_all('/IF\(\"(.*?)\"(.*?)\"(.*?)\"\)\{(.*?)\{:IF\}/s', $this->html, $ifmatches);
     
    		if(count($ifmatches['0']) != 0)
    		{	
    			foreach ($ifmatches['0'] as $key => $value) 
    			{
    				if(trim($ifmatches['2'][$key]) == '!=')
    				{
    					if($ifmatches['1'][$key] != $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '==')
    				{
    					if($ifmatches['1'][$key] == $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '<')
    				{
    					if($ifmatches['1'][$key] < $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '>')
    				{
    					if($ifmatches['1'][$key] > $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '%')
    				{
    					$mod = $ifmatches['1'][$key]%$ifmatches['3'][$key];
     
    					if($mod == 0)
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    			}
    		}
     
    		echo $this->html;
    	}
     
    	/*************************************************************************
    	* function CreatePageReturn () 
    	* Returns the finished template as a string
    	* USAGE example:
    	* $head_string = $header->CreatePageReturn($lang);
    	*************************************************************************
    	* $lang: The language list
    	* ***********************************************************************/
    	function CreatePageReturn ($lang,$config) 
    	{
    		foreach ($lang as $key => $value) 
    		{
    			$template_name = '{LANG_' . $key . '}';
    			$this->html = str_replace ($template_name, $value, $this->html);
    		}	
    		foreach ($this->parameters as $key => $value) 
    		{
    			$template_name = '{' . $key . '}';
     
    			$this->html = str_replace ($template_name, $value, $this->html);
    		}	
     
    		$this->html = str_replace ('{SITE_URL}', $config['site_url'], $this->html);
    		$this->html = str_replace ('{TPL_NAME}', $config['tpl_name'], $this->html);
    		$this->html = str_replace ('{CURRENCY_SIGN}', $config['currency_sign'], $this->html);
    		$this->html = str_replace ('{CURRENCY_CODE}', $config['currency_code'], $this->html);
    		$this->html = str_replace ('{CURRENCY_POS}', $config['currency_pos'], $this->html);
     
    		if(isset($_SESSION['user']['id']))
    		{
    			$this->html = str_replace ('{LOGGED_IN}', '1', $this->html);
    		}
    		else
    		{
    			$this->html = str_replace ('{LOGGED_IN}', '0', $this->html);
    		}
     
    		if(isset($config['temp_php']))
    		{
    			if($config['temp_php'])
    			{
    				$this->html = preg_replace_callback("/(<\?=)(.*?)\?>/si", array('HtmlTemplate', 'EvalPrintBuffer'),$this->html);
    				$this->html = preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si", array('HtmlTemplate', 'EvalBuffer'),$this->html);
    			}
    		}
     
    		$ifmatches = array();
    		preg_match_all('/IF\(\"(.*?)\"(.*?)\"(.*?)\"\)\{(.*?)\{:IF\}/s', $this->html, $ifmatches);
     
    		if(count($ifmatches['0']) != 0)
    		{	
    			foreach ($ifmatches['0'] as $key => $value) 
    			{
    				if(trim($ifmatches['2'][$key]) == '!=')
    				{
    					if($ifmatches['1'][$key] != $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '==')
    				{
    					if($ifmatches['1'][$key] == $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '<')
    				{
    					if($ifmatches['1'][$key] < $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '>')
    				{
    					if($ifmatches['1'][$key] > $ifmatches['3'][$key])
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    				elseif(trim($ifmatches['2'][$key]) == '%')
    				{
    					$mod = $ifmatches['1'][$key]%$ifmatches['3'][$key];
     
    					if($mod == 0)
    					{
    						$this->html = str_replace($value, $ifmatches['4'][$key], $this->html);
    					}
    					else
    					{
    						$this->html = str_replace($value, '', $this->html);
    					}
    				}
    			}
    		}
     
    		return $this->html;
    	}
     
    	function EvalBuffer($string) 
    	{
    		ob_start();
    		eval("$string[2];");
    		$return = ob_get_contents();
    		ob_end_clean();
    		return $return;
    	}
     
    	function EvalPrintBuffer($string) 
    	{
    		ob_start();
    		eval("print $string[2];");
    		$return = ob_get_contents();
    		ob_end_clean();
    		return $return;
    	}
    }
    ?>


    Enfin, class.template_engine.php génére les infos dans le fichier projects.html :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><p><br>      
             <span class="title1">{LANG_PROJECTSU}</span></p>
          <form name="form" method="post" action="">
            <span class="header1">Les projets listes ci-dessous sont en cours de negociation entre les proteurs de projets et les prestataires freelances. Pour deposer le votre ou laisser un devis, il vous suffit de creer un compte gratuitement. Vous pouvez affiner votre recherche en selectionnant ci-dessous votre domaine d expertise. </span><br><br>
            <select name="cats" onChange="openDir(this.form)">
              <option value="projects.php">{LANG_PROJTYPES}</option>
              <option value="projects.php">{LANG_ALL}</option>
     
     
              {LOOP: CATEGORIES}
              IF("{CATEGORIES.ctype}"=="0"){<option value="{SITEURL}projects.php?cat={CATEGORIES.id}" {CATEGORIES.selected} >{CATEGORIES.name}</option>{:IF}
              IF("{CATEGORIES.ctype}"=="1"){<option value="{SITEURL}projects.php?cat={CATEGORIES.id}" {CATEGORIES.selected} >{CATEGORIES.name}</option>{:IF}
              IF("{CATEGORIES.ctype}"=="2"){<option value="{SITEURL}projects.php?cat={CATEGORIES.id}" {CATEGORIES.selected} >&nbsp;&nbsp;&nbsp;{CATEGORIES.name}</option>{:IF}
              {/LOOP: CATEGORIES}
     
     
     
     
     
     
     
     
     
     
            </select>
          </form>      
          <table width="100%" cellpadding="0" cellspacing="1" border="0" class="table_titles">
            <tr bgcolor="#E1E1E1" align="center">
              <td width="40%" align="left" height="18" style="padding-left:5px;">{LANG_PROJNAME}</td>
              <td width="6%" bgcolor="#E1E1E1">{LANG_BIDS}</td>
              <td width="30%" align="left" style="padding-left:5px;">{LANG_JOBTYPE}</td>
              <td width="12%">{LANG_STARTED}</td>
              <td width="12%">{LANG_ENDS}</td>
            </tr>
     
     
     
      {LOOP: PROJECTS}
     
     
      <tr align="center">
    <td align="left" style="padding-left:5px; text-transform : capitalize ;">
     
    <a href="{PROJECTS.link}"><span style= "color: #547EDD;font-size: 12pt ; font-weight: bold;">{PROJECTS.title}</span> </a>
     
     
     
    <br/>
     
     
    <a href="projects.php?cat={CATEGORIES.id.selected}"><span style= "color: #646464;font-size: 10pt ; font-weight: bold;">{PROJECTS.types}</span> </a>
     
     
     
     
     
     
     
    IF("{PROJECTS.featured}"=="1")
     
    {&nbsp; <span class="featured">{LANG_FEATURED}</span>{:IF} IF("{PROJECTS.urgent}"=="1"){&nbsp; <span class="urgent">{LANG_URGENT}</span>{:IF}</td>
        <td>{PROJECTS.bids}</td>
        <td align="left" style="padding-left:5px;">{PROJECTS.types}</td>
        <td>{PROJECTS.startdate}</td>
        <td>{PROJECTS.enddate}</td>
      </tr>
      <tr>
        <Td colspan="5" background="templates/{TPL_NAME}/images/hline_dot.gif"><img src="templates/{TPL_NAME}/images/dot.gif" width="1" height="1" alt="" border="0"></TD>
      </tr>
      {/LOOP: PROJECTS}
      <tr>
        <td colspan="5"><br>
          <strong>{LANG_PAGES}:</strong> {LOOP: PAGES}<a href="{PAGES.link}">{PAGES.title}</a> {/LOOP: PAGES}<br><br></td>
      </tr>
          </table>
       </td>
      </tr>
    </table>



    Donc, pour conclure, je suis complètement paumé... Je pense que le soucis vient du fichier projects.php .


    J ai vraiement besoin d'aide... Je suis meme pret a renumerer avec mes maigres moyens la personne qui m aidera a me sortir de cette enorme prise de tete.

    J oubliais: le site tourne avec php5

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    En resumé : ton $_GET contient id=>6 mais pas option=>com_content,view=>article etc. ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 14
    Points : 7
    Points
    7
    Par défaut Nop
    Citation Envoyé par sabotage Voir le message
    En resumé : ton $_GET contient id=>6 mais pas option=>com_content,view=>article etc. ?
    Non, ce qui est etrange, si je me fais un petit echo $_GET j obtiens Array

    Si je fais un var_dump($_GET ) dans ma page avant le include j obtiens ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    array(5) { ["option"]=>  string(11) "com_content" ["view"]=>  string(7) "article" ["id"]=>  string(3) "125" ["Itemid"]=>  string(7) "84?id=$" ["layout"]=>  string(7) "default" }

    En gros c est bien ce que je pensais mes variables GET sont celles de ma page Joomla et n incluent pas celles de mon script. C est pour cela que cela ne tourne pas.

    Alors que si je fais un var_dump($_SESSION); j obtiens ( j ai remplace qq valeurs sensibles comme l adresse du site et l email) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    array(3) { ["__default"]=>  array(7) { ["session.counter"]=>  int(329) ["session.timer.start"]=>  int(1230722606) ["session.timer.last"]=>  int(1230729066) ["session.timer.now"]=>  int(1230729078) ["session.client.browser"]=>  string(108) "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729)" ["registry"]=>  object(JRegistry)#12 (3) { ["_defaultNameSpace"]=>  string(7) "session" ["_registry"]=>  array(1) { ["session"]=>  array(1) { ["data"]=>  object(stdClass)#13 (0) { } } } ["_errors"]=>  array(0) { } } ["user"]=>  &object(JUser)#14 (19) { ["id"]=>  int(0) ["name"]=>  NULL ["username"]=>  NULL ["email"]=>  NULL ["password"]=>  NULL ["password_clear"]=>  string(0) "" ["usertype"]=>  NULL ["block"]=>  NULL ["sendEmail"]=>  int(0) ["gid"]=>  int(0) ["registerDate"]=>  NULL ["lastvisitDate"]=>  NULL ["activation"]=>  NULL ["params"]=>  NULL ["aid"]=>  int(0) ["guest"]=>  int(1) ["_params"]=>  object(JParameter)#15 (7) { ["_raw"]=>  string(0) "" ["_xml"]=>  NULL ["_elements"]=>  array(0) { } ["_elementPath"]=>  array(1) { [0]=>  string(82) "/var/www/vhosts/monsite.com/httpdocs/libraries/joomla/html/parameter/element" } ["_defaultNameSpace"]=>  string(8) "_default" ["_registry"]=>  array(1) { ["_default"]=>  array(1) { ["data"]=>  object(stdClass)#16 (0) { } } } ["_errors"]=>  array(0) { } } ["_errorMsg"]=>  NULL ["_errors"]=>  array(0) { } } } ["user"]=>  array(7) { ["name"]=>  string(8) "monnom" ["comp"]=>  string(0) "" ["id"]=>  string(1) "1" ["email"]=>  string(798) "  Cette adresse email est protégée contre les robots des spammeurs, vous devez activer Javascript pour la voir. " ["type"]=>  string(8) "provider" ["lang"]=>  string(0) "" ["group"]=>  string(1) "1" } ["project_id"]=>  NULL }
    Existe t il un moyen de les faire passer??

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Donc avant include ('deposit.php'); ton $_GET est plein et apres il est vide ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 14
    Points : 7
    Points
    7
    Par défaut
    Citation Envoyé par sabotage Voir le message
    Donc avant include ('deposit.php'); ton $_GET est plein et apres il est vide ?

    En gros mon $_GET est plein lorsque je passe mon script SANS include ( donc hors Joomla).

    Des que je le passe dans une page ( que ce soit Joomla ou une page que je crée), le $_GET dégage.

    Strange....

  6. #6
    Membre actif Avatar de elvan49
    Profil pro
    Développeur Web
    Inscrit en
    Octobre 2006
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Octobre 2006
    Messages : 274
    Points : 204
    Points
    204
    Par défaut Téléscopage de variables GET
    Non, pas très étrange, puisque Joomla! gère tout son contenu grâce au GET. Donc tes varaiables GET se téléscopent et certaines sont remplacées lors de la réécriture notemment. As-tu penser à donner une information supplémentaire en GET quand tu réécris ton URL ? En gros la cause ne pourrait-elle venir du .htaccess ?
    La solution dans ce cas pourrait être :
    Tu fournis à Joomla! ce dont il a besoin et en fin d'URL tu fournirais à project.php ce dont il a besoin... Quitte à changer tes variables GET pour ne prendre aucun risque de téléscopage.
    "n'imprimez ces messages que si nécessaire... Préservez notre planète"

  7. #7
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 14
    Points : 7
    Points
    7
    Par défaut Precisions
    Citation Envoyé par elvan49 Voir le message
    Non, pas très étrange, puisque Joomla! gère tout son contenu grâce au GET. Donc tes varaiables GET se téléscopent et certaines sont remplacées lors de la réécriture notemment. As-tu penser à donner une information supplémentaire en GET quand tu réécris ton URL ? En gros la cause ne pourrait-elle venir du .htaccess ?
    La solution dans ce cas pourrait être :
    Tu fournis à Joomla! ce dont il a besoin et en fin d'URL tu fournirais à project.php ce dont il a besoin... Quitte à changer tes variables GET pour ne prendre aucun risque de téléscopage.

    Peux tu préciser un peu je ne suis pas sur de bien comprendre ?
    Dans mon htaccess j ai fait des redirections de type:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
     RewriteRule ^projects.php$        index.php?option=com_content&view=article&id=124&Itemid=83?id=$ [L]
    ou l url de l article est
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    index.php?option=com_content&view=article&id=124&Itemid=83
    et correspond aux valeurs de mon script.

    A la base mon script réecrit ses url de cette maniere : RewriteRule ^project_(.*).html$ project.php?id=$1

    En tout cas merci de me donner un coup de main.

  8. #8
    Membre expert
    Avatar de s.n.a.f.u
    Homme Profil pro
    Développeur Web
    Inscrit en
    Août 2006
    Messages
    2 760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Août 2006
    Messages : 2 760
    Points : 3 545
    Points
    3 545
    Par défaut
    Je ne suis pas très au fait de l'outil, mais ce sujet ne serait-il pas spécifique à Joomla ? Auquel cas je le déplace et il aura plus d'impact.

    • Avant de poser une question, n'hésitez pas à chercher dans la FAQ et les forums
    • Merci d'utiliser les balises de code (# dans l'éditeur)
    • N'oubliez pas de vous servir des boutons , et

    S.N.A.F.U

  9. #9
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 14
    Points : 7
    Points
    7
    Par défaut
    Citation Envoyé par jml94 Voir le message
    Je ne suis pas très au fait de l'outil, mais ce sujet ne serait-il pas spécifique à Joomla ? Auquel cas je le déplace et il aura plus d'impact.

    Je ne pense pas que cela soit tres specifique.

Discussions similaires

  1. [Sécurité] probleme de variable de session
    Par rane dans le forum Langage
    Réponses: 4
    Dernier message: 02/02/2006, 12h19
  2. Probleme d'identification avec sessions PHP
    Par bontbont dans le forum Langage
    Réponses: 5
    Dernier message: 09/12/2005, 19h15
  3. [Sécurité] Problème d'expiration de session
    Par marciv dans le forum Langage
    Réponses: 3
    Dernier message: 05/10/2005, 23h29
  4. [Session]Problème de fermeture de session
    Par july dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 16/06/2005, 12h25
  5. [JSP] probleme d'invalidation de session
    Par Jovial dans le forum Servlets/JSP
    Réponses: 11
    Dernier message: 04/06/2004, 15h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo