Navigation:  Advanced Features >

Database Example

Previous pageReturn to chapter overview

Here is an example for creating FTP accounts in PHPBB that every user registered in the forum can have an FTP account with his username and password, and the user data is stored via Mysql database, with which you can easily modify some user data fields by yourself, such as the 'expire time', 'upload quota', 'upload speed'...check out database schema reference, if necessary.

In this example, we use PHPBB version 3.0, and you would look for, in the source file "includes/ucp/ucp_register.php", the code:

 

$user_id = user_add($user_row, $cp_data);

 

then add the codes below directly after it.

 

//Wing FTP Server MOD start

$ftp_dbname = "wftp_database";               //Wing FTP Server's mysql database name, assume in the same server.

$ftp_domain_name = "default";                 //ftp's domain name.

$ftp_dirpath = "D:/ftp_data/".$data['username'];//user's directory path

$ftp_upload_limit = TRUE;                     //whether to limit the quota size

$ftp_maxuoload_size = 1024*1024*100;         //if $ftp_upload_limit = TRUE, this value means the max quota bytes.

$db->sql_query("USE ".$ftp_dbname.";");

$db->sql_query("INSERT INTO `wftp_mysqltable_user` VALUES ('".$ftp_domain_name."','".$data['username']."',1,1,'".md5($data['new_password'])."',63,0,NULL,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,0,0,0,0,0,'0',NULL,0,0,0,".intval($ftp_upload_limit).",0,".$ftp_maxuoload_size.",0,0,0,'');");

$mkdir_result = @mkdir($ftp_dirpath);

if($mkdir_result == TRUE)

  $db->sql_query("INSERT INTO `wftp_mysqltable_dir` VALUES ('".$ftp_domain_name."','".$data['username']."','".$ftp_dirpath."','/',1,1,1,1,1,1,1,1,1,1,1,1);");

$db->sql_query("USE ".$db->dbname.";");

//Wing FTP Server end

 

 

Note: Adding/editing user account by SQL operation is not a recommended method,  we suggest you use Lua webservice to make it.