dan's homepage http://pomocnik.com/users/dan VoIP, Linux, PHP Mon, 08 Jan 2007 13:48:12 +0000 http://wordpress.org/?v=2.2.1 en PHP performance checking (for example: because of Dreamhost CPU usage warning) http://pomocnik.com/users/dan/2006/01/php-performance-checking-for-example-because-of-dreamhost-cpu-usage-warning/ http://pomocnik.com/users/dan/2006/01/php-performance-checking-for-example-because-of-dreamhost-cpu-usage-warning/#comments Thu, 26 Jan 2006 17:42:21 +0000 dan http://pomocnik.com/users/dan/2006/01/php-performance-checking-for-example-because-of-dreamhost-cpu-usage-warning/ If you want to optimize your PHP script or find out what part of your PHP script causes problems (for example consumes too much CPU time on Dreamhost) - below you can find solution how to do it - how to check - chow long selected parts of your PHP script work.

For our convenience we need to prepare two usefull funcions, first to start timer, second to stop it and log some information into the log file.

//this funcion starts timer
function startLog(){
global $startTime;
$startTime = microtime();
}

//this funcion stops timer and logs some information to log
function stopLog($info){
global $startTime;
$startT = explode(’ ‘, $startTime);
$endT = explode(’ ‘, microtime());
$workTime = ($endT[1]+$endT[0]) - ($startT[1]+$startT[0]);
$f = fopen(’performance.log’, ‘a’, 1);
// time work_time info REQUEST_URI REMOTE_ADDR HTTP_USER_AGENT
fwrite($f, date(’m-d-Y H:m:s’) . “\t”.$workTime . “\t[” . $info . “]\t” . $_SERVER[’REQUEST_URI’] . “\t” . $_SERVER[’REMOTE_ADDR’] . “\t” . $_SERVER[’HTTP_USER_AGENT’] . “\n”);
fclose($f);
}

NOTICE: you must ensure that your www serwer (for example Apache) can write to specified location - where your performance.log file should be placed.

now you should (more…)

]]>
http://pomocnik.com/users/dan/2006/01/php-performance-checking-for-example-because-of-dreamhost-cpu-usage-warning/feed/
Adsense Notifier http://pomocnik.com/users/dan/2006/01/adsense-notifier/ http://pomocnik.com/users/dan/2006/01/adsense-notifier/#comments Wed, 18 Jan 2006 18:41:12 +0000 dan http://pomocnik.com/users/dan/2006/01/mincus-code-%c2%bb-adsense-notifier/ If you need to check your adsense stats “every three seconds” you should install Adsense Notifier extension for Firefox!

“Adsense Notifier simply shows your adsense stats on the status bar and updates the stats automatically. This is wonderful for anyone with OCD ( or GAD as some have called it ) who needs to check their stats every three seconds to see if they have gotten any more clicks :-p”

read more and download it at: mincus code ยป Adsense Notifier

]]>
http://pomocnik.com/users/dan/2006/01/adsense-notifier/feed/
checking for C compiler default output file name… configure: error: C compiler cannot create executables http://pomocnik.com/users/dan/2005/10/checking-for-c-compiler-default-output-file-name-configure-error-c-compiler-cannot-create-executables/ http://pomocnik.com/users/dan/2005/10/checking-for-c-compiler-default-output-file-name-configure-error-c-compiler-cannot-create-executables/#comments Mon, 24 Oct 2005 19:11:18 +0000 dan http://pomocnik.com/users/dan/2005/10/checking-for-c-compiler-default-output-file-name-configure-error-c-compiler-cannot-create-executables/ So, … you have gcc and try to compile some stuff - but ./configure answers:

checking for C compiler default output file name… configure: error: C compiler cannot create executables.

Solution:

Just install glibc-devel

that’s all.

]]>
http://pomocnik.com/users/dan/2005/10/checking-for-c-compiler-default-output-file-name-configure-error-c-compiler-cannot-create-executables/feed/
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration http://pomocnik.com/users/dan/2005/10/warning-fopen-functionfopen-url-file-access-is-disabled-in-the-server-configuration/ http://pomocnik.com/users/dan/2005/10/warning-fopen-functionfopen-url-file-access-is-disabled-in-the-server-configuration/#comments Sun, 09 Oct 2005 15:57:12 +0000 dan http://pomocnik.com/users/dan/2005/10/warning-fopen-functionfopen-url-file-access-is-disabled-in-the-server-configuration/ What to do if you’ve got this:

Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration

Warning: fopen(http://somelocation.com/somefile.xml) [function.fopen]: failed to open stream: no suitable wrapper could be found in /home/someuser/somephpfile.php on line [someline :-)]

???

It happens if - for security reasons fopen is restricted to open remote files. If it is on a hosting server and you cannot change configuration you may try curl. Example below:

instead of:

$file = "http://somelocation.com/somefile.xml";
$fp = fopen($file, "r");

try the solution with curl*:


$file = "http://somelocation.com/somefile.xml";
$ch = curl_init($file);
$fp = @fopen("temp.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$file = "temp.xml";
$fp = fopen($file, "r");

That’s all :-)

* - ensure that you have write access - so curl can write to temp.xml

]]>
http://pomocnik.com/users/dan/2005/10/warning-fopen-functionfopen-url-file-access-is-disabled-in-the-server-configuration/feed/
How to convert dos file to unix/linux format. http://pomocnik.com/users/dan/2005/08/how-to-convert-dos-file-to-unixlinux-format/ http://pomocnik.com/users/dan/2005/08/how-to-convert-dos-file-to-unixlinux-format/#comments Wed, 24 Aug 2005 19:16:44 +0000 dan http://pomocnik.com/users/dan/2005/08/hot-to-convert-dos-file-to-unixlinux-format/ How to get rid off all bad Windows line endings?

it’s simple, for example to convert all *.php files in directory write:

for x in *.php; do dos2unix $x; done

]]>
http://pomocnik.com/users/dan/2005/08/how-to-convert-dos-file-to-unixlinux-format/feed/
Apache Server Tutorial Part I: Preparing to Install WAMP on Windows NT 2000 Pro http://pomocnik.com/users/dan/2005/08/apache-server-tutorial-part-i-preparing-to-install-wamp-on-windows-nt-2000-pro/ http://pomocnik.com/users/dan/2005/08/apache-server-tutorial-part-i-preparing-to-install-wamp-on-windows-nt-2000-pro/#comments Tue, 16 Aug 2005 18:44:55 +0000 dan http://pomocnik.com/users/dan/2005/08/apache-server-tutorial-part-i-preparing-to-install-wamp-on-windows-nt-2000-pro/ Definition is an acronym for the combination Microsoft Windows, , and one or more of , and . It is modelled after the more well-known LAMP, referring to the all-open source/free software approach which uses Linux instead of Windows.

(more…)

]]>
http://pomocnik.com/users/dan/2005/08/apache-server-tutorial-part-i-preparing-to-install-wamp-on-windows-nt-2000-pro/feed/
How to password protect web directory (folder) http://pomocnik.com/users/dan/2005/07/how-to-password-protect-web-directory-folder/ http://pomocnik.com/users/dan/2005/07/how-to-password-protect-web-directory-folder/#comments Tue, 26 Jul 2005 21:16:09 +0000 dan http://pomocnik.com/users/dan/2005/07/how-to-password-protect-web-directory-folder/ 1. Create .htaccess file with the content below:

AuthUserFile /home/username/htdocs/.htpasswd
AuthName “Password Protected”
AuthType Basic
require valid-user

Of course in the AuthUserFile type in the location of the .htpasswd file (i.e. when you want to store that file, you’ll create it in next step)

2. Set password for the user(users) (-c option creates .htpasswd file)

If it is your first user’s password - use -c option

htpasswd -c .htpasswd username

type and confirm password

that’s all

(for other users you should ommit -c, because you not need to create .htpasswd file, simply write

htpasswd .htpasswd anotherusername

type and confirm password)

]]>
http://pomocnik.com/users/dan/2005/07/how-to-password-protect-web-directory-folder/feed/
Firefox & Thunderbird working together! http://pomocnik.com/users/dan/2005/07/firefox-thunderbird-working-together/ http://pomocnik.com/users/dan/2005/07/firefox-thunderbird-working-together/#comments Fri, 22 Jul 2005 20:49:06 +0000 dan http://pomocnik.com/users/dan/2005/07/firefox-thunderbird-working-together/ [description taken from ubuntuforums.org but might be usefull for all Linux distros :-)]

Some people have problems using mailto links with Thunderbird. To fix the “choose user profile” problem, follow this howto.

THUNDERBIRD: Open with firefox an URL contained in an email

  1. Open Nautilus and type this in the address bar: ~/.thunderbird (if that doesn’t work, try ~/.mozilla-thunderbird)
  2. Go your profile directory (with a random-generated name, like this Xbcgev.default). To be sure you’re in the correct directory check if a file named prefs.js exists.
  3. File > Create Document > Empty Document highlight it and press F2 to rename the document user.js (If it already exists skip this passage).
  4. Open user.js and write this line (if the file already exists append the line at the end): user_pref(”network.protocol-handler.app.http”, “/usr/bin/firefox”); /usr/bin/firefox is obviously the path to execute firefox
  5. That’s all

FIREFOX: open thunderbird when clicking on a “mailto:” link

  1. Open Nautilus and type this in the address bar: ~/.mozilla/firefox (if that doesn’t work, try ~/.mozilla-thunderbird)
  2. Go your profile directory (with a random-generated name, like this Xbcgev.default). To be sure you’re in the correct directory check if a file named prefs.js exists.
  3. File > Create Document > Empty Document highlight it and press F2 to rename the document user.js (If it already exists skip this passage).
  4. Open user.js and write this line (if the file already exists append the line at the end): user_pref(”network.protocol-handler.app.mailto”,”/usr/bin/mozilla-thunderbird”); /usr/bin/mozilla-thunderbird is the path to execute thunderbird
  5. That’s all
]]>
http://pomocnik.com/users/dan/2005/07/firefox-thunderbird-working-together/feed/
Great firefox extension - customizegoogle http://pomocnik.com/users/dan/2005/06/great-firefox-extension-customizegoogle/ http://pomocnik.com/users/dan/2005/06/great-firefox-extension-customizegoogle/#comments Thu, 09 Jun 2005 18:50:21 +0000 dan http://pomocnik.com/users/dan/2005/06/great-firefox-extension-customizegoogle/ Just look at: http://www.customizegoogle.com/ its great Mozilla Firefox extension for google!

]]>
http://pomocnik.com/users/dan/2005/06/great-firefox-extension-customizegoogle/feed/
Invisible dragon :-) http://pomocnik.com/users/dan/2005/05/invisible-dragon/ http://pomocnik.com/users/dan/2005/05/invisible-dragon/#comments Fri, 27 May 2005 15:40:23 +0000 dan http://pomocnik.com/users/dan/2005/05/invisible-dragon/ If you wanna see the Invisible Dragon walking through a blizzard! You can find him here :-)

]]>
http://pomocnik.com/users/dan/2005/05/invisible-dragon/feed/