Jump to content

wintallo

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

wintallo's Achievements

Member

Member (2/5)

0

Reputation

  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!
×
×
  • 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.