[advanced search]
Results from the most recent live auction are here.
25 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 05-10-2008, 03:18 AM   · #1
texasgamer
Senior Member
 
texasgamer's Avatar
 
Name: Ray
Location: iCue.mobi
Trader Rating: (28)
Join Date: Jan 2006
Posts: 2,004
NP$: 31.90 (Donate)
texasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to behold
Save The Children
Help! Php help needed

I have a very basic directory site in which people submit their sites too.
I have a very simple backend (admin.php) in which I can approve submitted links and then they get installed in the mysql database. The backend does not have any way to delete the links that I do not want. I can only approve the links.
Currently I have to approve the unwanted links and then, I log into cpanel and access the database and find the unwanted link and delete it. I need to add some code to my admin.php but am lacking the expertise to do this. Do I need to hire a php coder or is their a couple lines of code I can add?

Heres the php code I currently have in my admin.php

PHP Code:
<?
ob_start
();

?>
<style>
* {
    font-family: tahoma;
    font-size: 10pt;
    color: #000;
}
</style>
<?php

include("config.php");
$a = $_GET['action'];
$c = $_COOKIE['xxxx'];
$admin_pass = "xxxxxxxxxxxxxxx";
if(
$c!="") {
        print
"<b>Admin</b><p>";
    print
"<a href='admin.php?action=approve'>Approve Links</a><p>";
        print
"<a href='/'>HOME</a><p>";
        if(
$a == "") {
        print
"Please choose a section from above!";
    }
      if(
$a == "approve") {
        print
"<table border=0 cellpadding=2 cellspacing=0 width=100%>
        <tr>
        <Td>Title</td>
        <td>Category</td>
        <td>URL</td>
        <td>Description</td>
        <td></td>
        </tr>"
;
        
$sql = mysql_query("SELECT * FROM `directory` WHERE `approved`='0'");
        while(
$row = mysql_fetch_array($sql)) {
             
extract($row);
             
             
$sql2 = mysql_query("SELECT * FROM `directory_cats` WHERE `id`='$category'");
             while(
$row2 = mysql_fetch_array($sql2)) {
                  
$category_name = $row2["category"];
             }
                 print
"<tr>
             <td>$headline</td>
             <td>$category_name</td>
             <td>$url</td>
             <td>$description</td>
             <td><a href='admin.php?action=app&id=$id'>Approve</td>
             </tr>"
;
        }
            print
"</table>";
    }
    if(
$a == "app") {
            
$id = $_GET['id'];
                if(
$id) {
                 
mysql_query("UPDATE `directory` SET `approved`='1' WHERE `id`='$id'");
                
Header("Location: admin.php?action=approve");
            }
    }
}
else {
    
$p = $_POST['password'];
        if(
$p!="") {
         if(
$p==$admin_pass) {
              if(
setcookie("xxxx","xxxx",time()+3600)) {
                   
Header("Location: admin.php");
              }
              else {
                   print
"Cant Set Cookie";
              }
         }
         else {
              print
"Wrong Password";
         }
    }
    else {
    
?>
    <form action="admin.php" method="post">
    Type in a password: <input type="password" name="password" size="30"><p>
    <input type="submit" value="Login"></form>
    <?
    
}
}
?>


Please register or log-in into NamePros to hide ads
__________________
paper rock scissors
texasgamer is offline   Reply With Quote
Old 05-10-2008, 03:40 AM   · #2
-NC-
Stranger
 
-NC-'s Avatar
 
Location: in a strange land
Trader Rating: (35)
Join Date: Mar 2007
Posts: 1,304
NP$: 594.28 (Donate)
-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of
Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
Something like this should do the job:
( untested, please back up your database before using )

PHP Code:
<?
ob_start
();

?>
<style>
* {
    font-family: tahoma;
    font-size: 10pt;
    color: #000;
}
</style>
<?php

include("config.php");
$a = $_GET['action'];
$c = $_COOKIE['xxxx'];
$admin_pass = "xxxxxxxxxxxxxxx";
if(
$c!="") {
        print
"<b>Admin</b><p>";
    print
"<a href='admin.php?action=approve'>Approve Links</a><p>";
        print
"<a href='/'>HOME</a><p>";
        if(
$a == "") {
        print
"Please choose a section from above!";
    }
    
    if(
$a == "delete" &&  isset($_GET['id']) )
    {
        
        
$id = $_GET['id'];
        
        if(
is_numeric( $id ) )
        {
            
mysql_query("DELETE FROM `directory` WHERE `id`='$id' LIMIT 1");
        }
        
        
$a = "approve";
    }
    
    if(
$a == "approve") {
        print
"<table border=0 cellpadding=2 cellspacing=0 width=100%>
        <tr>
        <Td>Title</td>
        <td>Category</td>
        <td>URL</td>
        <td>Description</td>
        <td></td>
        </tr>"
;
         
$sql = mysql_query("SELECT * FROM `directory` WHERE `approved`='0'");
        while(
$row = mysql_fetch_array($sql)) {
             
extract($row);
             
             
$sql2 = mysql_query("SELECT * FROM `directory_cats` WHERE `id`='$category'");
             while(
$row2 = mysql_fetch_array($sql2)) {
                  
$category_name = $row2["category"];
             }
                 print
"<tr>
             <td>$headline</td>
             <td>$category_name</td>
             <td>$url</td>
             <td>$description</td>
             <td><a href='admin.php?action=app&id=$id'>Approve</a>&nbsp;|&nbsp;
                 <a href='admin.php?action=delete&id=$id'>Delete</a></td>
             </tr>"
;
        }
            print
"</table>";
    }
    if(
$a == "app") {
            
$id = $_GET['id'];
                if(
$id) {
                 
mysql_query("UPDATE `directory` SET `approved`='1' WHERE `id`='$id'");
                 
Header("Location: admin.php?action=approve");
            }
    }
}
else {
    
$p = $_POST['password'];
        if(
$p!="") {
         if(
$p==$admin_pass) {
              if(
setcookie("xxxx","xxxx",time()+3600)) {
                   
Header("Location: admin.php");
              }
              else {
                   print
"Cant Set Cookie";
              }
         }
         else {
              print
"Wrong Password";
         }
    }
    else {
    
?>
    <form action="admin.php" method="post">
    Type in a password: <input type="password" name="password" size="30"><p>
    <input type="submit" value="Login"></form>
    <?
    
}
}
?>
__________________
Unlimited Domain Name Hosts
Keep your names in the NameCooler
Vegas Trip
Reported NameJet to the FTC for not providing an opt out.

Last edited by -NC- : 05-12-2008 at 12:08 AM.
-NC- is offline  
  Reply With Quote
Old 05-10-2008, 10:55 AM   · #3
DomainManDave
NamePros Regular
 
Trader Rating: (8)
Join Date: Jun 2007
Posts: 609
NP$: 13.30 (Donate)
DomainManDave is just really niceDomainManDave is just really niceDomainManDave is just really niceDomainManDave is just really niceDomainManDave is just really nice
Cancer
That is very unsecure code... All I would need to do is find out the name of the cookie and im in.
DomainManDave is online now   Reply With Quote
Old 05-10-2008, 09:38 PM   · #4
-Nick-
I'll do it
 
-Nick-'s Avatar
 
Name: Keral. Patel.
Location: India
Trader Rating: (97)
Join Date: Dec 2005
Posts: 5,233
NP$: 9941.05 (Donate)
-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute
Member of the Month
September 2007 Adoption
Just delete the login stuff and put this admin.php into some folder called "admin"

Password protect that folder via cpanel Password protected directories option.

The rest of the code can be secured or unsecured it doesn't matters.
-Nick- is offline   Reply With Quote
Old 05-11-2008, 10:16 PM   · #5
texasgamer
Senior Member
 
texasgamer's Avatar
 
Name: Ray
Location: iCue.mobi
Trader Rating: (28)
Join Date: Jan 2006
Posts: 2,004
NP$: 31.90 (Donate)
texasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to beholdtexasgamer is a splendid one to behold
Save The Children
NC thanks for the help. I still can not get this to work. I really do appreciate your help tho.
The original developer, of the site, saw this thread and has contacted and offered assistance!
Nick, I took your advice and secured the admin.php file in a password protected folder.
I would have never thought about this - but its a great tip!
It may be oldhat too some, but tips like this are very helpful to us who are still learning...
__________________
paper rock scissors
texasgamer is offline   Reply With Quote
Old 05-11-2008, 10:33 PM   · #6
-Nick-
I'll do it
 
-Nick-'s Avatar
 
Name: Keral. Patel.
Location: India
Trader Rating: (97)
Join Date: Dec 2005
Posts: 5,233
NP$: 9941.05 (Donate)
-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute
Member of the Month
September 2007 Adoption
Originally Posted by texasgamer
Nick, I took your advice and secured the admin.php file in a password protected folder.
I would have never thought about this - but its a great tip!
It may be oldhat too some, but tips like this are very helpful to us who are still learning...


Thanks. Happens to me all the time when I am only looking at the cream floating on the glass and assume its filled with milk. Without knowing it could be water on which the cream is floating
-Nick- is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Build your NameBrand http://www.mobisitetrader.com/ Get Your Site Linked at LinkedKeywords.com
Advertise your business at NamePros
All times are GMT -7. The time now is 11:57 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0