function menuAuthorization($taskid, $userid) { $retVal = false; if (isDbConnect()) { $conn = pg_connect(getConnectionString()); $queryString = "\n select * \n from icrm.tr_applicationtaskrole a \n join icrm.tr_applicationuserrole b \n on a.roleid = b.roleid \n where a.taskid = {$taskid} \n and b.userid = {$userid} \n "; $recordset = pg_query($conn, $queryString); if (pg_num_rows($recordset) > 0) { $retVal = true; } } return $retVal; }
function listarClientes($inputs = array()) { extract($inputs); if (isset($data_inicio) && isset($data_fim)) { $data_inicio = explode('/', $inputs['data_inicio']); $data_fim = explode('/', $inputs['data_fim']); if (isset($inputs['tipoData'])) { if ($inputs['tipoData'] == 1) { $data_inicio = $data_inicio[2] . '-' . $data_inicio[1] . '-' . $data_inicio[0]; $data_fim = $data_fim[2] . '-' . $data_fim[1] . '-' . $data_fim[0]; } else { $data_inicio = $data_inicio[1] . '-' . $data_inicio[0]; $data_fim = $data_fim[1] . '-' . $data_fim[0]; } } } $sql = "select customer_id, firstname, lastname, email, data_nascimento, date_format(date_added, '%Y-%m-%d')"; $sql .= " from oc_customer"; $sql .= " where"; if (isset($inputs['tipoData']) && $inputs['tipoData'] == 1) { $sql .= " date_format(date_added, '%Y-%m-%d')"; $ord = ' date_added'; } else { $sql .= " date_format(data_nascimento, '%m-%d')"; $ord = ' data_nascimento'; } $sql .= " between '{$data_inicio}' and '{$data_fim}'"; $sql .= "order by {$ord}"; //$con = new PDO("mysql:host=$host;dbname=$banco;charset=utf8", $usuario, $senha); $str_con = getConnectionString($inputs['site']); $con = new PDO("mysql:host=" . $str_con['host'] . ";dbname=" . $str_con['banco'] . ";charset=utf8", $str_con['usuario'], $str_con['senha']); $con->exec("SET CHARACTER SET utf8"); $rs = $con->query($sql); $clientes = $rs->fetchAll(); return json_encode($clientes); }
<?php ini_set("error_log", "/tmp/php-error.log"); /** * Contains functions for interacting with data on the Sonic Flow data server. */ $dbconn = pg_connect(getConnectionString()); pg_prepare($dbconn, 'songCheck', 'SELECT id FROM songs WHERE id = $1'); pg_prepare($dbconn, 'artistCheck', 'SELECT id FROM artists WHERE id = $1'); pg_prepare($dbconn, 'albumCheck', 'SELECT id FROM albums WHERE id = $1'); pg_prepare($dbconn, 'artLocation', 'SELECT location FROM albums WHERE id = $1'); pg_prepare($dbconn, 'addSong', 'INSERT INTO songs VALUES ($1,$2,$3,$4,$5,$6)'); pg_prepare($dbconn, 'addArtist', 'INSERT INTO artists VALUES ($1,$2)'); pg_prepare($dbconn, 'addAlbum', 'INSERT INTO albums VALUES ($1,$2,$3,$4)'); pg_prepare($dbconn, 'addToQueue', 'INSERT INTO queue (songid, cached) VALUES ($1,$2)'); pg_prepare($dbconn, 'removeFromQueue', 'DELETE FROM queue WHERE id = $1'); pg_prepare($dbconn, 'artLocSong', 'SELECT location FROM albums WHERE id IN (' . 'SELECT albumid FROM songs where id = $1)'); // queries for limiting song requests // gets the last timestamp of a song request given a song id. pg_prepare($dbconn, 'getSongRequestTime', 'SELECT lastqueued FROM queuetimes ' . 'WHERE songid = $1'); // returns 1 in the first row if a song has ever been requested or 0 if it has // not, given a song id. pg_prepare($dbconn, 'songWasRequested', 'SELECT COUNT(songid) AS requested ' . 'FROM queuetimes WHERE songid = $1'); // sets the last queue time of a song to the current time, given a song id. pg_prepare($dbconn, 'updateSongRequestTime', 'UPDATE queuetimes SET ' . 'lastqueued = $2 WHERE songid = $1'); // inserts a song queue time with the default timestamp of 0, given a song id. pg_prepare($dbconn, 'addSongRequestTime', 'INSERT INTO queuetimes ' . '(songid, lastqueued, uid) VALUES ($1, 0, NULL)'); function getConnectionString() { global $config; $conn_string = "host=localhost dbname=%s user=%s password=%s";
/** * Validate an that an array contains valid database information. * * @param mixed $value The value to validate. * @param mixed $field Not used. * @param array $data The data to validate against. * @return bool|string Returns true if the value is valid or an error message otherwise. * @deprecated */ function validateConnection($value, $field, $data) { $DatabaseHost = val('Database.Host', $data, '~~Invalid~~'); $DatabaseName = val('Database.Name', $data, '~~Invalid~~'); $DatabaseUser = val('Database.User', $data, '~~Invalid~~'); $DatabasePassword = val('Database.Password', $data, '~~Invalid~~'); $ConnectionString = getConnectionString($DatabaseName, $DatabaseHost); try { $Connection = new PDO($ConnectionString, $DatabaseUser, $DatabasePassword); } catch (PDOException $Exception) { return sprintf(T('ValidateConnection'), strip_tags($Exception->getMessage())); } return true; }
function isHasChild($parentid) { $isHasChild = false; if (isDbConnect()) { $conn = pg_connect(getConnectionString()); $queryString = ""; // XIBAR-OLD $queryString = "select count(1) as xcount "; $queryString .= queryString(); $queryString .= "and a.parentid = " . $parentid . " "; $recordset = pg_query($conn, $queryString); while ($row = pg_fetch_object($recordset)) { $isHasChild = $row->xcount > 0 ? true : false; } pg_close(getConnectionString()); } return $isHasChild; }
$_SESSION[$_SESSION["appname"] . "_" . "username"] = null; $_SESSION[$_SESSION["appname"] . "_" . "user_password"] = null; $_SESSION[$_SESSION["appname"] . "_" . "user_datetime_start"] = null; if (isDbConnect()) { $conn = pg_connect(getConnectionString()); $queryString = "\n select \n id, name, password \n from \n icrm.tr_membershipuser \n order by \n id \n "; $recordset = pg_query($conn, $queryString); while ($row = pg_fetch_object($recordset)) { if ($userName == $row->name && $userPassword == $row->password) { $userStructure = new UserStructure1(); $userStructure->userId = $row->id; $userStructure->userName = $row->name; $userStructure->userPassword = $row->password; array_push($items, $userStructure); $result["State"] = 0; $result["Message"] = ""; // CARA FAJAR $message = "success"; // "success" / "error" $_SESSION[$_SESSION["appname"] . "_" . "iduser"] = $row->id; $_SESSION[$_SESSION["appname"] . "_" . "username"] = $row->name; $_SESSION[$_SESSION["appname"] . "_" . "user_password"] = $row->password; $_SESSION[$_SESSION["appname"] . "_" . "user_datetime_start"] = null; } } $result["User"] = $items; pg_close(getConnectionString()); } // echo json_encode($result); // CARA FAJAR echo $message;