Jump to content

TheLoveableMonty

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

TheLoveableMonty's Achievements

Member

Member (2/5)

0

Reputation

  1. Alright, I'm going to try pruning the script. It's this area essentially that has me baffled. foreach ($categorySearch as $line) { $compare = explode("#~#", $line); $compare[2] = trim($compare[2]); $complete = 0; if ($postFile == $compare[2] && $compare[0] != ""){ $ammend = "\n".str_replace("\\","",$postTitle)."#~#".$postLink."#~#".$postFile; if ($complete <= 0 && $compare[0] != ""){ fwrite($fp, $ammend); $complete = ($complete+1); echo "FILE CHANGED"; } else { echo "KNOCKED BACK"; } } else { fwrite($fp, $line."\n"); echo "FILE REWRITTEN"; } } I've pruned as much as possible but can't find any resources that give an easier method.
  2. I had a similar query. I went the long way about it, but essentially what I did is created a file containing two numerals with a separator - the current value and max value (the max value being used to reset the current value to "1"). Then assign each line to an array and echo the array instance with the current number. For example: $i = CURRENT NUMBER if ($i <= $maxValue) { echo "$array[$i]"; } else { $i = "0"; echo "$array[$i]"; } $i++; It's a summary as to how the code would work. Your best bet, however, is a DHTML ticker. There's many available online and they're all pretty efficient. As mentioned before, PHP is essentially a server application and is less dynamic in terms of varying display. PHP fit my purpose fine as I needed to progress through a list every fifteen seconds to span accross different browser sessions. That's the best advice I can give on that.
  3. function editLinkSave() { global $separator; $postTitle = $_POST["title"]; $postLink = $_POST["link"]; $postContent = $_POST["content"]; $postContent = eregi_replace("\n","<br>",$postContent); str_replace("\\","",$postContent); $category = $_POST["category"]; $postFile = $_POST["filenumber"]; $categoryURL = "$category.dat"; $categoryFile = file_get_contents($categoryURL); $categorySearch = explode("\n", $categoryFile); $fp = fopen($categoryURL,"w") or die($errorMessage); foreach ($categorySearch as $line) { $compare = explode("#~#", $line); $compare[2] = trim($compare[2]); $complete = 0; if ($postFile == $compare[2] && $compare[0] != ""){ $ammend = "\n".str_replace("\\","",$postTitle)."#~#".$postLink."#~#".$postFile; if ($complete <= 0 && $compare[0] != ""){ fwrite($fp, $ammend); $complete = ($complete+1); echo "FILE CHANGED"; } else { echo "KNOCKED BACK"; } } else { fwrite($fp, $line."\n"); echo "FILE REWRITTEN"; } } fclose($fp); if ($complete != 0) { echo "<TD BGCOLOR=\"#2A338D\" HEIGHT=\"100%\" VALIGN=\"top\"><FONT FACE=\"trebuchet ms\" COLOR=\"#F3B809\" SIZE=\"3\"><B>Link edited!</B></FONT><BR>"; echo "<FONT FACE=\"trebuchet ms\" COLOR=\"#FFFFFF\" SIZE=\"2\">Your link has been edited!<BR><BR>"; echo "<A HREF=\"".$_SERVER['PHP_SELF']."\">Click here</A> to return to link index. $complete, $categoryURL. $postTitle"; echo '</FONT></TD></TR>'; } else { echo "<TD BGCOLOR=\"#2A338D\" HEIGHT=\"100%\" VALIGN=\"top\"><FONT FACE=\"trebuchet ms\" COLOR=\"#F3B809\" SIZE=\"3\"><B>Link edit failed!</B></FONT><BR>"; echo "<FONT FACE=\"trebuchet ms\" COLOR=\"#FFFFFF\" SIZE=\"2\">Nothing was edited!<BR><BR>"; echo "<A HREF=\"".$_SERVER['PHP_SELF']."\">Click here</A> to return to link index."; echo '</FONT></TD></TR>'; } } I've written this code to edit lines in a data file. It loops an array and attempts to identify the correct file number using a variable taken from a string. I've had to put many unnecessary bug fixes to get the script working, but it's left me with a huge headache. The script echoes different phrases through the if/else functions to debug how the scripts performing. For some reason, it keeps looping an unnecessary amount of times for the number of data contained. For example, it'd loop five times if there was only one line in the data file. I'm sure it's due in part to my bug fixing, but I can't seem to crack it. I've spent two solid days on this thing. Has anybody got a clue where I've went wrong?
  4. Good point, actually. It somehow didn't dawn on me the the ecryption was a direct hash of the corresponding array element used to print the link's name. It's possible to do using the switch function and a bunch of cases for every instance, but you ARE better off scripting a login. They've become considerably easy to create. Just find a tutorial on cookie-based login systems for PHP and you're on your way.
  5. date('F \t\h\e jS Y'); That's the one.
  6. The four sub links worked fine for me when the md5 was in place. The reason no further links are working after the Admin links is you've not scripted anything to handle the new links. You're much, much better off encoding a series of login functions using md5 and cookies. There's numerous tutorials available. Encrypting the url with md5 is too daunting and unnecessary.
  7. I got it. I trimmed and checked the $title variable as it was the first instant of the split array. I seem to have a habit of spending hours on a problem, posting here and correcting it not too long after. Cheers.
  8. Alright, simple query. http://www.tenthousandbillboards.com/inf-bin/med/index.php As you can see under the Spain heading, there's a blank entry. The script has been programmed so that there is little to no chance of a line break slipping through so the page will display normally. That one managed to slip in though, so as a precaution I'd like to know the following. foreach ($infoSort as $infoDraft){ $infoLines = explode("#~#", $infoDraft); $title = $infoLines[0]; $link = $infoLines[1]; $location = "desc/".$infoLines[2].".dat"; if(file_exists($location)) { $description = file_get_contents($location); } if ($infoDraft != "\n") { echo " <FONT FACE=\"trebuchet ms\" COLOR=\"#FFFFFF\" SIZE=\"2\">"; echo " <BR><FONT FACE=\"trebuchet ms\" COLOR=\"#F3B809\" SIZE=\"2\"><B>$title</B></FONT> - "; echo " <A HREF=\"".$link."\">$link</A>\n"; if ($_COOKIE["u"] == $configUser && $_COOKIE["p"] == $configPass) { echo "<BR><A HREF=\"index.php?option=editEntry&filename=".$infoLines[3]."\">Edit Entry</A>"; echo " - <A HREF=\"index.php?option=deleteEntry&filename=".$infoLines[3]."\">Delete Entry</A>"; } echo " </FONT>"; } } How could I edit the above piece of code to not display blank lines from a data file? You can see my feeble attempt at attempting to not print lines from the $infoDraft variable. It doesn't work.
  9. What's supposed to display when you click the admin link? All four items are appearing for me.
  10. <?php require_once('common.php'); $error = '0'; if (isset($_POST['submitBtn'])){ // Get user input $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Try to login the user $error = loginUser($username,$password); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro Login System</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <?php if ($error != '') {?> <div class="caption">Site login</div> <div id="icon"> </div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <table width="100%"> <tr><td>Username:</td><td> <input class="text" name="username" type="text" /></td></tr> <tr><td>Password:</td><td> <input class="text" name="password" type="password" /></td></tr> <tr><td colspan="2" align="center"><input class="text" type="submit" name="submitBtn" value="Login" /></td></tr> </table> </form> <a href="register.php">Register</a> <?php } if (isset($_POST['submitBtn'])){ ?> <div class="caption">Login result:</div> <div id="icon2"> </div> <div id="result"> <table width="100%"><tr><td><br/> <?php if ($error == '') { echo '<a href="http://www.junglewebdesign.com/'.$username.'/myhome.html ">here </a>'; echo " $username Now you can visit the index page!"; } else echo $error; ?> <br/><br/><br/></td></tr></table> </div> <?php } ?> <div id="source">Micro Login System v 1.0</div> </div> </body> Small fix there. You didn't include the variable within the echo for the link correctly. The new code there should work fine, provided there aren't any other errors on the script.
  11. Yeah, the file exists on my server. The problem simply is the unexplained breaks forming in the med.dat and cat.dat files causing blank entries to be displayed and subsequently saved. I haven't got the foggiest why it's happening, although I believe it relates to the way I compare if articles are of a specific subject. Honestly, I've confused myself. This is the third damn query on the script I've been trying to write, but it's also the last one. I can't find any other forseen problems occuring with this script.
  12. $txt = fopen("ftp/announcements.txt", "r"); $txtdata = fread($txt, filesize("ftp/announcements.txt")); \\ Change normal page breaks to HTML page breaks... $txtdata=eregi_replace("\n'","<br>'",$txtdata); fclose($txt); echo nl2br(" $txtdata; "); That deals with your first issue of the page breaks not appearing in HTML. As for the links and bold tags, you'll have to stick to basic HTML within the file for that one. It is possible but an extremely unnecessary amount of work.
  13. Are you looking at having the form not send if someone attempts to send it fully blank?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.