Help with deciphering some code.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

Help with deciphering some code.

Post by srednatonmi »

I am in charge or redoing the penfieldbooks.com website however the entire thing is scripted in PHP and I'm not used to that. I've been attempting to figure out the code but I can't quite see what goes where. My first problem, I need to include a space between the Mexican and Swedish titles on the homepage but it isn't just as simple as finding the link in the text as it isn't there. I've included the code for index.php (index.html is just a redirect) and you can see what I'm talking about by visiting the actual site.

Code: Select all

<?php include("includes/copyright.php"); ?>
<?php
$page = "home";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
<html>
<head>
    <title>Penfield Press - Home Page</title>
 
    <meta name="robots" content="index, follow">
    <meta name="description" content="">
    <meta name="Keywords" content="">
 
    <link rel="stylesheet" href="stylesheet/penfield.css" type="text/css">
    <script src="javascript/javascripts.js"></script>
</head>
 
<body marginheight="0" marginwidth="0">
<table width="725" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffef00">
    <tr>
        <td background="images/side_background.gif" bgcolor="ffef00" width="25" rowspan="3"><img src="images/empty.gif" width="25" height="1" alt="" border="0"></td>
        <td><img src="images/empty.gif" width="1" height="3" alt="" border="0">
            <table width="700" border="0" cellspacing="0" cellpadding="1" bgcolor="#000099">
                <tr>
                    <td colspan="2" valign="top" height="63"><?php include("includes/header.php"); ?></td>
                </tr>
                <tr>
                    <td colspan="2" align="center" height="20" bgcolor="#ffef00" class="blueText"><!--<b>215 Brown Street, Iowa City, Iowa 52245</b><br /><b>Phone: 319-337-9998 | Fax: 319-351-6846 | Toll Free: 1-800-728-9998</b><br />--><b>Distributing Books of Ethnic Interest for 29 Years &nbsp;1979-2008</b></td>
                </tr>
                <tr>
                    <td align="left" valign="top" width="155" height="100%">
                    <?php include("includes/nav.php"); ?>
                    </td>
                    <td align="left" valign="top" width="100%">
                        <table width="550" height="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
                            <tr bgcolor="#FFFFFF">
                                <td align="left">
                                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#ffffff">
                                        <tr>
                                            <td align="right" class="dateText" bgcolor="#ffffff" valign="bottom"><?php include("includes/date.php"); ?><img src="images/empty.gif" width="20" height="1" alt="" border="0"></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr bgcolor="#FFFFFF">
                                <td align="center" height="100%" bgcolor="#ffffff">
                                    <!-- main content table -->
                                    <table width="100%" border="0" cellspacing="0" cellpadding="10" align="center" bgcolor="#ffffff">
<?php
// ############################################################################ //
//   SET THIS ADDRESS TO THE CGI-BIN DIRECTORY ON THE SERVER + "db_access.php"  //
//   THIS IS THE DATABASE ACCESS INFO                                           //
// ############################################################################ //
include("/var/www/vhosts/penfieldbooks.com/httpdocs/db_access.php");
// ############################################################################ //
$dbConn = @mysql_connect("localhost",$db_uid,$db_pswd);
if (!$dbConn)
{
    print("Error 1: Could not access Database.");
    exit;
}
 
mysql_select_db($db_name,$dbConn) or die("Couldn't open $db: ".mysql_error());
 
$query = "SELECT title, teaser, body, footer FROM article WHERE type_id = '6' AND status_id = '1'";
 
$result = mysql_query($query,$dbConn) or die("");
while ($result_set = mysql_fetch_object($result))
{
    $title = $result_set->title;
    $teaser = $result_set->teaser;
    $body = $result_set->body;
    $footer = $result_set->footer;
?>
                                        <tr>
                                            <td class="title" colspan="2" align="center"><b><?php print($title); ?></b></td>
                                        </tr>
                                        <tr>
                                            <td class="mainText" align="center" colspan="2"><?php print($body); ?>
                                              <p><br />
                                                <?php
    if ($footer != "")
    {
?>
                                                <?php print($footer); ?>
                                                <?
    }
}
mysql_close($dbConn);
?>
                                              </p>
                                          <tr>
                                            <td class="redTitle" align="center" colspan="2"><a href="book_store.php" class="titleLink">Click here to enter our Online Book Store</a></td>
                                        </tr>
                                        <tr>
                                            <td align="left" width="47%" valign="top" colspan="2"><img src="images/empty.gif" width="1" height="10" alt="" border="0"><br />
                                            <?php include("includes/homePage_headlines.php"); ?>
                                            <br /><br /><br /><br /></td>
 
                                        </tr>
                                    </table>
                                    <!-- end main content table -->
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
        <td background="images/side_background.gif" bgcolor="ffef00" width="25" rowspan="3"><img src="images/empty.gif" width="25" height="1" alt="" border="0">&nbsp;</td>
    </tr>
    <tr>
        <td class="copyText" align="center" valign="middle"><img src="images/empty.gif" width="1" height="18" alt="" border="0" align="absmiddle"><?php include("includes/copyright_footer.php"); ?></td>
    </tr>
</table>
</body>
</html>
 
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Help with deciphering some code.

Post by andym01480 »

That sounds like fun! You need to learn some php and mysql!

It looks like the main content of the site is stored in a mysql database. You need to have a look at it with phpmyadmin or something like that.

The homepage content is found by the query

Code: Select all

$query = "SELECT title, teaser, body, footer FROM article WHERE type_id = '6' AND status_id = '1'";
Bring that up and then add a <br/> between the Mexican and Swedish books.

Then use CSS, some PHP and mysql you can learn from online tutorials to separate out design from content and loose the horrible tables!
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

Re: Help with deciphering some code.

Post by srednatonmi »

I agree with you it must be in a database however, there are no databases on the site and I can't follow the query. I have database access credentials in db_access.php but that's only a username and password.

Any help finding this hidden database?! Something to search for perhaps? :?:
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Help with deciphering some code.

Post by andym01480 »

Databases aren't in a file that you can see easily on the site - you probably wont be able to access where it is on the server by looking with ftp.

Whoever wrote the original site should have written an admin area so the user can change stuff on the site - find out those details and have a go at changing it.

If not, does the hosting account have something like Cpanel that you can log into? or have they only given you ftp access? On most of my hosting accounts you can get in by http://www.domain.com/cpanel and then the ftp username and password. Try that!

With cpanel, you would be able to click on "phpmyadmin" which let you look at the database. Try that and then go back to your client for more info.

If those don't work - you have all the info we need to get into the database by writing your own php script. - But then it is time to really learn some php and mysql
Post Reply