@@ -422,10 +422,11 @@ class page_action extends tform_actions {
$this->urlBBDD($db_id, $this->bbdd_serv);
//echo('Id de la BBDD ' . $db_id);
// get site data para usarlo en la creació n de la cuenta ftp, otra forma de cargar una tupla dandole un id
// get site data para usarlo en la creació n de la cuenta ftp, otra forma de cargar una tupla dandole un id
//$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php');
$site_data = $app->remoting_lib->getDataRecord($sitio_id);
//$site_data = $app->remoting_lib->getDataRecord($sitio_id);
$site_data = $remoto->getDataRecordWebDNS($sitio_id);
$this->nombre_user_ftp = $this->generaNombreFTP();
// add ftp user
@@ -1578,6 +1579,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
}
}*/
class remote_actions extends remoting {
public function insert_query($formdef_file, $client_id, $params, $event_identifier = '') {
global $app;
@@ -1588,18 +1590,147 @@ class remote_actions extends remoting {
$app->remoting_lib->loadUserProfile();*/
//return $app->db->query($sql);//$this->insertQueryExecute($sql, $params, $event_identifier);
//echo(' insertQueryPrepare ' . $this->insertQueryExecute($sql, $params, $event_identifier));
return $this->insertQuery($formdef_file, $client_id, $params, $event_identifier);
return $this->insertQueryWebDNS($formdef_file, $client_id, $params, $event_identifier);
}
function insertQueryWebDNS($formdef_file, $client_id, $params, $event_identifier = '') {
$sql = $this->insertQueryPrepareWebDNS($formdef_file, $client_id, $params);
if($sql !== false) return $this->insertQueryExecuteWebDNS($sql, $params, $event_identifier);
else return false;
}
public function sites_database_user_add($session_id, $client_id, $params, $event_identifier = '')
{
function insertQueryPrepareWebDNS($formdef_file, $client_id, $params) {
global $app;
$app->uses('remoting_lib');
//* load the user profile of the client
//$app->remoting_lib->loadUserProfile($client_id);
//* Load the form definition
$app->remoting_lib->loadFormDef($formdef_file);
//echo(' Base de datos ' . $app->remoting_lib->loadFormDef($formdef_file));
//* Get the SQL query
$sql = $app->remoting_lib->getSQL($params, 'INSERT', 0);
/*if($app->remoting_lib->errorMessage != '') {
throw new SoapFault('data_processing_error', $app->remoting_lib->errorMessage);
return false;
}*/
$app->log('Executed insertQueryPrepareWebDNS', LOGLEVEL_DEBUG);
return $sql;
}
function insertQueryExecuteWebDNS($sql, $params, $event_identifier = '') {
global $app;
$app->uses('remoting_lib');
$app->db->query($sql);
/*if($app->db->errorMessage != '') {
throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql);
return false;
}*/
if ( isset($params['_primary_id'] ))
$insert_id = $params['_primary_id'];
else
$insert_id = $app->db->insertID();
// set a few values for compatibility with tform actions, mostly used by plugins
$this->id = $insert_id;
$this->dataRecord = $params;
$app->log('Executed insertQueryExecute, raising events now if any: ' . $event_identifier, LOGLEVEL_DEBUG);
if($event_identifier != '') $app->plugin->raiseEvent($event_identifier, $this);
//$app->uses('tform');
//* Save changes to Datalog
if($app->remoting_lib->formDef["db_history"] == 'yes') {
//$new_rec = $app->remoting_lib->getDataRecord($insert_id);
$new_rec = $this->getDataRecordWebDNS($insert_id);
$app->remoting_lib->datalogSave('INSERT', $primary_id, array(), $new_rec);
}
return $insert_id;
}
public function sites_database_user_add($session_id, $client_id, $params, $event_identifier = '') {
global $app;
/*if(!$this->checkPerm($session_id, 'sites_database_user_add')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}*/
//echo(' el loadUserProfile ' . $app->remoting_lib->loadUserProfile($client_id));
return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params, $event_identifier);
//echo(' la tablita ' . $this->formDef['db_table']);
return $this->insertQueryWebDNS('../sites/form/database_user.tform.php', $client_id, $params, $event_identifier);
}
function getDataRecordWebDNS($primary_id) {
global $app;
$escape = '`';
//$this->loadUserProfile();
if(@is_numeric($primary_id)) {
if($primary_id > 0) {
// Return a single record
return $this->getDataRecordPadreWebDNS($primary_id);
//return parent::getDataRecord($primary_id);
} elseif($primary_id == -1) {
// Return a array with all records
$sql = "SELECT * FROM ??";
return $app->db->queryAllRecords($sql, $this->formDef['db_table']);
} else {
throw new SoapFault('invalid_id', 'The ID has to be > 0 or -1.');
return array();
}
} elseif (@is_array($primary_id) || @is_object($primary_id)) {
if(@is_object($primary_id)) $primary_id = get_object_vars($primary_id); // do not use cast (array)xxx because it returns private and protected properties!
$sql_offset = 0;
$sql_limit = 0;
$sql_where = '';
$params = array($this->formDef['db_table']);
foreach($primary_id as $key => $val) {
if($key == '#OFFSET#') $sql_offset = $app->functions->intval($val);
elseif($key == '#LIMIT#') $sql_limit = $app->functions->intval($val);
elseif(stristr($val, '%')) {
$sql_where .= "?? like ? AND ";
} else {
$sql_where .= "?? = ? AND ";
}
$params[] = $key;
$params[] = $val;
}
$sql_where = substr($sql_where, 0, -5);
if($sql_where == '') $sql_where = '1';
$sql = "SELECT * FROM ?? WHERE ".$sql_where. " AND " . $this->getAuthSQLWebDNS('r', $this->formDef['db_table']);
if($sql_offset >= 0 && $sql_limit > 0) $sql .= ' LIMIT ' . $sql_offset . ',' . $sql_limit;
return $app->db->queryAllRecords($sql, true, $params);
} else {
$this->errorMessage = 'The ID must be either an integer or an array.';
return array();
}
}
function getDataRecordPadreWebDNS($primary_id) {
global $app;
$escape = '`';
$sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$this->getAuthSQLWebDNS('r', $this->formDef['db_table']);
return $app->db->queryOneRecord($sql, $this->formDef['db_table'], $this->formDef['db_table_idx'], $primary_id);
}
function getAuthSQLWebDNS($perm, $table = '') {
if($_SESSION["s"]["user"]["typ"] == 'admin' || $_SESSION['s']['user']['mailuser_id'] > 0) {
return '1';
} else {
if ($table != ''){
$table = ' ' . $table . '.';
}
$groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0;
$sql = '(';
$sql .= "(" . $table . "sys_userid = ".$_SESSION["s"]["user"]["userid"]." AND " . $table . "sys_perm_user like '%$perm%') OR ";
$sql .= "(" . $table . "sys_groupid IN (".$groups.") AND " . $table ."sys_perm_group like '%$perm%') OR ";
$sql .= $table . "sys_perm_other like '%$perm%'";
$sql .= ')';
return $sql;
}
}
public function sites_database_add($client_id, $params){
@@ -1607,7 +1738,7 @@ class remote_actions extends remoting {
//$app->remoting_lib->loadFormDef('../sites/form/database.tform.php');
//$app->tform->formDef('../sites/form/database.tform.php');
$sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params);
$sql = $this->insertQueryPrepareWebDNS ('../sites/form/database.tform.php', $client_id, $params);
if($sql !== false) {
$app->uses('sites_database_plugin');
@@ -1617,7 +1748,7 @@ class remote_actions extends remoting {
//$app->uses('sites_database_plugin');
$app->sites_database_plugin->processDatabaseInsert($this);
$retval = $this->insertQueryExecute($sql, $params);
$retval = $this->insertQueryExecuteWebDNS ($sql, $params);
// set correct values for backup_interval and backup_copies
if(isset($params['backup_interval']) || isset($params['backup_copies'])){