I am trying to alter php-nuke...
I have a main page that uses a switch/case statement to determine which content should be displayed. each case sets up the page using a main header.php page, so they each have an include(header.php).
in the header.php page, it include() a javascript.php page.
i wrote some javascript for a site not using php-nuke, and i want to integrate it into the php-nuke site.
the javascript is created using php, and in php i have some variables that are later used in the body of the main page.
I tried using: global $methNum, $MethodType;
(the two variables are $methNum and $MethodType... obviously)
but the variables end up being null.
I am using the command wrong, or is there some other specific reason why i can't do that, or...
Thanks in advance for your help.
global variables...
Moderator: General Moderators
- J_Iceman05
- Forum Commoner
- Posts: 72
- Joined: Wed Aug 03, 2005 10:52 am
- Location: Las Vegas, NV
- J_Iceman05
- Forum Commoner
- Posts: 72
- Joined: Wed Aug 03, 2005 10:52 am
- Location: Las Vegas, NV
ok... no one seems to be able to answer me, and i know there has to be an answer, so maybe I was just confusing in my question... so here goes another shot...
Header.php
Javascript.php
Account page // php stuff is inside php code tags, html is inside code tags.
okay... so...
[1] Acount page includes Header.php
[2] Header.php includes Javascript.php
[3] Javascript contains needed variables
[4] those variables are needed later on in Acount Page
[5] the global command is used, but the variables return null, when not used in php-nuke, it works just fine.
[6] What do i do... and what did i do wrong?
Thnx again...
Header.php
Code: Select all
require_once("mainfile.php");
$header = 1;
function head() {
global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle, $cust_head, $name;
include("includes/ipban.php");
$ThemeSel = get_theme();
include("themes/$ThemeSel/theme.php");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
echo "<html>\n";
echo "<head>\n";
echo "<title>$sitename $pagetitle</title>\n";
include("includes/meta.php");
include("includes/javascript.php");
if (file_exists("themes/$ThemeSel/images/favicon.ico")) {
echo "<link REL=\"shortcut icon\" HREF=\"themes/$ThemeSel/images/favicon.ico\" TYPE=\"image/x-icon\">\n";
}
echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"backend.php\">\n";
echo "<LINK REL=\"StyleSheet\" HREF=\"themes/$ThemeSel/style/style.css\" TYPE=\"text/css\">\n\n\n";
if (file_exists("includes/custom_files/custom_head.php")) {
include_once("includes/custom_files/custom_head.php");
}
echo "\n\n\n</head>\n\n";
if (file_exists("includes/custom_files/custom_header.php")) {
include_once("includes/custom_files/custom_header.php");
}
themeheader();
}
head();Code: Select all
global $module, $name, $admin, $advanced_editor, $lang, $no_editor, $op;
// I removed some unneccessary Javascript...
function db_connect ($database)
{
$link = mysql_connect("$var1", "$var2", "$var3"); //the actual code has what the vars equal, but for security reasons... i obviously had to change them...
if($link && mysql_select_db ($database))
return ($link);
return (FALSE);
}
db_connect ("$database") or die ("Cannot connect to database");
$queryPaymentMethodTypes = "SELECT * FROM Payment_Methods WHERE PaymentMethod != ''";
$resultPaymentMethodTypes = mysql_query($queryPaymentMethodTypes) or die(mysql_error());
$methNum = 0; //methNum
while ( $method = mysql_fetch_array($resultPaymentMethodTypes, MYSQL_ASSOC)){
$MethodType[$methNum]['id'] = $method['PaymentMethodID']; //MethodType
$MethodType[$methNum]['name'] = $method['PaymentMethod'];
$MethodType[$methNum]['credit'] = $method['CreditCard'];
$methNum ++;
}
$selector = "if(document.forms['MemberInfo'].elements['paymentmethod'].options[whichSelected].value == '";
$YcreditV = "document.getElementById('CC').style.visibility = 'visible'";
$YcreditI = "document.getElementById('Ch').style.visibility = 'hidden'";
$YcreditL = "document.getElementById('ChLabel').style.visibility = 'hidden'";
$YcreditT = "document.getElementById('CC').style.top = 0";
$NcreditV = "document.getElementById('Ch').style.visibility = 'visible'";
$NcreditL = "document.getElementById('ChLabel').style.visibility = 'visible'";
$NcreditI = "document.getElementById('CC').style.visibility = 'hidden'";
$NcreditT = "document.getElementById('CC').style.top = '-15'";
$function = "function updateMethods()\n";
$function .= "{\n";
$function .= "\t whichSelected = document.forms['MemberInfo'].elements['paymentmethod'].selectedIndex;\n";
$chainCount = 0;
while ($chainCount < $methNum) {
if ($MethodType[$chainCount]['credit'] == 0) {
$function .= "\t ".$selector.$MethodType[$chainCount]['id']."')\n";
$function .= "\t {\n";
$function .= "\t\t ".$NcreditV.";\n";
$function .= "\t\t ".$NcreditI.";\n";
$function .= "\t\t ".$NcreditL.";\n";
$function .= "\t\t ".$NcreditT.";\n";
$function .= "\t }\n";
}
if ($MethodType[$chainCount]['credit'] == 1) {
$function .= "\t ".$selector.$MethodType[$chainCount]['id']."')\n";
$function .= "\t {\n";
$function .= "\t\t ".$YcreditV.";\n";
$function .= "\t\t ".$YcreditI.";\n";
$function .= "\t\t ".$YcreditL.";\n";
$function .= "\t\t ".$YcreditT.";\n";
$function .= "\t }\n";
}
$chainCount ++;
}
$function .= "\t return true;\n";
$function .= "}\n";
echo '<script type="text/javascript" language="JavaScript">';
print($function);
echo '</script>';Code: Select all
//contains way too many cases to post, and they have no relevance in this situation...
// the corresponding funciton also contains much irrelevant info, so much of that was removed
function editccbauser() {
global $prefix, $db, $user, $userinfo, $cookie, $module_name, $bgcolor2, $bgcolor3;
cookiedecode($user);
getusrinfo($user);
if ((is_user($user)) AND (strtolower($userinfo['username']) == strtolower($cookie[1])) AND ($userinfo['user_password'] == $cookie[2])) {
if (file_exists("includes/custom_files/editccbauser_header.php")) {
include("includes/custom_files/editccbauser_header.php");
} else {
include("header.php");
}
OpenTable();
echo "<center><font class=\"title\"><b>"._PERSONALCCBAINFO."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
nav();
CloseTable();
echo "<br>";
if (!eregi("http://",$userinfo[user_website])) {
$userinfo[user_website] = "http://$userinfo[user_website]";
}
OpenTable();Code: Select all
<!-- info table -->
<table><tr>
<td>
Year
</td><td>
BillAmt
</td><td>
PaymentDate
</td><td>
PaymentAmount
</td><td>
CCLF
</td><td>
PaymentMethod
</td><td>
<div id="ChLabel">
Check #
</div>
</td>
</tr>
<tr>
<td>
<input name="year" type="text" size="4" maxlength="6" onFocus="if (this.value == '') {this.value = '<? echo date('Y'); ?>'; this.select();}">
</td><td>
<input name="billamt" type="text" size="8">
</td><td>
<input name="paymentdate" type="text" size="10" onFocus="if (this.value == '') {this.value = '<? echo date('m/d/Y');?>'; this.select();}">
</td><td>
<input name="paymentamount" type="text" size="11">
</td><td>
<input name="cclf" type="text" size="5" maxlength="6">
</td><td>
<select name="paymentmethod" onChange="updateMethods();">Code: Select all
global $methNum, $MethodType;
$methcount = 0;
while ($methcount < $methNum){ //methNum again ******************
echo "\t\t\t<option value=\"" . $MethodType[$methcount]['id'] . "\">" . $MethodType[$methcount]['name'] . "</option>\n"; // MethodType again ***********************
$methcount ++;
}Code: Select all
</select>
</td><td>
<div id="Ch">
<input name="check" type="text" size="6">
</div>
</td>
</tr>
<tr>
<td colspan="7">
<div id="CC">
<table><tr>
<td>
CreditCardNumber
</td><td>
CardholdersName
</td><td>
CreditCardExpDate
</td>
</tr>
<tr>
<td>
<input name="creditcardnumber" type="text">
</td><td>
<input name="cardholdersname" type="text">
</td><td>
<input name="creditcardexpdate" type="text">
</td>
</tr></table>
</div>
</form>
<script type="text/javascript" language="JavaScript">
updateMethods();
</script>
</td>
</tr></table>
<!-- Dues/Subscription row table end -->
</td>
</tr>
</table>
<!-- ################# BODY ################# END-->
</td>
</tr>
</table>
<!-- end table for title bar -->
</td></tr>
</table>
<!-- end of info table -->
</td></tr></table>
<!-- end of error check table -->
</div>
</body>
</html>Code: Select all
CloseTable();
include("footer.php");
} else { // in reference to the following line... >> if ((is_user($user)) AND (strtolower($userinfo['username']) == strtolower($cookie[1])) AND ($userinfo['user_password'] == $cookie[2])) {
main($user);
}
}
switch($op) {
case "edituser":
edituser();
break;
case "editccbauser":
editccbauser();
break;
default:
main($user);
break;
}[1] Acount page includes Header.php
[2] Header.php includes Javascript.php
[3] Javascript contains needed variables
[4] those variables are needed later on in Acount Page
[5] the global command is used, but the variables return null, when not used in php-nuke, it works just fine.
[6] What do i do... and what did i do wrong?
Thnx again...