Jump to content

ksteuber

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by ksteuber

  1. ksteuber:[quote]...I have been looking at the source after I run the script...[/quote]
  2. First of all, does this html work? If so I'm suprised. Let me redo this a bit... (quiz.php) [code] <?php $answerkey=array(1=>3,2=>2); if (isset($_POST['Number'])) { $grade=$_POST['grade']; if ($answerkey[$_POST['Number']]==$_POST['Answer']) $grade++; } ?> <html>   <head>     <title>Take my Quiz</title>     <style type="text/css">       table {         position: absolute;         left: 5px       }       h3 {         text-align:center;       }     </style>   </head>   <body>     <?php     if (($answerkey[$_POST['Number']]==$_POST['Answer'])&& isset($_POST['Number']))     echo "You got it correct!";     if (($answerkey[$_POST['Number']]!=$_POST['Answer'])&& isset($_POST['Number']))     echo "Sorry, You got it wrong.";     ?>     <table>       <tr>         <td>         <h3>Quiz about my site</h1>         <?php         if (!isset($_POST['Number']))         {         echo <<<END         <form action="test.php" method="POST">         1. When did I make this site?         <input type="hidden" name="Number" value="1">         <input type="hidden" name="grade" value="0">         <INPUT TYPE="radio" NAME="Answer" value="1"> in 1996         <INPUT TYPE="radio" NAME="Answer" VALUE="2"> in 1992         <INPUT TYPE="radio" NAME="Answer" VALUE="3"> in 2006         <INPUT TYPE="radio" NAME="Answer" VALUE="4"> in 2003         <input TYPE="submit" VALUE="Next question"></FORM> END;         } elseif ($_POST['Number']==1) {         echo <<<END         <form action="test.php" method="POST">         2. Who made this site?         <input type="hidden" name="Number" value="2"> <input type="hidden" name="grade" value="$grade">         <INPUT TYPE="radio" NAME="Answer" value="1"> Ksteuber         <INPUT TYPE="radio" NAME="Answer" VALUE="2"> Oyster         <INPUT TYPE="radio" NAME="Answer" VALUE="3"> the Yeti         <INPUT TYPE="radio" NAME="Answer" VALUE="4"> Mike Moore         <input TYPE="submit" VALUE="Finish"></FORM> END;         } elseif ($_POST['Number']==2) {           echo "Congratulations, you finished the test. You got $grade out of 2 correct. That's ",$grade*100/2," percent!";         }         ?>         </td>       </tr>     </table>   </body> </html> [/code] Is that what you were looking for?
  3. Let me see if I got this straight (I'm not sure I really understand the question). You're looking to make a script that figures out what the URL of the page it has been included in is, and then uses that information to decide what to do next? I think you want something like this: (main.php) [code] <?php $URL = $_SERVER['PHP_SELF']; if ($URL == "/index.php") echo "You are on the main page"; ?> [/code]
  4. Ok, so I tried the $done="hello"; idea, which made it so that the script would return a fopen error which turned out to be because $URL contained "http://" and "/" is a forbidden character in linux filenames. (Oops, thats an embarassing mistake) I changed the code to: [code] echo $done; $filename = "/home/content/k/s/t/ksteuber/html/php_uploads/logs/".substr($URL,7)." - ".date("F j, Y, g:i a"); $fp = fopen($filename,"w"); fwrite($fp,$done); fclose($fp); [/code] Now it makes the file properly, and the file contains the entire site (Yay). However, "echo $done;" still is not working properly. When I view the webpage, I still get only a fraction of $done. I also tried to export some different text at that point in the script that was the same length as $done would have been, but that didn't work either. But wait, here's the weird part. If I make a completely different script that echos that much info, but doesn't execute any of the other commands in the original script, it works. So presumably there is something else in the script that is interfering with the echo command. (The full code of the script is still at: http://www.kirksteuber.com/parser.txt)
  5. as for fopen, I have no way of knowing if it works, since the script doesn't even get past the echo command (it desplays a portion of $done, and not the rest of it, and I have tried but I can't get any other funtions that I use after "echo $done;" to give me a sign that it has been executed at all) as for the second idea, I have been looking at the source after I run the script, so I would see any abnormally long tags.
  6. Does anybody know? Shouldn't there be an easy solution?
  7. I'm not sure I understand the problem... You want a link that takes you to a new page with embeded video? doesn't that just require an object tag?
  8. Unless you are running these script on a pretty out of date server, or you are getting a ton of hits I don't think that you need to worry too much about that. Time the function; I would bet it takes less than a second. And afterwards, the memory no longer being used. Not a particularly heavy burden on any server.
  9. I suppose you could ftp in with something like: [code] <?php $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if ((!$conn_id) || (!$login_result)) {       echo "Could not connect to the FTP server";       exit;   } $upload = ftp_put($conn_id, 'log.txt', 'log.txt', FTP_BINARY); if (!$upload) {       echo "Could not upload to the FTP server";   } ftp_close($conn_id); ?> [/code] Is that what you had in mind?
  10. Well it seems like the html file ought to be fairly easy. I'm having a hard time understanding exactly where the information is comming from, but if I understand right, you want something like: [code] <?php $username = $_POST['username']; $userinfo1 = $_POST['userinfo1']; $userinfo2 = $_POST['userinfo2']; $html="<html><head><title></title></head><body><h1>This is Important User Information:</h1><table><tr><td>Piece of Information #1</td><td>$userinfo1</td></tr><tr><td>Piece of Information #2</td><td>$userinfo2</td></tr></table></body></html>"; $handle = fopen($username.".html", "w"); fwrite($handle, $html); fclose($handle); ?> [/code] Is this the sort of thing you were looking for?
  11. How do you plan to have this script executed? Since most php scripts are run when they are requested by some one over the internet, I don't see how you could have a script that would be executed based on when there are new pictures, or even a script that is run on a regular basis.
  12. if you are trying to find the size of the output of a page that will always be a constant size you can probably do this: [code] $site = file_get_contents('http://www.mywebsite.com/tracking.php?action=show'); print "filesize[" . strlen($site) . "]"; [/code] I believe that "filesize" only works for local files, so "filesize('http://www.mywebsite.com/tracking.php?action=show')" wouldn't work. Since 'http://www.mywebsite.com/tracking.php?action=show' is clearly not local. Also, if what you were attempting to do was to retrieve the file locally, the script would be looking for a file named 'tracking.php?action=show', not a file named 'tracking.php'. (Also retreiving a php file locally gets the code of the file, not the output. ie: filesize("helloworld.php") would get the length of "<?php echo 'Hello World'; ?>" rather than the length of "Hello World")
  13. Here are the answers as far as I know them 1) If any such function exists, I don't know of it. Just define one. [code] <?php function dirseek($path,$num) { if (!($handle = opendir($path))) { echo "The path could not be opened"; return; } else { $i=0; while (FALSE !== ($file = readdir($handle)) && $i < $num) {       $i++;   } closedir($handle); return $file; } } ?> [/code] 2) Whether or not this should be true hypothetically, it's not. 3) No, you underestimate how fast a computer, especially a server can find files.
  14. I'd have to agree with fran. I would direct the user to a different page. If you want you could even direct them to another page that uses <meta> or javascript to redirect them back to the original page
  15. Somebody correct me if I'm wrong, but in order to run a php script, apache has to request the page (which is usually a result of a person's browser requesting the page), so if you want a script to resond to email rather than browser requests, wouldn't you have to somehow integrate PHP with a POP3 server. I know Nothing about POP3 servers. Can you even do that?
  16. I'm not sure what you mean by [quote]"discussion", not "newsletter"[/quote] but as for a mailing list, are you looking for something like this? [code] <?php $mailinglist=file("mailinglistfile.txt"); $myemailaddress="example@domain.com"; $subject="The Subject of this Email"; $msg="Hello, I am sending you all this message."; $headers='From: '.$myemailaddress."\r\n".'MIME-Version: 1.0'."\r\n".'Content-type: text/html; charset=iso-8859-1'."\r\n"; foreach($mailinglist as $theiremailaddress) { mail($theiremailaddress,$subject,$msg,$headers); } ?> [/code]
  17. If you do use single quotes, only use one \ rather than 2, since double quotes render \\ as \ and single quotes don't render anything [code]<?php $newline=array("\r\n","\n","\r");          //If you know which new line the page is giving you, you can replace it, but I don't remember which is the default $somecontent = str_replace($newline,'\',$somecontent); // notice the single quotes instead of the double quotes ?>[/code]
  18. I'm having a little truoble making out your code (partially, I think, since i don't know what the includes are), but if I understand the gist of it correctly, you could replace [code]echo( '<font="arial" color="#003325">Thank you</font><br />');[/code] with [code]<?php // notice that i spelled script wrong so that the forum would let me submit my post echo <<<END <scipt type="text/javascript"> function disp_alert() { alert("Thank You") } </script> END; ?>[/code]
  19. Check this out, see if it helps: [url=http://www.thescripts.com/forum/thread4054.html]http://www.thescripts.com/forum/thread4054.html[/url]
  20. I agree with HuggieBear, I dont see where you defined $_Session['thumb']
  21. yeah... I like HuggieBear's idea, that's probably the way to do it.
  22. If you put in this code after you define $somecontent it should replace all newlines with a \ [code] <?php $newline=array("/n","/r","/r/n");          //If you know which new line the page is giving you, you can replace it, but I don't remember which is the defualt str_replace($newline,"\\",$somecontent); ?> [/code] Is that what you were looking for?
  23. Ok I think I've figure this one out (it took me a while) Let me rewrite your code the way it is executed: [code] <?php $file='test2.php'; function get_include_contents($filename) { ob_start();         //include($file);         $tempVar = " HELLO!";  //This varible is defined in the function definition get_include_contents         function doTest()         {       global $tempVar;       echo $tempVar;         }         doTest(); $contents = ob_get_contents(); ob_end_clean(); return $contents; } if($_GET['work']) { echo "This works!"; ob_start(); //include($file);         $tempVar = " HELLO!"; //This variable is defined outside of any function definitions in test1.php         function doTest()         {       global $tempVar;       echo $tempVar;         }         doTest(); $contents = ob_get_contents(); ob_end_clean(); } else { echo "This doesn't work!"; $contents = get_include_contents($file); } echo($contents); ?> [/code] Now when you look at it this way, it becomes clear that inside test1.php:get_include_contents:doTest, [code]global $tempVar;[/code] is looking to see if $tempVar has been defined in test1.php. Since it is not, $tempvar continues to equal "". Did I say that right?
  24. well if it is giving you that error message, it means that $_SESSION['thumb'] is not set. Maybe you want [code] <?php if( $_SESSION['thumb'] != "nopic.jpg" && $_SESSION['thumb']!="") { unlink("shared_files/thumbs/".$_SESSION['thumb']); ?> [/code]
×
×
  • 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.