作者:ranmadx
项目:dorc
function obtenerArancel($colegio_ID, $curso, $aran_anio)
{
DBConnect($this->dbh, BD_SIGA);
$SQL = "SELECT * FROM arancel WHERE FK_colegios_colegio_ID = '{$colegio_ID}'\r\n AND FK_curso = '{$curso}'\r\n AND aran_anio = '{$aran_anio}'";
$result = DBQuery($SQL, $this->dbh);
$row = DBFetchArray($result);
DBConnect($dbh);
//dpr($_SESSION['colegio']->colegio_ID);
if (!$row['aran_monto']) {
switch ($_SESSION['colegio']->colegio_ID) {
case "abello":
$row['aran_monto'] = ArancelColegio::ABELLO;
break;
case "edupac":
$row['aran_monto'] = ArancelColegio::EDUPAC;
break;
case "dor":
if (substr($curso, 0, -1) >= 9) {
$row['aran_monto'] = ArancelColegio::DOR_MEDIA;
} else {
$row['aran_monto'] = ArancelColegio::DOR_BASICA;
}
break;
}
//$_SESSION[''] =
}
return $row;
}
作者:pearlvoi
项目:a2billin
public function __construct()
{
$this->DBHandler = DBConnect();
$this->instance_table = new Table();
$this->FG_QUERY_ADITION_SIP = 'name, accountcode, regexten, amaflags, callgroup, callerid, canreinvite, context, DEFAULTip, dtmfmode, fromuser, fromdomain, host, insecure, language, ' . 'mailbox, md5secret, nat, deny, permit, mask, pickupgroup, port, qualify, restrictcid, rtptimeout, rtpholdtimeout, secret, type, username, disallow, allow, musiconhold, regseconds, ' . 'ipaddr, cancallforward, fullcontact, setvar, lastms, regserver, defaultuser, auth, subscribemwi, vmexten, cid_number, callingpres, usereqphone, incominglimit, subscribecontext, ' . 'musicclass, mohsuggest, allowtransfer, autoframing, maxcallbitrate, outboundproxy, rtpkeepalive';
$this->FG_QUERY_ADITION_IAX = 'name, accountcode, regexten, amaflags, callerid, context, DEFAULTip, host, language, mask, port, qualify, secret, username, disallow, allow, regseconds, ' . 'ipaddr, trunk, dbsecret, regcontext, sourceaddress, mohinterpret, mohsuggest, inkeys, outkey, cid_number, sendani, fullname, auth, maxauthreq, encryption, transfer, jitterbuffer, ' . 'forcejitterbuffer, codecpriority, qualifysmoothing, qualifyfreqok, qualifyfreqnotok, timezone, adsi, setvar, type, deny, permit, requirecalltoken, maxcallnumbers, ' . 'maxcallnumbers_nonvalidated';
}
作者:ranmadx
项目:dorc
function actualizarMensualidades($db1, $db2)
{
// $db1="dorcl_dor2007";
// $db2="dorcl_dor2008";
echo "actualizando {$db2}";
DBConnect($dbh, $db1);
$sql = 'SELECT * FROM `alumnos`';
$result = mysql_query($sql, $dbh);
$barrita = ".";
$cont = 0;
while ($row = mysql_fetch_array($result)) {
$detalle2 = "";
$barrita = $barrita . ".";
$rut = $row["rut"];
$apellidop = $row["apellidop"];
$apellidom = $row["apellidom"];
$nombres = $row["nombres"];
$curso = $row["curso"];
$sql3 = 'SELECT * FROM `mensualidades` where `rut` = ' . "'" . $rut . "';";
mysql_select_db($db1);
$result3 = mysql_query($sql3, $dbh);
$row3 = mysql_fetch_array($result3);
$mensualidad = $row3["mensualidad"];
$descuentos = $row3["descuentos"];
$deuda = $row3["deuda"];
$detalle = $row3["detalle"];
$deudaaux = 0;
$deuda2 = $deuda;
if ($deuda2 > 0) {
$detalle2 = $detalle;
}
//echo "Mensualidad:$mensualidad, Descuento: $descuentos, Deuda : $deuda, Detalles : $detalle<br>";
$c[0] = $row3["c0"];
for ($i = 1; $i <= 10; $i++) {
$c[$i] = $row3["c" . $i];
$deudaaux = $deudaaux + ($mensualidad - $mensualidad * ($descuentos / 100) - $c[$i]);
//echo "c$i:$c[$i]";
}
$deuda2 = $deuda2 + $deudaaux;
if ($deuda2 > 0) {
$detalle2 = $detalle2 . " Deuda arancel " . $_SESSION[base_datos]->anio;
}
mysql_select_db($db2);
$sql4 = "INSERT INTO `mensualidades` (rut, deuda, detalle) values('" . $deuda2 . "','" . $detalle2 . "');";
echo "{$sql4}<br>";
mysql_query($sql4, $dbh);
//echo"<br><br>";
/*
$letra = $curso{strlen($curso)-1};
$curso = $curso = substr ($curso, 0, -1);
$curso++;
$curso=$curso.$letra;
$sql2 = "UPDATE `alumnos` SET `curso` ="."'".$curso."' where `rut` ="."'".$rut."';";
mysql_select_db ($db2);
作者:eroru
项目:newsstan
function MCGetHouse($house, $key = 'ts')
{
global $memcache;
static $houseKeys = array();
if ($key == 'ts') {
if (isset($houseKeys[$house])) {
return $houseKeys[$house];
}
$houseKeys[$house] = $memcache->get('h' . $house . '_ts');
if ($houseKeys[$house] === false) {
$houseKeys[$house] = 1;
MCSetHouse($house, $key, $houseKeys[$house]);
// so we don't query a billion times on this key
$altDb = DBConnect(true);
if ($altDb) {
$stmt = $altDb->prepare('SELECT max(unix_timestamp(updated)) FROM tblSnapshot WHERE house = ?');
$stmt->bind_param('i', $house);
$stmt->execute();
$stmt->bind_result($houseKeys[$house]);
$gotHouse = $stmt->fetch() === true;
$stmt->close();
if ($gotHouse) {
MCSetHouse($house, $key, $houseKeys[$house]);
} else {
$houseKeys[$house] = 1;
}
$altDb->close();
}
}
return $houseKeys[$house];
}
return MCGet('h' . $house . '_' . MCGetHouse($house) . '_' . $key);
}
作者:notUserDevelope
项目:fl-ru-dam
/**
* Взять информацию по найденным результатам
*
* @return array массив с пользователями
*/
function getRecords($order_by = NULL)
{
if ($this->matches) {
$sql = "SELECT * FROM search_users_simple WHERE id IN (" . implode(', ', $this->matches) . ')';
if ($order_by) {
$sql .= " ORDER BY {$order_by}";
} else {
if ($this->_sortby && (($desc = $this->_sort == SPH_SORT_ATTR_DESC) || $this->_sort == SPH_SORT_ATTR_ASC)) {
$sql .= " ORDER BY {$this->_sortby}" . ($desc ? ' DESC' : '');
}
}
if ($res = pg_query(DBConnect(), $sql)) {
if (!$order_by && ($this->_sort == SPH_SORT_RELEVANCE || $this->_sort == SPH_SORT_EXTENDED)) {
$links = array();
$rows = array();
while ($row = pg_fetch_assoc($res)) {
$links[$row['id']] = $row;
}
for ($i = 0; $i < count($this->matches); $i++) {
$rows[] = $links[$this->matches[$i]];
}
} else {
$rows = pg_fetch_all($res);
}
return $rows;
}
}
return array();
}
作者:Root-Whoam
项目:xs
function __construct()
{
if (intval(EXPIRES) > 0) {
$expiryTime = intval(EXPIRES);
}
$this->db = DBConnect();
$this->tbUser = $this->db->tbPrefix . 'user';
$this->tbField = $this->db->tbPrefix . 'field';
$this->tbUserField = $this->db->tbPrefix . 'user_field';
$this->tbSession = $this->db->tbPrefix . 'session';
$this->ocKey = Val('ocKey', 'COOKIE');
if (!empty($this->ocKey)) {
$row = $this->db->FirstRow("SELECT userId,token,data FROM " . $this->tbSession . " WHERE ocKey='" . $this->ocKey . "' AND expires>" . time());
$this->userId = intval($row['userId']);
$this->token = $row['token'];
$data = $row['data'];
if (!empty($data)) {
$data = unserialize($data);
$this->adminLevel = intval($data['adminLevel']);
$this->userName = $data['userName'];
$avatarDir = URL_ROOT . '/upload/avatar/';
$this->avatarImg = empty($data['avatarImg']) ? $avatarDir . 'avatar_50_50.gif' : $avatarDir . $data['avatarImg'];
$this->avatarImg_s = empty($data['avatarImg_s']) ? $avatarDir . 'avatar_30_30.gif' : $avatarDir . $data['avatarImg_s'];
$this->signature = $data['signature'];
$this->db->Execute("UPDATE " . $this->tbSession . " SET updateTime='" . time() . "',expires=expires+" . $this->expiryTime . " WHERE ocKey='" . $this->ocKey . "'");
}
}
}
作者:juniorthiese
项目:das
function Init()
{
session_start();
// chama config
$configFile = $_SERVER['DOCUMENT_ROOT'] . '/painel/system/config.php';
if (!file_exists($configFile)) {
die('Erro arquivo config.php não existe!');
} else {
require_once $configFile;
}
//chama helpers
if (!file_exists(FILE_HELP)) {
die('Erro arquivo helpers.php não existe!');
} else {
require_once FILE_HELP;
}
//chama database
if (!file_exists(FILE_DATABASE)) {
die('Erro arquivo database.php não existe!');
} else {
require_once FILE_DATABASE;
}
DBConnect();
DoLogout();
}
作者:hsnune
项目:drmeatend
function DBExecute($query)
{
$link = DBConnect();
$result = mysqli_query($link, $query) or die(mysqli_error($link));
DBClose($link);
return $result;
}
作者:ranmadx
项目:dorc
public function DBCambioPermanente($anio)
{
DBConnect($dbh);
mysql_select_db(BD_SIGA);
$SQL = "UPDATE db SET anio = '{$anio}'\r\n WHERE db_ID ='" . $_SESSION['base_datos']->db_ID . "'";
$this->DBQuery($SQL, $dbh);
mysql_select_db($_SESSION['base_datos']->nombrebd);
}
作者:JeffM250
项目:HackShar
function SiteDB()
{
global $CONFIG_DATABASE_SERVER;
global $CONFIG_DATABASE_DATABSE;
global $CONFIG_DATABASE_USER;
global $CONFIG_DATABASE_PASS;
return DBConnect($CONFIG_DATABASE_SERVER, $CONFIG_DATABASE_DATABSE, $CONFIG_DATABASE_USER, $CONFIG_DATABASE_PASS);
}
作者:AnnaOze
项目:shp-php
function DBExec($sql)
{
DBConnect();
$res = mysql_query($sql);
if (false === $res) {
return false;
}
return true;
}
作者:AnnaOze
项目:php1_201
function DBQueryOne($sql)
{
DBConnect();
$res = mysql_query($sql);
if (!$res) {
return [];
}
$row = mysql_fetch_assoc($res);
return $row;
}
作者:Tair11
项目:php-p
function DBQuery($sql)
{
DBConnect();
$res = mysqli_query($sql);
$ret = [];
while ($row = mysqli_fetch_assoc($res)) {
$ret = $row;
}
return $ret;
}
作者:eroru
项目:newsstan
function DataIntervalsData()
{
$cacheKey = 'dataintervalstable';
if (($tr = MCGet($cacheKey)) !== false) {
return $tr;
}
$db = DBConnect();
$sql = <<<'EOF'
select t.house, t.lastupdate,
t.mindelta, modes.delta as modedelta, t.avgdelta, t.maxdelta,
r.region, group_concat(r.name order by 1 separator ', ') nms
from (
select deltas.house, max(deltas.updated) lastupdate, round(min(delta)/5)*5 mindelta, round(avg(delta)/5)*5 avgdelta, round(max(delta)/5)*5 maxdelta
from (
select sn.updated,
if(@prevhouse = sn.house and sn.updated > timestampadd(hour, -48, now()), unix_timestamp(sn.updated) - @prevdate, null) delta,
@prevdate := unix_timestamp(sn.updated) updated_ts,
@prevhouse := sn.house house
from (select @prevhouse := null, @prevdate := null) setup, tblSnapshot sn
order by sn.house, sn.updated) deltas
group by deltas.house) t
left join (
select house, delta
from (
select if(@prev = house, @rownum := @rownum + 1, @rownum := 0) o, delta, (@prev := house) as house, c
from (
select house, delta, count(*) c
from (
select sn.updated,
round(if(@prevh = sn.house, unix_timestamp(sn.updated) - @prevd, null)/5)*5 delta,
@prevd := unix_timestamp(sn.updated) updated_ts,
@prevh := sn.house house
from (select @prevh := null, @prevd := null) setup, tblSnapshot sn
where sn.updated > timestampadd(hour, -48, now())
order by sn.house, sn.updated) deltas
where delta is not null
group by house, delta
order by house, c desc
) tosort,
(select @rownum := 0, @prev := null) setup) filtered
where o=0
) modes on modes.house = t.house
join tblRealm r on r.house = t.house and r.locale is not null
group by r.house
order by 4 asc, 3 asc, region asc, nms asc
EOF;
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->get_result();
$tr = DBMapArray($result, null);
$stmt->close();
MCSet($cacheKey, $tr, 60);
return $tr;
}
作者:saydul
项目:a2billin
public function currencies()
{
$this->currencies = array();
$currenciesTable = new Table("cc_currencies", " * ");
$DBHandle = DBConnect();
$return = $currenciesTable->Get_list($DBHandle, "", 0);
$this->currencies = array();
foreach ($return as $value) {
$this->currencies[$value['currency']] = array('currency' => $value['currency'], 'name' => $value['name'], 'value' => $value['value'], 'decimal_point' => $value['decimal_point'], 'basecurrency' => $value['basecurrency'], 'decimal_places' => 2);
}
}
作者:mailyosanto
项目:portal-vestibula
function DBSearch_ByCpf($cpf)
{
$link = DBConnect();
$query_list = "SELECT * FROM candidato WHERE cpf='{$cpf}'";
if ($result = $link->query($query_list)) {
while ($row = $result->fetch_row()) {
$candidato = array('id' => $row[0], 'nome' => $row[1], 'cpf' => $row[2], 'rua' => $row[3], 'num' => $row[4], 'bairro' => $row[5], 'cidade' => $row[6], 'cep' => $row[7], 'fixo' => $row[8], 'cel' => $row[9], 'email' => $row[10], 'opc1' => $row[11], 'opc2' => $row[12], 'datahora' => $row[13]);
return $candidato;
}
}
return 0;
}
作者:mahyuddi
项目:emulab-stabl
function GetDBLink($authority)
{
if ($authority == "cm") {
$authority = "geni-cm";
}
if ($authority == "sa" || $authority == "geni-sa") {
$authority = "geni";
}
if ($authority == "ch") {
$authority = "geni-ch";
}
return DBConnect($authority);
}
作者:mailyosanto
项目:portal-vestibula
function DBInsert_Curso(array $curso, $foto1, $foto2, $foto3)
{
$link = DBConnect();
$query_curso = "INSERT INTO curso (idcurso, cod, nome, duracao, periodo, mensalidade, descricao, foto1, foto2, foto3) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $link->prepare($query_curso) or die(mysqli_error($link));
if ($stmt) {
$stmt->bind_param("ssissssss", $curso["cod"], $curso["nome"], $curso["duracao"], $curso["periodo"], $curso["mensalidade"], $curso["descricao"], $foto1, $foto2, $foto3);
$resultado = $stmt->execute() ? 1 : 0;
$stmt->store_result();
$stmt->close();
}
DBClose($link);
return $resultado;
}
作者:eroru
项目:newsstan
function TransmogGenericItemList($house, $params)
{
global $db, $canCache;
$key = 'transmog_gi2_' . md5(json_encode($params));
if ($canCache && ($tr = MCGetHouse($house, $key)) !== false) {
return $tr;
}
DBConnect();
if (is_array($params)) {
$joins = isset($params['joins']) ? $params['joins'] : '';
$where = isset($params['where']) ? ' and ' . $params['where'] : '';
$group = isset($params['group']) ? array_merge($params['group'], [false]) : null;
} else {
$joins = '';
$group = null;
$where = $params == '' ? '' : ' and ' . $params;
}
$sql = <<<EOF
select ab.id, ab.display, ab.buy, ab.class, ab.subclass, ifnull(ab.type, -1 & ab.subclass) `type`, ab.subclassname
from (
select aa.*, if(@previd = aa.display, 0, @previd := aa.display) previd
from (select @previd := 0) aasetup, (
SELECT i.id, i.display, a.buy, i.class, i.subclass, i.type, concat_ws('-', i.class, i.subclass) subclassname
FROM `tblDBCItem` i
join tblAuction a on a.item=i.id
{$joins}
WHERE i.auctionable=1
and i.quality > 1
{$where}
and i.display is not null
and i.flags & 2 = 0
and a.house = ?
and a.buy > 0
order by i.display, a.buy) aa
) ab
where ab.previd > 0
EOF;
$stmt = $db->prepare($sql);
if (!$stmt) {
DebugMessage("Bad SQL: \n" . $sql, E_USER_ERROR);
}
$stmt->bind_param('i', $house);
$stmt->execute();
$result = $stmt->get_result();
$tr = DBMapArray($result, $group);
$stmt->close();
MCSetHouse($house, $key, $tr);
return $tr;
}
作者:eroru
项目:newsstan
function AddToCurrentSubs($seconds, $message)
{
$allGood = true;
$db = DBConnect(true);
$stmt = $db->prepare('select id from tblUser where paiduntil > now()');
$stmt->execute();
$user = null;
$stmt->bind_result($user);
while ($stmt->fetch()) {
$allGood &= AddTheTime($user, $seconds, $message);
}
$stmt->close();
$db->close();
return $allGood;
}