public function resolve($sessionId, $urn)
 {
     mysqlConnect(USER, PASS, TABLE, HOST);
     // connecting mysql
     $urls = array();
     // initialise the urls array to be returned
     // wildcard parsing
     //TODO: if there is more than one *, this doesnt work anymore, but first we have to know how the possible wildcard could be. To know the wildcard design, we should take contact with Silvan (BitFlux)
     $wildcard = explode("*", $urn);
     // make array with hashed values, separator: *
     $substring = $wildcard[0];
     // take everything before the * in the urn string
     $query = "SELECT path FROM urn WHERE urn LIKE '" . $substring . "%'";
     // building query string
     $result = mysql_query($query);
     // execute mysql query
     $rows = mysql_num_rows($result);
     // count the number of results
     if ($rows == 0) {
         $urls[] = "URN not found!";
         // put error message into urls array witch is returned
     } else {
         while ($row = mysql_fetch_row($result)) {
             $urls[] = $row[0];
             // push the paths into the urls array
         }
     }
     mysql_close();
     // close mysql connection
     return $urls;
 }
 public function resolve($sessionId, $urn)
 {
     mysqlConnect(USER, PASS, TABLE, HOST);
     // connecting mysql
     $urls = array();
     // initialise the urls array to be returned
     // wildcard
     $wildcard = str_replace("*", "%", $urn);
     // remplace the * with % and make it compatible for the mysql query
     $query = "SELECT path FROM urn WHERE urn LIKE '" . $wildcard . "%'";
     // building query string
     $result = mysql_query($query);
     // execute mysql query
     $rows = mysql_num_rows($result);
     // count the number of results
     if ($rows == 0) {
         $urls[] = "URN not found!";
         // put error message into urls array witch is returned
     } else {
         while ($row = mysql_fetch_row($result)) {
             $urls[] = $row[0];
             // push the paths into the urls array
         }
     }
     mysql_close();
     // close mysql connection
     return $urls;
 }
Esempio n. 3
0
	function dbConnect($srcName) {
		global $DBProvider;
		if (isset($DBProvider)&&($DBProvider=='mysql')) {
			return mysqlConnect($srcName);
		} else {
			return sqliteConnect($srcName);
		}
	}
Esempio n. 4
0
function getDptInfo()
{
    $sql = "SELECT * FROM dpt";
    $result = mysqli_query(mysqlConnect(), $sql);
    $mainHTML .= "<ul>";
    while ($row = mysqli_fetch_array($result)) {
        $mainHTML .= "<li class='menu_titles'><a href='?option=viewDept&dpt=" . $row['dpt_name'] . "' class='menuTitles'>" . $row['dpt_name'] . "</a>";
        $sql1 = "SELECT * FROM cats WHERE cat_dpt_id = '" . $row['dpt_id'] . "'";
        $result1 = mysqli_query(mysqlConnect(), $sql1);
        if ($result1) {
            $mainHTML .= "<ul class='subMenu'>";
            while ($row1 = mysqli_fetch_array($result1)) {
                $mainHTML .= "<li><a href='#'>" . $row1['cat_name'] . "</a></li>";
            }
            $mainHTML .= "</ul>";
        }
        $mainHTML .= "</li>";
    }
    $mainHTML .= "</ul>";
    return $mainHTML;
}
Esempio n. 5
0
function ae_nocache()
{
    header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
}
ae_nocache();
session_start();
ini_set('display_errors', 1);
$USERLOGGEDIN = false;
$BODY = "<div id=innercontent>";
require_once "mysql.inc.php";
require_once "auth.lib.php";
mysqlConnect();
if (checkSessionAuth() == true) {
    $USERLOGGEDIN = true;
}
if (!isset($_GET['page'])) {
    $page = "home";
} else {
    $page = $_GET['page'];
    if ($page == "") {
        $page = "home";
    }
}
if ($page == "login") {
    require_once "ui/login.lib.php";
    checkLogin($USERLOGGEDIN);
    if ($USERLOGGEDIN == true) {
Esempio n. 6
0
    }
    return $mysqli;
}
// Check trade configuration
if (!(isset($TRADE['trade_pair']) && isset($TRADE['trade_wait']) && isset($TRADE['trade_stop_loss']) && isset($TRADE['trade_sma_short']) && isset($TRADE['trade_sma_long']) && isset($TRADE['trade_threshold']))) {
    die("Not all configuration options are present");
}
// Enter trade loop
$simulation = isset($argv[2]) && $argv[2] === 'real' ? false : true;
$tradeLog = './logs/' . $profile . '.log';
$bought = 0;
$buy_price = 0;
$trailing_stop_margin = 0;
while (true) {
    if (!$mysqli) {
        $mysqli = mysqlConnect($CONFIG);
    }
    // Get ticker status for trading pair
    $ticker = getTicker($TRADE['trade_pair']);
    if ($ticker === false) {
        sleep($TRADE['trade_wait']);
        continue;
    }
    // Get balance for trading pair from db
    list($currency1, $currency2) = explode('_', $TRADE['trade_pair']);
    $balance = $mysqli->query("SELECT * FROM balance LIMIT 1")->fetch_assoc();
    $accountValue = $balance[$currency1] * $ticker['sell'] + $balance[$currency2];
    // Calculate average/threshold/etc
    $SmaShort = floatval($mysqli->query("SELECT AVG(x." . $TRADE['trade_pair'] . ") FROM (SELECT " . $TRADE['trade_pair'] . " FROM ticker ORDER BY id DESC LIMIT " . $TRADE['trade_sma_short'] . ") x")->fetch_array()[0]);
    $SmaLong = floatval($mysqli->query("SELECT AVG(x." . $TRADE['trade_pair'] . ") FROM (SELECT " . $TRADE['trade_pair'] . " FROM ticker ORDER BY id DESC LIMIT " . $TRADE['trade_sma_long'] . ") x")->fetch_array()[0]);
    $SmaDiff = 100 * ($SmaShort - $SmaLong) / (($SmaShort + $SmaLong) / 2);
Esempio n. 7
0
                    $db = mysqlConnect('');
                    $query = "UPDATE ".$datasource['Table']." SET ".$IN['UpdateField']."='".md5(htmlentities($IN['UpdateValue'],ENT_QUOTES,'UTF-8'))."' WHERE ".$datasource['PK'].'='.$IN[$datasource['PK']];
                    $result = mysql_query($query,$db) or trigger_error("MySQL Datasource($dsname) Query Error:".mysql_error($db));
                    print '{"Status":"Updated","Id":"'.$IN[$datasource['PK']].'"}';
                    fb($query,FIREPHP::INFO);
                break;
                case "Delete":
                    $db = mysqlConnect('');
                    if (isset($IN['Id'])) {
                        $query = "DELETE FROM ".$datasource['Table']." WHERE ".$datasource['PK'].'='.$IN['Id'];
                        $result = mysql_query($query,$db) or trigger_error("MySQL Datasource($dsname) Query Error:".mysql_error($db));
                        print '{"Status":"Deleted","Id":"'.$IN['Id'].'"}';
                        fb($query,FIREPHP::INFO);
                    } else {
                        trigger_error('PK not found.');
                    }
                break;
                case "CascadeDelete":
                    $db = mysqlConnect('');
                    $query = $datasource['CascadeSQL'];
                    $result = mysql_query($query,$db) or trigger_error("MySQL Datasource($dsname) Query Error:".mysql_error($db));
                    print '{"Status":"Deleted"}';
                    fb($query,FIREPHP::INFO);
                break;
            }
        break;
    }
} else {
        print "alert('Gateway Error:Unknown Datasource (".$IN['datasource'].")');";
}
Esempio n. 8
0



<?php 
/*
require_once('../../include/connect.php');
$mysqli = mysqlConnect();
*/
require_once '../../include/connect.php';
$mysqli = mysqlConnect();
$id = $_POST['id'];
$status = $mysqli->escape_string($_POST['status']);
$placed = $mysqli->escape_string($_POST['placed']);
$dispatched = $mysqli->escape_string($_POST['dispatched']);
$placed = date($placed);
$dispatched = date($dispatched);
$sqlupdate = "UPDATE `Order` SET date_placed='{$placed}', date_dispatched='{$dispatched}', status='{$status}' WHERE id='{$id}'";
$mysqli->query($sqlupdate);
header('Location: orders.php');
Esempio n. 9
0
<?php

require "function.php";
$con = mysqlConnect('localhost', 'root', '123qwe', 'stock');
$sql = "select * from price where code = '" . $_GET['name'] . "'";
$result = mysqlQuery($con, $sql);
if ($row = mysql_fetch_array($result)) {
    $diff = $row['time'];
    $diff = time() - $diff;
    $up = true;
} else {
    $diff = 4 * 3600;
    $up = false;
}
if ($diff >= 4 * 3600) {
    $url = sprintf("http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv&e=.csv", $_GET['name']);
    $handle = fopen($url, "r");
    if ($handle !== FALSE) {
        $data = fgetcsv($handle);
        fclose($handle);
    }
    if (!$up) {
        $sql = "Insert into price (avg,max,min,code,time) values (%s,%s,%s,'%s',%d)";
        $sql = sprintf($sql, $data[1], $data[6], $data[7], $data[0], time());
    } else {
        $sql = "update price set avg=%s,max=%s,min=%s,time=%s where code = '%s'";
        $sql = sprintf($sql, $data[1], $data[6], $data[7], time(), $data[0]);
    }
    mysqlQuery($con, $sql);
    echo $data[1] . " " . $data[6] . " " . $data[7] . " " . $data[0];
} else {
Esempio n. 10
0
#!/usr/bin/php
<?php 
require_once '/var/www/www.example.org/Engine/Utils/CLI.inc';
if ($argc < 2 || $argc > 3) {
    echo "Usage: {$argv[0]} <partner_id> [date]\n";
    die;
}
$partnerId = (int) $argv[1];
$date = strftime('%Y-%m-%d', strtotime($argv[2] ?: 'now'));
echo "User agents for {$partnerId} on {$date}\n";
mysqlConnect(MYSQL_SLAVE);
$sql = "SELECT lsm.user_agent AS user_agent FROM log_sessions ls LEFT JOIN log_session_meta lsm ON (lsm.log_session_id=ls.id) WHERE ls.time_firstaction >= '{$date}' AND ls.time_firstaction < TIMESTAMPADD(DAY, 1, '{$date}') AND ls.partner_id={$partnerId};";
$select = mysql_query($sql);
$uas = array();
while ($row = mysql_fetch_assoc($select)) {
    $uas[$row['user_agent']]++;
}
$browsers = array();
$parser = new \UAS\Parser();
$parser->SetCacheDir(sys_get_temp_dir() . "/uascache/");
foreach ($uas as $ua => $count) {
    $browser = 'unknown';
    if ($ret = $parser->parse($ua)) {
        $browser = "{$ret['typ']} - {$ret['ua_family']}";
    }
    $browsers[$browser] += $count;
}
ksort($browsers);
$total = $max1 = $max2 = 0;
foreach ($browsers as $browser => $count) {
    $max1 = max($max1, strlen($browser));
Esempio n. 11
0
function jobStart($cronId, $hostname, $pid)
{
    $cronId = (int) $cronId;
    $hostnameSQL = mysql_real_escape_string($hostname);
    $pid = (int) $pid;
    if ($pid <= 0) {
        return null;
    }
    debug("Storing start time for cron id {$cronId}, pid {$pid}.");
    // Update start time and pid in database.
    $master = mysqlConnect(MYSQL_MASTER);
    $select = mysql_query_debug("SELECT id FROM cron_status WHERE cron_id='{$cronId}' AND hostname='{$hostnameSQL}';", __LINE__, $master);
    $row = mysql_fetch_assoc($select);
    $statusId = (int) $row['id'];
    if (!$statusId) {
        $upsert = mysql_query_debug("INSERT INTO cron_status (cron_id, hostname, pid) VALUES ('{$cronId}', '{$hostnameSQL}', '{$pid}') ON DUPLICATE KEY UPDATE time_start=NOW(), time_end=NULL, pid='{$pid}';", __LINE__, $master);
        $statusId = $result ? mysql_insert_id() : null;
    } else {
        $update = mysql_query_debug("UPDATE cron_status SET time_start=NOW(), time_end=NULL, pid='{$pid}' WHERE id='{$statusId}';", __LINE__, $master);
    }
    return $statusId;
}
Esempio n. 12
0
function core_inputCheck($str)
{
    mysqlConnect();
    return mysql_real_escape_string($str);
}
Esempio n. 13
0
    }
    $response->getBody()->write(json_encode($rows));
    return $response;
});
$app->get('/scene/{id}', function (Request $request, Response $response) {
    $id = $request->getAttribute('id');
    $conn = mysqlConnect();
    $sth = $conn->query("UPDATE scenes SET accessCount = accessCount + 1, lastAccess = NOW() where id = {$id}");
    $sth = $conn->query("SELECT id, nickname as nickName, title, description as 'desc', jsondata from scenes where id = {$id}");
    $rows = array();
    while ($r = mysqli_fetch_assoc($sth)) {
        $rows[] = $r;
    }
    $response->getBody()->write(json_encode($rows));
    return $response;
});
$app->post('/scene', function (Request $request, Response $response) {
    $jsondata = $request->getBody();
    $obj = json_decode($jsondata);
    $conn = mysqlConnect();
    $nickName = $conn->real_escape_string($obj->nickName);
    $title = $conn->real_escape_string($obj->title);
    $descr = $conn->real_escape_string($obj->desc);
    $jsondata = $conn->real_escape_string($jsondata);
    $ip = $_SERVER['REMOTE_ADDR'];
    $sth = $conn->query("insert into scenes (nickname, title, description, ipaddress, jsondata, lastaccess, added) values('{$nickName}','{$title}','{$descr}','{$ip}','{$jsondata}', NOW(), NOW())");
    $response->getBody()->write($obj->nickName);
    return $response;
});
$app->run();
//$conn->close();
    }
    $mysqli_result->free();
    return $res;
}
function getInsertCommand($wowzaHostName, $wowzaDc, $wowzaServerNodeType)
{
    $t = time();
    $date = date("Y-m-d", $t);
    $insertCommand = "insert into server_node set created_at = \"{$date}\", updated_at = \"{$date}\", dc = {$wowzaDc}, name = \"{$wowzaHostName}\", host_name = \"{$wowzaHostName}\", type = {$wowzaServerNodeType}, partner_id = -5, status = 1";
    $custom_data = array();
    $custom_data["application_name"] = "kLive";
    $serializedCustomData = serialize($custom_data);
    $insertCommand .= ", custom_data = '{$serializedCustomData}'";
    return $insertCommand;
}
$link = mysqlConnect();
$wowzaServerNodeType = getWowzaServerNodeDynamicType($link);
$mysqli_result = mysqli_query($link, "SELECT * from media_server");
while ($row = $mysqli_result->fetch_assoc()) {
    $wowzaDc = $row[DC_INDEX];
    $wowzaHostName = $row[HOST_NAME_INDEX];
    if (!validateHostNameDoesNotExist($link, $wowzaHostName, $wowzaServerNodeType)) {
        $insertCommand = getInsertCommand($wowzaHostName, $wowzaDc, $wowzaServerNodeType);
        $result = mysqli_query($link, $insertCommand);
        if (!$result) {
            $message = 'Invalid query: ' . mysql_error() . "\n";
            $message .= 'Whole query: ' . $insertCommand;
            die($message);
        }
    }
}