dan's homepage VoIP, Linux, PHP 2007-01-08T13:48:12Z WordPress http://pomocnik.com/users/dan/feed/atom/ dan http:// <![CDATA[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/ 2006-01-26T17:42:21Z 2006-01-26T17:42:21Z 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

]]>
dan http:// <![CDATA[Adsense Notifier]]> http://pomocnik.com/users/dan/2006/01/mincus-code-%c2%bb-adsense-notifier/ 2006-01-18T18:41:12Z 2006-01-18T18:41:12Z 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

]]>
dan http:// <![CDATA[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/ 2005-10-24T19:11:18Z 2005-10-24T19:11:18Z 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.

]]>
dan http:// <![CDATA[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/ 2005-10-09T15:57:12Z 2005-10-09T15:57:12Z 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

]]>
dan http:// <![CDATA[How to convert dos file to unix/linux format.]]> http://pomocnik.com/users/dan/2005/08/hot-to-convert-dos-file-to-unixlinux-format/ 2005-08-24T19:16:44Z 2005-08-24T19:16:44Z 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

]]>
dan http:// <![CDATA[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/ 2005-08-16T18:44:55Z 2005-08-16T18:44:55Z 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.

]]>
dan http:// <![CDATA[How to password protect web directory (folder)]]> http://pomocnik.com/users/dan/2005/07/how-to-password-protect-web-directory-folder/ 2005-07-26T21:16:09Z 2005-07-26T21:16:09Z 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)

]]>
dan http:// <![CDATA[Firefox & Thunderbird working together!]]> http://pomocnik.com/users/dan/2005/07/firefox-thunderbird-working-together/ 2005-07-22T20:49:06Z 2005-07-22T20:49:06Z [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
]]>
dan http:// <![CDATA[Great firefox extension - customizegoogle]]> http://pomocnik.com/users/dan/2005/06/great-firefox-extension-customizegoogle/ 2005-06-09T18:50:21Z 2005-06-09T18:50:21Z Just look at: http://www.customizegoogle.com/ its great Mozilla Firefox extension for google!

]]>
dan http:// <![CDATA[Invisible dragon :-)]]> http://pomocnik.com/users/dan/2005/05/invisible-dragon/ 2005-05-27T15:40:23Z 2005-05-27T15:40:23Z If you wanna see the Invisible Dragon walking through a blizzard! You can find him here :-)

]]>