Beispiel #1
0
function queryScores($maxPlayers)
{
    global $serialConnection;
    if ($maxPlayers < 1) {
        logIt('maxPlayers must be at least 1.', true);
    }
    $scores = array();
    for ($i = 1; $i <= $maxPlayers; ++$i) {
        sleep(1);
        $response = queryData('zc mod 0x5c073564 ' . $i);
        $pattern = '/=([0-9a-fA-F]+)/';
        preg_match($pattern, $response, $matches);
        if (!isset($matches[1])) {
            return false;
        }
        $scores[$i] = hexdec($matches[1]);
        if ($scores[$i] === 0) {
            // If Player 2 has a score of zero, no need to check Players 3 & 4
            break;
        }
    }
    if (count($scores) == 0) {
        return false;
    }
    return max($scores);
}
                $product_category[] = formatTableRow($dpc['row_id'], $dpc['sold_pieces'], $dpc['total_sales'], $dpc['total_sales_ratio'], $dpc['avg_price'], $dpc['avg_margin'], $dpc['total_profit'], $dpc['total_profit_ratio'], $dpc['return_rate'], false);
            }
        }
        $table_product_category = tep_draw_table('', $product_category, false, true);
        //PRICE GROUP TABLE
        $price_category = array();
        $price_category[] = formatTableRow(REPORT_TABLE_TYPE_PRICEGROUP);
        $data_price_categories = queryData(REPORT_TABLE_TYPE_PRICEGROUP, $id_source_order, $start_date, $end_date);
        foreach ($data_price_categories as $dpc) {
            $price_category[] = formatTableRow($dpc['row_id'], $dpc['sold_pieces'], $dpc['total_sales'], $dpc['total_sales_ratio'], $dpc['avg_price'], $dpc['avg_margin'], $dpc['total_profit'], $dpc['total_profit_ratio'], $dpc['return_rate'], false);
        }
        $table_price_group = tep_draw_table('', $price_category, false, true);
        //PRODUCT BRAND TABLE
        $brand_category = array();
        $brand_category[] = formatTableRow(REPORT_TABLE_TYPE_BRAND);
        $data_brand_categories = queryData(REPORT_TABLE_TYPE_BRAND, $id_source_order, $start_date, $end_date);
        foreach ($data_brand_categories as $dbc) {
            $brand_category[] = formatTableRow($dbc['row_id'], $dbc['sold_pieces'], $dbc['total_sales'], $dbc['total_sales_ratio'], $dbc['avg_price'], $dbc['avg_margin'], $dbc['total_profit'], $dbc['total_profit_ratio'], $dbc['return_rate'], false);
        }
        $table_brand = tep_draw_table('', $brand_category, false, true);
        //Merge all tables as 1 html
        $result = '<h3 style="margin-top:20px;">' . REPORT_TABLE_TYPE_CATEGORY . '</h3>' . '<div>' . $table_product_category . '</div>' . '<h3 style="margin-top:20px;margin-bottom:0px;">' . REPORT_TABLE_TYPE_PRICEGROUP . '</h3>' . '<span class="notice">Average price before return is used for seperating data into each Price Group</span>' . '<div style="margin-top:5px;">' . $table_price_group . '</div>' . '<h3 style="margin-top:20px;">' . REPORT_TABLE_TYPE_BRAND . '</h3>' . '<div>' . $table_brand . '</div>';
        echo utf8_encode($result);
        exit;
    }
}
//Set Available Tables
$arr_data_table = array();
$arr_data_table[] = 'Product Category';
$arr_data_table[] = 'Price Group';
$arr_data_table[] = 'Brand';
Beispiel #3
0
<?php

include 'api/dbBase.php';
$con = connectToDB();
$tbl_name = "users";
// username and password sent from form
$myusername = $_POST['myusername'];
$mypassword = $_POST['mypassword'];
$redirect = $_POST['redirect'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = $con->real_escape_string($myusername);
$mypassword = $con->real_escape_string($mypassword);
$count = fetchCountWithClause($tbl_name, " email='{$myusername}' and pword='{$mypassword}'");
// If result matched $myusername and $mypassword, table row must be 1 row
session_start();
if ($count == 1) {
    // Register $myusername
    $_SESSION['user'] = $myusername;
    // Load user id and register
    $rows = queryData('Select guid from ' . $tbl_name . " where email='{$myusername}' and pword='{$mypassword}'");
    $guid = $rows[0]['guid'];
    $_SESSION['userId'] = $guid;
    header("location:" . $redirect);
    exit;
} else {
    $_SESSION['errorMessage'] = "Wrong Username or Password";
    header("location:login.php");
    exit;
}
Beispiel #4
0
function fetchObject($tableName, $includeDeleted = false)
{
    global $con;
    if (strcmp($tableName, "users") == 0) {
        $query = "select guid, email, lastModifiedDatetime, lastModifiedById from users " . ($includeDeleted ? ";" : " where isDeleted='false';");
    } else {
        $query = "select * from " . $tableName . ($includeDeleted ? ";" : " where isDeleted='false';");
    }
    $rows = queryData($query);
    if (!$con->error) {
        printJSONData($rows);
    }
}
Beispiel #5
0
//$passwd = '123456';
//$db = new PDO($dsn, $username, $passwd);
$conf = parse_ini_file(__DIR__ . '/../conf/db.ini');
$dsn = 'mysql:host=' . $conf['host'] . ';port=' . $conf['port'] . ';dbname=' . $conf['dbname'] . ';charset=' . $conf['charset'];
$db = new PDO($dsn, $conf['username'], $conf['password']);
/*** set the error reporting attribute ***/
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function queryData($db, $sql)
{
    $stmt = $db->query($sql);
    $count = $stmt->rowCount();
    echo "<h4>{$count} rows selected </h4>";
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
try {
    $r = queryData($db, "select id,mobile, email,homeaddress from hxjb_user limit 10");
} catch (Exception $e) {
    $msg = $e->getMessage();
    echo "PDO Exception: {$msg}";
}
if (empty($r)) {
    echo "no data ...";
    return;
}
echo "<table border='1px solid red'>";
foreach ($r as $key => $val) {
    echo "<tr>";
    foreach ($val as $k1 => $v2) {
        echo "<td>{$v2}</td>";
    }
    echo "</tr>";