18.10. Modifying the PHP-Nuke Downloads module

Figure 18-13. Administration panel: Downloads.

Administration panel: Downloads.

In this section we modify the PHP-Nuke Downloads module:

18.10.1. How to add URLs longer than 100 characters in Downloads and Web Links

Not always is the database the sole culprit when you stumble upon an arbitrary limitation of the functionality: constraints are, for some obscure design reason, also eagerly set in the code of PHP-Nuke itself. A typical example of this situation, is the limitation of the URL length in the Downloads and Web_Links modules to just 100 characters. To remove this constraint you need to make changes to the database tables and the programming code.

The database change consists of a MySQL command that changes the length of the relevant field. For the Downloads module, the relevant field is the “url” field in the nuke_downloads_downloads table, for the Web_Links module it is the “url” field in the nuke_links_links table. To change its length, type on the MySQL command line

alter table nuke_downloads_downloads modify url varchar(200);

for the Downloads module, and

alter table nuke_links_links modify url varchar(200);

for the Web_links module.

TipChanging the length of database fields
 

If you don't feel comfortable with the MySQL command line, you can use a graphical user interface (GUI) for it, like phpMyAdmin (see Section 3.4). But you can also pack the above commands in a PHP program:

<?php
include_once("mainfile.php");
global $prefix, $dbi;
$result=sql_query("alter table nuke_downloads_downloads modify url varchar(200)", $dbi);
if (!$result) {
 print (mysql_error());
}
$result=sql_query("alter table nuke_links_links modify url varchar(200)", $dbi);
if (!$result) {
 print (mysql_error());
}
?>

Upload it to your web server in the PHP-Nuke root directory (the one where config.php and mainfile.php are also located) and point your browser to it. The script even takes care to print a descriptive error message (a good programming practice), if an error occurs.

But you are not done yet: for the length change to really take effect, you must change all relevant occurences of "maxlength" in the PHP code to reflect the new length of the field in the various HTML forms. This means searching not only the modules folder, but also the admin folder, for files related to the two modules and containing the string “maxlength”.

TipSearch for "maxlength" thoroughly!
 

If it still does not work, then you forgot to change "maxlength" somewhere - perhaps in a file under the admin folder. Search thoroughly!