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

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.

Tip Changing 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".

  • For the Downloads module, those are:

    1. The modules/Downloads/index.php file:

      .""._FILEURL.": <input type=\"text\" name=\"url\" size=\"50\" 
      maxlength=\"100\" value=\"http://\"><br>";
      .""._URL.":<br><input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\"><br><br>" 
      
    2. The admin/modules/download.php file:

      .""._FILEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\">&nbsp;[ <a target=\"_blank\" href=\"$url\">"._CHECK."</a> ]<br>"
      .""._FILEURL.": <input type=\"text\" name=\"url\" size=\"50\" 
      maxlength=\"100\" value=\"http://\"><br>";
      .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\">&nbsp;[ <a href=\"$url\">"._CHECK."</a> ]<br>"
      
  • For the Web Links module, they are:

    1. The modules/Web_Links/index.php file:

      .""._PAGEURL.": <input type=\"text\" name=\"url\" size=\"50\" 
      maxlength=\"100\" value=\"http://\"><br>";
      .""._URL.":<br><input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\"><br><br>" 
      
    2. The admin/modules/links.php file:

      .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\">&nbsp;[ <a target=\"_blank\" href=\"$url\">"._VISIT."</a> ]<br>"
      .""._PAGEURL.": <input type=\"text\" name=\"url\" size=\"50\" 
      maxlength=\"100\" value=\"http://\"><br>";
      .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\">&nbsp;[ <a href=\"$url\">Visit</a> ]<br>"
      .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\"
      maxlength=\"100\">&nbsp;[ <a target=\"_blank\" href=\"$url\">"._VISIT."</a> ]<br>"
      
Tip Search 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!


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

 

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 343,862,864
  • Today: 35,131
Server InfoServer Info
  • Dec 11, 2017
  • 02:49 pm PST
 
 

Daily Inspiration