PDA

View Full Version : [Lock Please] Integrate script with php safe includes?


Tequila
03-30-2009, 01:23 PM
I am working on a design that uses Safe Dynamic Includes (http://www.tutorialtastic.co.uk/snippets/1) to navigate and display the site.

Is there any way to integrate the script into the coding I am doing for the site?

Here is a snippet of the code I'm working with if that helps.
<HTML>
<HEAD>
<TITLE>The World of Earith | Familiar Elements</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" />
</HEAD>

<body><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td class="clear">&nbsp;</td><td class="clear" width="25"></td><td class="content" width="400"><img src="images/mapblank.jpg" border="0" /></td></tr>
<tr><td colspan="3" class="clear"></td></tr>
<tr><td class="header">World Map</td><td class="clear" width="25"></td><td class="header">Welcome to Earith</td></tr>
<tr><td class="content" rowspan="4" valign="top">

<ul>
<li><a href="?x=tower">The Wizard's Tower</a></li>
<li><a href="?x=marketplace">The Marketplace</a><li>
<li><a href="?x=glenn">The Fairy Glenn</a></li>
<li><a href="?x=ruins">The Ruins</a></li>
</ul>
<h2>Apprentice Panel</h2>
<ul><li><a href="login.php">Return</a>
<li><a href="?x=dormitory">Your Dormitory</a></li>





</td><td class="clear" rowspan="4">&nbsp;</td><td class="content"><p>Welcome young apprentice. Here you can adopt a Familiar to help you grow in your magic abilities. Please join our <a href="http://forum.familiarelements.info" target="_blank">forum</a> after registering for the site to keep up to date.</p>
<p>Here you will find the animals that we have carefully bred from enhanced parents that will become wonderful familiars with magickal abilities.</p>
<p>Each familiar has it's own nuances and abilities, you'll have to wait until our Grimore is finished before you can figure out what your familiar can do.</p>

<p>A magickal world not unlike others, mystical and full of wonder.</p>

<p>Visit the Wizard's Tower to adopt a familiar to raise and train. Take care of your familiar when you rest in the dormitory.</p>
<p>Learn more about Earith and the familiars you have access to through the Grimoire. Spend some time at the Conclave with your peers and other fully trained wizards and witches.</p>

<p>Fund the efforts of the Tower Master and see who has helped and contributed to our world.</p>

</td></tr>
<tr><td class="clear">&nbsp;</td></tr>
<tr><td class="header">Updates</td></tr>
<tr><td class="content">
<p><!-- Twitter Please --->
<div id="twitter_div">
<h2 style="display: none;" >Twitter Updates</h2>

<ul id="twitter_update_list"></ul>
<a href="http://twitter.com/familiarelement" id="twitter-link" style="display:block;text-align:right;">follow me on Twitter</a>
</div>
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/familiarelement.json?callback=twitterCallback2&amp;cou nt=5"></script>
</p>





</td></tr>
<tr><td class="clear" colspan="3">&nbsp;</td></tr>
<tr><td class="header" colspan="3">Affiliates</td></tr>

<tr><td class="content" colspan="3"><center><a href="http://starduskstudios.net" target="_blank"><img src="http://i221.photobucket.com/albums/dd159/tlcportfolio/linkus/sds-button.jpg" border="0" alt="Stardusk Studios" title="Stardusk Studios" /></a> <a href="http://www.arvyre.com/" target="_blank"><img src="images/arvyre.png" border="0" alt="Arvyre" title="Arvyre" /></a> <a href="http://www.petsgalorespa.net" target="_blank"><img src="http://i44.tinypic.com/jufozk.gif" border="0" alt="Pets Galore Spa"></a><br />
<a href="http://www.kqzyfj.com/click-3414594-10653867" target="_blank">
<img src="images/image-3414594-10653867.htm" width="88" height="31" alt="DAZ 3D" title="Daz 3D" border="0"/></a> <a href="http://www.renderosity.com/index.php?AID=164" target="_blank"><img src="images/rosity.gif" border="0" alt="Renderosity" title="Renderosity" /></a><br /><a href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=enddayne-fepets" target="_blank"><img src="images/hostgator_green80x15.gif" border="0" alt="HostGator" title="HostGator" /></a>
</center></td></tr>
<tr><td class="clear" colspan="3">&nbsp;</td></tr>
</table></div>
</BODY>
</HTML>

Tequila
03-31-2009, 09:05 AM
I just had a thought Brandon. If I kill the template information for the script and insert the PHP codes for the script into the header of the site would that work? If so, what would I need to delete and where?

BMR777
03-31-2009, 04:18 PM
To kill the template system, in each file you would need to find and comment out / delete:

echo $template;

Then you would just echo the $article_content and $article_title variables out. These contain all of the text that is generated by the script for the most part. :)

You can also echo the other variables for the script out such as the one that controls if a user is logged in or not, or you can integrate that all some other way.

Tequila
04-01-2009, 07:34 AM
All right. Now that I know what to get rid of I'll be able to get the new layout up for users soon. They'll be happy about that.

Tequila
04-01-2009, 08:52 AM
I'm doing this in a beta subdomain, and I'm getting this error now:
Parse error: syntax error, unexpected $end in /home/enddayne/public_html/beta/header.php on line 248

Line 248 is the end of the header.php file which tells the includes to end the header and input the default page.
</td><td class="clear" rowspan="4">&nbsp;</td><td class="content">

So do I have to change the way I have the site setup? Put the header and footer in the index file and leave the <?php if (isset($_GET['x'])) {
if (strpos($_GET['x'], "/")) {
$dir = substr(str_replace('..', '', $_GET['x']), 0, strpos($_GET['x'], "/")) . "/";
$file = substr(strrchr($_GET['x'], "/"), 1);
if (file_exists($dir.$file.".php")) {
include($dir.$file.".php");
} else {
include("world.php");
}
} else {
if (file_exists(basename($_GET['x']).".php")) {
include(basename($_GET['x']).".php");
} else {
include("world.php");
}
}
} else {
include("world.php");
} ?>
between?

BMR777
04-01-2009, 04:25 PM
Is that the whole code of header.php? What is the link to this so I can take a look.

Tequila
04-01-2009, 04:56 PM
I've got some sections of it sorted out, but there are still errors popping up (register2, can't display login box in sidebar).

The link is http://beta.familiarelements.info, I've been adding ?x=pageid at the end of the address to display the page I want.

Tequila
04-02-2009, 10:39 AM
New development, working on editing register2.php
Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in /home/enddayne/public_html/beta/register2.php on line 19

<?
//Protect the database
$username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username);
$pass1 = preg_replace("/[^a-zA-Z0-9s]/", "", $pass1);
$pass2 = preg_replace("/[^a-zA-Z0-9s]/", "", $pass2);
$email = preg_replace("/[^a-zA-Z0-9@._-]/", "", $email);
$tos = preg_replace("/[^a-zA-Z0-9s]/", "", $tos);

// Connect to our database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);

//Check for errors...
if($username == "" or $pass1 == "" or $pass2 == "" or $email == ""){

echo("A required form element was left blank. Please <a href='register.php'>go back</a> and fill out all the form elements and try again.")

if($tos != 'tosyes'){
echo "You did not agree to the Terms of Service. You must agree to the TOS to use this site."

}

if($pass1 != $pass2){
echo "Your passwords do not match. Please <a href="register.php">go back</a> and correct this issue."

die();
}

//Check that username does not already exist

$query = "SELECT * FROM users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$luser=@mysql_result($result,$i,"username");


$i++;
}

$luser = strtolower($luser);
$u2 = $str = strtolower($username);

if($luser == $u2){
echo "Your username has been taken. Please <a href="register.php">go back</a> and select a different username."

die();
}

//All checks pass, create the user
$pass1 = md5($pass1); //MD5 the password
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free','0')");

echo "Your account has been created with the username '.$username.'. <a href="login.php">Click here to log in to your account.</a>"


?>

BMR777
04-02-2009, 02:36 PM
This line is incorrect:

echo("A required form element was left blank. Please <a href='register.php'>go back</a> and fill out all the form elements and try again.")

Should be:

echo "A required form element was left blank. Please <a href='register.php'>go back</a> and fill out all the form elements and try again.";

BMR777

Tequila
04-03-2009, 01:47 PM
I'm just going to scrap this. Did some editing and now the site works fine. Going to have to do a new template though...

Rsmiley
04-03-2009, 03:27 PM
Locked by Request