Example #1
1
            }
        }
    }
    header('Location: admin.php');
}
function add_database($db)
{
    if ($fd = fopen('../private/bde.csv', 'a+')) {
        foreach ($_POST as &$value) {
            $value = htmlspecialchars($value);
        }
        if (!isset($db[$_POST['id']]) && flock($fd, LOCK_EX | LOCK_NB)) {
            fputcsv($fd, create_dbo($_POST['location'], $_POST['name'], $_POST['categories'], $_POST['price'], $_POST['description'], $_POST['id']), ';');
            flock($fd, LOCK_UN);
        } else {
            $new = create_dbo($_POST['location'], $_POST['name'], $_POST['categories'], $_POST['price'], $_POST['description'], $_POST['id']);
            modify_item($db, $new, $_POST['id']);
        }
        fclose($fd);
    }
    header('Location: admin.php');
}
if (isset($_POST['submit'])) {
    if ($_POST['submit'] == 'add_db') {
        add_database(get_database());
    } else {
        if ($_POST['submit'] == 'del_db') {
            del_id(get_database(), $_POST['id']);
        }
    }
}
Example #2
0
function select_session($player)
{
    $session = get_database();
    if (isset($session[$player])) {
        return $session[$player];
    }
}
function get_membre($id, $database = false)
{
    if (!$database) {
        $database = get_database();
    }
    if ($id > count($database)) {
        return false;
    } else {
        return $database[$id];
    }
}
Example #4
0
function categorie_list()
{
    $list = array();
    $db = get_database();
    $list[] = "all";
    foreach ($db as $obj) {
        $cats = array_filter(explode(' ', $obj['categories']));
        foreach ($cats as $c) {
            if (!in_array($c, $list)) {
                array_push($list, $c);
            }
        }
    }
    return $list;
}
Example #5
0
function add_cart_obj($id, $nb)
{
    $obj = get_database();
    if (!isset($_SESSION['cart'])) {
        $_SESSION['cart'] = array();
    }
    if (isset($obj[$id])) {
        $obj = $obj[$id];
        if (isset($_SESSION['cart'][$obj['name']])) {
            echo "adasdasdas\n";
            $_SESSION['cart'][$obj['name']]['nb'] += $nb;
        } else {
            $_SESSION['cart'][$obj['name']] = $obj;
            $_SESSION['cart'][$obj['name']]['nb'] = $nb;
        }
    }
    header("Location: shop.php");
}
Example #6
0
/**
 * Returns configuration errors
 * @param array $config
 * @return array 
 */
function find_configuration_errors($config)
{
    // create ruleset
    $v = new Validation();
    //$v->addRule('base_url', Validation::NOT_EMPTY, 'Base URL must not be empty');
    //$v->addRule('base_url', Validation::URL, 'Base URL must be a valid URL');
    $v->addRule('db.host', Validation::NOT_EMPTY, 'Database Host must not be empty');
    $v->addRule('db.host', Validation::STRING, 'Database Host must be a string');
    $v->addRule('db.name', Validation::NOT_EMPTY, 'Database Name must not be empty');
    $v->addRule('db.name', Validation::STRING, 'Database Name must be a string');
    $v->addRule('db.username', Validation::NOT_EMPTY, 'Database Username must not be empty');
    $v->addRule('db.username', Validation::STRING, 'Database Username must be a string');
    //$v->addRule('db.password', Validation::NOT_EMPTY, 'Database Password must not be empty');
    $v->addRule('db.password', Validation::STRING, 'Database Password must be a string');
    $v->addRule('user.name', Validation::NOT_EMPTY, 'User Name must not be empty');
    $v->addRule('user.name', Validation::STRING, 'User Name must be a string');
    $v->addRule('user.email', Validation::NOT_EMPTY, 'E-mail must not be empty');
    $v->addRule('user.email', Validation::STRING, 'E-mail must be a string');
    $v->addRule('user.email', Validation::EMAIL, 'E-mail must be a valid e-mail address');
    $v->addRule('user.address1', Validation::STRING, 'Address 1 must be a string');
    $v->addRule('user.address2', Validation::STRING, 'Address 2 must be a string');
    $v->addRule('user.city', Validation::STRING, 'City must be a string');
    $v->addRule('user.state', Validation::STRING, 'State/Province must be a string');
    $v->addRule('user.zip', Validation::STRING, 'Postal Code must be a string');
    $v->addRule('user.country', Validation::STRING, 'Country must be a string');
    $v->addRule('default_invoice_theme', Validation::STRING, 'Default Invoice Theme must be a string');
    $v->addRule('default_receipt_theme', Validation::STRING, 'Default Receipt Theme must be a string');
    $v->addRule('default_wage', Validation::NUMERIC, 'Default Wage must be a decimal number');
    // get errors
    $errors = $v->validateList(Set::flatten($config));
    // test database connnection
    try {
        get_database($config);
    } catch (Exception $e) {
        $errors[] = 'Could not connect to database with the given database information';
    }
    // return
    return Set::flatten($errors);
}
Example #7
0
?>
		<div class="container">
	        <div class="row">
				<div class="col-md-12">
					<div class="col-md-6" style="margin:0 auto;">
					<h2> Hospital Management </h2>
        <?php 
if (!isset($_REQUEST["step"]) && !isset($_GET["auto"])) {
    /** Step 1 */
    // Check if application is installled or not
    if (is_installed()) {
        /** Check the version */
        $server = get_server();
        $username = get_username();
        $password = get_password();
        $database = get_database();
        $dbprefix = get_dbprefix();
        // Connect to Server
        $conn = new Database();
        echo $conn->Connection($server, $username, $password);
        $con = $conn->get_Connection();
        // Select Database
        mysql_select_db($database, $con);
        if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $dbprefix . "version'")) == 1) {
            $sql = "Select current_version from " . $dbprefix . "version;";
            $result = mysql_query($sql, $con);
            if (!$result) {
                $current_version = '0.0.1';
            } else {
                $row = mysql_fetch_assoc($result);
                $current_version = $row['current_version'];
Example #8
0
<?php

require_once __DIR__ . "/inc/header.php";
$db = get_database();
$sql = "SELECT\n            `Person`.`first_name`,\n            `Person`.`last_name`,\n            `Person`.`email`,\n            `CabinetMember`.`position`\n        FROM\n            `CabinetMember`\n                LEFT JOIN `Person` ON\n                    `CabinetMember`.`username` = `Person`.`username`\n        ORDER BY\n            `CabinetMember`.`rank` ASC,\n            `Person`.`last_name` ASC,\n            `Person`.`first_name` ASC";
$cabinet_result = $db->query($sql);
?>
<div class="row">
    <div class="col-xs-offset-2 col-xs-8">
        <table class="table table-hover table-striped">
            <thead>
                <tr>
                    <th>Position</th>
                    <th>Name</th>
                    <th>Email</th>
                </tr>
            </thead>
            <tbody>
                <?php 
while ($cabinet_row = $cabinet_result->fetch_assoc()) {
    ?>
                    <tr>
                        <td><?php 
    echo $cabinet_row["position"];
    ?>
</td>
                        <td><?php 
    echo $cabinet_row["first_name"];
    ?>
 <?php 
    echo $cabinet_row["last_name"];
Example #9
0
function get_collection($collection)
{
    $db = get_database(OPENSHIFT_DB);
    return $db->{$collection};
}
<?php

include 'database_utlities.php';
$link = get_database();
$card_db = json_decode(file_get_contents('AllSets.json'), true);
$set_key = "";
$test = 0;
/*
 * Iterating through the whole JSON array
 * preg_replacing all set keys 
 */
foreach ($card_db as $set_key => $field) {
    echo '<pre>';
    echo "entered the set loop ";
    echo $test;
    echo '</pre>';
    try {
        /*
         * Iterating through the sets 
         * and setting the values
         */
        // Define any arrays
        $booster = array();
        $set_name = set_val($field['name'], true);
        $set_code = set_val($field['code'], true);
        $gatherer_code = set_val($field['gathererCode'], true);
        $magic_cards_info_code = set_val($field['magicCardsInfoCode'], true);
        $release_date = set_val($field['releaseDate'], true);
        $border = set_val($field['border'], true);
        $type = set_val($field['type'], true);
        $booster = set_array($field['booster'], true);
Example #11
0
function display_id()
{
    $list = get_database();
    foreach ($list as $ob) {
        print '<option value="' . $ob['id'] . '">' . $ob['name'] . '</option>';
    }
}
Example #12
0
function ucd_shortcode()
{
    ob_start();
    get_database();
    return ob_get_clean();
}
    $url = "http://bp.vin-info.com/api2/q/" . $function . "/license:" . $license . "/apiuid:" . $apiuid . "/checksum:" . $check_sum . "/vin:" . $VIN;
    $curl_handle = curl_init();
    curl_setopt($curl_handle, CURLOPT_URL, $url);
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
    $res = curl_exec($curl_handle);
    curl_close($curl_handle);
    //var_dump(curl_error($curl_handle));
    //echo $res.'<br>';
    return $res;
}
//----------------------primim info despre toate,salvam in var, apoi inkidem load si afisam-------------------
if (isset($_POST['vin'])) {
    ini_set("display_errors", 1);
    if (!get_database($_POST['vin'])) {
        $damage = check("checkDamagesForVin", $_POST['vin']);
        $history = check("checkVinHistory", $_POST['vin']);
        $decoder = check("checkVinDecoder", $_POST['vin']);
        $data = check("checkDataForVinNl", $_POST['vin']);
        $photos = check("checkVinPhotos", $_POST['vin']);
        $checkDamagesForVin = json_decode($damage, true);
        $checkVinHistory = json_decode($history, true);
        $checkVinDecoder = json_decode($decoder, true);
        $checkDataForVinNl = json_decode($data, true);
        $checkVinPhotos = json_decode($photos, true);
        $insert_values = $damage . ';' . $history . ';' . $decoder . ';' . $data . ';' . $photos;
        $insert_into_database = mysql_query("INSERT INTO `vin_database`(`vin`,`values`,`type`,`date`)VALUES('{$_POST['vin']}','{$insert_values}','EU','{$date}')");
        if (!$insert_into_database) {
            exit(mysql_error());
        }
Example #14
0
function action_chat()
{
    $user_id = $_SESSION['user_id'];
    $smarty = get_smarty();
    $ecs = get_ecs();
    $db = get_database();
    /**
     * 判断当前用户是为聊天系统的注册用户
     */
    $exist = check_of_username_exist($user_id);
    // 获取用户头像
    if (!empty($user_id)) {
        $sql = "select password, headimg from " . $ecs->table('users') . " where user_id = '{$user_id}'";
        $row = $db->getRow($sql);
        $headimg = $row['headimg'];
        $password = $row['password'];
        $smarty->assign('headimg', $headimg);
    }
    if (!$exist) {
        // 查询ECShop内用户信息
        $sql = 'select a.user_id, a.password, a.email, a.user_name from ' . $ecs->table('users') . ' AS a where a.user_id = "' . $user_id . '"';
        $user = $GLOBALS['db']->getRow($sql);
        if (empty($user)) {
            // 根据user_id未查找到任何用户信息
        }
        // 用户不存在,创建用户信息
        $username = $user_id;
        $password = $user['password'];
        $name = $user['user_name'];
        $email = $user['email'];
        $type = 10;
        $shop_id = -1;
        $result = create_of_user($username, $password, $name, $email, $type, $shop_id);
        if ($result) {
            // 创建成功
        } else {
            // 创建失败
        }
    }
    // 获取前端传来的商品编号、订单编号、店铺编号等
    // 商品编号则显示商品信息
    // 订单编号则显示订单信息
    // 店铺编号则显示店铺信息
    $goods_id = null;
    $supp_id = -1;
    $order_id = null;
    $customers = null;
    // 获取客服信息
    $tab_items = array();
    // 客服类型
    $cus_types = CUSTOMER_SERVICE;
    // 记录需要发给客服的URL
    if (!empty($_REQUEST['chat_goods_id'])) {
        /* 咨询商品信息 */
        $goods_id = $_REQUEST['chat_goods_id'];
        $goods = goods_info($goods_id);
        $smarty->assign('chat_goods', $goods);
        $smarty->assign('chat_goods_id', $goods_id);
        // 获取店铺信息
        $supp_id = null;
        $tab_items[] = array("id" => "chat_goods", "name" => "咨询商品");
        // 客服+售前
        $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE;
    }
    if (!empty($_REQUEST['chat_supp_id'])) {
        /* 店铺信息 */
        $supp_id = $_REQUEST['chat_supp_id'];
        $supp_info = get_dianpu_baseinfo($supp_id);
        $smarty->assign('supp_info', $supp_info);
        $smarty->assign('chat_supp_id', $supp_id);
        $tab_items[] = array("id" => "chat_supp", "name" => "店铺信息");
        // 客服+售前
        $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE;
    }
    if (!empty($_REQUEST['chat_order_id'])) {
        /* 咨询订单信息 */
        require 'includes/lib_order.php';
        $order_id = $_REQUEST['chat_order_id'];
        // 获取商品和店铺信息
        $goods_id = null;
        $supp_id = null;
        $order = order_info($order_id);
        $order['order_status_text'] = $GLOBALS['_LANG']['os'][$order['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$order['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$order['shipping_status']];
        $order['goods_list'] = order_goods($order_id);
        $smarty->assign('chat_order', $order);
        $smarty->assign('chat_order_id', $order_id);
        $smarty->assign('chat_order_sn', $order['order_sn']);
        $tab_items[] = array("id" => "chat_order", "name" => "咨询订单");
        // 客服+售后
        $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_AFTER;
    }
    if (true) {
        /* 最近订单列表 */
        require 'includes/lib_transaction_1.php';
        // 获取用户最近的5条订单列表
        $order_list = get_user_orders_1($user_id, 5, 0);
        // 所有客服忙碌状态,提示web端
        $smarty->assign('order_list', $order_list);
        $smarty->assign('order_count', count($order_list));
        $tab_items[] = array("id" => "chat_order_list", "name" => "最近订单");
        // 客服
        $cus_types = CUSTOMER_SERVICE;
    }
    // 获取客服信息
    $customers = get_customers($cus_types, $supp_id);
    // 转换为JSON数据
    $smarty->assign('tab_items', json_encode($tab_items));
    $to = null;
    // 客服获取策略:0-顺序、1-随机、2-竞争
    if (!empty($customers)) {
        // 暂时采用随机策略
        $poliy = 1;
        if ($poliy == 0) {
            foreach ($customers as $customer) {
                $status = $customer['status'];
                if ($status == '在线' || $status == '空闲') {
                    $to = $customer;
                    break;
                    // 					if(isset($customer['cus_status']) && count($customers) > 1)
                    // 					{
                    // 						if(time() - $customer['chat_time'] > 5*60)
                    // 						{
                    // 							set_customer_status($customer['cus_id'], 0);
                    // 							$customer['cus_status'] = 0;
                    // 						}
                    // 						if($customer['cus_status'] == 0)
                    // 						{
                    // 							$to = $customer;
                    // 							break;
                    // 						}
                    // 					}
                    // 					else
                    // 					{
                    // 						$to = $customer;
                    // 						break;
                    // 					}
                }
            }
        } else {
            if ($poliy == 1) {
                /* 随进策略 */
                $onlines = array();
                foreach ($customers as $customer) {
                    $status = $customer['status'];
                    if ($status == '在线' || $status == '空闲') {
                        $onlines[] = $customer;
                    }
                }
                if (count($onlines) > 0) {
                    $min = 1;
                    $max = count($onlines);
                    $i = mt_rand($min, $max);
                    $to = $onlines[$i - 1];
                }
            } else {
            }
        }
        if (empty($to)) {
            if ($supp_id == -1) {
                // 所有客服忙碌状态,提示web端
                $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!');
            } else {
                // 所有客服忙碌状态,提示web端
                $smarty->assign('system_notice', '当前店铺客服忙碌,请稍后联系!');
            }
        } else {
            $xmpp_domain = get_xmpp_domain();
            $_SESSION['OF_FROM'] = $user_id . '@' . $xmpp_domain;
            $_SESSION['OF_TO'] = $to['of_username'] . '@' . $xmpp_domain;
            $smarty->assign('from', $_SESSION['OF_FROM']);
            $smarty->assign('password', $password);
            // $smarty->assign('password', "123456");
            $smarty->assign('to', '==to==');
            $smarty->assign('username', $_SESSION['user_name']);
            $smarty->assign('customername', $to['cus_name']);
            // 存储在Session中方便其他地方使用
            // 所有客服忙碌状态,提示web端
            $smarty->assign('system_notice', '客服<span class="kf_name">' . $to['cus_name'] . '</span>已加入会话!');
        }
    } else {
        // 所有客服忙碌状态,提示web端
        $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!');
    }
    // 打开聊天页面
    $smarty->display('chat.dwt');
}
Example #15
0
function do_houseclean()
{
    /* this is a *very* inefficient method, but it's needed... */
    //header("Content-Type: text/xml; charset=UTF-8");
    header("Content-type: multipart/x-mixed-replace;boundary=--ThisRandomString");
    global $metadata_dir;
    echo "--ThisRandomString\n";
    $out = "Content-type: text/html\n\n" . "<html><head><title>Housecleaning</title></head><body>\n" . "<p>Performing housecleaning, please wait...</p>\n";
    echo "{$out}--ThisRandomString\n";
    ob_end_flush();
    flush();
    set_time_limit(300);
    // this might take a while, but
    // shouldn't be more than 5 mins even on slow machines
    $db = get_database();
    $res = "failed";
    try {
        $time = current_time_millis();
        $list = $db->getAll();
        if (!isset($list['file'])) {
            return;
        }
        $files = $list['file'];
        $db->disconnect();
        $list = scandir($metadata_dir);
        $total = count($list);
        $fixed = 0;
        $errors = 0;
        $fcount = 0;
        $fcount_inv = 0;
        $tcount = 0;
        foreach ($list as $f) {
            $r = strrpos($f, ".lyric");
            $tcount++;
            if ($r !== false && $r + 6 == strlen($f)) {
                $xml = @simplexml_load_file($metadata_dir . $f);
                $fcount++;
                if ($fcount % 100 == 0) {
                    echo $out;
                    echo "<p>Processed {$fcount} (" . (int) ($tcount * 100 / $total) . "%)..</p>\n";
                    echo "--ThisRandomString\n";
                    flush();
                }
                if ($xml) {
                    $x_files = array();
                    foreach ($xml->file as $v) {
                        $x_files[] = (string) $v;
                    }
                    $dis = array_intersect($x_files, $files);
                    if (count($dis) != count($x_files)) {
                        $dom = @dom_import_simplexml($xml);
                        if ($dom === false) {
                            $errors++;
                            continue;
                        }
                        while ($elem = $dom->getElementsByTagName("file")->item(0)) {
                            $dom->removeChild($elem);
                        }
                        $xml = simplexml_import_dom($dom);
                        array_to_xml($dis, $xml, "file");
                        @$xml->asXML($metadata_dir . $f);
                        $fixed++;
                    }
                } else {
                    $fcount_inv++;
                }
            }
        }
        $result = array("time" => intval(current_time_millis() - $time), "fixed" => $fixed, "errors" => $errors);
    } catch (PEAR_Exception $e) {
    }
    echo "Content-type: text/html\n\n";
    echo "<p>";
    if (is_array($result)) {
        echo "Result of cleaning:<br/>\n";
        echo "{$fcount} files checked in " . $result['time'] . "ms of which {$fcount_inv} was invalid<br/>";
        echo "Fixed: " . $result['fixed'] . "<br/>";
        echo "Errors: " . $result['errors'] . "<br/>\n";
    } else {
        if ($result == "failed") {
            echo "It appears housecleaning failed, check your MPD settings";
        } else {
            echo "hmm.. somethings wrong, try again";
        }
    }
    echo "</p><p><a href='config.php'>Back to configuration</a></p></body></html>\n";
    echo "\n--ThisRandomString\n";
}