Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Yeah, on 64 bit machines the integer type is going to be larger than 32 bits, so your not is flipping bits above 32. Try: echo PHP_INT_MAX; On both architectures, and I think you'll see the problem. I think this will work for 32 and 64bit, but check. echo (abs(ip2long('255.255.255.0') ^ 4294967295)) + 1;
  2. Yes, you shouldn't worry about the fact that you can't remove a session cookie. The other steps you are taking to terminate authentication and eliminate the session data that would allow it, are the important thing.
  3. Perhaps you should start here (including the comments): http://devlup.com/mobile/cross-platform-mobile-development-tools/2416/ Many mobile apps require serverside components and php is great for that, but actually writing the code for the apps in php? Not really an option. However as you can see, HTML5, css and javascript, which are typically also employed into the mix by php developers for web apps, are the basis for many of the cross platform tools out there.
  4. Maybe things have degenerated, but it didn't use to be that way. The recent evolution of joomla has probably contributed highly to the confusion. I worked on a gallery module back in the 1.x days, and did a 1.5x site recently with K2 and even since then, Joomla is like a new product in many ways. It is not a piece of crap at all, and many of the things that I thought were ludicrous when I was working on the gallery module, have been addressed. However, what I have always found is that the documentation and tutorials only get you so far. To truly be successful you have to roll up your sleeves and get into the code, both for important modules you may be using, for templates, and the core in order to figure out how they work. It doesn't hurt to be able to reverse engineer the database as well, which I've done both for core and some modules. I guess it very much comes down to what exactly your issues are. It sounds like your expectations might not be realistic, in terms of the type and timeliness of the type of support you want.
  5. Also, read the last few posts of this thread, specifically my post and PFMaBiSmAd's at the end. http://www.phpfreaks.com/forums/index.php?topic=223785.15 There is no defined way to tell a browser to delete a cookie. I hope it is clear why this is not important.
  6. The concept of authentication is one you provide. When a user hits your site, and the top of your page has a session_start() call, then php sessions are in play. All the cookie provides is a key to that session. When someone hits your site and they have not logged in, they will still have a session id assigned (or at least attempted to be assigned via the issuance of a session cookie). It does not matter that you logged out and you have a session id that is persisting. What matters is that the information you stored in the session no longer allows for that session id to authenticate the person. You are not in control of what happens with cookies. All you can control is what is happening on the serverside. When you logout, the important thing is that whatever you are storing in the session that indicates that session is authenticated, has been changed so that your site responds accordingly by denying access and requiring fresh authentication. Even the serverside session data itself (by default the files that TLG referred to) will hang around for a period of time depending on the way php has been configured.
  7. To add to what kicken stated, a cookie is the responsibility of the browser. PHP simply issues a request to the browser for it to save a cookie. Whether it does or not is up to the browser. So called "session cookies" are not saved by the browser as seperate files because they will not persist beyond the lifetime of the browser. This should help you figure out where your cookie files might be for firefox: http://kb.mozillazine.org/Profile_folder_-_Firefox You might also try the web developer plugin that ostensibly has some cookie management features. Not to be confused with a session cookie is the php "session id" cookie that links requests to php sessions. That typically has the name PHPSESSID unless you change it. Most everything about the way php sessions work can be tweaked or reconfigured in some way including the name of the session id variable.
  8. First off, there is nothing weak about a switch statement. The rule of thumb is that if you have a single variable that can have a variety of values, and you need to branch on those values, a switch is always going to be clearer both to you, and to anyone reading your code in the future. It is always going to be clearer than a big nested if elseif elseif elseif etc.. At the end of the day, the code generated is going to be exactly the same for either construct. PHP is a loosely typed language. This means that while there are variable types you do not need to declare them, and php will typecast between types without you having to explicity cast a value from one type to another. In most cases this is a huge convenience and advantage of the language. PHP figures out what you want to do, and does the right thing using the operator involved. So I can have 2 string values, that both happen to be integers, and multiply them together and use the result. So in the case of comparison operators like the equality operator ("==") there is an option to check both equality AND that the types of the variables match. As scootsah had in his example this most often is a concern with boolean values. Here's a typical example (not that I would recommend this) but frequently people write database functions or methods that return values. Let's say you have a function that takes a name, and then returns the number of people in the database who have that lastname. This might be accomplished using a SELECT count(*) FROM... or mysql_num_rows(). In either case a perfectly valid return value would be '0'. This means that the query ran, but there were no rows matched for that lastname. Now lets say that same function has error checking in case the query fails: $count = getPersonCount($lastname); if ($count == false) { // Display database error message/log error. echo "Database error: the Administrator has been alerted."; } else { echo "We found $count people with $lastname"; } The problem with this code is that it is going to display the database error message, even when the query runs ok, but there are no people matched. This is because the "0" integer return gets typecast to a boolean, which is equivalent to false. Let's assume that in the getPersonCount() function, when an actual database error occurs, the function explicitly will return false, otherwise it will return the count. We can fix the comparison and have it work correctly by using: $count = getPersonCount($lastname); if ($count === false) { // Display database error message/log error. echo "Database error: the Administrator has been alerted."; } else { echo "We found $count people with $lastname"; } And now when the query returns 0 as the result, it will actually display "We found 0 people...." where it would never display that using the == comparison.
  9. This is a question for your webhost. Do you have ssh access to your site? If so you can run the commands as listed, with only slight alterations to the path (assuming it's linux). Just use the command line mysql client.
  10. Yes, because you are first assigning the innerhtml one value, then assigning it a 2nd value. That is going to overwrite the initial value. function greet() { var a = document.getElementById('area'); a.innerHTML = "How are you?"; var b = document.getElementById('area'); b.innerHTML = a.innerHTML + " Am fine"; }
  11. It's very easy to use, however if you don't know the basics of javascript it may be a bit confusing. Hopefully you do. The design goal of jquery is cross browser compatibility, so problems like the one you describe are the exact reason jquery was developed. It has an excellent manual, however. See: http://api.jquery.com/jQuery.get/ http://api.jquery.com/jQuery.post/ Which are both shorthand wrappers for variation on: http://api.jquery.com/jQuery.ajax/
  12. Yes, it works fine. The specific code you're using may not work in those browsers, but the functions provided by libraries like jquery work across browsers.
  13. Most developers would simplify this to: $photo_num = countPhotos(); if (!$photo_num) { // false } You can also simplify it even further: if (!$photo_num = countPhotos()) { // false } You might want to read the php manual on boolean conversion: http://us.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
  14. Ok, I see the issue, I missed the mysqli call. Yes, so the problem is that you have to explicity call the parent class constructor in your subclass: class UpperNavigation extends Connection { public function __construct() { parent::__construct(); } This issue is described clearly in the php manual here: http://us.php.net/manual/en/language.oop5.decon.php
  15. The answer is: yes it will continue to work. I think you can figure this out by looking at the functions being used: http://msdn.microsoft.com/en-us/library/ms186819.aspx http://msdn.microsoft.com/en-us/library/ms188383.aspx http://msdn.microsoft.com/en-us/library/ms189794.aspx You can run these functions interactively and answer your own questions as to whether or not you would agree. For example, when you take a piece of the first function that generates the start date for the between.... SELECT GETDATE(); SELECT DATEDIFF(yy,0,getdate()); SELECT DATEADD(yy, DATEDIFF(yy,0,getdate()), 0); It should be pretty apparent that this is going to generate the first day of the current calendar year. Since this is driven by GETDATE(), and a specific year is not hardwired, it should be easy to see that will continue to work. The 2nd part of the between does not look to me like its purpose is to generate the "Current date". It is attempting to work with "weeks" and there appears to be some code missing, so it's a bit hard to tell exactly. Again the best way to work this out is to go into a command line client and try out the individual pieces so you understand what they are returning.
  16. Number one google result: http://www.maxkpage.com/blog/free-sqlite-to-mysql-converter-super-easy/
  17. Ivan, Your specific issue based on the code you provided, is that the connection class does not have a query method. So of course you're getting an error. This is a very good example of where dependency injection is (in my opinion) a superior solution. Rather than try and explain it I'll just point you to this http://components.symfony-project.org/dependency-injection/documentation. They do a fantastic job talking about why DI is a great approach, and also provide a DI Container class that is at the heart of the symfony 2 framework. You don't have to use it, but it's there in case you like what you see. The problem with your connection class as I see it, is that it is actually attempting to be a connection class, and a model class. In other words, you have a mixture of database connection activity and setup, with specific data and tables. I would recommend that you break those out into discrete classes. Have a model class for any specific table. You can pass an instance of your database connection object to the model class in the constructor. Likewise your UpperNavigation class should not be trying to inherit from connection, as it has nothing to do with connections. It is not a subtype of connection -- it s purpose is to facilitate the output of your menu from the looks of it. That class should not have the internals of a specific database query -- simply pass in either a specific model, or array of model objects that make sense. From the look of what you have there is only one table being used: db_table_names['sport']. Let's say that instead you had a SportModel.class.php class definition. So someone might expect to find code like this: $connection = new Connection($dbconfig); $sportModel = new SportModel($connection); $upperNav = new UpperNavigation($sportModel); Obviously this is just a sketch, but I wanted to give you an idea of how you might simplify and decouple your classes.
  18. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=350189.0
  19. Yes, it matters, because what works from the command line doesn't necessarily work from the browser, as depending on how things have been setup, the environment of the two -- CLI (php.exe) and php as an apache module are different. As an apache module php runs as the apache configured user, often with an environement that has a minimal or empty path environment variable associated with it.
  20. gizmola

    round corners

    Wow, really neat find, thanks nano.
  21. No I'm saying that this call: exec('java -jar d:\java\Test.jar'); Probably needs to be exec('/path/to/java -jar d:\java\Test.jar'); You can use firebug to see if the jquery.get() is working or not.
  22. Try in your exec call, passing the full path to the java program.
  23. Require pulls php code or html into the php script. It does not read it as a string into a variable. Use file_get_contents $body = file_get_contents('path/to/file/filename'); $message = " email body section A $body email body section B ";
  24. You can install xdebug with pecl as I described in this article: http://www.flingbits.com/tutorial/view/xdebug-for-developing-debugging-and-profiling-php I don't think there's anything wrong with creating your own profiling solution. No one solution works for all people in all circumstances.
×
×
  • 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.