Jump to content

Jerzxu

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by Jerzxu

  1. I find it kind of weird that spl_autoload uses this functionality for namespaces. Numerous places online I've read mentioned that spl will look at the namespace and attempt to load it based on the namespace as if it were a directory structure. http://www.dreamincode.net/forums/topic/148935-php-53-namespacing-and-autoloading/ Example of autoloading with namespaces. Though this is done on windows though, not linux. Guess I will just specify a function to load it. Thanks.
  2. Forgot to post that. Class file looks like this: namespace Test\Systems { class User { #Class functions etc. } }
  3. I did a search on the forums before posting this So I have been attempting to use spl_autoload_extensions('.php') to autoload my classes based off namespaces but it continually says that the namespace does not exist. Code I am using: spl_autoload_extensions('.php'); spl_autoload_register(); use Test\Systems\User as User; $usr = new User(); The error I get is this: Class Test\Systems\User could not be loaded in.. My files are exactly as named in the namespace. So Test > Systems > User.php I have also tried variations of that like: spl_autoload_extensions('.php'); spl_autoload_register(); use Test\Systems as Test; $usr = new Test\User(); And so on. Nothing appears to be working. I looked around online and seen that at one point *nix systems couldn't use autoloading but apparently php 5.3.3 fixed this functionality. The server currently is running on 5.3.13 so I am not sure why this isn't working. Any insight would be appreciated.
  4. Update: So I resolved the issues. I actually went into the source code of the page I was getting and replaced all the random html characters like to regular spaces. This resolved the issue with everything and now my original RegEx works.
  5. http://ekoverse.com/tests/test.php Doesn't seem to. Code for that page: <?php $page = file_get_contents('http://www.skinakiska.com/conditions/snow-report.aspx'); $content = strip_tags($page); preg_match('/24(?:h| h)\s+\d+°(?:C|F)\s+\d+\s+cm/i', $content, $matches); $pattern = '/24(?:h| h)\s+\d+°(?:C|F)\s+\d+\s+cm/i'; print "Matches: <br/>"; print_r($matches); print "<br/><br/>"; print "Pattern: <br/>"; print $pattern; print "<br/><br/>"; print "Content: <br/>"; print $content; ?> Guessing it doesn't work due to the degrees symbol issue. I almost got what I needed by doing this RegEx: /((24 Hr|24 Hrs|24 Hour|24 Hours|24H|24 H).*?(\d+)?(cm| cm))/si Except the value I need, the 0, isn't appearing. Possibly due to a conflict of digits? The reason I need the RegEx to be like that is because there is numerous other websites that I will be looping through to get the same sort of data so the expression can't be just for this site.
  6. The website it's coming from is here: http://www.skinakiska.com/conditions/snow-report.aspx If that helps. Basically file_get_contents from that url put it into a var, then strip_tags, then do the preg_match. Some PHP Code: $page = file_get_contents(http://www.skinakiska.com/conditions/snow-report.aspx); $content = strip_tags($page); preg_match('/(24H|24 H).*?(\d+?)(cm| cm)/si', $content, $matches); print_r($matches); Should actually say that my expected output should be the number next to the cm, rather than what I said before. This RegEx is used for a bunch of different locations, so its put into a loop, but for now I just need this one to work. The difference between some of the other resorts is that they use 24 Hours, etc. which would just mean the first grouping would have 24 Hours|24H etc.
  7. Well basically I am just trying to get the number value before the centimeters (in this case 0) that appears directly after 24 h. The reasoning: We are getting snow reports for the last 24 hours and generally they are 24 h some characters, then 0 cm etc. So essentially I need the first occurrence of some number cm that appears after 24h or 24 h. Which is true, that's what I should expect, but I actually get no matches at all. I'm using preg_match to match and file_get_contents and strip_tags to alter the text before it hits preg_match, but I can't see those modifying the output to result in nothing when a test case on the same text, with 10 cm instead, results in proper matching.
  8. So I have a problem in which I have to get a webpage using file_get_contents, strip out the HTML then parse it with Regular Expressions to get the current snow conditions for that area. With my test cases, which are just copies of the text but with modified values of the amount of snow, it works. But when it goes to get the actual live value, which is currently 0 cm (hasn't changed so I don't know if it works on a different value), it returns a empty array. I have been looking across the web for the what could be causing this, and have try many different cases but nothing seems to work. The regex is: /(24H|24 H).*?(\d+?)(cm| cm)/si The text is: My expected output: 24 h 5°C 0 cm Any help would be appreciated.
  9. Sure just want my email or something??? For contact? Or post it on here??? (prob not best idea)
  10. That is true. Actually I was trying to debate whether or not to use ID (int 255, auto-inc.) as a primary key in the Actions table as I am going to set up a cronjob to delete 2 day old actions. So the auto-incrementing ID would be used up eventually except it would take ALONG time I would imagine. But I couldn't think of a way around, any thoughts?
  11. That sir is a good question. Well, helps me remember what its doing, BUT now that I think about it I could probably just put comments to remind me what I am doing.
  12. That seems to have worked. Thank you! Never have, I will look into that though. THANKS
  13. Good Morning/Afternoon (whichever applies) Okay, I am making a area on my website which users let each other know what they did. (Kinda like facebook's recent friend actions) Anyways, I ran into some problems. You see with the code I have to grab the friends that you have from one table, use them for another tables query to get the actions. So basically: Query Friends -> Use Friends to Query Actions -> Output Recent Actions The code I have is below $friends = mysql_query(sprintf("SELECT `Friend` FROM `Friends` WHERE `Username`='%s' AND `Blocked`='No' AND `Mutual`='Yes'", mysql_real_escape_string($username))); while ($friends = mysql_fetch_array($friends)){ foreach ($friends as $fri){ $actions = mysql_query("SELECT * FROM `Actions` WHERE `Username`='$fri'"); $actionrows = mysql_num_rows($actions); for ($i=0;$i=$actionrows;$i++){ while ($recs = mysql_fetch_array($actions)){ echo $recs['Username']; } } } } The code just gives me a timeout error, but does output the $recs['Username']; It just takes forever to load it. I probably can achieve this some other way, I just don't know exactly where to turn. If you could show me a sign it would help~ Regards, Jerzxu
  14. Update: (Just some tidbits of info.) I was looking at a tutorial on how to insert images into a database and got it successfully running. Except I ran into some problems resizing it etc. I got frustrated and was about to go back to normal way just uploading etc. and realized this line of code when displaying an image from the database: header("content-type: text/jpeg"); After some messing around with changing the file extensions etc. around I actually got my way of viewing to work. So now it will display a file with no file extension, or with a .somemadeupextension regardless. And the way I did it makes it quite difficult to copy without using printscreen. And that's all she wrote.
  15. Posting a picture in a database. I was wondering about that actually. Does it actually post the picture itself into the database or just the link to the picture?
  16. I came up with an idea for stopping hotlinking, but I am not sure if it is possible. See with fileupload I devised the way of encrypting the filename so that it isn't possible to just randomly guess the image. (you could but it would be by extreme chance) Then it would move it with just that name and no extension so it isn't viewable. Problem I ran into was that the browser doesn't know how to read the image seeing as it doesn't have an extension. Is there a possible way to make it so the web browser would know that it was an image using php codes, without making the files name also include a extension? Here's the basics of what's happening with the code: File upload -> Checks to see if its acceptable file type -> Generates a random number and adds it into the middle of the filename -> Encrypts new filename -> Moves to the images folder. So the file went from: image.jpg -> ima9328342734ge.jpg -> 8a5cd29fa948465792a084cff17a162e So in essence I am asking is it possible to make that file viewable without adding the extension onto the filename at the end?
  17. I believe if you use SSL it encodes it tighter so that its harder, except I'm not sure on how to do that exactly.
  18. How would you stop session hijacking then? Use cookies?
  19. On the php.net site for the examples they give they don't have that. Anyone confirm this?
  20. session_start(); include("connect.php"); $username = $_POST['username']; $password = $_POST['password']; if ($_POST['username'] == "" || $_POST['password'] == ""){ $_SESSION['Login'] = "None"; header("Location: loginfail.php"); } else { $password = md5($password); $query = sprintf("SELECT * FROM `Accounts` WHERE `Username`='%s' AND `Password`='%s'", mysql_real_escape_string($username), mysql_real_escape_string($password)); $sql = mysql_query($query); //$sql = mysql_query("SELECT * FROM `Accounts` WHERE `Username`='$username' AND `Password`='$password'"); if (mysql_num_rows($sql) == 0){ $_SESSION['Login'] = "Incorrect"; header("Location: loginfail.php"); } else { $sql2 = mysql_query("SELECT `Activated` FROM `Accounts` WHERE `Username`='$username'"); $active = mysql_result($sql2,0); if ($active == "No") { $_SESSION['Login'] = "UnAct"; header("Location: loginfail.php"); } else { $_SESSION['Login'] = "Successful"; $_SESSION['username'] = $_POST['username']; header("Location: code.php"); } } } Just reassuring, is that correct?
  21. NEVER MIND Fixed it, I think.
  22. ahh yes. I will be adding that then. THANK YOU!
×
×
  • 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.