本文整理汇总了PHP中tform_actions::onBeforeUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP tform_actions::onBeforeUpdate方法的具体用法?PHP tform_actions::onBeforeUpdate怎么用?PHP tform_actions::onBeforeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tform_actions
的用法示例。
在下文中一共展示了tform_actions::onBeforeUpdate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeUpdate
function onBeforeUpdate()
{
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 />';
}
//* 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);
//* Prevent that the database name and charset is changed
$old_record = $app->tform->getDataRecord($this->id);
$dbname_prefix = $app->tools_sites->getPrefix($old_record['database_name_prefix'], $dbname_prefix);
$this->dataRecord['database_name_prefix'] = $dbname_prefix;
if ($old_record["database_name"] != $dbname_prefix . $this->dataRecord["database_name"]) {
$app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"] . '<br />';
}
if ($old_record["database_charset"] != $this->dataRecord["database_charset"]) {
$app->tform->errorMessage .= $app->tform->wordbook["database_charset_change_txt"] . '<br />';
}
if (!$this->dataRecord['database_user_id']) {
$app->tform->errorMessage .= $app->tform->wordbook["database_user_missing_txt"] . '<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 />';
}
//* Check if the server has been changed
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
if ($old_record["server_id"] != $this->dataRecord["server_id"]) {
//* Add a error message and switch back to old server
$app->tform->errorMessage .= $app->lng('The Server can not be changed.');
$this->dataRecord["server_id"] = $rec['server_id'];
}
}
unset($old_record);
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 />';
}
if ($app->tform->errorMessage == '') {
/* restrict the names if there is no error */
/* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
$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"] . "' AND database_id != '" . $this->id . "'");
if ($tmp['dbnum'] > 0) {
$app->tform->errorMessage .= $app->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::onBeforeUpdate();
}
示例2: onBeforeUpdate
function onBeforeUpdate()
{
global $app, $conf, $interfaceConf;
/*
* we can not change the username and the dir, so get the "old" - data from the db
* and set it
*/
$data = $app->db->queryOneRecord("SELECT * FROM webdav_user WHERE webdav_user_id = " . intval($this->id));
$this->dataRecord["username"] = $data['username'];
$this->dataRecord["dir"] = $data['dir'];
$passwordOld = $data['password'];
/*
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule
* needs (only if the pwd is changed)
*/
if (isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '' && $this->dataRecord["password"] != $passwordOld) {
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
$this->dataRecord["password"] = $hash;
}
parent::onBeforeUpdate();
}
示例3: onBeforeUpdate
function onBeforeUpdate()
{
global $app, $conf, $interfaceConf;
/*
* If the names should be restricted -> do it!
*/
//* 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);
//* Prevent that the database name and charset is changed
$old_record = $app->tform->getDataRecord($this->id);
if ($old_record["database_name"] != $dbname_prefix . $this->dataRecord["database_name"]) {
$app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"] . '<br />';
}
if ($old_record["database_charset"] != $this->dataRecord["database_charset"]) {
$app->tform->errorMessage .= $app->tform->wordbook["database_charset_change_txt"] . '<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 />';
}
if ($this->dataRecord['database_user'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"] . '<br />';
}
//* Check if the server has been changed
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
if ($old_record["server_id"] != $this->dataRecord["server_id"]) {
//* Add a error message and switch back to old server
$app->tform->errorMessage .= $app->lng('The Server can not be changed.');
$this->dataRecord["server_id"] = $rec['server_id'];
}
}
unset($old_record);
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 />';
}
if ($app->tform->errorMessage == '') {
/* restrict the names if there is no error */
/* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
$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"] . "' AND database_id != '" . $this->id . "'");
if ($tmp['dbnum'] > 0) {
$app->tform->errorMessage .= $app->lng('database_name_error_unique') . '<br />';
}
parent::onBeforeUpdate();
}
示例4: onBeforeUpdate
function onBeforeUpdate()
{
global $app, $conf, $interfaceConf;
/*
* we can not change the username and the dir, so get the "old" - data from the db
* and set it
*/
$data = $app->db->queryOneRecord("SELECT * FROM webdav_user WHERE webdav_user_id = " . $app->functions->intval($this->id));
$this->dataRecord["username"] = $data['username'];
$this->dataRecord["dir"] = $data['dir'];
$this->dataRecord['username_prefix'] = $data['username_prefix'];
$this->dataRecord['passwordOld'] = $data['password'];
parent::onBeforeUpdate();
}
示例5: onBeforeUpdate
function onBeforeUpdate()
{
global $app, $conf, $interfaceConf;
//* Get the 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->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_database_user WHERE database_user_id = '" . $this->id . "'");
$dbuser_prefix = $app->tools_sites->getPrefix($this->oldDataRecord['database_user_prefix'], $dbuser_prefix);
$this->dataRecord['database_user_prefix'] = $dbuser_prefix;
//* Database username shall not be empty
if ($this->dataRecord['database_user'] == '') {
$app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"] . '<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 user against blacklist
$dbuser_blacklist = array($conf['db_user'], 'mysql', 'root');
if (in_array($dbuser_prefix . $this->dataRecord['database_user'], $dbuser_blacklist)) {
$app->tform->errorMessage .= $app->lng('Database user not allowed.') . '<br />';
}
if ($app->tform->errorMessage == '') {
/* restrict the names if there is no error */
/* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
$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::onBeforeUpdate();
}