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.
I supposed no one would be so silly to click on delete for 20 times
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:
if(filter_has_var(INPUT_POST,'login')) {
//manage login
}
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():
$result = $mysql->query("SELECT id FROM $table ORDER BY RAND()");
for($i=1;$row=$result->fetch_row();$i++) {
$mysql->query("UPDATE $table SET rand_sort=$i WHERE id=".$row[0]);
}
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
<img src=”button.png” id=”btn_change” />
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";
2 simple class for sitemap:
http://www.smartango.com/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