本文整理汇总了PHP中tform_actions::onBeforeInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP tform_actions::onBeforeInsert方法的具体用法?PHP tform_actions::onBeforeInsert怎么用?PHP tform_actions::onBeforeInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tform_actions
的用法示例。
在下文中一共展示了tform_actions::onBeforeInsert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
$this->dataRecord['username_prefix'] = $ftpuser_prefix;
if ($app->tform->errorMessage == '') {
$this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username'];
}
parent::onBeforeInsert();
}
示例2: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
// check if the username is not blacklisted
$blacklist = file(ISPC_LIB_PATH . '/shelluser_blacklist');
foreach ($blacklist as $line) {
if (strtolower(trim($line)) == strtolower(trim($this->dataRecord['username']))) {
$app->tform->errorMessage .= 'The username is not allowed.';
}
}
unset($blacklist);
/*
* If the names should be restricted -> do it!
*/
if ($app->tform->errorMessage == '') {
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$shelluser_prefix = $app->tools_sites->replacePrefix($global_config['shelluser_prefix'], $this->dataRecord);
$this->dataRecord['username_prefix'] = $shelluser_prefix;
/* restrict the names */
$this->dataRecord['username'] = $shelluser_prefix . $this->dataRecord['username'];
}
parent::onBeforeInsert();
}
示例3: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
//* Site shell not be empty
if ($this->dataRecord['parent_domain_id'] == 0) {
$app->tform->errorMessage .= $app->tform->lng("database_site_error_empty") . '<br />';
}
//* Database username and database name shall not be empty
if ($this->dataRecord['database_name'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"] . '<br />';
}
//* Get the database name and database user prefix
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord);
$this->dataRecord['database_name_prefix'] = $dbname_prefix;
if (strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) {
$app->tform->errorMessage .= str_replace('{db}', $dbname_prefix . $this->dataRecord['database_name'], $app->tform->wordbook["database_name_error_len"]) . '<br />';
}
//* Check database name and user against blacklist
$dbname_blacklist = array($conf['db_database'], 'mysql');
if (in_array($dbname_prefix . $this->dataRecord['database_name'], $dbname_blacklist)) {
$app->tform->errorMessage .= $app->lng('Database name not allowed.') . '<br />';
}
/* restrict the names */
/* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
if ($app->tform->errorMessage == '') {
$this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64);
}
//* Check for duplicates
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = '" . $this->dataRecord['database_name'] . "' AND server_id = '" . $this->dataRecord["server_id"] . "'");
if ($tmp['dbnum'] > 0) {
$app->tform->errorMessage .= $app->tform->lng('database_name_error_unique') . '<br />';
}
// get the web server ip (parent domain)
$tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = '" . $this->dataRecord['parent_domain_id'] . "'");
if ($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) {
// we need remote access rights for this server, so get it's ip address
$server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
if ($server_config['ip_address'] != '') {
if ($this->dataRecord['remote_access'] != 'y') {
$this->dataRecord['remote_ips'] = '';
}
$this->dataRecord['remote_access'] = 'y';
if (preg_match('/(^|,)' . preg_quote($server_config['ip_address'], '/') . '(,|$)/', $this->dataRecord['remote_ips']) == false) {
$this->dataRecord['remote_ips'] .= ($this->dataRecord['remote_ips'] != '' ? ',' : '') . $server_config['ip_address'];
}
}
}
parent::onBeforeInsert();
}
示例4: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
$app->uses('getconf');
$global_config = $app->getconf->get_global_config('sites');
//$ftpuser_prefix = ($global_config['ftpuser_prefix'] == '')?'':str_replace('[CLIENTNAME]', $this->getClientName(), $global_config['ftpuser_prefix']);
$ftpuser_prefix = replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
if ($app->tform->errorMessage == '') {
$this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username'];
}
parent::onBeforeInsert();
}
示例5: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
/*
* If the names should be restricted -> do it!
*/
if ($app->tform->errorMessage == '') {
$app->uses('getconf');
$global_config = $app->getconf->get_global_config('sites');
$webdavuser_prefix = replacePrefix($global_config['webdavuser_prefix'], $this->dataRecord);
/* restrict the names */
$this->dataRecord['username'] = $webdavuser_prefix . $this->dataRecord['username'];
/*
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule needs
*/
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
$this->dataRecord["password"] = $hash;
/*
* Get the data of the domain, owning the webdav user
*/
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = " . intval($this->dataRecord["parent_domain_id"]));
/* The server is the server of the domain */
$this->dataRecord["server_id"] = $web["server_id"];
/* The Webdav user shall be owned by the same group then the website */
$this->dataRecord["sys_groupid"] = $web['sys_groupid'];
}
parent::onBeforeInsert();
}
示例6: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
/*
* If the names should be restricted -> do it!
*/
if ($app->tform->errorMessage == '') {
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$webdavuser_prefix = $app->tools_sites->replacePrefix($global_config['webdavuser_prefix'], $this->dataRecord);
$this->dataRecord['username_prefix'] = $webdavuser_prefix;
/* restrict the names */
$this->dataRecord['username'] = $webdavuser_prefix . $this->dataRecord['username'];
/*
* Get the data of the domain, owning the webdav user
*/
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = " . $app->functions->intval($this->dataRecord["parent_domain_id"]));
/* The server is the server of the domain */
$this->dataRecord["server_id"] = $web["server_id"];
/* The Webdav user shall be owned by the same group then the website */
$this->dataRecord["sys_groupid"] = $web['sys_groupid'];
}
parent::onBeforeInsert();
}
示例7: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
//* Database username and database name shall not be empty
if ($this->dataRecord['database_name'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"] . '<br />';
}
if ($this->dataRecord['database_user'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"] . '<br />';
}
//* Get the database name and database user prefix
$app->uses('getconf');
$global_config = $app->getconf->get_global_config('sites');
$dbname_prefix = replacePrefix($global_config['dbname_prefix'], $this->dataRecord);
$dbuser_prefix = replacePrefix($global_config['dbuser_prefix'], $this->dataRecord);
if (strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) {
$app->tform->errorMessage .= str_replace('{db}', $dbname_prefix . $this->dataRecord['database_name'], $app->tform->wordbook["database_name_error_len"]) . '<br />';
}
if (strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) {
$app->tform->errorMessage .= str_replace('{user}', $dbuser_prefix . $this->dataRecord['database_user'], $app->tform->wordbook["database_user_error_len"]) . '<br />';
}
//* Check database name and user against blacklist
$dbname_blacklist = array($conf['db_database'], 'mysql');
if (in_array($dbname_prefix . $this->dataRecord['database_name'], $dbname_blacklist)) {
$app->tform->errorMessage .= $app->lng('Database name not allowed.') . '<br />';
}
$dbuser_blacklist = array($conf['db_user'], 'mysql', 'root');
if (in_array($dbname_prefix . $this->dataRecord['database_user'], $dbname_blacklist)) {
$app->tform->errorMessage .= $app->lng('Database user not allowed.') . '<br />';
}
/* restrict the names */
/* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
if ($app->tform->errorMessage == '') {
$this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64);
$this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16);
}
//* Check for duplicates
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = '" . $this->dataRecord['database_name'] . "' AND server_id = '" . $this->dataRecord["server_id"] . "'");
if ($tmp['dbnum'] > 0) {
$app->tform->errorMessage .= $app->tform->lng('database_name_error_unique') . '<br />';
}
parent::onBeforeInsert();
}
示例8: onBeforeInsert
function onBeforeInsert()
{
global $app, $conf, $interfaceConf;
//* Database username shall not be empty
if ($this->dataRecord['database_user'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"] . '<br />';
}
//* Get the database name and database user prefix
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord);
$this->dataRecord['database_user_prefix'] = $dbuser_prefix;
if (strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) {
$app->tform->errorMessage .= str_replace('{user}', $dbuser_prefix . $this->dataRecord['database_user'], $app->tform->wordbook["database_user_error_len"]) . '<br />';
}
//* Check database user against blacklist
$dbuser_blacklist = array($conf['db_user'], 'mysql', 'root');
if (is_array($dbuser_blacklist) && in_array($dbuser_prefix . $this->dataRecord['database_user'], $dbuser_blacklist)) {
$app->tform->errorMessage .= $app->lng('Database user not allowed.') . '<br />';
}
/* restrict the names */
/* crop user names if they are too long -> mysql: user: 16 chars / db: 64 chars */
if ($app->tform->errorMessage == '') {
$this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16);
}
$this->dataRecord['server_id'] = 0;
// we need this on all servers
parent::onBeforeInsert();
}