Jump to content

wintallo

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by wintallo

  1. Hey, I have a simple question. Will this line of code pose as a security threat? The reason I ask this is because I know people can spoof their referrer. header("Location: ".$_SERVER['HTTP_REFERER']); Thanks!
  2. Okay, nevermind. I just figured my problem out. My firewall was blocking access of cmd.exe to ImageMagick.
  3. Hi, I'm having some trouble with ImageMagick and PHP. I'm not using the extension. What I did was use the command line interface of the ImageMagick package. This is my problem. When I try use php to run command line commands, such as "mkdir testfolder" (I'm on Windows), it works great. But when I put in commands in such as "convert wallpaper.bmp wallpaper.jpg," nothing happens. This is all the different attempts I've made. <?php system("mkdir test"); // This works great! system("convert wallpaper.bmp wallpaper.jpg"); // This doesn't work... exec("convert wallpaper.bmp wallpaper.jpg"); // This doesn't work... shell_exec("convert wallpaper.bmp wallpaper.jpg"); // This doesn't work... escapeshellcmd("convert wallpaper.bmp wallpaper.jpg"); // This doesn't work... `convert wallpaper.bmp wallpaper.jpg` // This doesn't work... ?> What am I doing wrong?
  4. Nevermind, I figured it out on my own. Here's the code for future reference function output_date($timezone = 0, $time = -1) { if ( $time == -1 ) { $time = time(); } $adjusted_time = $time; $adjustment = 60*60*(date('O', time())/100); $adjusted_time = $adjusted_time - $adjustment; $adjustment = 60*60*$timezone; $adjusted_time = $adjusted_time + $adjustment; return date('n/j/Y g:i:s A', $adjusted_time); } Search Engine Keywords: timezone, php, adjust, change, user, time zone, localize, local, calculate <solved>
  5. Hey, I want to get all times one my website to be outputted in the user's time zone, so I wrote a function that should make the proper adjustment. function output_date($timezone = 0, $time = -1) { if ( $time == -1 ) { $time = time(); } $adjustment = 60*60*(date('O', time())/100); $adjustment = $adjustment - (60*60*$timezone); return date('n/j/Y g:i:s A', $time+$adjustment); } The user's time zone is passed as the first parameter, and the time is passed as the second parameter, with the default of the current time. The function isn't working for me. The format of the timezone pass is as follows: -5 for GMT - 5, 0 for GMT, etc. Thanks! -wintallo
  6. I don't think it's possible to put flash in PDFs. I've never seen it and never heard of it, but that doesn't mean it doesn't exist! -wintallo
  7. How is it not working? Is it throwing an error? Also, make sure no html is before the header("Location... part. This includes echoing or printing any text. -wintallo
  8. Hey, I'm making a program that need a dropdown menu with timezones in it. So I wrote a function to output the menu, with an optional parameter of certain timezone to have automatically selected. here's my code. function output_timezone_menu($timezone = 0) { echo "<select name=\"timezone\">"; if ( $timezone == -12 ) { echo "<option value=\"-12\">GMT - 12 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-12\">GMT - 12 Hours</option>"; } if ( $timezone == -11 ) { echo "<option value=\"-11\">GMT - 11 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-11\">GMT - 11 Hours</option>"; } if ( $timezone == -10 ) { echo "<option value=\"-10\">GMT - 10 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-10\">GMT - 10 Hours</option>"; } if ( $timezone == -9 ) { echo "<option value=\"-9\">GMT - 9 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-9\">GMT - 9 Hours</option>"; } if ( $timezone == -8 ) { echo "<option value=\"-8\">GMT - 8 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-8\">GMT - 8 Hours</option>"; } if ( $timezone == -7 ) { echo "<option value=\"-7\">GMT - 7 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-7\">GMT - 7 Hours</option>"; } if ( $timezone == -6 ) { echo "<option value=\"-6\">GMT - 6 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-6\">GMT - 6 Hours</option>"; } if ( $timezone == -5 ) { echo "<option value=\"-5\">GMT - 5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-5\">GMT - 5 Hours</option>"; } if ( $timezone == -4 ) { echo "<option value=\"-4\">GMT - 4 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-4\">GMT - 4 Hours</option>"; } if ( $timezone == -3.5 ) { echo "<option value=\"-3.5\">GMT - 3.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-3.5\">GMT - 3.5 Hours</option>"; } if ( $timezone == -3 ) { echo "<option value=\"-3\">GMT - 3 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-3\">GMT - 3 Hours</option>"; } if ( $timezone == -2 ) { echo "<option value=\"-2\">GMT - 2 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-2\">GMT - 2 Hours</option>"; } if ( $timezone == -1 ) { echo "<option value=\"-1\">GMT - 1 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"-1\">GMT - 1 Hours</option>"; } if ( $timezone == 0 ) { echo "<option value=\"0\">GMT</option>"; } else { echo "<option selected=\"selected\" value=\"0\">GMT</option>"; } if ( $timezone == 1 ) { echo "<option value=\"1\">GMT + 1 Hour</option>"; } else { echo "<option selected=\"selected\" value=\"1\">GMT + 1 Hour</option>"; } if ( $timezone == 2 ) { echo "<option value=\"2\">GMT + 2 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"2\">GMT + 2 Hours</option>"; } if ( $timezone == 3 ) { echo "<option value=\"3\">GMT + 3 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"3\">GMT + 3 Hours</option>"; } if ( $timezone == 3.5 ) { echo "<option value=\"3.5\">GMT + 3.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"3.5\">GMT + 3.5 Hours</option>"; } if ( $timezone == 4 ) { echo "<option value=\"4\">GMT + 4 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"4\">GMT + 4 Hours</option>"; } if ( $timezone == 4.5 ) { echo "<option value=\"4.5\">GMT + 4.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"4.5\">GMT + 4.5 Hours</option>"; } if ( $timezone == 5 ) { echo "<option value=\"5\">GMT + 5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"5\">GMT + 5 Hours</option>"; } if ( $timezone == 5.5 ) { echo "<option value=\"5.5\">GMT + 5.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"5.5\">GMT + 5.5 Hours</option>"; } if ( $timezone == 6 ) { echo "<option value=\"6\">GMT + 6 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"6\">GMT + 6 Hours</option>"; } if ( $timezone == 6.5 ) { echo "<option value=\"6.5\">GMT + 6.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"6.5\">GMT + 6.5 Hours</option>"; } if ( $timezone == 7 ) { echo "<option value=\"7\">GMT + 7 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"7\">GMT + 7 Hours</option>"; } if ( $timezone == 8 ) { echo "<option value=\"8\">GMT + 8 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"8\">GMT + 8 Hours</option>"; } if ( $timezone == 9 ) { echo "<option value=\"9\">GMT + 9 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"9\">GMT + 9 Hours</option>"; } if ( $timezone == 9.5 ) { echo "<option value=\"9.5\">GMT + 9.5 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"9.5\">GMT + 9.5 Hours</option>"; } if ( $timezone == 10 ) { echo "<option value=\"10\">GMT + 10 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"10\">GMT + 10 Hours</option>"; } if ( $timezone == 11 ) { echo "<option value=\"11\">GMT + 11 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"11\">GMT + 11 Hours</option>"; } if ( $timezone == 12 ) { echo "<option value=\"12\">GMT + 12 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"12\">GMT + 12 Hours</option>"; } if ( $timezone == 13 ) { echo "<option value=\"13\">GMT + 13 Hours</option>"; } else { echo "<option selected=\"selected\" value=\"13\">GMT + 13 Hours</option>"; } echo "</select>"; } Is there a more elegant or faster way to do this? It seems like all of the if statements could really slow down the load time. What I'm asking is there some other condition structure I could use to speed up the process? Thanks! -wintallo
  9. Thanks you so much for all your help guys! For future viewers: This is the code I used to do what I was looking for: $movie_code = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/SRzm3wm1Qu0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/SRzm3wm1Qu0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; preg_match_all('~((?<=width=")[0-9]+(?=")|(?<=width:)[0-9]+(?=px;))~', $movie_code, $matches); echo $matches[0][0]."<br />"; $movie_code = '<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=3728266100951844857&hl=en" flashvars=""> </embed>>'; preg_match_all('~((?<=width=")[0-9]+(?=")|(?<=width:)[0-9]+(?=px;))~', $movie_code, $matches); echo $matches[0][0]; // The first "echo" outputted 425 and the second outputted 400. Yay! That's just what I needed! Keywords for the Google Spider: use regexp regex regular expressions to grab extract get pull HTML attributes parameters preg_match preg_match_all php
  10. Thanks a lot for your replies! I have a few questions though. I gave the regex: (width)(=")[0-9]{3,4} You gave me a regex that looks a lot different: ~(?<=width=")[0-9]+(?=")~ I honestly have no idea how to read the latter regex. If I wanted to write a regex that works with preg_match_all (like the one you gave me) that matches both the example I gave above: width="425" and width:425px; how would I do that? In both cases I wanted the "$matches" array to contain 425.
  11. Hello, Right now, I'm trying to right a piece of PHP that grabs data out of a string, based on a regular expression. This is the regex: (width)(=")[0-9]{3,4} Say I want to get the "425" out of the following bit of HTML (stored as a string in PHP) and store it in another variable. <object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/SRzm3wm1Qu0"></param><param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/SRzm3wm1Qu0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed> </object> The regex that matches the width="425" but I don't know how to use it with a PHP function to actually get the number out of the string. I looked into ereg, which test if its in the string or not, and ereg_replace, which replaces it in the string. Niether of those functions do what I am looking for. I want to (in terms of the above example) get the "425" out of the block of HTML. Thanks for the read! (and sorry if this shouldn't be in the regex forum )
  12. Hey, I am currently writing a user interface system in PHP using mySQL. It also has a private messaging system. One thing that isn't working right now is editting a user's website (on the edit profile page). Other than than, everything should be working. I'm not too sure of my applications security. Thanks! -wintallo
  13. I might be wrong, but try posting this question in the Apache forum. http://www.phpfreaks.com/forums/index.php/board,2.0.html -Joel
  14. Hello, I have a simple question. What is an efficient way to encrypt POST information. This question came up because I'm developing a PHP login system, and when I tried to log in, Firefox tells me I am about to POST data on a insecure connection. How do I make my POST connection secure? Thanks!
  15. My first guess would be to nest two foreach statements, like this: foreach($tables[1] as $whole) { foreach (f$tables[2] as $number) { echo $whole; echo $number; } }
  16. For archival purposes and so Trium918 can see how I did it, I will post my completed code. NOTE: this is untested because I haven't had the time This is the script that is loaded on every page. It is meant to update the time if the user is logged in. if ( confirm_user($_SESSION['username'], $_SESSION['password']) ) { include 'database.php'; $query = "DELETE FROM online WHERE username = '".mysql_real_escape_string($_SESSION['username'])."';"; mysql_query($query); $query = "INSERT INTO online ( username, time ) VALUES ( '".mysql_real_escape_string($_SESSION['username'])."', '".time()."' );"; mysql_query($query); mysql_close($database_connection); } This is inside the login script so that the user is logged as online when he or she dives the correct username and password (logs in). include 'includes/database.php'; $query = "UPDATE users SET lastlogin = '".time()."' WHERE username = '".$_POST['username']."';"; mysql_query($query); mysql_close($database_connection); This is inside the logout script, so it deletes the record of a user being online from the "online" table. include 'includes/database.php'; $query = "DELETE FROM online WHERE username = '".mysql_real_escape_string($_SESSION['username'])."';"; mysql_query($query); mysql_close($database_connection); This is the script that outputs what users are online. It's not pretty, but it works. <? include 'includes/include.php'; $seconds_to_wait = 600; $threshold = time() - $seconds_to_wait; include 'includes/database.php'; $query = "DELETE FROM online WHERE time < '".$value."';"; mysql_query($query); $query = "SELECT username FROM online;"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo $row['username']." "; } mysql_close($database_connection); ?>
  17. Okay, thanks for the replies! I'll try those out, that answers my question so I will make this thread "SOLVED"
  18. Hey, Right now I'm programming a user authentication system in PHP and I have a question about a fun feature I want to add. I want to have one of those things that tells you if a user is logged on at the moment, such as the one on PHP Freaks. I was thinking that I should have a mySQL table dedicated solely to online users. I just don't know how (and where) I should put the script that deletes old users from the "online" table, say if the users didn't use the log out feature, but just closed his/her browser. If you have any idea what I mean, I would appreciate some help. Thanks. p.s. this is what I have so far. -wintallo
  19. Hello, what does this error mean? Warning: ereg() [function.ereg]: REG_ERANGE in /home/wintallo/public_html/login_sys/register.php on line 27 Line 27 is: if (ereg($pattern_username, trim($_POST['username']))) { (where $pattern_username = '\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b' And $_POST['username'] was "wintallo". Thanks!
  20. Okay, I found my problem. When I create a new file using PHP, it gives it a permissions value that does not let the outside world see its contents. So I chmod'd it to 0644, which apparently is sufficient. For future reference, this is my final working code <? $movie_page = "<?php\n echo \"Hello, world!\";\n ?>"; $movie_page_name = "test.php"; $handler = fopen($movie_page_name, 'w'); fwrite($handler, $movie_page); fclose($handler); chmod($movie_page_name, 0644); ?>
  21. Okay, I revised my code as you said. Here is the code for the PHP file that creates the other PHP files. <? $movie_page = "<?php\n echo \"Hello, world!\";\n ?>"; $movie_page_name = "test.php"; $handler = fopen($movie_page_name, 'w'); fwrite($handler, $movie_page); fclose($handler); ?> And the file that code creates is <?php echo "Hello, world!"; ?>
  22. Yah, you need to use stripslashes() to... strip the slashes wherever in your code where you output the database data. Also, when inputting data into the mySQL, I would use mysql_real_escape_string() as apposed to addslashes().
  23. Hello, I'm writing a PHP application that has a component that writes other PHP files. I have the fopen, fwrite, and fclose all working correctly. The problem is, is that when it writes the new PHP file, and I open it, my server throws a 500 error. When I open the new PHP file in a text editor, It looks like perfectly valid PHP. Here's my code. <? $movie_page = "<? echo \"Hello, world!\"; ?>"; $movie_page_name = "test.php"; $handler = fopen($movie_page_name, 'w'); fwrite($handler, $movie_page); fclose($handler); ?> Is there some special parameter I have to use to write PHP files using PHP?
  24. So I could set a cookie every time a logged in user goes to a page setcookie("loggedin", 1, time()+60*10); But how would this help? Yes, after 10 minutes the cookie would die, but how could I interface this with a database? I want to use this so that on a user list, people could see which users are online and which are not. I might just be missing something really obvious Thanks for your time!
×
×
  • 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.