Daniele Cruciani
Programmatore Developer PHP/MySQL Freelance
mobile: +39 3489215204

icq skype msn linkedin fb t ff youtube picasa google
seconds to the end of World
End of World 21 December, 2012 11:11:00
Hire me before that day! | don't bother

Tu sei qui

php

    Why not to use remove link

    This is my experience: I have to rewrite administration page where
    there is remove button (in a form) with only javascript confirm.

    I thought: "no one had problem with no limitation in the past, why they
    should now? I'll use a link with javascript confirm.

    It happened I have a dashboard page where is listed the last entries
    and links for update and delete its. It happened that few day later 20
    entries was deleted and I was looking for what caused the problem for
    one day.

    Undefined

    php goodies: filter

    Filter is in php by default from 5.2.0 and is a usefull library for web developer, so it is the time to make use of it.

    It was created for validation and sanitization of foreign input, that is GET, POST, COOKIE, or anything that you can't trust on.


    With php filter one can tests if a variable is present in the current request:

    Undefined

    shuffle db table order

    simple code to shuffle a table ... with php shuffle:

    $result = $mysql->query("SELECT id FROM $table ORDER BY id");
    $rows = $result->num_rows;
    $order = shuffle(range(1,$rows));
    while($row=$result->fetch_row()) {
      $num=array_shift($order);
      $mysql->query("UPDATE $table SET rand_sort=$num WHERE id=".$row[0]);
    }
    

    added:
    with MySQL RAND():

    Undefined

    Ajax frontend for my backoffice in jQuery and PHP

    This is my way to organize php for a simple jQuery frontend ajax based:

    1.in a administration page include the php that generate html for each box
    2.for each box setup behavior in Javascript
    3.let each php manage POST request (for change/update) and GET request for show content


    So in admin.php we could have something like that

    Undefined

    Email from your host you are banned (mail php security matter)

    I found this in a server:

    $header = "From: <".$_REQUEST['email'].">\n";
    #... 
    mail($from,$subjet,$message,$header);
    

    $_REQUEST['email'] came from a form input ...

    Here $_REQUEST['email'] should be, at least, stripped by all \n no matter on how you trust to js code..

    $from = $_REQUEST['email'];
    $from = str_replace("\n","",$from);
    $header = "From: <$from>\n";
    
    Undefined

    SiteMap php class

    2 simple class for sitemap:

    http://www.smartango.com/sites/default/files/sitemap.txt

    simple use:

    $root = $_SERVER['DOCUMENT_ROOT'];
    $sm = new SiteMap($root,'sitemap-1.xml');
    $sm->start();
    $http = "http://www.example.com";
    $sm->addUrl($http."/file.html");
    $sm->end();
    

    ...SiteMapIdx similar

    Undefined
    Iscriviti a RSS - php