PHP Guru is here to solve your problem!

Post your problem they will try to solve your problem as soon as possible!

Thanks
Moderator


PHP 5.2.6 Released

[01-May-2008]

The PHP development team would like to announce the immediateavailability of PHP 5.2.6. This release focuses on improving the stability ofthe PHP 5.2.x branch with over 120 bug fixes, several of which are security related.All users of PHP are encouraged to upgrade to this release.

Further details about the PHP 5.2.6 release can be found in the release announcement for 5.2.6, the full list of changes is available in the ChangeLog for PHP 5.

Security Enhancements and Fixes in PHP 5.2.6:

* Fixed possible stack buffer overflow in the FastCGI SAPI identified by Andrei Nigmatulin.

* Fixed integer overflow in printf() identified by Maksymilian Aciemowicz.

* Fixed security issue detailed in CVE-2008-0599 identified by Ryan Permeh.

* Fixed a safe_mode bypass in cURL identified by Maksymilian Arciemowicz.

* Properly address incomplete multibyte chars inside escapeshellcmd() identified by Stefan Esser.

* Upgraded bundled PCRE to version 7.6

Update (May 6th): The Windows installers were missing the XSL and IMAP extensions.

Update (May 3rd): The Windows archives were missing the XSL and IMAP extensions.
TestFest 2008

[30-Mar-2008]

The PHP-QA team would like to announce the TestFest for the month of May 2008. The TestFest is an event that aims at improving the code coverage of the test suite for the PHP language itself. As part of this event, local User Groups (UG) are invited to join the TestFest. These UGs can meet physically or come together virtually. The point however is that people network to learn together. Aside from being an opportunity for all of you to make friends with like minded people in your (virtual) community, it also will hopefully reduce the work load for the PHP.net mentors.

All it takes is someone to organize a UG to spearhead the event and to get others involved in writing phpt tests. The submissions will then be reviewed by members of php.net before getting included in the official test suite. Please visit the TestFest homepage to get additional details on the TestFest on how to get involved, either as a UG or by setting up the necessary infrastructure.

Google Summer of Code 2008
[19-Mar-2008]

Once again we are glad to announce that we have been accepted to be a Google Summer of Code project. See our program for this year’s GSoC.

We would like to take this opportunity to say thanks to Google Inc. for this privilege to participate once again, and would like to invite everyone to look at our list of ideas: http://wiki.php.net/gsoc/2008. Students are of course more than welcome to come up with their own ideas for their proposals and we will consider each and every application that we will receive.

So once again, thanks to everyone who is involved in this magnificent journey and we hope to see many of you great students and open source passionate join us in our most enjoyable Google Summer of Code projects.

PHP 4.4.8 Released

[03-Jan-2008]

The PHP development team would like to announce the immediate availability of PHP 4.4.8. It continues to improve the security and the stability of the 4.4 branch and all users are strongly encouraged to upgrade to it as soon as possible. This release wraps up all the outstanding patches for the PHP 4.4 series, and is therefore the last normal PHP 4.4 release. If necessary, releases to address security issues could be made until 2008-08-08.

Security Enhancements and Fixes in PHP 4.4.8:

* Improved fix for MOPB-02-2007.

* Fixed an integer overflow inside chunk_split(). Identified by Gerhard Wagner.

* Fixed integer overlow in str[c]spn().

* Fixed regression in glob when open_basedir is on introduced by #41655 fix.

* Fixed money_format() not to accept multiple %i or %n tokens.

* Added “max_input_nesting_level” php.ini option to limit nesting level of input variables. Fix for MOPB-03-2007.

* Fixed INFILE LOCAL option handling with MySQL – now not allowed when open_basedir or safe_mode is active.

* Fixed session.save_path and error_log values to be checked against open_basedir and safe_mode (CVE-2007-3378).

3 Responses to “PHP”

  1. prafulkr Says:

    Using globals in PHP

    Abstract

    In this article you will be shown how to properly use globals in PHP. We will take a look at the global keyword, function arguments, Singletons and the Registry pattern.
    Introduction

    Whenever you’re developing a new large-scale PHP script, you’re bound to use global variables, since some data needs to be used by multiple parts of your script. Good examples of global data are script settings, database connections, user credentials and more. There are many ways of making this data global, but the most commonly used way is to use the global keyword, which we will explore later on in this article.

    The only problem with the global keyword, and any global data for that matter, is that’s it’s actually a very bad way of programming, and usually tends to lead to bigger problems later on. The reason for this is that global data ties all the separate parts of your script together, and often if you make a change in one part, something else will break in another part. If you have more than a few global variables, you’re whole script will eventually become a big kludge of unmaintainable code.

    That’s why this article will show you how to prevent this by using various techniques and design patterns. But first, let’s have a look at the global keyword and how it works.
    Using globals and the global keyword

    By default PHP defines a few variables called Superglobals which are automatically global, and can be accessed anywhere, like the $_GET or $_REQUEST variables. These are mainly used to retrieve form data or other outside data, and there’s no real harm in using these variables, since they should never be written to anyway.

    But you can also use your own global variables, with the global keyword which is used to import variables from the global scope into the local scope of a function. If you don’t know what I mean by “scope”, have a look at the PHP Variable Scope documentation.

    The following example demonstrates use of the global keyword:

    As you can see in the above example, the global keyword is used to important variables from the global scope. Seems to work fine, and it’s nice and simple, so why should you worry about using the global keyword?

    There are three good reasons:

    1. Reusing parts of the script is impossible
    If a certain function relies on global variables, it becomes almost impossible to use that function in a different context. Another problem is that you can’t take that function, and use it in another script.

    2. Solving bugs is much harder
    Tracking a global variable is much harder than a non-global variable. A global variable could be declared in some obscure include file, which could take hours to find, although a good text editor / IDE could help with this.

    3. Understanding the code in a year will be much more difficult
    Globals make it difficult to see where a variable is coming from and what it does. You might know about every global during development, but after a year or so you’ll probably have forgotten at least half of them, and then you’ll be kicking yourself for using so many globals.

    So if we shouldn’t use globals, what can we use? Let’s have a look at some solutions.

  2. prafulkr Says:

    Using globals in PHP

    Using function arguments

    One way to stop using the global keyword is to simply pass the values as a function argument, like this:

    If you only need to pass one global variable, this is an excellent solution, and should be the standard thing. But what if you have to pass multiple values?

    For example, let’s imagine we are using a database object, a settings object and a user object. These three objects are used by all the components in our script, and therefore must be passed to each component. If we were to use function arguments, we’d have to do something like this:

    Obviously this isn’t really working, and as soon as we have another object we will have to add another function argument. We’re going to have to do it in a different way.
    Using Singletons

    One way to solve the problem with function arguments is to use Singletons instead of function arguments. Singletons are a special kind of object which can only be instantiated once, and include a static function to return the object instance. The below example demonstrates a simple Singleton:
    user = ‘sa’;

    // Set second variable (which points to the same instance)
    $second =& DBConnection::getInstance();

    // Should print ‘sa’
    echo $second->user;

    Class DBConnection {
    var $user;

    function &getInstance() {
    static $me;

    if (is_object($me) == true) {
    return $me;
    }

    $me = new DBConnection;
    return $me;
    }

    function connect() {
    // TODO
    }

    function query() {
    // TODO
    }

    }

    ?>

    The most important part of the example above is the getInstance() function. This function makes sure that there is only one instance of the DBConnection class, by using a static variable called $me, and returns the instance of the class.

    The advantage of using a Singleton is that we don’t have to explicitly pass the object, but instead can simple use the getInstance() function to get the object, like this:

    But there are several disadvantages to using Singletons like this. For one, what if we need multiple objects of a particular class? Since we are using singletons that isn’t possible (hence the name singletons). Another problem is that singletons aren’t testable with unit tests. It’s completely impossible, unless you introduce all kinds of hacks, which is something you obviously don’t want. That’s why singletons aren’t really the magical solution we’re looking for either.

  3. prafulkr Says:

    Create links to all pages in an array without the use of SQL. Puts in prev/next images and a “here”-image by comparing the pagenumber with the array. The files have to be named file_1.php, file_2.php, file_3.php, etc.

    [PHP]
    <?php
    //This script is created by RF
    //www.reptilian-feline.net
    //If you use it, please link to my site
    $full_path = getenv(“REQUEST_URI”);
    //put the base URL in case you need it
    $base = “http://subomain.domain.ext”;
    //Get the name of the file
    $page_file = basename($full_path);
    //The files are named file_1.php, file_2.php, etc. Extract number from it.
    $page_num = substr($page_file
    , strrpos($page_file, “_”) + 1
    , strpos($page_file, “.php”) – strrpos($page_file, “_”) – 1
    );
    $partial_path = substr($page_file, 0, strrpos($page_file, “_”));
    //Build array of pagenumbers. Here are ten pages.
    $all_pages = array (1,2,3,4,5,6,7,8,9,10);

    foreach ($all_pages as $all_page)
    {
    //Create link to all the previus pages and put in prev-image.
    if ($all_page < $page_num)
    {
    print ““;
    }
    //Create I-am-here-image.
    elseif ($all_page == $page_num)
    {
    print “”;
    }
    //Create links to all the next pages and put in next-image.
    else
    {
    print ““;
    }
    }

    ?>

Leave a comment