Example #1
0
    /**
     * Returns the list of addressbooks for a specific user.
     *
     * @param string $principalUri
     * @return array
     */
    function getAddressBooksForUser($principalUri)
    {
        $sql = 'SELECT MAX(GREATEST(p.tms, s.tms)) lastupd FROM ' . MAIN_DB_PREFIX . 'socpeople as p
				LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc
				WHERE p.entity IN (' . getEntity('societe', 1) . ')
				AND (p.priv=0 OR (p.priv=1 AND p.fk_user_creat=' . $this->user->id . '))';
        $result = $this->db->query($sql);
        $row = $this->db->fetch_array($result);
        $lastupd = strtotime($row['lastupd']);
        $addressBooks = [];
        $addressBooks[] = ['id' => $this->user->id, 'uri' => 'default', 'principaluri' => $principalUri, '{DAV:}displayname' => 'Dolibarr', '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'Contacts Dolibarr ' . $this->user->login, '{http://calendarserver.org/ns/}getctag' => $lastupd, '{http://sabredav.org/ns}sync-token' => $lastupd];
        return $addressBooks;
    }
Example #2
0
 /**
  * Deletes a card
  *
  * @param mixed $addressBookId
  * @param string $cardUri
  * @return bool
  */
 function deleteCard($addressBookId, $cardUri)
 {
     debug_log("deleteContactObject( {$addressBookId} , {$cardUri} )");
     if (!$this->user->rights->societe->contact->supprimer) {
         return false;
     }
     if (strpos($cardUri, '-ct-') > 0) {
         $contactid = $cardUri * 1;
         // cardUri starts with contact id
     } else {
         $sql .= "SELECT `fk_object` FROM " . MAIN_DB_PREFIX . "socpeople_cdav\n\t\t\t\t\tWHERE `uuidext`= '" . $this->db->escape($cardUri) . "'";
         // cardUri comes from external apps
         $result = $this->db->query($sql);
         if ($result !== false && ($row = $this->db->fetch_array($result)) !== false) {
             $contactid = $row['fk_object'] * 1;
         } else {
             return false;
         }
         // not found
     }
     $sql = "UPDATE " . MAIN_DB_PREFIX . "socpeople SET ";
     $sql .= " statut = 0, tms = NOW(), fk_user_modif = " . $this->user->id;
     $sql .= " WHERE rowid = " . $contactid;
     $res = $this->db->query($sql);
     return true;
 }
Example #3
0
    /**
     * Returns a list of calendars ID for a principal.
     *
     * @return array
     */
    function _getCalendarsIdForUser()
    {
        debug_log("_getCalendarsIdForUser()");
        $calendars = [];
        if (!$this->user->rights->agenda->myactions->read) {
            return $calendars;
        }
        if (!isset($this->user->rights->agenda->allactions->read) || !$this->user->rights->agenda->allactions->read) {
            $onlyme = true;
        } else {
            $onlyme = false;
        }
        $sql = 'SELECT 
					u.rowid
                FROM ' . MAIN_DB_PREFIX . 'actioncomm as a 	LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type=\'user\'
														LEFT JOIN ' . MAIN_DB_PREFIX . 'user u ON (u.rowid = ar.fk_element)
				WHERE  
					a.entity IN (' . getEntity('societe', 1) . ')
					AND a.code IN (SELECT cac.code FROM ' . MAIN_DB_PREFIX . 'c_actioncomm cac WHERE cac.type<>\'systemauto\')';
        if ($onlyme) {
            $sql .= ' AND u.rowid=' . $this->user->id;
        }
        $sql .= ' GROUP BY u.rowid';
        $result = $this->db->query($sql);
        while ($row = $this->db->fetch_array($result)) {
            $calendars[] = $row['rowid'];
        }
        return $calendars;
    }
Example #4
0
 /**
  * Class constructor of diskspace. Gets reference for database connection.
  * Builds self::taxclasses from database values.
  *
  * @param db     Reference to database handler
  *
  * @author Former03 GmbH :: Florian Lippert <*****@*****.**>
  */
 function __construct($db)
 {
     $this->db = $db;
     $default_taxclass_result = $this->db->query_first('SELECT `classid` FROM `' . TABLE_BILLING_TAXCLASSES . '` WHERE `default` = \'1\' LIMIT 0,1');
     $this->default_taxclass = $default_taxclass_result['classid'];
     $last_taxclass_validfrom = 0;
     $taxclasses_result = $this->db->query('SELECT `taxclass`, `taxrate`, `valid_from` FROM `' . TABLE_BILLING_TAXRATES . '` ORDER BY `valid_from` ASC');
     while ($taxclasses_row = $this->db->fetch_array($taxclasses_result)) {
         if (!isset($this->taxclasses[$taxclasses_row['taxclass']]) || !is_array($this->taxclasses[$taxclasses_row['taxclass']])) {
             $this->taxclasses[$taxclasses_row['taxclass']] = array();
         }
         $this->taxclasses[$taxclasses_row['taxclass']][$taxclasses_row['valid_from']] = $taxclasses_row;
         if (isset($this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]) && is_array($this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]) && $taxclasses_row['valid_from'] != 0) {
             $this->taxclasses[$taxclasses_row['taxclass']][$last_taxclass_validfrom]['valid_to'] = $taxclasses_row['valid_from'];
         }
         $last_taxclass_validfrom = $taxclasses_row['valid_from'];
     }
 }
Example #5
0
 public function print_report()
 {
     $db = new db();
     $result = $db->query("select * from rfid order by ID desc limit 100");
     echo "<table border='1'><tr><th>ID</th><th>GUID</th><th>DATE</th></tr>";
     while ($row = $db->fetch_array($result)) {
         echo "<tr><td>" . $row['ID'] . "</td><td>" . htmlspecialchars($row['guid']) . "</td><td>" . $row['date_created'] . "</td></tr>";
     }
     echo "</table>";
 }
 /**
  * This method fills the service_detail and service_templates.
  *
  * @param array The Ids to gather details for.
  *
  * @author Former03 GmbH :: Florian Lippert <*****@*****.**>
  */
 function fetchData($userIds = array())
 {
     if (!is_array($userIds)) {
         $this->userIds = array(intval($userIds));
     } else {
         $this->userIds = $userIds;
     }
     unset($userIds);
     if (is_array($this->toInvoiceTableData) && isset($this->toInvoiceTableData['table']) && $this->toInvoiceTableData['table'] != '' && isset($this->toInvoiceTableData['keyfield']) && $this->toInvoiceTableData['keyfield'] != '' && isset($this->toInvoiceTableData['condfield']) && $this->toInvoiceTableData['condfield'] != '') {
         $toInvoiceTable_requiredFields = array($this->toInvoiceTableData['keyfield'], $this->toInvoiceTableData['condfield'], 'setup_fee', 'interval_fee', 'interval_length', 'interval_type', 'interval_payment', 'service_active', 'servicestart_date', 'serviceend_date', 'lastinvoiced_date');
         $condition = '';
         if (is_array($this->userIds) && !empty($this->userIds)) {
             $condition = ' WHERE `' . $this->toInvoiceTableData['condfield'] . '` IN ( ' . implode(', ', $this->userIds) . ' ) ';
         }
         $toInvoice_result = $this->db->query('SELECT * FROM `' . $this->toInvoiceTableData['table'] . '` ' . $condition . ' ORDER BY `servicestart_date` ASC, `serviceend_date` ASC ');
         while ($toInvoice_row = $this->db->fetch_array($toInvoice_result)) {
             $rowOk = true;
             reset($toInvoiceTable_requiredFields);
             foreach ($toInvoiceTable_requiredFields as $fieldname) {
                 if (!isset($toInvoice_row[$fieldname])) {
                     $rowOk = false;
                 }
             }
             if ($rowOk && $toInvoice_row[$this->toInvoiceTableData['keyfield']] != '') {
                 $this->service_details[$toInvoice_row[$this->toInvoiceTableData['keyfield']]] = $toInvoice_row;
             }
         }
     }
     if (is_array($this->serviceTemplateTableData) && isset($this->serviceTemplateTableData['table']) && $this->serviceTemplateTableData['table'] != '' && isset($this->serviceTemplateTableData['keyfield']) && $this->serviceTemplateTableData['keyfield'] != '') {
         $serviceTemplateTable_requiredFields = array($this->serviceTemplateTableData['keyfield'], 'setup_fee', 'interval_fee', 'interval_length', 'interval_type', 'interval_payment', 'taxclass', 'valid_from', 'valid_to');
         $serviceTemplate_result = $this->db->query('SELECT * FROM `' . $this->serviceTemplateTableData['table'] . '` ORDER BY `valid_from` ASC, `valid_to` ASC ');
         while ($serviceTemplate_row = $this->db->fetch_array($serviceTemplate_result)) {
             $rowOk = true;
             reset($serviceTemplateTable_requiredFields);
             foreach ($serviceTemplateTable_requiredFields as $fieldname) {
                 if (!isset($serviceTemplate_row[$fieldname])) {
                     $rowOk = false;
                 }
             }
             if ($rowOk && $serviceTemplate_row[$this->serviceTemplateTableData['keyfield']] != '') {
                 if (!isset($this->service_templates[$serviceTemplate_row[$this->serviceTemplateTableData['keyfield']]]) || !is_array($this->service_templates[$serviceTemplate_row[$this->serviceTemplateTableData['keyfield']]])) {
                     $this->service_templates[$serviceTemplate_row[$this->serviceTemplateTableData['keyfield']]] = array();
                 }
                 $valid = $serviceTemplate_row['valid_from'] . ':' . $serviceTemplate_row['valid_to'];
                 $this->service_templates[$serviceTemplate_row[$this->serviceTemplateTableData['keyfield']]][$valid] = $serviceTemplate_row;
             }
         }
     }
     $this->defaultvalues = array('interval_fee' => '0.00', 'interval_length' => '0', 'interval_type' => 'y', 'interval_payment' => '0', 'setup_fee' => '0.00', 'taxclass' => '0', 'service_type' => '', 'caption_setup' => '', 'caption_interval' => '');
 }
Example #7
0
function clientesFone()
{
    $db = new db("../config.php");
    $db->_DEBUG = 1;
    $json = new Services_JSON();
    $rs = $db->executa($db->getAll("clientes", "(cli_nome = '" . $_GET["cli_nome"] . "'\n  \t                                                 AND cli_foneprinc = " . $_GET["cli_fone"] . ")\n  \t                                             or (cli_nome = '" . $_GET["cli_nome"] . "' and  cli_ruaid = " . $_GET["rua_id"] . ")\n  \t                                             ", '', 0));
    if ($db->num_rows > 0) {
        while ($ln = $db->fetch_array($rs)) {
            $itens[] = array("cli_id" => $ln["cli_id"], "tem" => "S");
        }
    } else {
        $itens[] = array("tem" => "N");
    }
    $str = $json->encode($itens);
    return $str;
}
Example #8
0
 private function getAvailableColumns()
 {
     $res = db::query("\n      SELECT sc.name, sc.on_execute, sc.internal_name\n      FROM " . TBL_PREF . "submodule_columns sc\n      JOIN " . TBL_PREF . "modules m ON m.id = sc.module_id\n      JOIN " . TBL_PREF . "submodules sm ON sm.id = sc.submodule_id\n      WHERE m.internal_name = '" . db::input($this->module) . "'\n        AND sm.name = '" . db::input($this->submodule) . "'\n    ");
     $result = array();
     while ($row = db::fetch_array($res)) {
         if (isset($result[$row['internal_name']])) {
             $temp = $result[$row['internal_name']];
             unset($result[$row['internal_name']]);
             $result[$row['internal_name']][] = $temp;
             $result[$row['internal_name']][] = array('name' => $row['name'], 'handler' => $row['on_execute']);
         } else {
             $result[$row['internal_name']] = array('name' => $row['name'], 'handler' => $row['on_execute']);
         }
     }
     $this->availableColumns = $result;
 }
Example #9
0
function trazItens($cpi_id)
{
    $db = new db("../config.php");
    $db->_DEBUG = 1;
    $json = new Services_JSON();
    $rs = $db->executa($db->getAll("catprodutos_itens", "cpi_id={$cpi_id}", '', 0));
    if ($db->num_rows > 0) {
        while ($ln = $db->fetch_array($rs)) {
            $itens = array("cpi_id" => $ln["cpi_id"], "cpi_item" => urlencode($ln["cpi_item"]), "tem" => "S");
        }
    } else {
        $itens = array("tem" => "N");
    }
    $str = $json->encode($itens);
    return $str;
}
/**
 * This file is part of the SysCP project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.syscp.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**>
 * @license    GPLv2 http://files.syscp.org/misc/COPYING.txt
 * @package    Functions
 * @version    $Id$
 */
function correctMysqlUsers($mysql_access_host_array)
{
    global $db, $settings, $sql, $sql_root;
    foreach ($sql_root as $mysql_server => $mysql_server_details) {
        $db_root = new db($mysql_server_details['host'], $mysql_server_details['user'], $mysql_server_details['password'], '');
        unset($db_root->password);
        $users = array();
        $users_result = $db_root->query('SELECT * FROM `mysql`.`user`');
        while ($users_row = $db_root->fetch_array($users_result)) {
            if (!isset($users[$users_row['User']]) || !is_array($users[$users_row['User']])) {
                $users[$users_row['User']] = array('password' => $users_row['Password'], 'hosts' => array());
            }
            $users[$users_row['User']]['hosts'][] = $users_row['Host'];
        }
        $databases = array($sql['db']);
        $databases_result = $db->query('SELECT * FROM `' . TABLE_PANEL_DATABASES . '` WHERE `dbserver` = \'' . $mysql_server . '\'');
        while ($databases_row = $db->fetch_array($databases_result)) {
            $databases[] = $databases_row['databasename'];
        }
        foreach ($databases as $username) {
            if (isset($users[$username]) && is_array($users[$username]) && isset($users[$username]['hosts']) && is_array($users[$username]['hosts'])) {
                $password = $users[$username]['password'];
                foreach ($mysql_access_host_array as $mysql_access_host) {
                    $mysql_access_host = trim($mysql_access_host);
                    if (!in_array($mysql_access_host, $users[$username]['hosts'])) {
                        $db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
                        $db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = \'' . $db_root->escape($password) . '\'');
                    }
                }
                foreach ($users[$username]['hosts'] as $mysql_access_host) {
                    if (!in_array($mysql_access_host, $mysql_access_host_array)) {
                        $db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
                        $db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\\_', $db_root->escape($username)) . '` . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
                        $db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($username) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
                    }
                }
            }
        }
        $db_root->query('FLUSH PRIVILEGES');
        $db_root->close();
        unset($db_root);
    }
}
Example #11
0
 public function __construct()
 {
     $db = new db();
     $this->most_recent_object = false;
     $result = $db->query("select * from touch order by ID desc limit 100");
     $output = "";
     $output .= "<table border='1'>";
     $output .= "<tr><th>ID</th><th>X</th><th>Y</th><th>TYPE</th><th>DATE</th></tr>";
     $downs = array();
     $downs_index = 0;
     while ($row = $db->fetch_array($result)) {
         $output .= "<tr ";
         if ($row['type_percent'] == 1) {
             //type_percent 1 is "down" (as opposed to up or move which could be detected as well in the future)
             //collect the last 3
             if ($downs_index <= 2 && !$this->down_already_exists($downs, $row['x_percent'], $row['y_percent'])) {
                 $downs[$downs_index] = new stdClass();
                 $downs[$downs_index]->x = $row['x_percent'];
                 $downs[$downs_index]->y = $row['y_percent'];
                 $downs[$downs_index]->timestamp = strtotime($row['date_created']);
                 $downs_index++;
             }
             //}
         }
         $output .= "><td>" . $row['ID'] . "</td><td>" . $row['x_percent'] . "</td><td>" . $row['y_percent'] . "</td><td>" . $this->type_to_english($row['type_percent']) . "</td><td>" . $row['date_created'] . "</td></tr>";
     }
     $output .= "</table>";
     $this->output = $output;
     if (count($downs) == 3) {
         //check if timestamps are close; logic is that if an object is placed on the captouch all 3 points should be recorded in less than 1 second.   If > 1 second they are likely not related.
         if (abs($downs[0]->timestamp - $downs[1]->timestamp) <= 1 && abs($downs[2]->timestamp - $downs[1]->timestamp) <= 1) {
             $this->most_recent_object = $downs;
             $this->determine_objects_orientation();
         }
     }
 }
<?php

error_reporting(E_ALL);
$listaYear = '';
$listaComunidades = '';
include 'class.db.php';
include 'config.php';
$db = new db();
$db->connectdb($host, $user, $pass, $database);
$query = $db->query("SELECT id,comunidad FROM comunidades");
while ($data = $db->fetch_array($query)) {
    $listaComunidades .= '<option value="' . $data['id'] . '">' . $data['comunidad'] . '</option>';
}
for ($x = 2003; $x < 2009; $x++) {
    $listaYear .= '<option value="' . $x . '">' . $x . '</option>';
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <title>Comunidades Aut&oacute;nomas</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <link href="style1.css" rel="stylesheet" type="text/css" />
      <link href="formstyle.css" rel="stylesheet" type="text/css" />
      <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
      <script type="text/javascript" src="jquery.form.js"></script>
  </head>

  <body>
      <div id="main">
Example #13
0
*/
error_reporting(E_ALL);
session_name("lito");
session_start();
$sid = session_id();
setlocale(LC_ALL, array('de_DE', 'de_DE@euro', 'de', 'ger'));
define('TIMESTAMP', time());
define('LITO_ROOT_PATH', dirname(__FILE__) . '/../');
define('LITO_INCLUDES_PATH', LITO_ROOT_PATH . 'includes/');
require LITO_INCLUDES_PATH . 'config.php';
require LITO_INCLUDES_PATH . 'class_db_mysqli.php';
$db = new db($dbhost, $dbuser, $dbpassword, $dbbase);
if (isset($_SESSION['userid'])) {
    $db = new db($dbhost, $dbuser, $dbpassword, $dbbase);
    $result_id = $db->query("SELECT design_id FROM cc" . $n . "_users where userid ='" . $_SESSION['userid'] . "'");
    $row_id = $db->fetch_array($result_id);
    if (intval($row_id['design_id']) > 0) {
        $theme_1 = $db->query("SELECT `design_name` FROM `cc" . $n . "_desigs` WHERE `design_id` = '" . $row_id['design_id'] . "'");
        $row_theme = $db->fetch_array($theme_1);
        define("LITO_THEMES", $row_theme['design_name']);
    }
} else {
    define("LITO_THEMES", 'standard');
}
// e.g.  /srv/www/vhosts/freebg.de/subdomains/dev/httpdocs/
define('LITO_ROOT_PATH_URL', $litotex_url);
// e.g.  http://dev.freebg.de/
define('LITO_CACHE_PATH', LITO_ROOT_PATH . 'cache/');
// e.g.  /srv/www/vhosts/freebg.de/subdomains/dev/httpdocs/cache/
define("LITO_THEMES_PATH", LITO_ROOT_PATH . 'themes/' . LITO_THEMES . '/');
// e.g.  srv/www/vhosts/freebg.de/subdomains/dev/httpdocs/themes/standard/
Example #14
0
/*
 * RFID reader reads a tag and passes it to this script.  This writes that value to the database.
 */
require_once $_SERVER['DOCUMENT_ROOT'] . "/db.php";
header('Content-Type: application/json');
if (!isset($_POST['rfid_api_guid']) || trim($_POST['rfid_api_guid']) == "") {
    echo json_encode(array("success" => false));
    return false;
}
$db = new db();
$guid = $_POST['rfid_api_guid'];
if ($guid == "(No Tags)" || $guid == "") {
    echo json_encode(array("success" => false));
    return false;
}
if (strpos($guid, ", Disc") !== false) {
    $guid = substr($guid, 0, strpos($guid, ", Disc"));
    $guid = str_replace("Tag:", "", $guid);
    $guid = trim($guid);
    $guid = str_replace(" ", "", $guid);
    //remove spaces
}
$guid = $db->cl($guid);
//prevent duplicates; every object should have it's own unique GUID.  In the future it'd be better to move to MIT's EPC format (combining both an EPC_ID & TAG_ID allowing anti-duplication to be testing against TAG_ID and not EPC_ID therefore allowing unlimited of the same type of objects)
$result = $db->query("select * from rfid where guid = '{$guid}' limit 1");
if ($row = $db->fetch_array($result)) {
    echo json_encode(array("success" => false));
    return false;
}
$db->query("insert into rfid values(NULL,'{$guid}',NOW())");
echo json_encode(array("success" => true));
Example #15
0
    $db->query(createtable("CREATE TABLE " . UC_DBTABLEPRE . "pms_tmp (\r\n\t\t  pmid int(11) unsigned NOT NULL auto_increment,\r\n\t\t  msgfrom varchar(255) NOT NULL default '',\r\n\t\t  msgfromid int(11) unsigned NOT NULL default '0',\r\n\t\t  msgtoid int(11) unsigned NOT NULL default '0',\r\n\t\t  folder enum('inbox','outbox') NOT NULL default 'inbox',\r\n\t\t  new tinyint(1) NOT NULL default '0',\r\n\t\t  subject varchar(255) NOT NULL default '',\r\n\t\t  dateline int(11) unsigned NOT NULL default '0',\r\n\t\t  message text NOT NULL,\r\n\t\t  delstatus tinyint(1) unsigned NOT NULL default '0',\r\n\t\t  related int(11) unsigned NOT NULL default '0',\r\n\t\t  fromappid INT(11) UNSIGNED NOT NULL DEFAULT '0',\r\n\t\t  PRIMARY KEY(pmid),\r\n\t\t  KEY msgtoid(msgtoid,folder,dateline),\r\n\t\t  KEY msgfromid(msgfromid,folder,dateline),\r\n\t\t  KEY related (related),\r\n\t\t  KEY getnum (msgtoid,folder,delstatus)\r\n\t\t) TYPE=MyISAM", UC_DBCHARSET));
    $totalcount = $db->result_first("SELECT count(*) FROM " . UC_DBTABLEPRE . "pms");
    echo 'Converted the user short messages: 0.0000% ......';
    redirect('pmconvert.php?step=2&totalcount=' . $totalcount);
} elseif ($step == 2) {
    $totalcount = isset($_GET['totalcount']) ? intval($_GET['totalcount']) : 0;
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    $msgfromid = isset($_GET['msgfromid']) ? intval($_GET['msgfromid']) : 0;
    $msgtoid = isset($_GET['msgtoid']) ? intval($_GET['msgtoid']) : 0;
    $query = $db->query("SELECT * FROM " . UC_DBTABLEPRE . "pms ORDER BY msgfromid, msgtoid, dateline DESC LIMIT {$start}, {$limit}");
    if (!$db->num_rows($query)) {
        echo 'The user short message conversion is completed ...';
        redirect('pmconvert.php?step=3&totalcount=' . $totalcount);
    } else {
        $last = $db->fetch_first("SELECT * FROM " . UC_DBTABLEPRE . "pms_tmp ORDER BY pmid DESC LIMIT 1");
        while ($pm = $db->fetch_array($query)) {
            if ($pm['folder'] == 'inbox' && $pm['msgfromid'] > 0 && $pm['msgtoid'] > 0) {
                if ($msgfromid != $pm['msgfromid'] || $msgtoid != $pm['msgtoid']) {
                    insertrow($pm, 0);
                }
                if ($last['subject'] != $pm['subject'] || $last['message'] != $pm['message'] || $last['dateline'] != $pm['dateline'] || $last['msgtoid'] != $pm['msgtoid']) {
                    insertrow($pm, 1);
                }
                $msgfromid = $pm['msgfromid'];
                $msgtoid = $pm['msgtoid'];
                $last = $pm;
            } else {
                insertrow($pm, 0);
            }
        }
        $start += $limit;
Example #16
0
  		parent.comanda.location.href='ate_nitemcomanda.php?com_id='+valor
  		parent.winList["comanda"].open();
  	
  	
  }
 </script> 
</head>
<body bgcolor="#EAE5DA" oncontextmenu='return false'>
<?php 
//echo $db->getJoinRecord("comandas(=)mesas|mes_id=com_mesid","com_id=".$_GET["com_id"],'',0);
$db->executa($db->getJoinRecord("comandas(=)mesas|mes_id=com_mesid", "com_id=" . $_GET["com_id"], '', 0), true, "pro");
$form->Append("<center><h1 style='color:#96928B'>" . $db->pro["mes_nome"] . "</h1>(comanda nº" . $_GET["com_id"] . ")</center><hr>");
$rsite = $db->executa($db->getJoinRecord("comandas(=)comanda_itens|com_id=cti_comid\n                                     (=)produtos|cti_proid=pro_id", "com_id=" . $_GET["com_id"], '', 0));
$form->Append("<table width='100%' cellspacing='0'>");
$vltotal = 0;
while ($lnite = $db->fetch_array($rsite)) {
    $obs = '';
    if ($lnite["cti_obs"] != '') {
        $obs = "<br><small>(" . $lnite["cti_obs"] . ")</small>";
    }
    $form->Append("<tr><td><b style='color:#96928B'>" . $lnite["cti_qtde"] . "</b> &nbsp;" . $lnite["pro_nome"] . "{$obs}</td>\n\t                <td style='text-align:right' valign='bottom'>" . number_format($lnite["pro_preco"], 2, ",", ".") . "</td>\n\t                <td style='text-align:right' valign='bottom'>\n\t                <b style='color:blue'>" . number_format($lnite["pro_preco"] * $lnite["cti_qtde"], 2, ",", ".") . "</b></td>\t                \n\t                <td><img src='libs/imagens/delitem.png'></td></tr>");
    $sql2 = "select  cpi_valor, cpi_item from comanda_itensextra inner join catprodutos_itens on cpi_id = ext_cipid\n             where   cpi_valor is not null and ext_iteid = " . $lnite["cti_id"];
    $rs2 = $db->executa($sql2);
    $valorext = 0;
    while ($ln2 = $db->fetch_array($rs2)) {
        $form->Append("<tr><td style='text-align:left' colspan='2'><b style='color:#96928B'>&nbsp;&nbsp;+" . $ln2["cpi_item"] . "</td>\n\t                <td style='text-align:right;color:blue;font-weight:bold' valign='bottom'>" . number_format($ln2["cpi_valor"], 2, ",", ".") . "</td></tr>");
        $valorext += $ln2["cpi_valor"];
    }
    $vltotal += $lnite["pro_preco"] * $lnite["cti_qtde"] + $valorext;
}
$form->Append("<tr style=''><td colspan='2' style='text-align:right;border-top:1px outset black'><b>Total R\$</b></td>\n               <td style='text-align:right;border-top:1px outset black'>" . number_format($vltotal, 2, ",", "."));
$estornado = 0;

$diaatual = date ( 'd' );

$sql = "INSERT INTO mv_vendas_vip ( controle, data_venda, id_cliente, cad_login_id, sync_timestamp ) VALUES ( " . $_SESSION ['controlevenda'] . ", '" . date ( 'Y-m-d' ) . "', " . $idcliente . ", " . $idlogin . ", '" . $sync_timestamp . "' )";
$query = $db->query ( $sql );

$venda_vip_id = $db->insert_id ();

$lista_carrinho = $_SESSION ['carrinho_venda'];

$num_lista = 0;
foreach ( $lista_carrinho ['produto_nome'] as $key => $value ) {
	$sql = "SELECT vlcusto FROM produto WHERE idproduto=" . $key . "";
	$query = $db->query ( $sql );
	$row = $db->fetch_array ( $query );
	
	if (isset ( $lista_carrinho ['grade_nome'] [$key] )) {
		$quantidade = array_sum ( $lista_carrinho ['grade_qtd'] [$key] );
		$grade = true;
	} else {
		$quantidade = $lista_carrinho ['produto_quantidadetotal'] [$key];
		
		$sql = "INSERT INTO mv_vendas_vip_movimento (venda_vip_id, produto_idproduto, produto_quantidade, grade_id, sync_timestamp) VALUES ( {$venda_vip_id}, '{$key}', {$quantidade}, '0',{$sync_timestamp} )";
		$query = $db->query ( $sql );
		
		$grade = false;
	}
	
	$sql = "UPDATE estoque SET nquantidade=(nquantidade-" . $quantidade . "), sync_timestamp=" . $sync_timestamp . " WHERE produto_idproduto=" . $key . "";
	$query = $db->query ( $sql );
Example #18
0
require 'functions.php';
require LITO_INCLUDES_PATH . 'smarty/Smarty.class.php';
// Smarty class laden und pr�fen
if (intval($op_use_ftp_mode == 1)) {
    define("C_FTP_METHOD", '1');
}
$db = new db($dbhost, $dbuser, $dbpassword, $dbbase);
$time_start = explode(' ', substr(microtime(), 1));
$time_start = $time_start[1] + $time_start[0];
$tpl = new smarty();
$tpl->template_dir = LITO_THEMES_PATH;
$tpl->compile_dir = LITO_ROOT_PATH . 'cache/Smarty/templates_c_acp/';
$tpl->cache_dir = LITO_ROOT_PATH . 'cache/Smarty/cache_acp/';
setlocale(LC_ALL, array('de_DE', 'de_DE@euro', 'de', 'ger'));
if (isset($_SESSION['userid'])) {
    $result = $db->query("SELECT * FROM cc" . $n . "_users WHERE userid='" . $_SESSION['userid'] . "'");
    $userdata = $db->fetch_array($result);
    $tpl->assign('if_user_login', 1);
    $tpl->assign('LOGIN_USERNAME', $userdata['username']);
} else {
    $tpl->assign('if_user_login', 0);
    $tpl->assign('LOGIN_USERNAME', "unbekannt");
}
$tpl->assign('if_login_error', 0);
$tpl->assign('if_disable_menu', 0);
$tpl->assign('menu_name', '');
$tpl->assign('GAME_TITLE_TEXT', $op_set_gamename);
$tpl->assign('GLOBAL_RES1_NAME', $op_set_n_res1);
$tpl->assign('GLOBAL_RES2_NAME', $op_set_n_res2);
$tpl->assign('GLOBAL_RES3_NAME', $op_set_n_res3);
$tpl->assign('GLOBAL_RES4_NAME', $op_set_n_res4);
Example #19
0
require "libs/classes.class";
require "libs/form2.class";
require "libs/funcoes.php";
$db->_DEBUG = 1;
$db = new db();
$form = new form("", true);
if (isset($_POST["criar"])) {
    $campos = $db->getAttTable($_POST["pro_tabela"]);
    $nome_progconsulta = str_replace("_", "_c", $_POST["pro_nomeprog"]);
    $nome_progadd = $_POST["pro_nomeprog"];
    $rs = fopen("/tmp/" . $_POST["pro_nomeprog"], "w");
    fputs($rs, "<?\nrequire(\"libs/fc_sessoes.php\");\nrequire(\"libs/classes.class\");\nrequire(\"libs/form2.class\");\nrequire(\"libs/funcoes.php\");\nrequire(\"libs/class_interface.php\");\n");
    fputs($rs, "\$db   = new db();\n\n");
    fputs($rs, "if (isset(\$_POST['btncadastrar'])){\n\n");
    fputs($rs, "    \$campos = array(\n");
    while ($ln = $db->fetch_array($campos)) {
        if ($_POST["pkey"] != $ln["attname"]) {
            fputs($rs, "        \"" . $ln["attname"] . "\" => \$_POST[\"" . $ln["attname"] . "\"],\n");
        }
    }
    fputs($rs, "    );\n");
    fputs($rs, "    \$db->valida_trans(\$db->insert(\$campos,\"" . $_POST["pro_tabela"] . "\"),0);\n\n");
    fputs($rs, "}\n\n");
    fputs($rs, "if (isset(\$_POST['btnalterar'])){\n\n");
    fputs($rs, "    \$campos = array(\n");
    $db->result_seek($campos, 0);
    while ($ln = $db->fetch_array($campos)) {
        if ($_POST["pkey"] != $ln["attname"]) {
            fputs($rs, "        \"" . $ln["attname"] . "\" => \$_POST[\"" . $ln["attname"] . "\"],\n");
        }
    }
Example #20
0
$i = 0;
$j = 0;
while ($ln = pg_fetch_array($rsmod)) {
    if ($pai == $ln["pai"]) {
        echo "&nbsp;&nbsp;<input type='checkbox' id='chk" . $ln["mnu_filid"] . "' name='per_menu[]' value='" . $ln["mnu_filid"] . "'";
        echo $ln["mnu_filid"] == $ln["mnu_id"] ? "checked" : "";
        echo ">" . $ln["mnu_nome"] . "<br>\n";
        //gera o menu filho do item...
        if ($ln["mnu_arq"] == "") {
            if (isset($cbousu_id)) {
                $sqlfilho = "SELECT  p.mnu_nome as pai, f.mnu_nome,mnu_arq, mnu_filid,mnu_id,mnu_sub,mnu_paisub\n\t                             from    mnu_filho f inner join mnu_pai p on mnu_pai = mnu_paiid\n\t\t                             left outer join per_menus on mnu_id = mnu_filid and  per_usuid = {$cbousu_id}\n\t\t                     where   mnu_sub = 1 and mnu_paisub = " . $ln["mnu_filid"];
            } else {
                $sqlfilho = "select p.mnu_nome as pai,mnu_filid, f.mnu_nome,mnu_sub,mnu_paisub\n                                     from   mnu_filho f inner join mnu_pai p on\n\t                                    mnu_pai = mnu_paiid\n\t                             where  mnu_sub = 1 and mnu_paisub= " . $ln["mnu_filid"];
            }
            $rs1 = $db->executa($sqlfilho);
            while ($ln1 = $db->fetch_array($rs1)) {
                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                echo "<input type='checkbox' name='per_menu[]' value='" . $ln1["mnu_filid"] . "'";
                echo $ln1["mnu_filid"] == $ln1["mnu_id"] ? "checked" : "";
                echo ">" . $ln1["mnu_nome"] . "<br>\n";
            }
        }
    } else {
        echo "</td><td height='100%' align='center' valign=top id='col{$j}'>\n\t\t       <input type='checkbox' onclick=\"marcachk('col{$j}',this)\"><b onclick=>" . $ln["pai"] . "</b><br>\n";
        echo "&nbsp;&nbsp;<input type='checkbox' id='chk" . $ln["mnu_filid"] . "' name='per_menu[]' value='" . $ln["mnu_filid"] . "'";
        echo $ln["mnu_filid"] == $ln["mnu_id"] ? "checked" : "";
        echo ">" . $ln["mnu_nome"] . "<br>\n";
        //gera o menu filho do item...
        if ($ln["mnu_arq"] == "") {
            if (isset($cbousu_id)) {
                $sqlfilho = "SELECT  p.mnu_nome as pai, f.mnu_nome,mnu_arq, mnu_filid,mnu_id,mnu_sub,mnu_paisub\n\t                             from    mnu_filho f inner join mnu_pai p on mnu_pai = mnu_paiid\n\t\t                             left outer join per_menus on mnu_id = mnu_filid and  per_usuid = {$cbousu_id}\n\t\t                     where   mnu_sub = 1 and mnu_paisub = " . $ln["mnu_filid"];
Example #21
0
     */
    $db->query("UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET `bytes_in_used`='" . (double) $current_diskspace['all'] . "'*1024 WHERE `name` = '" . $row['loginname'] . "' OR `name` LIKE '" . $row['loginname'] . $settings['customer']['ftpprefix'] . "%'");
    /**
     * Pureftpd Quota
     */
    if ($settings['system']['ftpserver'] == "pureftpd") {
        $result_quota = $db->query("SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = '" . $row['customerid'] . "'");
        // get correct user
        if ($settings['system']['mod_fcgid'] == 1 && $row['deactivated'] == '0') {
            $user = $row['loginname'];
            $group = $row['loginname'];
        } else {
            $user = $row['guid'];
            $group = $row['guid'];
        }
        while ($row_quota = $db->fetch_array($result_quota)) {
            $quotafile = "" . $row_quota['homedir'] . ".ftpquota";
            $fh = fopen($quotafile, 'w');
            $stringdata = "0 " . $current_diskspace['all'] * 1024 . "";
            fwrite($fh, $stringdata);
            fclose($fh);
            safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($quotafile) . '');
        }
    }
}
/**
 * Admin Usage
 */
$result = $db->query("SELECT `adminid` FROM `" . TABLE_PANEL_ADMINS . "` ORDER BY `adminid` ASC");
while ($row = $db->fetch_array($result)) {
    if (isset($admin_traffic[$row['adminid']])) {
Example #22
0
 * Includes the MySQL-Connection-Class.
 */
require "{$pathtophpfiles}/lib/class_mysqldb.php";
$debugMsg[] = 'Database Class has been loaded';
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
$db_root = new db($sql['host'], $sql['root_user'], $sql['root_password'], '');
if ($db->link_id == 0 || $db_root->link_id == 0) {
    /*
     * Do not proceed further if no database connection could be established (either normal or root)
     */
    die('Cant connect to mysqlserver. Please check userdata.inc.php! Exiting...');
}
unset($sql['password']);
unset($db->password);
$result = $db->query('SELECT `settingid`, `settinggroup`, `varname`, `value` FROM `' . TABLE_PANEL_SETTINGS . '`');
while ($row = $db->fetch_array($result)) {
    $settings["{$row['settinggroup']}"]["{$row['varname']}"] = $row['value'];
}
unset($row);
unset($result);
if (!isset($settings['panel']['version']) || $settings['panel']['version'] != $version) {
    /*
     * Do not proceed further if the Database version is not the same as the script version
     */
    die('Version of File doesnt match Version of Database. Exiting...');
}
/**
 * Includes the Functions.
 */
require "{$pathtophpfiles}/lib/functions.php";
$result = $db->query('SELECT * FROM `' . TABLE_PANEL_HTACCESS . '` ');
Example #23
0
    public function show()
    {
        $progressPath = CACHE_DIR . 'progress.txt';
        $totalPath = CACHE_DIR . 'total.txt';
        $is_next = true;
        if (file_exists($progressPath) && file_exists($totalPath)) {
            $progress = file_get_contents($progressPath);
            $total = file_get_contents($totalPath);
        } else {
            file_put_contents($progressPath, 0);
            $sql = 'SELECT max(member_id) as max,min(member_id) as min FROM ' . DB_PREFIX . 'member_bind WHERE member_id != platform_id AND type =  \'m2o\' AND inuc = 0';
            $max_min = $this->db->query_first($sql);
            file_put_contents($totalPath, $max_min['max']);
            file_put_contents($progressPath, $max_min['min']);
            $progress = $max_min['min'] - 1;
            $total = $max_min['max'];
        }
        $newlegth = intval($progress + LENGTH);
        if ($newlegth > intval($total)) {
            $newlegth = $total;
            $is_next = false;
        }
        $sql = 'SELECT member_id FROM ' . DB_PREFIX . 'member_bind where ( member_id >' . $progress . ' AND member_id != platform_id AND type =  \'m2o\' AND inuc = 0) AND ( member_id <= ' . $newlegth . ' AND member_id != platform_id AND type =  \'m2o\' AND inuc = 0) order by member_id asc ';
        $query = $this->db->query($sql);
        $arr = array();
        $member_id = array();
        while ($row = $this->db->fetch_array($query)) {
            $arr[$row['member_id']] = array('member_id' => $row['member_id']);
            $member_id[] = $row['member_id'];
        }
        $source_db = array('host' => 'localhost', 'user' => 'root', 'pass' => 'hogesoft', 'database' => 'dev_member', 'charset' => 'utf8', 'pconncet' => '0', 'dbprefix' => 'm2o_');
        $sourceDB = new db();
        $sourceDB->connect($source_db['host'], $source_db['user'], $source_db['pass'], $source_db['database'], $source_db['charset'], $source_db['pconnect'], $source_db['dbprefix']);
        if (!empty($member_id)) {
            $sql = 'SELECT * FROM ' . DB_PREFIX . 'member_bound WHERE member_id IN (' . implode(',', $member_id) . ')';
            $query = $sourceDB->query($sql);
            $platform_id = array();
            while ($row = $sourceDB->fetch_array($query)) {
                $arr[$row['member_id']]['platform_id'] = $row['platform_id'];
                $platform_id[] = $row['platform_id'];
            }
            $sourceDB->close();
        }
        if ($platform_id && $this->settings['App_share']) {
            $platform_id_str = implode(',', $platform_id);
            //$access_plat_token_str .= ',d4cf3e1c11842fc401dac4785fc7cb74,4161492c9e237fc3a6a33b6420fdbb73';
            $this->curl->setSubmitType('post');
            $this->curl->initPostData();
            $this->curl->addRequestData('a', 'get_user_by_id');
            $this->curl->addRequestData('id', $platform_id_str);
            $ret = $this->curl->request('get_user.php');
            $ret = $ret[0];
        }
        if (!empty($arr)) {
            foreach ($arr as $key => $val) {
                if (!empty($ret[$val['platform_id']])) {
                    $arr[$key]['type'] = $this->plat_maps[$ret[$val['platform_id']]['plat_type']]['type'];
                    $arr[$key]['type_name'] = $this->plat_maps[$ret[$val['platform_id']]['plat_type']]['type_name'];
                    $arr[$key]['platform_id'] = $ret[$val['platform_id']]['uid'];
                } else {
                    $arr[$key]['type'] = 'm2o';
                    $arr[$key]['type_name'] = 'm2o';
                }
            }
            $source_db = array('host' => 'localhost', 'user' => 'root', 'pass' => 'hogesoft', 'database' => 'hoolo_members', 'charset' => 'utf8', 'pconncet' => '0', 'dbprefix' => 'm2o_');
            $_sourceDB = new db();
            $_sourceDB->connect($source_db['host'], $source_db['user'], $source_db['pass'], $source_db['database'], $source_db['charset'], $source_db['pconnect'], $source_db['dbprefix']);
            foreach ($arr as $key => $val) {
                if ($val['platform_id']) {
                    $sql = 'UPDATE ' . DB_PREFIX . 'member SET type=\'' . $val['type'] . '\',type_name = \'' . $val['type_name'] . '\' WHERE member_id = ' . $val['member_id'];
                    $_sourceDB->query($sql);
                    $sql = 'UPDATE ' . DB_PREFIX . 'member_bind SET
					platform_id = \'' . $val['platform_id'] . '\',type=\'' . $val['type'] . '\',type_name = \'' . $val['type_name'] . '\' WHERE member_id = ' . $val['member_id'];
                    $_sourceDB->query($sql);
                } else {
                    echo "数据修复出错";
                    exit;
                }
            }
            $_sourceDB->close();
            file_put_contents($progressPath, $newlegth);
            if ($is_next) {
                $percent = round(intval($newlegth) / intval($total) * 100, 2) . "%";
                echo $message = '系统正在修复数据,别打扰唉...' . $percent;
                $this->redirect('membersDataRecovery.php');
            }
            echo "数据修复完成";
            exit;
        } else {
            echo "已经修复完成,请勿重复修复数据";
        }
        exit;
    }
Example #24
0
             echo "<script>alert('Database backup was successful!');location.href='save_data.php?action=export';</script>";
         }
         exit;
     } else {
         $size = $bktables = $bkresults = $results = array();
         $k = 0;
         $totalsize = 0;
         $query = $db->query("SHOW TABLES FROM " . $dbname);
         while ($r = $db->fetch_row($query)) {
             $tables[$k] = $r[0];
             $count = $db->get_one("SELECT count(*) as number FROM {$r['0']} WHERE 1");
             $results[$k] = $count['number'];
             $bktables[$k] = $r[0];
             $bkresults[$k] = $count['number'];
             $q = $db->query("SHOW TABLE STATUS FROM `" . $dbname . "` LIKE '" . $r[0] . "'");
             $s = $db->fetch_array($q);
             $size[$k] = round($s['Data_length'] / 1024 / 1024, 2);
             $totalsize += $size[$k];
             $k++;
         }
         include template('export');
     }
     break;
 case 'import':
     if (@$dosubmit) {
         if ($filename && fileext($filename) == 'sql') {
             $filepath = './data/' . $filename;
             if (!file_exists($filepath)) {
                 message("对不起, {$filepath} 不存在");
             }
             $sql = file_get_contents($filepath);
Example #25
0
$form->Append("<input type='hidden' value='" . $comanda . "' name='com_id'>");
$form->Append("<input type='hidden' value='" . $gravado . "' name='gravado'>");
$form->AbreCelula("Item");
$form->FrmInput("", "cti_proid", 8, 7, "Código do item", '', $_POST["cti_proid"], 'onBlur="document.form1.submit()"', 0);
if ($_POST["cti_proid"] != '') {
    $db->executa($db->getAll("produtos", "pro_id=" . $_POST["cti_proid"], '', 0), true, 'pro');
    if ($db->num_rows > 0) {
        $hab1 = 1;
        $form->Append("&nbsp;&nbsp;<span style='color:blue;font-size:12pt;font-weight:bold'>" . $db->pro["pro_nome"] . "</span></td>");
        $rs = $db->executa($db->getAll("produtos_itens", "ite_proid=" . $db->pro["pro_id"], '', 0));
        $form->FechaCelula();
        $form->linha(false, true);
        $form->Append("<td>&nbsp;</td><td colspan='10'>");
        $form->Append("<table><tr><td valign='top'>");
        $j = 1;
        while ($ln = $db->fetch_array($rs)) {
            if ($j == 5) {
                $form->Append("</td><td valign='top'>");
                $j = 1;
            }
            $form->Append("<input type='checkbox' name='itens[]' id='item" . $ln["ite_id"] . "' value='" . $ln["ite_produto"] . "'>\n\t  \t              <label for='item" . $ln["ite_id"] . "'><b>" . $ln["ite_produto"] . "</b></label><br>");
            $j++;
        }
        $rs = $db->executa($db->getall("catprodutos_itens", "cpi_catid=" . $db->pro["pro_catid"], '', 0));
        //$form->AbreCelula("");
        $j = 0;
        $form->Append("</td></tr><tr><td valign='top'><hr></td></tr><tr><td valign='top'>");
        while ($ln = $db->fetch_array($rs)) {
            if ($j == 5) {
                $form->Append("</td><td valign='top'>");
                $j = 1;
Example #26
0
 } else {
     $tmp = explode(',', $str);
     $perpage = intval(trim($tmp[1]));
     $qid = $DB->query($db_sql);
     $total = $DB->query_first('select found_rows() as total');
     if ($total['total'] > $perpage) {
         $total['total'] = $perpage;
     }
 }
 $total = $total['total'];
 //计算分页
 $page_link = array('totalpages' => $total, 'curpage' => intval($pp), 'perpage' => $perpage, 'pagelink' => '?sql=' . urlencode($_REQUEST['sql']) . '&server=' . $db_choice);
 $p_links = hg_build_pagelinks($page_link);
 $results = array();
 $result_tbl = '<table>';
 while (false != ($r = $DB->fetch_array($qid))) {
     $results = array_keys($r);
     $result_tbl1 .= '<tr onmouseover="javascript:this.style.background=\'#D3DFEB\';" onmouseout="this.style.background=\'#fff\';">';
     foreach ($r as $k => $v) {
         $result_tbl1 .= '<td>' . $v . '</td>';
     }
     $result_tbl1 .= '</tr>';
 }
 $result_tbl_th = '<tr class="result_title">';
 foreach ($results as $vv) {
     $result_tbl_th .= '<th>' . $vv . '</th>';
 }
 $result_tbl_th .= '</tr>';
 $result_tbl .= $result_tbl_th . $result_tbl1;
 $result_tbl .= '</table>';
 echo $db_sql;
Example #27
0
EOT;
$extend = <<<EOT
ALTER TABLE ask_answer DROP tag;
EOT;
if (!$action) {
    echo '<meta http-equiv=Content-Type content="text/html;charset=' . TIPASK_CHARSET . '">';
    echo "本程序仅用于升级 Tipask2.5beta 到 Tipask2.5正式版,请确认之前已经顺利安装Tipask2.5beta版本!<br><br><br>";
    echo "<b><font color=\"red\">运行本升级程序之前,请确认已经上传 Tipask2.5正式版的全部文件和目录</font></b><br><br>";
    echo "<b><font color=\"red\">本程序只能从Tipask2.5beta版到 Tipask2.5正式版,切勿使用本程序从其他版本升级,否则可能会破坏掉数据库资料.<br><br>强烈建议您升级之前备份数据库资料!</font></b><br><br>";
    echo "正确的升级方法为:<br>1. 上传 Tipask2.5正式版的全部文件和目录,覆盖服务器上的Tipask2.5beta版;<br>2. 上传本程序(2.5betato2.5.php)到 Tipask目录中;<br>3. 运行本程序,直到出现升级完成的提示;<br>4. 登录Tipask后台,更新缓存,升级完成。<br><br>";
    echo "<a href=\"{$PHP_SELF}?action=upgrade\">如果您已确认完成上面的步骤,请点这里升级</a>";
} else {
    $db = new db(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_CHARSET, DB_CONNECT);
    runquery($upgrade);
    $query = $db->query("SELECT * FROM " . DB_TABLEPRE . "answer WHERE tag<>''");
    while ($answer = $db->fetch_array($query)) {
        $question = $db->fetch_first("SELECT * FROM " . DB_TABLEPRE . "question WHERE `id`=" . $answer['qid']);
        $taglist = tstripslashes(unserialize($answer['tag']));
        $stime = $answer['time'];
        foreach ($taglist as $index => $tag) {
            $stime += rand(60, 7200);
            $tag = '<p>' . strip_tags($tag) . '</p>';
            if ($index % 2 == 0) {
                $db->query("INSERT INTO " . DB_TABLEPRE . "answer_append(appendanswerid,answerid,author,authorid,content,time) VALUES (NULL," . $answer['id'] . ",'" . $question['author'] . "'," . $question['authorid'] . ",'{$tag}',{$stime})");
            } else {
                $db->query("INSERT INTO " . DB_TABLEPRE . "answer_append(appendanswerid,answerid,author,authorid,content,time) VALUES (NULL," . $answer['id'] . ",'" . $answer['author'] . "'," . $answer['authorid'] . ",'{$tag}',{$stime})");
            }
        }
    }
    runquery($extend);
    $config = "<?php \r\ndefine('DB_HOST',  '" . DB_HOST . "');\r\n";
Example #28
0
 public function migration($config)
 {
     //hg_pre($config);exit();
     //关闭原数据库连接
     if (!class_exists('pdo')) {
         return false;
     }
     $dsn = $config['dbtype'] . ':' . 'host=' . $config['dbinfo']['host'] . ':' . $config['dbinfo']['port'] . ';dbname=' . $config['dbinfo']['database'];
     //检测数据库连接状态
     try {
         $this->pdolink = new PDO($dsn, $config['dbinfo']['user'], $config['dbinfo']['pass']);
     } catch (PDOException $e) {
         return false;
     }
     //设置编码
     $this->pdolink->query('set names ' . $config['dbinfo']['charset']);
     //检测是否有数据更新
     if (!$config['sql']) {
         return false;
     }
     $sql = $config['sql'] . ' WHERE 1 AND ' . $config['sqlprimarykey'] . '>' . $config['offset'];
     $query = $this->pdolink->prepare($sql);
     $query->execute();
     $fetchrow = $query->fetch(PDO::FETCH_ASSOC);
     if (!$fetchrow) {
         //数据全部导入完毕
         $this->_importstatus($config['id'], 2);
         return false;
     }
     $num = $config['offset'] . '+' . $config['count'];
     $sql = $config['sql'] . ' WHERE 1 AND ' . $config['sqlprimarykey'] . '>' . $config['offset'] . ' AND ' . $config['sqlprimarykey'] . '<=' . $num;
     $query = $this->pdolink->prepare($sql);
     $query->execute();
     $arr = array();
     //前置关系数据处理
     $beforeimportfield = array();
     $beforeimportrelation = array();
     if ($config['relyonids']) {
         $beforeimport = $config['beforeimport'];
         if ($beforeimport && is_array($beforeimport)) {
             foreach ($beforeimport as $key => $val) {
                 $beforeimportfield[] = $val['field'];
                 $beforeimportrelation[$val['field']] = $val;
                 //将关联字段做键值
             }
         }
     }
     //hg_pre($beforeimportfield);exit();
     //hg_pre($beforeimportrelation);exit();
     $beforeimportfield = array_filter($beforeimportfield);
     //过滤空值
     $search = array();
     while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
         if ($config['datadeal']) {
             eval($config['datadeal']);
         }
         if (!empty($beforeimportfield)) {
             foreach ($beforeimportfield as $field) {
                 if ($row[$field]) {
                     $search[$beforeimportrelation[$field]['id']][] = $row[$field];
                 }
             }
         }
         $arr[$row[$config['primarykey']]] = $row;
     }
     //hg_pre($search);exit();
     //hg_pre($arr);exit();
     //验证是否全部导入完成
     $sql = $config['sql'] . ' WHERE 1 AND ' . $config['sqlprimarykey'] . '>' . $num;
     $query = $this->pdolink->prepare($sql);
     $query->execute();
     $fetchrow = $query->fetch(PDO::FETCH_ASSOC);
     //hg_pre($config);exit();
     if (!$fetchrow) {
         //数据全部导入完毕
         $this->_importstatus($config['id'], 2);
     } else {
         $this->_importstatus($config['id'], 1);
     }
     //查询转发数据关系
     $source = new db();
     $source->connect($this->db->dbhost, $this->db->dbuser, $this->db->dbpw, $this->db->dbname);
     $sqlcondition = '';
     //hg_pre($search);exit();
     foreach ($search as $key => $val) {
         if (is_array($val) && !empty($val)) {
             $temp = implode(',', $val);
             $sqlcondition .= ' AND ( sid = ' . $key . ' AND  cid IN (' . $temp . '))';
         }
     }
     //hg_pre($sqlcondition);exit();
     $sqlcondition = $sqlcondition ? $sqlcondition : ' AND id = -1';
     //当不满足条件时,将条件置空
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'data_relation WHERE 1 ' . $sqlcondition;
     $query = $source->query($sql);
     $r = array();
     while ($row = $source->fetch_array($query)) {
         if (!$row['rid']) {
             if ($beforeimport[$row['sid']]['default']) {
                 $row['rid'] = $beforeimport[$row['sid']]['default'];
             }
         }
         $r[$row['sid']][$row['cid']] = $row['rid'];
     }
     //hg_pre($config['paras']);exit();
     //未配置转发关系的,直接推出
     if (empty($config['paras']) || !$config['paras']) {
         return false;
     }
     $newData = array();
     $mapDataKeys = array_keys($beforeimportrelation);
     foreach ($arr as $row => $rowdata) {
         if ($config['paras'] && is_array($config['paras'])) {
             foreach ($config['paras'] as $key => $val) {
                 //将配置字段进行匹配转换
                 /*
                 if (is_string($rowdata[$val]))
                 {
                 	$tmp = explode(',', $rowdata[$val]);
                 	foreach ($tmp as $kk=>$vv)
                 	{
                 		$tmp[$kk] = $r[$beforeimportrelation[$vv]['id']][$row];
                 	}
                 	$rowdata[$val] = implode(',', $tmp);
                 }
                 else 
                 {
                 	$rowdata[$val] = $r[$beforeimportrelation[$val]['id']][$row];
                 }
                 */
                 //hg_pre($rowdata);exit();
                 //$rowdata[$val] = $r[$beforeimportrelation[$val]['id']][$row];
                 $relationValue = $r[$beforeimportrelation[$val]['id']][$row];
                 //没有转发关系,则认为没有前置导入
                 $rowdata[$val] = $relationValue ? $relationValue : $rowdata[$val];
                 $newData[$row][$key] = $rowdata[$val];
             }
             //匹配出错直接清空
             $tmp = $newData[$row];
             $tmp = array_filter($tmp);
             if (empty($tmp)) {
                 unset($newData[$row]);
             } else {
                 $newData[$row]['dataplat_id'] = $row;
             }
         }
     }
     //hg_pre($newData);exit();
     //数据导入
     if (!$config['apiurl'] || empty($config['apiurl'])) {
         return false;
     }
     $res = $this->_forward($config['apiurl'], $newData);
     return $res;
 }
 @(include 'class.db.php') or die('db class no encontrada');
 @(include 'config.php') or die('archivo configuración no encontrado');
 $db = new db();
 $db->connectdb($host, $user, $pass, $database);
 /*****/
 if (isset($_POST['year']) && $_POST['year'] != '') {
     /****************
     			Esterilizar los datos
     			***************/
     $yearSeguro = (int) $_POST['year'];
     /*************/
     $query = $db->query("SELECT * FROM comunidades WHERE id = '{$comunidadSeguro}'");
     if (mysql_num_rows($query) != 1) {
         echo 'No se ha encontrado informaci&oacute;n. Por favor, vuelva al formulario.';
     } else {
         $d = $db->fetch_array($query);
         echo '<h3>' . $yearSeguro . ' poblaci&oacute;n para ' . $d['comunidad'] . '</h3>';
         echo '<p>' . $d[$yearSeguro] . '</p>';
     }
     //rows == 1
 } else {
     //Mostrar todos los años de una comunidad
     $query = $db->query("SELECT * FROM comunidades WHERE id = '{$comunidadSeguro}'");
     if (mysql_num_rows($query) != 1) {
         echo 'No se ha encontrado informaci&oacute;n. Por favor, vuelva al formulario.';
     } else {
         $d = $db->fetch_array($query);
         echo '<h3>Poblaci&oacute;n de todos los a&ntilde;os para ' . $d['comunidad'] . '</h3>';
         for ($x = 2003; $x < 2009; $x++) {
             echo '<p>' . $x . ' &raquo; ' . $d[$x] . '</p>';
         }
function tmpr_view_main($params)
{
    $ret = '';
    $use_diff = false;
    $r = array();
    if ($diff = timezone_diff_get($params)) {
        $use_diff = true;
        $diff = timezone_diff_get($params);
    }
    $db = new db();
    $db->query('select hour_id, time, hour, data, unix_timestamp(ts) from measure_tmpr_hourly order by hour_id desc limit 72');
    $ret = $db->results();
    foreach ($ret as $d) {
        $ts = $d['unix_timestamp(ts)'];
        # update old data entries
        if ($d['unix_timestamp(ts)'] == 0) {
            $ts = strtotime($d['time'] . ' ' . $d['hour'] . ':00:00');
            $date = $d['time'] . ' ' . $d['hour'] . ':00:00';
            $db->query('update measure_tmpr_hourly set ts = "' . $date . '" where hour_id = ' . $d['hour_id']);
        }
        if ($use_diff) {
            $ts = $diff['prefix'] == '-' ? $ts - $diff['diff'] : $ts + $diff['diff'];
        }
        $r[][$ts . '000']['data'] = $d['data'];
        //$r[@date( 'Y-m-d', $ts )][@date( 'G', $ts )]['data'] = $d['data'];
        //ksort($r[@date( 'Y-m-d', $ts )]);
        #$r .= '['.$ts.','.$d['data'].'],';
    }
    header('Content-Type: application/json');
    print json_encode($r);
    return true;
    while ($d = $db->fetch_array($query)) {
        $r[@date('Y-m-d', $date)][@date('G', $date)]['data'] = $d['data'];
        ksort($r[@date('Y-m-d', $date)]);
    }
    print json_encode($r);
    return true;
}