Esempio n. 1
0
File: data.php Progetto: milkae/Php
function getLink($cid)
{
    global $config;
    foreach ($config['hosts'] as $o) {
        if ($o['cid'] == $cid) {
            break;
        }
        $o = NULL;
    }
    if (!$o) {
        return;
    }
    $link = GetMySQLLink($o['host'], $o['uname'], $o['passwd'] === NULL ? $o['tempPasswd'] : $o['passwd'], $o['port']);
    if (is_string($link)) {
        respondError($link, TRUE);
    }
    return $link;
}
Esempio n. 2
0
}
if (!$task) {
    exit("Task #{$req['task']} was not found");
}
$host = NULL;
foreach ($conf['hosts'] as $h) {
    if ($h['cid'] == $task['cid']) {
        $host = $h;
        break;
    }
}
if (!$host) {
    exit("Connection with ID {$task['cid']} was not found");
}
require __INC__ . '/mysql.php';
$link = GetMySQLLink($host['host'], $host['uname'], $host['passwd'], $host['port'], $task['db']);
if (is_string($link)) {
    exit($link);
}
$res = MySQLQuery($link, $task['sql'], NULL, 0, -1, 1024);
if (is_string($res)) {
    exit($res);
}
echo '<div>' . $task['title'] . '</div>';
$cnt = count($res['fields']);
for ($i = 0; $i < $cnt; $i++) {
    echo '<div class="t"><div class="r header">';
    foreach ($res['fields'][$i] as $f) {
        echo '<div class="c">' . $f['fieldAlias'] . '</div>';
    }
    echo '</div>';