Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by sKunKbad

  1. There are worse things to worry about, but if it really bothers you, check out php's Tidy extension.
  2. Before even looking at your files, I've got to advise you on your table schema for users. 1) The official length of an email address can be up to 255 characters. 2) Your password field length indicates that you may not be hashing your passwords, or if you are, then not doing it correctly. You should read up on bcrypt, or PHP's new password functions. 3) Your session ID being a unix time value is really weak, but if you insist, unix time is better stored as int(10).
  3. I didn't try that (and don't know what it is without reading/searching), but the problem was that there was an .htaccess in a parent directory with a conflicting rewrite rule. EDIT -- Thanks for your reply! I appreciate your time.
  4. mod_rewrite is for sure enabled on both servers, but the following script doesn't work on dev. Instead it rewrites to sitemap (no file extension), which results in a 404. Any idea what's up? RewriteEngine On RewriteBase / RewriteRule ^sitemap\.xml$ sitemap.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] I just need to generate the sitemap via the sitemap.php script. What's weird is that I can't even call the script directly. Requests for sitemap.xml and sitemap.php are both routed to "sitemap".
  5. Even if we are not all professional devs (or aspire to be), we should all have some integrity. Spoofing PayPal is directly related to identity theft and in many cases grand theft. In some countries they chop off your fingers or hands if you steal. Stealing is serious. Let's not be accomplices.
  6. Paypal would probably be very interested in this thread.
  7. I have a sqlite database of zip codes and their geo coordinates. When I want to find the distance between two zip codes I query the db and then use the following function: <?php /** * This function calculates the distance between two * points (given the latitude/longitude of those points). * * @param decimal degrees latitude of point 1 * @param decimal degrees longitude of point 1 * @param decimal degrees latitude of point 2 * @param decimal degrees longitude of point 2 * @param string the unit for results * 'M' is statute miles * 'K' is kilometers * 'N' is nautical miles */ if( ! function_exists( 'distance_between_geo_coords' ) ) { function distance_between_geo_coords( $lat1, $lng1, $lat2, $lng2, $unit ) { $theta = $lng1 - $lng2; $dist = sin( deg2rad( $lat1 ) ) * sin( deg2rad( $lat2 ) ) + cos( deg2rad( $lat1 ) ) * cos( deg2rad( $lat2 ) ) * cos( deg2rad( $theta ) ); $dist = acos( $dist ); $dist = rad2deg( $dist ); $miles = $dist * 60 * 1.1515; $unit = strtoupper( $unit ); if( strtolower( $unit ) == 'k' ) { return $miles * 1.609344; } else if( strtolower( $unit ) == 'n' ) { return $miles * 0.8684; } else { return $miles; } } } // --------------------------------------------------------------
  8. I feel the same way, but voted "Libertarian" in the poll because they best represent how I feel about government's limited role and size. Most people that I talk to more or less agree that the 2 party stronghold on America is destroying this country. I'm fascinated by politics and what I perceive as the brainwashing of the masses.
  9. Without starting a war between members, I was wondering if US based forum members tend to be affiliated with one political party versus the others. If you care to comment, please don't bash other parties without first stating why your party is better. Please refrain from name calling, cussing, or insults.
  10. <?php $sel1 = isset( $_POST['b_midw'] ) ? (int) $_POST['b_midw'] : FALSE; $sel2 = isset( $_POST['b_weeke'] ) ? (int) $_POST['b_weeke'] : FALSE; if( $sel1 === FALSE && $sel2 === FALSE ) { // Nothing selected } else if( $sel1 !== FALSE && $sel2 !== FALSE ) { // Both were selected } else if( $sel1 !== FALSE OR $sel2 !== FALSE ) { // One was selected }
  11. Verisign, Comodo, or your web host for the SSL. If you just want to learn about website authentication in general, you're doing the right thing. There's lots to learn. Owasp: https://www.owasp.org/index.php/Authentication_Cheat_Sheet Read this: http://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication The thing is, it's fairly complicated to design your own authentication. You're not likely to get it right unless you have lots of time. I started working on mine about 5 years ago. It has evolved and had major changes multiple times. Looking back, v1 was an absolute mess. It has been very valuable though, because I've learned a lot, so I say do it.
  12. Since you say security of the user ID is important, you'll for sure want to use SSL. From there, to make it easy for you, try one of the php frameworks that has built in authentication aka Auth. I wrote a codeigniter app called Community Auth a while back. It would be overkill, but would definitely work.
  13. For me there have been a few things that have made a big difference: 1) in my early days of php, reading books on php. I think I read 5 before I could feel comfortable doing anything. 2) choosing a big task, like making an ecommerce app, just for experience. Choose something you think is hard for extra fun. 3) reading the php docs. Anything i don't know, read it, play with it. Right now I'm playing with SPL. 4) browse and play with php frameworks, never trying to stick with only one. Try to make your own. 5) always consider what everyone else is doing. If the trend is x, y, or z, then learn them, even if I don't use them.
  14. I'm getting closer to having an expected result, although the method isn't really using SimpleXmlIterator the way I think it should. I'm getting those unknown namespaces and using them nicely. The issue now is that XML can have more than one of the same element, but an array can't. I've got to get to my real job, but this is what I've got now: public function to_array( $xml, $r = NULL, $namespace = NULL ) { if( is_string( $xml ) ) { $sxi = new \SimpleXmlIterator( $xml ); } else { $sxi = $xml; } $namespaces = $sxi->getNameSpaces( TRUE ); $el = $sxi->getName(); $r[ $el ] = strval( $sxi ) ? trim( strval( $sxi ) ) : []; // Do regular children foreach( $sxi->children() as $k => $v ) { $r[ $el ] = $this->to_array( $v, $r[ $el ], '' ); } // Do regular attributes foreach( $sxi->attributes() as $k => $v ) { $r[ $el . '_attrs'][$k] = "$v"; } // Do children and attributes of namespaces foreach( $namespaces as $pre => $ns ) { foreach( $sxi->children( $ns ) as $k => $v ) { $r[ $el ]['_' . $pre] = $this->to_array( $v, @$r[ $el ]['_' . $pre], $pre ); } } return $r; }
  15. If you don't already have a website to advertise yourself for freelance work, then you should make one. Make sure your phone number is very visible. You will get calls if the site is made well.
  16. First, let me point out that I am familiar with parsing namespaced XML with SimpleXML. For the purposes of iteration over XML, which I want to assume I know nothing about, when the element is namespaced SimpleXmlIterator constructor throws an error, saying that the namespace is not defined. So I define the namespace, and no more error being thrown, but the iteration skips the namespaced element, like it doesn't know what to do with it. I realize that under normal parsing circumstances, I would use getNamespaces and use the namespace to access the element, but I declare that manually, like this: // Vanilla SimpleXML usage to get namespace, apply it to a var, then use the var to get the element contents $namespaces = $feed->getNamespaces(true); $yweather = $feed->channel->children( $namespaces['yweather'] ); echo $yweather->location->attributes()->city; But for the purposes of a generic XML iterator, I can't manually apply the namespaces. So, what I want to know is, in the code below, what would be the best way to get the namespaces and use them, with the intent to iterate over any namespace. As long as the XML is well formed, I'd like to convert it to an array, or use the data in some other way. function xml2array( $fname ) { $sxi = new SimpleXmlIterator( $fname ); return sxiToArray( $sxi ); } function sxiToArray( $sxi ) { $a = array(); for( $sxi->rewind(); $sxi->valid(); $sxi->next() ) { if( ! array_key_exists( $sxi->key(), $a ) ) { $a[ $sxi->key() ] = array(); } if( $sxi->hasChildren() ) { $a[ $sxi->key() ][] = sxiToArray( $sxi->current() ); } else { $a[ $sxi->key() ][] = strval( $sxi->current() ); } } return $a; } Now, I'm not looking for a solution that uses DOMDocument or other unrelated classes. I'm just curious about SPL classes/iterators, and doing some studying. What do you do when your iterator encounters an unknown namespace, and you must get the values it holds (and even do recursive iterations inside that)? I'm still trying to figure out some good use cases for these SPL iterators. That's why I'm focusing on the XML to array code above.
  17. I looked at the issues section of this apps repo on github. Somebody else reported an issue a while back, and no action was taken. So you can count on there being some bugs, and nobody wants to do anything about them. You'd be better off just writing your own app.
  18. Why not use a cloud type hosting of just a single domain? Seems like a lot less work, and then you don't need to worry about any of this.
  19. The problem we have seen with geo location is that it isn't reliable. Sometimes it says I'm in Los Angeles, and sometimes it says I'm in Virginia. Those locations are about 3000 miles apart.
  20. I prefer Allman style (#2) for position of comments, and the fact that if you've got longer lines of code you can't see your opening bracket when an indent style is used that leaves opening brackets on the same line. So, I say pick an indent style and stick with it, as long as it is Allman style!
  21. Barand turned me on to database normalization through the video on this link: http://forums.phpfreaks.com/topic/273634-best-way-to-set-up-tables-when-multiple-values/?do=findComment&comment=1408360 I think if you watch the series of videos, you'll find the real answer to your problem. What this means for you is a better database design, and getting familiar with SQL joins.
  22. You should consider Responsive Web Design. Browser detection just means more work for you because then you essentially maintain two websites.
  23. What have you got so far? I don't think you're going to find anyone that is willing to code up your entire assignment, no matter how fun this "puzzle" might be. Do some work and then let us help you with where you get stuck.
  24. Actually no, I don't know what chroot is. I'll guess. Is it for restricting a user and/or group to a certain area (directories) of the server?
  25. I only chose to show one method. There are a few others, but didn't want to post a bunch of code that was off topic.
×
×
  • 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.