PHP/MySQL Freelance
mobile: +39 3489215204
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” />
this was a problem with www.tecnomagazine.it :
http://www.tecnomagazine.it/recensioni/casio-exilim_ex-z60/442
could be accessed from /node/442
Solution is to redirect all /node/[0-9]* url to the aliased one
... and is very simple in code:
includes/path.inc :
function drupal_init_path() {
if (!empty($_GET['q'])) {
// add this conditional
if(preg_match('/node\/[0-9]*$/',$_GET['q'])) {
include "includes/common.inc";
$newq = trim(url($_GET['q']),'/');
if($newq!=$_GET['q']) {
http://www.skype.com/download/skype/linux/
released skype for linux 2.1, I followed link and downloaded 64 bit version for ubuntu .. but look at package control:
Package: skype
Status: install ok installed
Priority: extra
Section: non-free/net
Installed-Size: 25096
Maintainer: Skype Technologies
Architecture: amd64
Version: 2.1.0.47-1
Depends: lib32stdc++6 (>= 4.1.1-21), lib32asound2 (>> 1.0.14), ia32-libs (>= 1.6), libc6-i386 (>= 2.7-1), lib32gcc1 (>= 1:4.1.1-21+ia32.libs.1.19)
Umh, a tricky way to make amd64 package ...
I lost some time to debug this
$("#link").click(function(){
$("#target").load('url/to/load');
});
The problem is on Internet Explorer (all version) that refuse to load data in #target, using $.get and innerHTML(data) do not help. The problem is with no well formed html! Internet Explorer refuse to load in dom a malformed html.
Thus
$("#link").click(function(){
$("#target").load('url/to/load');
window.open('url/to/load');
});
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";
A plugin for display list of item to insert.
List item are stored in input hidden comma separed, the call is simple
Some bug to fix
options are
$("#morelink").optionlist({
target:'#optionlist',
input: '#iptvalues',
items: {'0':'prova','1':'test','2':'due','3':'tre'},
preset: [0]
});
moreitem
.optionlist_itemlist {
position:absolute;
display:none;
border:1px solid #000;
padding:2px;
background:#fff;
z-index:3001;
}
.optionlist_additem{
cursor:pointer;
color:blue;
}
.optionlist_additem:hover{
text-decoration:underline;
}
.optionlist_item{
width:100px;
float:left;
}
.optionlist_rmitm{
position:absolute;
background: #999;
opacity:0.7;
display:none;
cursor:pointer;
}
also #optionlist_overlay is the overlay at z-index:3000
I wasted some time to check if there is a script to deploy to ftp hosting from my svn, and I found nothing
...
2009-06-27
project in sourceforge: http://svnftpdeploy.sourceforge.net/
M-x grep command is very useful in a number of situation, because, for example, it give you direct access to all matched file ...
But there is not so intuitive how to use grep when opening file via ssh, this is the trick:
First generate a key pair and upload public part to the remote server:
(suppose remote host/user is B/b)
ssh-keygen -t rsa #... ssh b@B mkdir -p .ssh cat ~/.ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys' ssh-add
be sure to use ssh-agent in order to use ssh-add
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