Log in

View Full Version : How to send argument through php include?



rctxtreme
04-02-2007, 08:24 AM
include("language.php?show=lang");

Throws up this:


Warning: include(language.php?show=lang) [function.include]: failed to open stream: Invalid argument in C:\Program Files\xampp\htdocs\display.php on line 65

Warning: include() [function.include]: Failed opening 'language.php?show=lang' for inclusion (include_path='.;C:\Program Files\xampp\php\pear\') in C:\Program Files\xampp\htdocs\display.php on line 65

This is language.php:


<?php
/* Simply edit the following line to translate Free Smileys into your own language. */
$themsg="Like this smiley? Simply click the box above and copy its contents, then paste it into the message box.";
/*Uncomment the following line if you have translated the above to another language*/
$difflang=" (EN)";

if ($_GET["show"] == "lang") {
echo $difflang;
}
else {
echo $themsg;
}
?>

Twey
04-02-2007, 12:40 PM
The included page will inherit $_GET from its parent, so modify $_GET there:
$_GET['show'] = 'lang';
include('language.php');

rctxtreme
04-04-2007, 06:34 AM
Does not work.


echo '<font size="1">', include("language.php"), '<br />
Free Smileys 0.9.1.1<script>
<!--
document.write(unescape("&#37;3Cscript%3E%0A%3C%21--%0Adocument.write%28unescape%28%22%253Cscript%253E%250A%253C%2521--%250Adocument.write%2528unescape%2528%2522%252520-%252520%25253Ca%252520href%25253D%252522http%25253A//www.a2h.8m6.net%252522%25253Eanger2headshot%25253C/a%25253E%2522%2529%2529%253B%250A//--%253E%250A%253C/script%253E%22%29%29%3B%0A//--%3E%0A%3C/script%3E"));
//-->
</script>';
$_GET['show'] = 'lang';
include('language.php');
echo '</font>
</td>
</tr>



</table>
</body>

</html>';

codeexploiter
04-04-2007, 06:42 AM
Try the following



include 'http://www.yourserver.com/language.php?show=lang';

codeexploiter
04-04-2007, 06:50 AM
Check the following example



//This is the file which I am going to be include in my second file
//file name: inc.php
echo "$var";




//The main file which will be browsed using a browser.
//file name: first.php
$var="lang";
include 'inc.php';


Enter the following address

http://localhost/first.php

The $var is available in the inc.php.

rctxtreme
04-04-2007, 07:06 AM
Try the following



include 'http://www.yourserver.com/language.php?show=lang';


NOT a good idea - this is the display part of an SMF modification, and so giving all users the same domain to link to would not be a good idea - SMF is a forum system for those who don't know.


Check the following example



//This is the file which I am going to be include in my second file
//file name: inc.php
echo "$var";




//The main file which will be browsed using a browser.
//file name: first.php
$var="lang";
include 'inc.php';


Enter the following address

http://localhost/first.php

The $var is available in the inc.php.

Same result turns up.

codeexploiter
04-04-2007, 07:12 AM
It worked for me in my machine and according to PHP manual this is the way. My first response might not be correct but definitely my second response worked for me.

You can check the PHP manual -> Search for include and in the include statement tutorial check the example 11-5

What is your PHP version?

rctxtreme
04-04-2007, 07:17 AM
XAMPP
[PHP: 5.2.1]

I might as well upload both files for you to have a look at. Be sure to comment out the line requiring SMF's SSI.php in display.php...

codeexploiter
04-04-2007, 08:19 AM
Try the following code in place of your display.php code


<?php
// Version 0.9.1.1 of the Free Smileys mod
// Language translators, please check the lang.php file instead.

require("../SSI.php");
echo '<html>

<head>
<title>Free Smileys Mod</title>
<!-- The ?rc3 part of this link is just here to make sure browsers don\'t cache it wrongly. -->
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?rc3" />
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?rc3" media="print" />
</head>

<body class="windowbg">


<script language="javascript">
function next()
{
try{
setTimeout(\'randomImage("http://skins.hotbar.com/skins/mailskins/em/google_emoticons/emoti_","gif",484)\',200);
} catch(Error) {}
}

next();

</script>
<script language="javascript">
function randomImage(baseURL,ext,maxNum)
{
try {
randNum= Math.floor(Math.random()*maxNum);
randNum++;
var url = baseURL+randNum+"."+ext;
emoti.src = url;
emoti.style.visibility="visible";
box.value = "" + url + "";
} catch (error) {alert(error);}
}</script>

<table border="0" align="center">
<tr>
<td valign="middle">
<script>
<!--
document.write(unescape("%3Cbutton%20name%3D%22fetchnewsmiley%22%20onclick%3D%22next%28%29%22%3E%3Cimg%20src%3D%22fetchnewsmiley.gif%22%3E%3C/button%3E%3Cinput%20type%3D%22text%22%20name%3D%22box%22%20id%3D%22box%22%20value%3D%22%22%20size%3D%22100%22%20onClick%3D%22javascript%3Athis.focus%28%29%3Bthi s.select%28%29%3B%22%3E"));
//-->
</script>
</td>
</tr>
<tr height=150>
<td align=center valign=center>
<img id=emoti style="visibility:hidden" border="0"><br />
<font size="1">'. include("language.php"). '<br />
Free Smileys 0.9.1.1<script>
<!--
document.write(unescape("%3Cscript%3E%0A%3C%21--%0Adocument.write%28unescape%28%22%253Cscript%253E%250A%253C%2521--%250Adocument.write%2528unescape%2528%2522%252520-%252520%25253Ca%252520href%25253D%252522http%25253A//www.a2h.8m6.net%252522%25253Eanger2headshot%25253C/a%25253E%2522%2529%2529%253B%250A//--%253E%250A%253C/script%253E%22%29%29%3B%0A//--%3E%0A%3C/script%3E"));
//-->
</script>';
$show = 'lang';
include('language.php');
echo '</font>
</td>
</tr>



</table>
</body>

</html>';
?>


It worked for me once I comment that require line without any problem. I strongly suggest to test the above mentioned code in place of your original display.php page and make sure that the path information is correct.

rctxtreme
04-04-2007, 10:02 AM
OK...

OH SHOOT, I OVERWRITED LANGUAGE.PHP WITH AN OLDER VERSION

Oh wait, there's a copy in the first post...

Let's see...

Well it appears the credits have been removed and so has the (EN) message...

You replaced ', include(language.php), ' with full stops!


<?php
// Version 0.9.1.1 of the Free Smileys mod
// Language translators, please check the lang.php file instead.

//require("../SSI.php");
echo '<html>

<head>
<title>Free Smileys Mod</title>
<!-- The ?rc3 part of this link is just here to make sure browsers don\'t cache it wrongly. -->
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?rc3" />
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?rc3" media="print" />
</head>

<body class="windowbg">


<script language="javascript">
function next()
{
try{
setTimeout(\'randomImage("http://skins.hotbar.com/skins/mailskins/em/google_emoticons/emoti_","gif",484)\',200);
} catch(Error) {}
}

next();

</script>
<script language="javascript">
function randomImage(baseURL,ext,maxNum)
{
try {
randNum= Math.floor(Math.random()*maxNum);
randNum++;
var url = baseURL+randNum+"."+ext;
emoti.src = url;
emoti.style.visibility="visible";
box.value = "" + url + "";
} catch (error) {alert(error);}
}</script>

<table border="0" align="center">
<tr>
<td valign="middle">
<script>
<!--
document.write(unescape("&#37;3Cbutton%20name%3D%22fetchnewsmiley%22%20onclick%3D%22next%28%29%22%3E%3Cimg%20src%3D%22fetchnewsmiley.gif%22%3E%3C/button%3E%3Cinput%20type%3D%22text%22%20name%3D%22box%22%20id%3D%22box%22%20value%3D%22%22%20size%3D%22100%22%20onClick%3D%22javascript%3Athis.focus%28%29%3Bthi s.select%28%29%3B%22%3E"));
//-->
</script>
</td>
</tr>
<tr height=150>
<td align=center valign=center>
<img id=emoti style="visibility:hidden" border="0"><br />
<font size="1">';
include("language.php");
echo '<br />
Free Smileys 0.9.1.1 - <a href="http://www.a2h.8m6.net">anger2headshot</a>';
$show = 'lang';
include('language.php');
echo '</font>
</td>
</tr>



</table>
</body>

</html>';
?>

This new version isn't working well either...

BTW (language.php from the first post, not the one in the zip file!)