In order to a miss configuration I had for a long time the problem with hundreds of
files which had a crap name. Tonight I had the time to solve this:
Preamble:
-rw------- 1 apache root 273K 24. Jul 15:37 UPLOAD_PATH1
-rw-r--r-- 1 apache root 275K 24. Jul 15:37 UPLOAD_PATH10
-rw-r--r-- 1 apache root 220K 19. Okt 15:14 UPLOAD_PATH11
-rw-r--r-- 1 apache root 3,1M 19. Okt 15:17 UPLOAD_PATH12
-rw-r--r-- 1 apache root 241K 19. Okt 16:13 UPLOAD_PATH13
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH2
-rw------- 1 apache root 105K 24. Jul 15:37 UPLOAD_PATH3
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH4
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH5
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH6
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH7
-rw------- 1 apache root 60K 24. Jul 15:37 UPLOAD_PATH8
-rw-r--r-- 1 apache root 273K 24. Jul 15:37 UPLOAD_PATH9
The way to rename them is pretty simple with a bash script, but the notation/ syntax
is just a little bit tricky.
While searching with google, I’d found several scripts but no simple solution.
My solution just executes a ls command, push the output in an array, and the builds a new name using sed.
After this steps, the new name is ready to use with a simple mv command.
Solution via bash:
#!/bin/bash
list=(`ls `)
for filename in "${list[@]}"
do
myvar=$(echo $filename | sed 's/UPLOAD_PATH//g')
#echo 'mv '$filename' '$myvar
mv $filename $myvar
done
Linux Bash, Linux, Ubuntu
Something beside the usually blog entries…
After the my last surf holidays in September 2009 I had a problem with my two cameras… Sony Alpha 200 and Pentax Option W60. Both got different filenamings and right now I’ve never seen a camera where you can fully design the filename format.
While I worked with windows, years ago, I used a app named ‘Joe’,.. but port a windows app to Linux.. no thanks 
The name of (one) solution is exiv2!
Installing exiv2 on debian based systems:
sudo apt-get update
apt-get install exiv2
Renaming:
Launch a terminal, go to the dir where the photos are located
cd /home/per/Documents/Portugal2009
Rename them:
exiv2 mv -r "%Y-%m-%d_%H:%M:%S_My_Name" *
Before: IMGP0078.JPG
After: 2009-09-03_16:54:42_My_Name.JPG
Linux, Photo Bash, Linux, Photographie, Ubuntu
If you building a simple web-application and you are not really sure, ow secure are the authentication and or the rest of the application you should think about to limit the access to the application.
Furthermore, may your application should be available only for testing purpose of several customers the following could help you:
First way… using a .htaccess which controls the access using a apache web server.
This is a very fast sollution BUT you CAN’T use hostnames and or full qualified dns names like skycube.net or yourname.dyndns.org
<Limit GET HEAD POST>
order deny,allow
allow from 62.75.185.219
allow from 127.0.1.1
allow from 127.0.0.1
deny from all
</Limit>
The second way… which I prefer, using a php code snippet. This allows you to use hostnames and full qualified domain names. Definitely you can write it in less than the lines I used below for the code, but in of understanding what the code does, it’s better
<?php
/**
* ACL array
*/
$valid_hosts = array();
$valid_hosts[] = 'localhost';
$valid_hosts[] = '127.0.0.1';
$valid_hosts[] = '127.0.1.1';
$valid_hosts[] = 'yourname.dyndns.org';
$valid_hosts[] = 'skycube.net';
for($i=0;$i<sizeof($valid_hosts);$i++){
$valid_ip = gethostbyname($valid_hosts[$i]);
if($valid_ip == $_SERVER['REMOTE_ADDR']){
$valid_state = 'valid';
break;
}
else{
$valid_state = 'invalid';
}
}
if($valid_state != 'valid')
header("Location: http://www.skycube.net");
?>
other, php apache, Linux, php
While working with large databases, phpMyAdmin is in serveral cases not the perfect application to handle changes and or administrate the databases but may the only one you are allowed to use.
In this order there are two default configuration the following to configuration vars will help you to work better and faster.
Show all rows without a limit:
Show full update statements:
$cfg['MaxCharactersInDisplayedSQL'] = 2147483647;
In order to the default value, updates with more than 1000 chars will be replaced with […].
Just place these in the config.inc.php e.g. /var/www/htdocs/phpmyadmin/config.inc.php
php MySQL, php
When you start up or just join a project based on webapplications, the design of interface is maybe good. Otherwise this should be changed. In order to Web 2.0 applications you will work with dynamic contents, many effects and other stuff. All these things are fine, but no one thought about to style up the JavaScript alert and confirm boxes.
Here is the they way,.. completely dynamic, JS and CSS driven…

The HTML & CSS code:
body {
background-color: white;
font-family: sans-serif;
}
#jsconfirm {
border-color: #c0c0c0;
border-width: 2px 4px 4px 2px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
top: -1000px;
z-index: 100;
}
#jsconfirm table {
background-color: #fff;
border: 2px groove #c0c0c0;
height: 150px;
width: 300px;
}
#jsconfirmtitle {
background-color: #B0B0B0;
font-weight: bold;
height: 20px;
text-align: center;
}
#jsconfirmbuttons {
height: 50px;
text-align: center;
}
#jsconfirmbuttons input {
background-color: #E9E9CF;
color: #000000;
font-weight: bold;
width: 125px;
height: 33px;
padding-left: 20px;
}
#jsconfirmleft{
background-image: url(left.png);
}
#jsconfirmright{
background-image: url(right.png);
}
-->
<a onclick="javascript:showConfirm('Please confirm','Are you really really sure to visit google?','Yes','http://www.google.com','No','#')" href="#">JsConfirmStyled</a>
The JS Code:
//Check for ie5+ and nn6
ie5=(document.getElementById&&document.all&&document.styleSheets)?1:0;
nn6=(document.getElementById&&!document.all)?1:0;
xConfirmStart=800;
yConfirmStart=100;
if(ie5||nn6) {
if(ie5) cs=2,th=30;
else cs=0,th=20;
document.write(
"
<div id="jsconfirm">"+
"
<table border="0">"+
"
<tbody>
<tr>
<td id="jsconfirmtitle"></td>
</tr>
"+
"
<tr>
<td id="jsconfirmcontent"></td>
</tr>
"+
"
<tr>
<td id="jsconfirmbuttons">"+
"
<input id="jsconfirmleft" onclick="leftJsConfirm()" type="button" />"+
" "+
"
<input id="jsconfirmright" onclick="rightJsConfirm()" type="button" />"+
"</td>
</tr>
"+
"</tbody></table>
"+
"</div>
"
);
}
document.write("");
function leftJsConfirm() {
document.getElementById('jsconfirm').style.top=-1000;
document.location.href=leftJsConfirmUri;
}
function rightJsConfirm() {
document.getElementById('jsconfirm').style.top=-1000;
document.location.href=rightJsConfirmUri;
}
function confirmAlternative() {
if(confirm("Scipt requieres a better browser!")) document.location.href="http://www.mozilla.org";
}
leftJsConfirmUri = '';
rightJsConfirmUri = '';
/**
* Show the message/confirm box
*/
function showConfirm(confirmtitle,confirmcontent,confirmlefttext,confirmlefturi,confirmrighttext,confirmrighturi) {
document.getElementById("jsconfirmtitle").innerHTML=confirmtitle;
document.getElementById("jsconfirmcontent").innerHTML=confirmcontent;
document.getElementById("jsconfirmleft").value=confirmlefttext;
document.getElementById("jsconfirmright").value=confirmrighttext;
leftJsConfirmUri=confirmlefturi;
rightJsConfirmUri=confirmrighturi;
xConfirm=xConfirmStart, yConfirm=yConfirmStart;
if(ie5) {
document.getElementById("jsconfirm").style.left='25%';
document.getElementById("jsconfirm").style.top='35%';
}
else if(nn6) {
document.getElementById("jsconfirm").style.top='25%';
document.getElementById("jsconfirm").style.left='35%';
}
else confirmAlternative();
}
You can dowload all scripts:
jsconfirmstyle.zip (33.5 KiB, 4,999 hits)
Projects ajax, css, html, js
Today I tried to install the (new) version of Google Earth 5.0 (beta), cause some one told me about new Streetview pics in town..
After I installed the app, I just tried to run,.. Saw the splash and then everything closes..
What happened..
I started the program in a shell and there is the problem:
Installing desktop icon...
Warning: Unable to create prefs directory '/home/pbaasch/.googleearth'. File exists.
./googleearth-bin: relocation error: /usr/lib/i686/cmov/libssl.so.0.9.8: symbol BIO_test_flags, version OPENSSL_0.9.8 not defined in file libcrypto.so.0.9.8 with link time reference
The sollution is very simple, just a workaround, but it works:
Find the file libcrypto.so.0.9.8 and just rename or delete it...
Linux Google, Linux, Ubuntu
While you working with web applications it could happen that you get several errors.. Never underestimate real server problems. When you try to start a new Web 2.0 application or just the usage and/or visits of your application increase, maybe non-linear, you can login to your application but you can’t proceed.
On enterprise applications it’s recommended to set php display errors to off, so won’t see what really happened.
While tracking the problem to your browser and the customers and may the service provider, you should just login with a shell.
First thing you should do is, like all time, who and last. After that, may you try to find out what happen in the apache access and error log. You will find nothing, cause there is nothing critical, nothing new. May you see the session file in your filesystem, but why is it empty? A php bug?
Why? Ok just the answer, try this: df -h , you will see the a 100% full partition
and when you try a du -shm /var/log/* you see your problem… GB’s of apache logs…
What happened? Your Web 2.0 application uses polling, and your apache got a custom, combined log which writes to access.log.
- Solution 1: Drop the line in your apache virtualhost configuration for custom, combined log
- Solution 2: Proceed a massive logrotation
- Solution 3: Pipe the combined log to a perl or php-cli script which filters the polling events (I prefer)
On local, staging and or development installations you should switch the display errors for php to on,… then you get messages like this:
WARNING: session_write_close() [function.session-write-close]...
Linux ajax, apache, Linux, php
Did you ever thought about to show an image on a website using a table?
The following script analyze the image and does a print out using a standard html table.
The CSS code:
1
2
3
4
| <style type="text/css" media="screen">
.tableImage { padding: 0; margin: 0; border: 0; }
.tableImage TD { width: 1px; height: 1px; padding: 0; margin: 0; }
</style> |
The php code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <?php
$image='sample.jpg';
$im = imagecreatefromjpeg($image);
$info=getimagesize($image);
$width=$info[0];
$height=$info[1];
for ($i=0; $i<$height; $i++){
$html .= "<tr>";
for ($j=0; $j<$width; $j++){
$color_index = imagecolorat($im, $j, $i);
$color_tran = imagecolorsforindex($im, $color_index);
$html .= "<td style=\"background-color: rgb($color_tran[red],$color_tran[green],$color_tran[blue]);\"></td>\n";
}
$html .= "</tr>\n";
}
?> |
Begin of the output table:
1
| <table class="tableImage" cellpadding="0" cellspacing="0"> |
Include the generated image:
End of output table:
Please note, that this could crash your web-server or browser, if you use to large images…
Projects css, html, php
Dear all,
there is a new version of this site 
Stay tuned, while I add all old content…
Site
Dear community,
the ZMG-Project is finally closed!
After long discussions, many ideas and hundreds of emails, we decided there is no way back… We can’t spend the time any longer and we have no youthful enthusiasm anymore to reanimate and produce a new stable version of ZMG for Joomla! 1.5.
May the force be with us 
Per Lasse Baasch for the ZMG-Team
Joomla!, Projects ajax, css, html, Jommla!, js, php