Compdigitec Labs

PHP

Disable the jump box of the FAQ in phpBB 3

Saturday, December 20th, 2008

If you think that the “jump to” box at the bottom of the FAQ in the phpBB 3 package is annoying or unessesary, you can use this article to disable it in four easy steps.

Download faq.php from your phpBB3 installation.
Open it with a text editor.
Comment out (add a #) line 170 (“make_jumpbox(append_sid(”{$phpbb_root_path}viewforum.$phpEx”));”).
Reupload and you’re done! [...]

phpBB force login hack

Tuesday, December 16th, 2008

To set up a private forum in phpBB, you could simply make all the forums “No Access” to guests and bots. But if they can still view your member list and profiles, that is a security leak. Here is a patch to remedy that by forcing the guest or bot to login before they can [...]

Simple timer script for command-line PHP

Wednesday, November 12th, 2008

Are you looking for a simple timer script written in command-line PHP? If so, here is one pre-written (released under the GPL v2 or later):

<?php
define(“endl”,“\n”);
// Timer script
if($argv[1] == “”) {
echo “Usage: ”.$argv[0].“ minutes”.endl;
die();
}
$dtime = strtotime(“+”.$argv[1].“ minute”);
while(true) {
echo “Enter to check time: ”;
$tt = fgets(STDIN);
$i = date(“i”,$dtime-time());
$s = date(“s”,$dtime-time());
echo “$i minutes, $s seconds”.endl;
}
?>

Usage: When launching use first parameter as number or minutes to count (0-59 min). Press enter to check the [...]

Allowing shorter passwords in AutoIndex

Thursday, October 30th, 2008

If you’ve ever found AutoIndex PHP Script’s password valiator’s resrictions on a long password annoying, you’re not alone. Fortunately, we have found a workaround for it.
Steps

Download the AutoIndex script.
Extract the archive and open classes/Admin.php
Find the line that says “private static function validate_new_password($pass1, $pass2)“.
Move further down to the line that says “if (strlen($pass1) < ” and:
Change [...]

SimpleXML - solution for XML manipulation in PHP

Sunday, September 7th, 2008

If you ever do get the need to manipulate (read/write) XML, you could try using the PHP DOM API, but it’s very difficult to use the DOM. An good extension-less way to access and manipulate XML instead is SimpleXML. It’s very easy to use compared to DOM and features a easy way to access attributes [...]

12 things you need to know about PHP

Tuesday, September 2nd, 2008

Are you still thinking that PHP is an web-only language or is “not a real language”? Well, that used to be true with PHP 2.0, but with PHP5, it’s not so true anymore. Here are 12 things you need to know about PHP:

PHP is not only for the web. PHP used to be only a [...]

DOMNodeList as an Array

Sunday, August 31st, 2008

When using getElementsByTagName, it returns a DOMNodeList which you can use with foreach, but you can’t use array indexes to access elements.
For example, you can use the following code to the contents of the first “test” tag:

<?php
$file = ‘z.xml’;
$xmlfile = new DOMDocument();
@$xmlfile->load($file);
$iplist = $xmlfile->getElementsByTagName(‘test’);
$i = 0;
foreach($iplist as $v) {
if($i == 0) {
var_dump($v->nodeValue);
}
$i++;
}
?>
Use this as z.xml:
<?xml version=”1.0″ ?><test>Testing: hello, [...]

The “Gtk-CRITICAL gtk_text_buffer_emit_insert assertion” warning in PHP-GTK2

Saturday, August 30th, 2008

If your internationalized PHP-GTK2 apps have ever failed to work, you probably received the following message in the terminal before:
Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)’ failed
This means that you have been using or passing non-UTF8 (good chance that it is CP1252 on Windows) strings to PHP-GTK2 classes and methods, such as GtkWindow, GtkLabel [...]

Changing the user agent of PHP

Wednesday, August 20th, 2008

If you ever need to adjust or change the default user agent that PHP accesses pages with (http and ftp wrappers) because either the default PHP user agent was blocked (”PHP”) or you wrote a bot with PHP and wish to customize it, you can do so easily with a php directive called “user_agent”. Note [...]

Using UTF-8 in PHP-GTK2

Monday, August 18th, 2008

When trying to use a string that has characters that are non-English (Asian and middle east characters) or characters that have accents for PHP-GTK’s widgets, you may possibly encounter a situation like the image to the right.
This bug or glitch is caused by the fact that you are trying to use a regional encoding for [...]

« Previous Entries