31st May 2007
Earlier in one of my posts (Using PEAR HTTP_Client or HTTP_Request with HTTP proxy) I gave an example of using PEAR HTTP_Client and/or HTTP_Request from behind an http proxy. However, I didn’t tell how to make PEAR itself work properly from behind an HTTP proxy (e.g., for online operations like “pear upgrade-all”).
So here’s that tiny missing bit of information.
Windows:
Launch regedit, navigate to HKEY_CURRENT_USER\Environment, and create a string value called PHP_PEAR_HTTP_PROXY. Modify that new value to hold the string like: http://proxy_username:proxy_password@proxy_server_address:proxy_port.
Linux:
In the Terminal/Konsole, execute (for a system-wide pear configuration)
sudo pear config-set http_proxy http://proxy_username:proxy_password@proxy_server_address:proxy_port
If your proxy password has symbols, special for the shell (e.g. question or exclamation mark) – enclose full proxy specifications with single-quotes, e.g.
sudo pear config-set http_proxy ‘http://proxy_username:proxy_password@proxy_server_address:proxy_port’
If your HTTP proxy server does not require authentication, then use http://proxy_server_address:proxy_port instead.
I think the strings are completely self-explanatory; however, here’s an example of proxy (with authentication) specification: http://john.smith:CrAzYP433WoRd@192.168.0.1:3128.
Posted in Misc, PHP, Programming | No Comments »
23rd May 2007
Yesterday I needed to put together a rather simple PHP script: it would read the contents of a single pre-configured directory, and randomly select up to a pre-configured number of files. These files were images, and were just dumped as IMG tags into the webpage. I came up with a solution, shown below.
The script is simple, but still it’s easier to use the ready solution than to write your own
.
It is heavily commented, and should be easy to understand.
Read the rest of this entry »
Posted in PHP, Programming, Web | No Comments »
23rd May 2007
Found a nicely illustrated method for running a background shell command from PHP and continuously checking if the process is still running.
Here's sample code without explanations:
PHP:function run_in_background($Command, $Priority = 0)
{
if($Priority)
$PID =
shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!");
else
$PID =
shell_exec("nohup $Command 2> /dev/null & echo $!");
return($PID);
}
function is_process_running($PID)
{
exec("ps $PID",
$ProcessState);
return(count($ProcessState)>=
2);
}
To run something like hmmsearch from the HMMER package, you’d do this:
PHP:echo("Running hmmsearch. . .") $ps = run_in_background("hmmsearch $hmmfile $fastafile> $outfile");
while(is_process_running($ps))
{
}
Posted in Links, PHP, Programming | 2 Comments »
30th April 2007
When using PHP, the simplest way to find the absolute path of your files/folders on the server is by creating a simple path.php file with the following contents (click on the "Plain text" box header for copy-pasting):
Put the new file anywhere in the web-accessible folder on your server,
then just access that file from your favourite web-browser - and you'll have the absolute path shown to you.
Alternatively, you may use the following code:
This also should display the absolute path on your server.
Posted in Notepad, PHP, Programming, Web | 12 Comments »
10th March 2007
This is a collection of links related to the multiple-language content in Drupal CMS.
i18n module
i18n: Getting the whole thing to work : http://drupal.org/node/81094
Patch: Translations of menu titles and descriptions: http://drupal.org/node/70919
Translated links: http://drupal.org/node/67814
i18n: menu not expanding with URL-Alias: http://drupal.org/node/80820
There was an alternative module to i18n, but I cannot find it at the moment.
Posted in CMS, Drupal, PHP, Programming, Web | No Comments »
22nd January 2007
Update: the same solution seems to still apply to dotProject 2.1.2; the post instructions have been modified for dP 2.1.2.
Update 2: fsmullin suggested a method to fix a similar error in index_table.php, the files_count_max cannot be found error when you click the FILES tab/menu item. His suggestion is now incorporated into the post.
Update 3: this post is still relevant for dotProject 2.1.3.
In one of my recent posts about project management software I stated the desire to extensively test dotProject 2.0.4. However, many shared hosting providers appear incompatible with dotProject: the right to CREATE TEMPORARY TABLES in MySQL is not granted, but is needed by dotProject.
Here's sample error (2.0.4):
query failed(CREATE TEMPORARY TABLE tasks_sum SELECT task_project, COUNT(distinct task_id) AS total_tasks,
SUM(task_duration * task_percent_complete * IF(task_duration_type = 24, 8.0, task_duration_type))/
SUM(task_duration * IF(task_duration_type = 24, 8.0, task_duration_type)) AS project_percent_complete FROM `tasks` GROUP BY task_project)
For 2.1.2, sample error would be:
Table 'tasks_total' doesn't exist
I tried looking for solutions, and here's what I found...
Read the rest of this entry »
Posted in PHP, Programming, Software, Web | 10 Comments »