Example #1
0
 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;
 }
Example #2
0
 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';
 }
Example #3
0
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);
Example #4
0
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);
}
 /**
  * Взять информацию по найденным результатам
  *
  * @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();
 }
Example #6
0
 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 . "'");
         }
     }
 }
Example #7
0
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();
}
Example #8
0
function DBExecute($query)
{
    $link = DBConnect();
    $result = mysqli_query($link, $query) or die(mysqli_error($link));
    DBClose($link);
    return $result;
}
Example #9
0
 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);
 }
Example #10
0
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);
}
Example #11
0
function DBExec($sql)
{
    DBConnect();
    $res = mysql_query($sql);
    if (false === $res) {
        return false;
    }
    return true;
}
Example #12
0
function DBQueryOne($sql)
{
    DBConnect();
    $res = mysql_query($sql);
    if (!$res) {
        return [];
    }
    $row = mysql_fetch_assoc($res);
    return $row;
}
Example #13
0
function DBQuery($sql)
{
    DBConnect();
    $res = mysqli_query($sql);
    $ret = [];
    while ($row = mysqli_fetch_assoc($res)) {
        $ret = $row;
    }
    return $ret;
}
Example #14
0
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;
}
Example #15
0
 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);
     }
 }
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;
}
Example #17
0
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);
}
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;
}
Example #19
0
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;
}
Example #20
0
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;
}
Example #21
0
function DBEscape($dados)
{
    $link = DBConnect();
    if (!is_array($dados)) {
        $dados = mysqli_real_escape_string($link, $dados);
    } else {
        $arr = $dados;
        foreach ($arr as $key => $value) {
            $key = mysqli_real_escape_string($link, $key);
            $value = mysqli_real_escape_string($link, $value);
            $dados[$key] = $value;
        }
    }
    DBClose($link);
}
 /**
  * Взять информацию по найденным результатам.
  *
  * @return array
  */
 public function getRecords($order_by = null)
 {
     if ($this->matches && $this->active_search) {
         $sql = 'SELECT * FROM search_projects WHERE id IN (' . implode(', ', $this->matches) . ')';
         if ($order_by) {
             $sql .= " ORDER BY {$order_by}";
         } elseif ($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)) {
             return pg_fetch_all($res);
         }
     }
     return;
 }
Example #23
0
function DBEscape($data)
{
    $link = DBConnect();
    if (!is_array($data)) {
        $data = mysqli_real_escape_string($link, $data);
    } else {
        $arr = $data;
        foreach ($arr as $key => $value) {
            $key = DBEscape($key);
            $value = DBEscape($value);
            $data[$key] = $value;
        }
    }
    DBClose($link);
    return $data;
}
Example #24
0
function calc_salida_dia($dia, $mes, $anio)
{
    DBConnect($dbh);
    $fechadia = $dia . "/" . $mes . "/" . $anio;
    $totaldia = 0;
    $aux = 1;
    $abono = 0;
    $sql = 'select * from salidas where `fecha` =' . "'" . $fechadia . "';";
    //dpr($sql);
    $result = mysql_query($sql, $dbh);
    while ($row = mysql_fetch_array($result)) {
        $abono = $row["cantidad"];
        $totaldia = $totaldia + $abono;
    }
    return $totaldia;
}
Example #25
0
 function guardarMatricula($datos)
 {
     $matricula = $this->obtenerMatricula($datos);
     DBConnect($this->dbh, BD_SIGA);
     if ($matricula['matric_ID'] > 0) {
         $array_ID = array("matric_ID" => $matricula['matric_ID']);
         $sql = "UPDATE matriculas\n                            SET FK_colegios_colegio_ID='" . $datos['FK_colegios_colegio_ID'] . "',\n                            matric_monto='" . $datos['matric_monto'] . "',\n                            matric_anio='" . $datos['matric_anio'] . "',\n                            matric_estado='" . $datos['matric_estado'] . "',\n                            matric_observaciones='" . $datos['matric_observaciones'] . "',\n                            matric_fecha='" . $datos['matric_fecha'] . "',\n                            FK_rut='" . $datos['FK_rut'] . "' \n                      WHERE matric_ID='" . $matricula['matric_ID'] . "' ";
         DBQuery($sql, $this->dbh);
         $matric_ID = $matricula['matric_ID'];
     } else {
         $sql = "INSERT INTO matriculas (\n                                    FK_colegios_colegio_ID,\n                                     matric_monto,\n                                     matric_anio,\n                                     matric_estado,\n                                     matric_observaciones,\n                                     FK_rut,\n                                     matric_fecha\n                                    ) VALUES (\n                                    '" . $datos['FK_colegios_colegio_ID'] . "',\n                                     '" . $datos['matric_monto'] . "',\n                                     '" . $datos['matric_anio'] . "',\n                                     '" . $datos['matric_estado'] . "',\n                                     '" . $datos['matric_observaciones'] . "',\n                                     '" . $datos['FK_rut'] . "',\n                                     '" . $datos['matric_fecha'] . "'\n                                    )";
         DBQuery($sql, $this->dbh);
         $matric_ID = mysql_insert_id($this->dbh);
     }
     mysql_select_db($_SESSION['base_datos']->nombrebd);
     return $matric_ID;
 }
Example #26
0
function DBProtect($dados)
{
    //Protege contra SQL Inject
    $link = DBConnect();
    if (!is_array($dados)) {
        $dados = mysqli_real_escape_string($link, $dados);
    } else {
        $arr = $dados;
        foreach ($arr as $key => $value) {
            $key = mysqli_real_escape_string($link, $key);
            $value = mysqli_real_escape_string($link, $value);
            $dados[$key] = $value;
        }
    }
    DBClose($link);
    return $dados;
}
Example #27
0
function GetSellerList()
{
    $cacheKey = 'extra:multirealm:sellers';
    $sellers = MCGet($cacheKey);
    if ($sellers !== false) {
        return $sellers;
    }
    $sellers = [];
    $sql = <<<'EOF'
        select z2.sscnt, z2.itemcnt, s.name sellername, r.name realmname, s.firstseen, s.lastseen, r.house, r.slug
        from (
            select seller, count(distinct `snapshot`) sscnt, count(distinct item) itemcnt
            from (
                SELECT seller, item, `snapshot`
                FROM `tblSellerItemHistory` 
                where item in (128159, 127736, 127738, 127732, 127731, 127737, 127735, 127730, 127734, 127733, 127718, 128158, 127720, 127714, 127713, 127719, 127717, 127712, 127716, 127715)
            ) z1
            group by seller
            having (count(distinct item) = 2 or count(distinct item) > 3)
        ) z2
        left join tblSellerItemHistory h on h.seller = z2.seller and h.item not in (128159, 127736, 127738, 127732, 127731, 127737, 127735, 127730, 127734, 127733, 127718, 128158, 127720, 127714, 127713, 127719, 127717, 127712, 127716, 127715)
        join tblSeller s on s.id = z2.seller
        join tblRealm r on s.realm = r.id
        where h.seller is null
        and r.region = 'US'
        and s.firstseen > timestampadd(day, -14, now())
        and s.lastseen > timestampadd(hour, -36, now())
        order by r.house, s.firstseen, z2.sscnt desc, s.lastseen desc
EOF;
    $db = DBConnect();
    $db->query('set transaction isolation level read uncommitted, read only');
    $db->begin_transaction();
    $stmt = $db->prepare($sql);
    $stmt->execute();
    $result = $stmt->get_result();
    while ($row = $result->fetch_assoc()) {
        $sellers[$row['house']][] = $row;
    }
    $result->close();
    $stmt->close();
    $db->commit();
    // end transaction
    MCSet($cacheKey, $sellers);
    return $sellers;
}
Example #28
0
 function obtenerStyle($colegio_ID)
 {
     DBConnect($this->dbh, BD_SIGA);
     if (!$colegio_ID) {
         throw new Exception("Se requiere el colegio ID, para obtener el style");
     }
     $sql = "SELECT * FROM style WHERE FK_colegios_colegio_ID = '" . $colegio_ID . "'";
     $result = DBQuery($sql, $this->dbh);
     $row = DBFetchArray($result);
     mysql_select_db($_SESSION['base_datos']->nombrebd);
     if (!$row) {
         $row['style_ID'] = "0";
         $row['FK_colegios_colegio_ID'] = $colegio_ID;
         $row['style_css'] = "style.css";
         $row['style_path'] = "default";
     }
     return $row;
 }
Example #29
0
 /**
  * Обработка пачки событий (вызывается демоном).
  *
  * @param int $batch_id
  *
  * @return bool
  */
 public function process_batch($batch_id)
 {
     $events = $this->preprocess_batch($batch_id);
     if ($events === false) {
         $this->log->verbose('PGQDaemonBanners.preprocess_batch got not events (False).');
         return false;
     }
     /*
      * Event processing loop!
      */
     $abort_batch = false;
     $sql = "PREPARE updBanners (int, int, int) AS \n        \t\tUPDATE ban_stats1 set views = views + \$2, clicks = clicks + \$3 WHERE banner_id = \$1;\n";
     foreach ($events as $event) {
         if ($abort_batch) {
             break;
         }
         $id = $event->data['id'];
         $type = $event->type;
         if ($type == 'click') {
             ++$bans[$id]['click'];
         } elseif ($type == 'view') {
             ++$bans[$id]['view'];
         }
         $this->log->verbose('PGQDaemonBanners.process_batch type %s event %d of batch %d ', $type, $event->id, $batch_id);
         $this->log->verbose('PGQDaemonBanners.process_batch processed event %d of batch %d', $event->id, $batch_id);
     }
     if ($bans) {
         foreach ($bans as $ikey => $ban) {
             $sql .= "EXECUTE updBanners({$ikey}, " . zin($ban['view']) . ', ' . zin($ban['click']) . ");\n";
         }
         $sql .= 'DEALLOCATE updBanners;';
         $result = pg_query(DBConnect(), $sql);
         $this->log->debug('UPDATE : %s ', $sql);
         if ($result === false) {
             $this->log->error('Unable to update : %s ', $sql);
             $abort_batch = true;
         }
     } else {
         $this->log->verbose('PGQDaemonBanners.process_batch has no banners');
     }
     return $this->postprocess_batch($batch_id, $abort_batch);
 }
 /**
  * Взять информацию по найденным результатам.
  *
  * @return array
  */
 public function getRecords()
 {
     if ($this->matches && $this->active_search) {
         $where = array();
         foreach ($this->matches as $id => $match) {
             $where[$match['attrs']['type']][] = $id;
         }
         $_where = '';
         $i = 0;
         $cnt = count($where) - 1;
         foreach ($where as $key => $value) {
             $_in = implode(', ', $value);
             $_where .= "(type = {$key} AND id IN({$_in})) " . ($i < $cnt ? 'OR' : '');
             ++$i;
         }
         $sql = "SELECT * FROM search_{$this->_indexes[0]} WHERE {$_where}";
         if (!($res = pg_query(DBConnect(), $sql))) {
             return;
         }
         $rows = pg_fetch_all($res);
         if (!$rows) {
             return;
         }
         $data = array();
         foreach ($rows as $row) {
             $data[$row['id']] = $row;
         }
         $ids = array_keys($this->matches);
         $result = array();
         foreach ($ids as $id) {
             if (!isset($data[$id])) {
                 continue;
             }
             $result[] = $data[$id];
         }
         return $result;
     }
     return;
 }