Author |
Message |
gregexp
The Mouse Is Extension Of Arm

Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Tue Apr 11, 2006 12:39 am |
|
i want to make a simple page that takes a username and e-mail and makes it go into the database table for authors
this is meant to be an addon..ive read a lot on it....but i cant see how the variables r defined half the time...plus it asks me to put in server connect code..well im usin nuke so i guess that means config.php should handle it.
ive been workin on this not too long but curious if ne1 could help.
ive gotten the html part down..makin a form in html.
its understanding how to insert the info provided into the database tables.
this should only be able to be access by admins.
like i said..i got the form part down(html) now i need to know what to define as a variable and how to define it.
thanx
 |
|
|
 |
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue Apr 11, 2006 5:49 am |
|
I would take a look at one of the other administration modules within nuke and pattern off of that. And, please, make sure it is a patched version that you model after! It isn't exactly the best model of code from a true "coder" perspective, but it should give you what you need to start answering your questions about how to get data into your tables. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Tue Apr 11, 2006 5:52 am |
|
The config.php has the connection parameters, but the actual connections are defined via the mainfile - though that's already included in the main index, modules, and admin files. I'd agree that your best bet is to follow montego's suggestions. |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
gregexp

|
Posted:
Tue Apr 11, 2006 2:28 pm |
|
if tried that and to be honest iv tried lookin in over three ways from sunday.
im havin trouble understanding how the functions r defined .
heres how i see it so far..but apparently this is not right.
i made a function like add admin
Code:>?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin(){
global $admin, $prefix, $db, $language, $multilingual, $admin_file, $bgcolor2;
if (is_admin($admin)) {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . addadmin .
"< /b></font></center>";
echo "<br>";
CloseTable();
OpenTable();
."<table border=\"1\" align=\"center\">"
."<tr><td bgcolor=\"$bgcolor2\"> <b>"._ADMINID."</b> </td><td ";
$result = $db->sql_query("SELECT aid, name, admlanguage from " . $prefix . "_admin");
while ($row = $db->sql_fetchrow($result)) {
$a_aid = filter($row['aid'], "nohtml");
$name = filter($row['name'], "nohtml");
$a_aid = strtolower(substr("$a_aid", 0,25));
$name = substr("$name", 0,50);
echo "<tr><td> $a_aid </td>";
CloseTable();
}
?>
| now i got no clue if this is right...im goin to do my best to read the other files associated with this and see how its done is there neway i can view this to see if itll work without it being put in the site itself?
ok ive tried it that way...i wrote a case.admin_looks.php
a links.admin_looks.php
and the above is the module file for the admins...ne1 able to tell me where i went wrong?...its not even showin up.
case.admin_looks.php
Code:<?php
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
switch($op) {
case "admin_looks":
include("admin/modules/admin_looks.php");
break;
}
?>
|
links.admin_looks.php
Code:<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2005 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $admin_file;
if ($radminsuper==1) {
adminmenu("".$admin_file.".php?op=addadmins", ""._UGROUPS."", "groups.gif");
}
?>
|
all this is in the attempt to make a block work the way id like...see i have a block..most know it..called data_center. it shows admins when they r online and from what i get out of viewin the code...it shows them bein an admin if the username and admin name r 1 in the same. thing is i dont even want to give some1 a starting point..all of my admins usernames r different from their admin names...this works by creatin a table called nuke_admins. and if i add it in through phpmyadmin then yes the block works..id like to make a more user friendly interface...thanx |
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Tue Apr 11, 2006 4:36 pm |
|
I'm just learning this mystical stuff myself so bear with me hear.....
Examine your first code extract.
The first line begins with a php closing tag and of course it should be an opening tag to tell it to start executing php code.
So in the first line change
Next, you see where the refernce to God is?
At the end of that line is an open curly bracket. The full lin is saying, IF the user is a superadmin or God admin the DO whatever is inside the opening and closing curly brackets.
In your case it is executing the function addanadmin()
The function addanadmin is, itself enclosed in opening and curly brackets.
So if you look very closely at your code you will see this;
Code:if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin(){
function code here
}
?>
|
So as you can see, there is no corresponding closing curly bracket for the opening one after the admin check. So you need to add another curly bracket after the very last one in your code but before the closing php tag.
Try that and see how you get on. |
|
|
|
 |
gregexp

|
Posted:
Tue Apr 11, 2006 5:28 pm |
|
u were absolutley right about the code not bein right
montego...u saw how far i got with ur advice...i appreciate it.. i got some understandin..not enough to do what i need though
now i got no clue on this but as u can tell with this stuff there is a limited amount of ability to learn from just lookin at the code and usin it as an example...i have read the tutorials...but the whole.... do this and itll work...i need to understand how it works so i can do this the right way....now i know there is somethin wrong with the code...it wont show right even if i could get a button to show up in the admin panel...lol...well if ne1 can help me to understand the code..id really appreciate it |
|
|
|
 |
montego

|
Posted:
Wed Apr 12, 2006 5:56 am |
|
darklord, to make this work within the administration panel, you must also have a corresponding file in the "case" directory and "links" directory. The file in "links" is what actually shows your icon in the admin panel and the file in the "case" directory just tells nuke where to find your admin index.php file and what operations are valid. If you use an $op that does not existing in this list... "Blank Page" will be the result. |
|
|
|
 |
Guardian2003

|
Posted:
Wed Apr 12, 2006 6:13 am |
|
Just spotted what may be a typo too.
In your admin file (first code example you posted) you named the function
addadmin
In your links.admin_looks.php you specify =addadmins when it should be addadmin if it is to match up.
Your doing great btw  |
|
|
|
 |
gregexp

|
Posted:
Thu Apr 13, 2006 6:30 am |
|
u guys r awesome...its not quite workin right yet...but i think ill work on it a little tomorrow
thanx for lettin me know im on the right path
also..thanx for fillin me in on how the admin panel is showin me what i see...u guys r awesome...simplified is exactly what i need..and i know this is not a training type forum:lol:
but u guys r helpin me out a lot and i thank u
after this im sure ill have a whole lot better understanding of all this..thank you...and for all the "n00bs"...this is a learnin process...never give up..see how much ravens scripts r willin to help....no wonder im gonna make a donation..
u guys r awesome.
1 more thing....thanx for not approachin me with a script..i prefer to write it myself...u dont learn nuffin if ppl just write it for u.  |
|
|
|
 |
gregexp

|
Posted:
Thu Apr 13, 2006 8:26 am |
|
this is my current admin/modules/admin_looks.php
ive named it this Code:<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin(){
global $admin, $prefix, $db, $language, $multilingual, $admin_file, $bgcolor2;
if (is_admin($admin)) {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . addadmin . "< /b></font></center>";
echo "<br>";
CloseTable();
OpenTable();
echo "<table border=\"1\" align=\"center\">";
echo "<tr><td bgcolor=\"$bgcolor2\"> <b>"._ADMINID."</b> </td><td> ";
$result = $db->sql_query("SELECT aid, name, admlanguage from " . $prefix . "_admin");
while ($row = $db->sql_fetchrow($result)) {
$a_aid = filter($row['aid'], "nohtml");
$name = filter($row['name'], "nohtml");
$a_aid = strtolower(substr("$a_aid", 0,25));
$name = substr("$name", 0,50);
echo "<tr><td> $a_aid </td>";
CloseTable();
}
}
}
}
?>
| there is without a doubt somethin wrong here...now all this should do is display current admins...if im reading the code right..i also believe the code emplies that u have to be a god admin to access this file...i could be reading it wrong...if u all wouldnt mind takin a look and lettin me know what u think...it goes to a blnk page...i believe that is because the ops r not right...based on what montego said...so in the case...i changed it from admin_looks to addadmin..under the case part of the code...to define an op...perhaps a more correct question would be what r ops and how do i create 1...from other modules..it seems ops r functions defined in the module file..i think this is correct..now imma back a few steps up..and try to just get it to display a simple html page..using echo command of course. imma do my best to keep u all informed of my progress..ur all willin to help and thats awesome...but without knowin where im at on this..u cant help to much..thnax a ton  |
|
|
|
 |
montego

|
Posted:
Fri Apr 14, 2006 10:04 am |
|
Please re-post your latest admin module's case and link files. I want to make sure the user is getting to this file. Usually I find this is caused by not having the links and case files lined up properly to the module.
Also, you need to move the "CloseTable()" outside the while loop... |
|
|
|
 |
gregexp

|
Posted:
Tue Apr 18, 2006 7:03 pm |
|
admin_looks.php
Code:<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin(){
global $admin, $prefix, $db, $language, $multilingual, $admin_file, $bgcolor2;
if (is_admin($admin)) {
$row = $db->sql_fetchrow($result);
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . addadmin . "< /b></font></center>";
echo "<br>";
CloseTable();
OpenTable();
echo "<table border=\"1\" align=\"center\">";
echo "<tr><td bgcolor=\"$bgcolor2\"> <b>"._ADMINID."</b> </td><td> ";
$result = $db->sql_query("SELECT aid, name, admlanguage from " . $prefix . "_admin");
while ($row = $db->sql_fetchrow($result)) {
$a_aid = filter($row['aid'], "nohtml");
$name = filter($row['name'], "nohtml");
$a_aid = strtolower(substr("$a_aid", 0,25));
$name = substr("$name", 0,50);
echo "<tr><td> $a_aid </td>";
}
}
}
}
CloseTable();
?>
|
this is my case.admin_looks.php
Code:<?php
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
switch($op) {
case "addadmin":
include("admin/modules/admin_looks.php");
break;
}
?>
|
this is my links.admin_looks.php
Code:<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2005 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $admin_file;
if ($radminsuper==1) {
adminmenu("".$admin_file.".php?op=addadmin", "Datacenteradmin", "groups.gif");
}
?>
|
now my apologies for not getting back with you in time..i never got an e-mail sayin post had been made..sorry..if there is somethin i can read on this..i mean if u notice im not quite understanding somethin..this is only to make it show something..it should show all that i have in there..after i learn how to make this work..im goin to make an add admin to the database part. |
|
|
|
 |
gregexp

|
Posted:
Tue Apr 18, 2006 7:43 pm |
|
ok ive found that it is tryin to open the right file and it is usin it...somewhere in my admin_looks.php there is somethin wrong. or at least thats how i figure it....now imma look over this and make sure its not a spellin error. |
|
|
|
 |
Guardian2003

|
Posted:
Tue Apr 18, 2006 8:19 pm |
|
in admin_looks.php
Temporarily remove all the function addadmin() code and add a simple echo or print - that will then tell you the problem lies somewhere within the function itself.
This will leave you with something like
Code:
<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
include ("header.php");
echo "Oops the function has a problem!";
}
?>
|
|
|
|
|
 |
gregexp

|
Posted:
Tue Apr 18, 2006 9:08 pm |
|
 ..thats it so now i know how to make an admin module..my next question will be about functions...let me work on the code and see if i cant figure this out....any insight though would be greatly appreciated. |
|
|
|
 |
Guardian2003

|
Posted:
Wed Apr 19, 2006 5:15 am |
|
The beauty of any programming language is that everything is one step at a time in a logical sequence (more or less).
All you need to do is re-add parts of your function as 'steps'.
For example
Code:
<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin(){
global $admin, $prefix, $db, $language, $multilingual, $admin_file, $bgcolor2;
if (is_admin($admin)) {
$row = $db->sql_fetchrow($result);
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . addadmin . "< /b></font></center>";
echo "<br>";
CloseTable();
}
>?
|
So that 'step' will show you the header, the admin icons and also check to see if you are an admin. You can then move onto the next step by introducing say the code between the next open/close table bits.
Keep an eye on those curly brackets - if you open one, you have to close it again 'somewhere'  |
|
|
|
 |
Guardian2003

|
Posted:
Wed Apr 19, 2006 5:25 am |
|
In fact, lets alter the 'look' slightly so you can see the 'steps' better.
[code]
<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
function addadmin() {
global $admin, $prefix, $db, $language, $multilingual, $admin_file,$bgcolor2;
if (is_admin($admin)) {
$row = $db->sql_fetchrow($result);
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" .addadmin . "< /b></font></center>";
echo "<br>";
CloseTable();
}
}
}
>? |
|
|
|
 |
gregexp

|
Posted:
Wed Apr 19, 2006 12:25 pm |
|
ok i just wanted to see if my function was right like u showed me. so i put the the code like thisCode: <?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if (($row['radminsuper'] == 1) && ($row['name'] == 'God')) {
include ("header.php");
function addadmin(){
echo "Oops the function has a problem!";
}
}
?>
|
now i may be wrong in assuming this but i was under the impression that if my op was addadmin and that case was defined in the case.whatever.php file then it would display the Oops the function has a problem. but it did not do this..matter of fact the header.php was the only thing displayed. any ideas on what im doin wrong?[/code] |
|
|
|
 |
gregexp

|
Posted:
Wed Apr 19, 2006 12:25 pm |
|
thanx for all the help as well |
|
|
|
 |
gregexp

|
Posted:
Thu Apr 20, 2006 2:02 am |
|
i have tried even your code..it still shows a blank page.
grrrrrrrrr what am i doin wrong?..ohh yeah..sorry but its ?> not >?..lol
like i got ne room to talk...uve been awesome but i cant seem to find whats wrong. my op is the same as the function...is this right?...its just not callin the function like i need it to..this is the step im stuck at. ne ideas on where i went wrong? wait..after doin some MAJOR code lookin...all the current i had to add a Code:switch ($op) {
default:
addadmin();
break;
}
|
just like in the case..but this sets it to default so im assuming that means that if i make a submit button it must point to the function and the function must be defined in the admin/module file as well as the case.module.php file.
if im wrong plz help...but i got it to display whats in the function  |
|
|
|
 |
gregexp

|
Posted:
Thu Apr 20, 2006 2:39 am |
|
i am actually gettin somewhere now..i think i might actually accomplish this...this will be an addon to the datacenter module if the owner will accept this..i will not publish this work publicly without talkin to him first...I am makin this in the effort to slow a hacker down. Also just to learn this...man once i got passed the function problem..now i know how to make a function work. time to make the rest of this happen..ill be done in about a week. if it all goes well...if not ull see me again..i like to help ppl so ull see me in here more neway..lol |
|
|
|
 |
gregexp

|
Posted:
Thu Apr 20, 2006 3:11 am |
|
just to keep you all informed..im using the authors.php module file as the template for what im doing..and so far in this night alone i have managed to get it to display what i want. In the first option i used the authors code..with a ton of editing of course to show the info within that table. this table is just gonna have the aid name and e-mail so thats all i want it to display and thats all it does display...ohh yeah i got somewhere. now after lookin over all the posts again i see what the case does and just to make sure i got this right im gonna give you my perspective on what i am reading. The links.module.php file just tells the site what to displayin the admin panel and where to send u on click. the case just verifys that its a legitimate option. the modules file must define the options in the form of a case like i showed be4 and then it must carry out the actions of that function. so its takin 1 file and doing ONLY what its told to within that function. so a single file contains as many pages as functions r in it. awesome. if im right..this is awesome ..to be honest im beatin myself up over not seein this before..lol.
hope this shows you how persistant i am at accomplishing this and i also hope you see that your help and i mean all of your help has not gone in veign. now im not done but i think this may be enough to make the code..now if i only understood all of what i put in there...lol. i do understand it..no way i could do it from scratch though..well with enough time..i dont give up easily. |
|
|
|
 |
|