Beispiel #1
0
 public function search($page = 0, $limit = 200)
 {
     $end = $this->timeEnd ? $this->timeEnd->getTimestamp() : Time::microtime() + 1;
     $start = $this->timeStart ? $this->timeStart->getTimestamp() : 0;
     $args = array($start, $end, $page * $limit, $limit);
     $keys = $this->buildSearchKeys();
     if (($keysCount = count($keys)) > 1) {
         $args[] = $keysCount;
         $keysString = "ARGV[5]";
         foreach ($keys as $i => $k) {
             $keysString .= " ,KEYS[" . ($i + 2) . "]";
         }
         $command = "redis.call('zinterstore', KEYS[1], {$keysString}, 'AGGREGATE', 'MAX')" . PHP_EOL;
         array_unshift($keys, 'searchtmp:' . uniqid(getmypid() . ':', true));
     } else {
         $command = "";
         count($keys) or $keys[0] = 'index:job:all';
     }
     // zREVrangebyscore so ARG[2] ARG[1] are reversed
     $command .= "local result = redis.call('zrevrangebyscore', KEYS[1], ARGV[2], ARGV[1], 'LIMIT', ARGV[3], ARGV[4])" . PHP_EOL;
     $command .= "local count = redis.call('zcount', KEYS[1], ARGV[1], ARGV[2])" . PHP_EOL;
     if ($keysCount > 1) {
         $command .= "redis.call('del', KEYS[1])" . PHP_EOL;
     }
     $command .= 'return {count, result}';
     list($count, $list) = $this->commandExecutor->execute(new Phresque\Redis\Commands\DynamicCommand($command, $keys, $args));
     $jobs = array();
     foreach ($list as $jobID) {
         $jobs[] = $this->commandExecutor->execute(new Phresque\Redis\Commands\GetJob($jobID));
     }
     return $this->withCount ? array($jobs, $count) : $jobs;
 }
function db_createItemsTable($con)
{
    $sql = "CREATE TABLE items\n                  (\n                    IID          INT           NOT NULL PRIMARY KEY AUTO_INCREMENT, # key to the items table\n                    OID          INT           NOT NULL, # key to the orders table\n                    PKID         INT           NOT NULL, # key to the packages table\n                    Personality  INT           ,         # foreign key to the pieces table\n                    Price        DECIMAL(6,2)  ,\n                    Quantity     INT\n                  )";
    if (!execute($con, $sql, "Table 'items' create")) {
        return false;
    }
}
/**
 * Init function of API.
 */
function init()
{
    if ($paramArr = getParam()) {
        $repeat = $paramArr[2];
        for ($i = 4; $i < 30; $i++) {
            $ogListArr = getRandOgList(1, 29, $i, $repeat);
            $total1 = 0;
            $total2 = 0;
            foreach ($ogListArr as $ogList) {
                echo json_encode($ogList);
                echo '<br>';
                $statics = execute($ogList, $paramArr[0], $paramArr[1]);
                $total1 += $statics[0]['count'];
                $total2 += $statics[1]['count'];
            }
            $avg1 = $total1 / $repeat;
            $avg2 = $total2 / $repeat;
            echo '1/2 --- ' . (string) $avg1 . '<br>';
            echo '1   --- ' . (string) $avg2 . '<br>';
            echo '<br>';
        }
    } else {
        printParamErr();
    }
}
Beispiel #4
0
 public function insertTemp()
 {
     $temp = $_REQUEST['temp'];
     $date = $_REQUEST['datum'];
     $name = strtolower($_REQUEST['name']);
     execute("INSERT INTO forecast(date, temp, name) VALUES('{$date}', {$temp}, '{$name}')", $this->mysqli);
 }
function getPoke($url)
{
    $result = execute($url);
    $myfilePkd = fopen("pokedexLib.lua", "w") or die("Unable to open file!");
    fwrite($myfilePkd, "PokeDex={");
    foreach ($result->objects as $pokedex) {
        $txt = "['" . $pokedex->name . "'] = {attack='" . $pokedex->attack . "'," . "catch_rate='" . $pokedex->catch_rate . "'," . "sp_atk='" . $pokedex->sp_atk . "'," . "sp_def='" . $pokedex->sp_def . "'," . "species='" . $pokedex->species . "'," . "defense='" . $pokedex->defense . "'," . "egg_cycles='" . $pokedex->egg_cycles . "'," . "hp='" . $pokedex->hp . "'," . "male_female_ratio='" . $pokedex->male_female_ratio . "'," . "speed='" . $pokedex->speed . "'," . "height='" . $pokedex->height . "'," . "weight='" . $pokedex->weight . "'," . "evolutions={";
        foreach ($pokedex->evolutions as $evo) {
            if (isset($evo->level)) {
                $txt .= "{level='" . $evo->level . "',";
            } else {
                $txt .= "{level='0',";
            }
            $txt .= "method='" . $evo->method . "',";
            $txt .= "to='" . $evo->to . "'},";
        }
        $txt .= "},";
        $txt .= "types={";
        foreach ($pokedex->types as $types) {
            $txt .= "{name='" . $types->name . "'},";
        }
        $txt .= "},";
        $txt .= "moves={";
        foreach ($pokedex->moves as $move) {
            $idAPI = $move->resource_uri;
            $IdMove = explode('/', $idAPI);
            $txt .= "{id='" . $IdMove[4] . "',";
            $txt .= "learn_type='" . $move->learn_type . "',";
            $txt .= "name='" . ucwords(strtolower(str_replace("-", " ", $move->name))) . "'},";
        }
        $txt .= "},\n";
        $txt .= "},\n";
        fwrite($myfilePkd, $txt);
    }
}
 public function run()
 {
     include_once SANWEN_LIB . '/Common/functions.php';
     include_used_file();
     //include the file that used
     Log::write('begin initApp');
     $this->initApp();
     //use the filter
     $filter = new Filter();
     //filter all url
     Log::write('begin to filter url');
     if ($filter->filter_all_url()) {
         $include_file = get_include_file();
         if (file_exists($include_file)) {
             Log::write('get_include_file:' . $include_file);
             include_once $include_file;
             execute(null, null);
         } else {
             //对应地址的类不存在的时候,执行默认首页
             if (file_exists(APP . '/Index/Action/Index.action.php')) {
                 include_once APP . '/Index/Action/Index.action.php';
                 execute("Index", "Index");
             } else {
                 //默认首页不存在的时候,抛出错误信息
                 echo get_langage_message('system.lang.php', 'DEFAULT_INDEX_NOT_FOUND');
             }
         }
     } else {
         echo get_langage_message('system.lang.php', 'CAN_NOT_ACCESS');
     }
 }
Beispiel #7
0
function run_cron()
{
    campaign_limit_update();
    execute();
    update_configvar('last_cron_job', time());
    add_syslog('daily_cron', '');
}
Beispiel #8
0
function queryOptionsList($query)
{
    $result = execute($query);
    while ($row = mysql_fetch_row($result)) {
        echo "<option value=\"{$row[0]}\">{$row[0]}</option>";
    }
}
/**
 * Init function of API.
 */
function init()
{
    if ($paramArr = getParam()) {
        $repeat = $paramArr[0];
        for ($i = 1; $i < 101; $i++) {
            $halfNum = $i / 100;
            for ($j = 4; $j < 29; $j++) {
                $ogListArr = getRandOgList(1, 29, $j, $repeat);
                $total = 0;
                foreach ($ogListArr as $ogList) {
                    $statics = execute($ogList, $halfNum);
                    $total += $statics['count'];
                }
                $avgNumber = $total / $repeat;
                echo $avgNumber;
                if ($j < 28) {
                    echo ',';
                }
            }
            echo '<br>';
        }
    } else {
        printParamErr();
    }
}
function addUser($voornaam, $achternaam, $telefoon, $geslacht, $email, $logonNaam, $wachtwoord)
{
    $sql = "INSERT INTO users (user_voornaam, user_achternaam, user_telefoon, user_geslacht, user_email)\nVALUES (?, ?,?,?,?)";
    $sql2 = "INSERT INTO users (user_login_naam, user_wachtwoord)\nVALUES (?,?)";
    $conn = $getConnection();
    $stmt = $conn->prepare($sql);
    $stmt->bind_param('s', $voornaam);
    $stmt->bind_param('r', $achternaam);
    $stmt->bind_param('t', $telefoon);
    $stmt->bind_param('u', $geslacht);
    $stmt->bind_param('v', $email);
    $stmt2 = $conn->prepare($sql2);
    $stmt->bind_param('s', $logonNaam);
    $stmt->bind_param('r', $wachtwoord);
    //laten staan voor debugging voor nu
    if ($stmt - execute() === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $stmt->error;
    }
    if ($stmt2 - execute() === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $stmt2->error;
    }
    $conn->close();
}
 public function login_user()
 {
     //função de login do usuario
     $cod = $this->_user_cod;
     $login = $this->_user_login;
     $pass = $this->_user_pass;
     require_once 'config/connection_server.php';
     //arquivo de conexao
     $sql = "select COD_U,login,senha from usuario where login = :login and senha = :senha";
     //comando de pesquisa
     $dados = array(':cod_user' => $cod, ':login' => $login, ':login' => $pass);
     $query = $banco->prepare($sql);
     $query - execute($dados);
     if ($query->rowcount() >= 1) {
         while ($i = $query->fetch(PDO::FETCH_OBJ)) {
             //confirmação de existencia e redirecionando se verdadeiro
             if ($login == $i->login && $pass == $i->senha) {
                 session_start();
                 $_SESSION['cod'] = $i->cod;
             } else {
             }
         }
     } else {
         session_start();
         $_SESSION['menMenssagem']++;
     }
     $sql = "insert into usuario_login(COD_UL,cod_usu,horario_login)values(null,:cod_user,null)";
     //cod_user vem do $dados na linha 23
     $query = $banco->prepare($sql);
     $query->execute($dados);
     //executa o o sql para sinalizar o login do usuario
     header('Location:index2.php');
     // redireciona para a pagina de usuario
 }
Beispiel #12
0
 public function recvFile($remote, $local)
 {
     if (!($info = parse_url($remote))) {
         return;
     }
     if (isset($info['path'])) {
         $info = array_merge($info, pathinfo($info['path']));
     }
     if (!isset($info['filename'])) {
         trigger_error('iPlayer: No PID specified', E_USER_WARNING);
         return false;
     }
     if (!isset($info['extension'])) {
         trigger_error('iPlayer: No file type (extension) specified', E_USER_WARNING);
         return false;
     }
     if (is_dir($local)) {
         $localdir = $local;
         $local .= '/' . $info['basename'];
     } else {
         $localdir = dirname($local);
     }
     if ($info['extension'] == 'jpg') {
         return copy('http://www.bbc.co.uk/iplayer/images/episode/' . $info['filename'] . '_832_468.jpg', $local);
     }
     if ($info['extension'] == 'rdf') {
         return copy('http://www.bbc.co.uk/programmes/' . $info['filename'] . '.rdf', $local);
     }
     if ($info['extension'] == 'flv') {
         $tmpfile = $localdir . '/.iplayer-tmp-' . $info['filename'] . '.flv';
         if (!file_exists($tmpfile)) {
             $args = array();
             $args[] = GET_IPLAYER_PATH;
             $args[] = '--flvstreamer';
             $args[] = FLVSTREAMER_PATH;
             $args[] = '--modes=flashhd1,flashhd2,flashvhigh,flashhigh';
             $args[] = '--quiet';
             $args[] = '--nocopyright';
             $args[] = '--nopurge';
             $args[] = '--file-prefix=.iplayer-tmp-' . $info['filename'];
             $args[] = '--pid=' . $info['filename'];
             $args[] = '--force';
             $args[] = '--raw';
             $args[] = '-o';
             $args[] = $localdir;
             $result = execute(GET_IPLAYER_PATH, $args, false);
             if (!file_exists($tmpfile)) {
                 trigger_error('get_iplayer failed to download ' . $info['basename'], E_USER_NOTICE);
                 return false;
             }
         }
         if (!rename($tmpfile, $local)) {
             return false;
         }
         return true;
     }
     print_r($info);
     die;
 }
Beispiel #13
0
/**
 * Init function of API.
 */
function init()
{
    if (($paramArr = getParam()) && validateParam($paramArr[0]) && validateParam($paramArr[1])) {
        execute($paramArr[0], $paramArr[1], $paramArr[2]);
    } else {
        printParamErr();
    }
}
Beispiel #14
0
/**
 * Init function of API.
 */
function init()
{
    if (($idArr = parseParam()) && validateParam($idArr)) {
        execute($idArr);
    } else {
        printParamErr();
    }
}
Beispiel #15
0
 public function execute()
 {
     if (execute('which traceroute') != '') {
         echo execute('traceroute ' . escapeshellarg(CenterBot::getInstance()->_actionText));
     } else {
         echo 'Error: system comand (traceroute) not found';
     }
 }
Beispiel #16
0
function which($prog)
{
    $path = execute("which {$prog}");
    if (!empty($path)) {
        return $path;
    }
    return '';
}
Beispiel #17
0
/**
 * Init function of API.
 */
function init()
{
    if (($idArrGroup = parseParam()) && validateParam($idArrGroup[0]) && validateParam($idArrGroup[1])) {
        execute($idArrGroup);
    } else {
        printParamErr();
    }
}
Beispiel #18
0
 public function execute()
 {
     $instance = CenterBot::getInstance();
     $text = $instance->_actionRaw;
     if (execute('which elizatalk') != '') {
         echo execute('echo ' . escapeshellarg($text) . ' | elizatalk');
     }
 }
Beispiel #19
0
function run()
{
    if (!is_end()) {
        execute($_SESSION['mem'][$_SESSION['instr_ptr']]);
        return true;
    } else {
        return false;
    }
}
Beispiel #20
0
function num($link, $sql_count)
{
    //此自定义函数是技术功能
    $result = execute($link, $sql_count);
    // 调用了上一个函数execute,执行数据库语句
    $count = mysqli_fetch_row($result);
    /// 然后把结果放在 row这个函数里开始计数
    return $count[0];
    //返回第0个结果
}
 public function withBlankPages($filename, $pageCount)
 {
     $newFilename = tempnam(TMP_DIR, 'blank');
     if (execute($this->PAGE_INSERTER, "{$filename} {$newFilename} {$pageCount}") != 0) {
         unlink($newFilename);
         $GLOBALS['log']->error('OQC: Problem with PageInserter, withBlankPages error');
         //			trigger_error("Problem with OpenOffice or DocumentModifier", E_USER_NOTICE);
         return null;
     }
     return $newFilename;
 }
function db_createPiecesTable($con)
{
    // This sets up the table with the desired information.
    // Everything in this table is required except for Abbrev.
    $sql = "CREATE TABLE pieces\n                  (\n                    PID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY,   # Key to the pieces table\n                    PieceName CHAR(30) NOT NULL,                        # Name for each piece\n                    Abbrev CHAR(10),                                    # Abbrev for each piece\n                    Active SMALLINT NOT NULL,                           # Whether or not each piece is active (0 is not active)\n                    IsPersonality SMALLINT NOT NULL\t\t\t# Whether this piece is a personality or not\n                  )";
    // this command actually creates the table with the above confirguration.
    // If the table is created it returns true, if it fails to be created it returns false.
    if (!execute($con, $sql, "Table 'pieces' create")) {
        return false;
    }
    return true;
}
Beispiel #23
0
function updateEntry($hash, $editor_hash, $text, $title, $description)
{
    $db = connectDB();
    $query = "\nUPDATE " . DB_TABLE . "\nSET text_content = :text ,\n\ttitle = :title ,\n\tdescription = :desc ,\n\tdate_edited = CURRENT_TIMESTAMP\nWHERE hash = :hash \nAND   editor_hash = :ehash ";
    $params = array(":hash" => $hash, ":ehash" => $editor_hash, ":text" => $text, ":title" => $title, ":desc" => $description);
    $rowCount = execute($db, $query, $params);
    close($db);
    if ($rowCount > 0) {
        return getEntry($hash);
    } else {
        return null;
    }
}
Beispiel #24
0
function populateDB($sitename, $sitedesc, $adminuser, $adminemail, $adminpass)
{
    // Prepare SQL Statements...
    $sql = array("CREATE TABLE `nf_users` ( `id` DOUBLE NOT NULL AUTO_INCREMENT , `username` VARCHAR(20) NOT NULL , `email` VARCHAR(50) NOT NULL , `password` VARCHAR(100) NOT NULL , `firstname` VARCHAR(30) NOT NULL , `lastname` VARCHAR(30) NOT NULL , `gender` INT NOT NULL DEFAULT '0' , `birthday` DATE NOT NULL , `status` VARCHAR(140) NOT NULL , `location` VARCHAR(100) NOT NULL , `occupation` VARCHAR(100) NOT NULL , `website` VARCHAR(255) NOT NULL , `about` TEXT NOT NULL , `avatar` VARCHAR(255) NOT NULL , `twitter` VARCHAR(15) NOT NULL , `postcount` DOUBLE NOT NULL , `groups` TEXT NOT NULL , `permissions` TEXT NOT NULL , PRIMARY KEY (`id`), INDEX (`gender`), UNIQUE (`username`), UNIQUE (`email`)) ENGINE = InnoDB;", "CREATE TABLE `nf_groups`( `id` DOUBLE NOT NULL AUTO_INCREMENT , `name` VARCHAR(30) NOT NULL , `title` VARCHAR(20) NOT NULL , `description` TEXT NOT NULL , `color` VARCHAR(8) NOT NULL DEFAULT '#FFFFFF' , `permissions` TEXT NOT NULL , PRIMARY KEY (`id`), UNIQUE (`name`)) ENGINE = InnoDB;", "CREATE TABLE `nf_posts` ( `forumid` DOUBLE NOT NULL , `topicid` DOUBLE NOT NULL AUTO_INCREMENT , `postid` DOUBLE NOT NULL , `title` VARCHAR(100) NOT NULL , `content` TEXT NOT NULL , `date` DATETIME NOT NULL , `edited` BOOLEAN NOT NULL DEFAULT FALSE , `ownerid` DOUBLE NOT NULL , `locked` BOOLEAN NOT NULL DEFAULT FALSE , `rating` TEXT NOT NULL ) ENGINE = InnoDB;", "CREATE TABLE `nf_forums`( `id` DOUBLE NOT NULL AUTO_INCREMENT , `type` INT NOT NULL DEFAULT '0' , `title` VARCHAR(100) NOT NULL , `content` VARCHAR(255) NOT NULL , `url` VARCHAR(255) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;", "CREATE TABLE `nf_site`  ( `id` DOUBLE NOT NULL AUTO_INCREMENT , `sitename` VARCHAR(255) NOT NULL , `sitedesc` TEXT NOT NULL , `canregister` BOOLEAN NOT NULL DEFAULT TRUE , `defaultgroup` DOUBLE NOT NULL DEFAULT '0' , PRIMARY KEY (`id`)) ENGINE = InnoDB;", "CREATE TABLE `nf_data`  ( `id` DOUBLE NOT NULL AUTO_INCREMENT , `name` VARCHAR(255) NOT NULL , `value` TEXT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;", "INSERT INTO `nf_groups`(`name`, `title`, `description`, `color`, `permissions`) VALUES ('admin', 'Admin', 'Default Admin Group', '#ab0013', '{\"permissions.all\"}');", "INSERT INTO `nf_users` (`username`, `email`, `password`) VALUES (?,?,?);", "INSERT INTO `nf_site` (`sitename`, `sitedesc`, `canregister`, `defaultgroup`) VALUES (?,?,0,0);", "INSERT INTO `nf_data` (`name`, `value`) VALUES (?,?); ", "INSERT INTO `nf_data` (`name`, `value`) VALUES (?,?); ");
    // And arguments...
    $args = array(array(), array(), array(), array(), array(), array(), array(), array($adminuser, $adminemail, $adminpass), array($sitename, $sitedesc), array("activetheme", "default"), array("loginrequired", "false"));
    // And then execute everything.
    for ($i = 0; $i < count($sql); $i++) {
        $exec = execute($sql[$i], $args[$i]);
        if ($exec != null) {
            echo $exec;
        }
    }
}
Beispiel #25
0
function removeGroupPermissions($groupid, $permissions)
{
    if (is_double($groupid) && is_array($permissions)) {
        $grouppermissions = json_decode(executeResult("SELECT `permissions` FROM `nf_groups` WHERE `id`=?", array($groupid))[0], true);
        foreach ($grouppermissions as $key => $value) {
            if (in_array($value, $permissions)) {
                unset($grouppermissions[$key]);
            }
        }
        execute("UPDATE `nf_groups` SET `permissions`=? WHERE `id`=?", array(json_encode($grouppermissions), $groupid));
    } else {
        return false;
    }
}
Beispiel #26
0
function is_manage_login($link)
{
    if (isset($_SESSION['manage']['name']) && isset($_SESSION['manage']['pw'])) {
        $query = "select * from cfc_manage where name='{$_SESSION['manage']['name']}' and sha1(pw)='{$_SESSION['manage']['pw']}'";
        $result = execute($link, $query);
        if (mysqli_num_rows($result) == 1) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Beispiel #27
0
/**
 * Init function of API.
 */
function init()
{
    if (($paramArr = getParam()) && validateParam($paramArr[0]) && validateParam($paramArr[1])) {
        echo json_encode($paramArr[0]);
        echo '<br>';
        echo json_encode($paramArr[1]);
        echo '<br>';
        execute($paramArr[0], $paramArr[1], $paramArr[2]);
        echo '----1<br>';
        execute($paramArr[0], $paramArr[1], $paramArr[3]);
        echo '----1/2<br>';
    } else {
        printParamErr();
    }
}
function main()
{
    global $pieces;
    global $packages;
    global $DB_HOST;
    global $DB_DATABASE;
    global $DB_USERNAME;
    global $DB_PASSWORD;
    // we want to know when we use variables that aren't defined
    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    // First, create a connection to the database with the given config information
    $con = mysqli_connect($DB_HOST, $DB_USERNAME, $DB_PASSWORD);
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error() . "\n";
        return;
    }
    $sql = "USE {$DB_DATABASE}";
    if (!execute($con, $sql, "Set database '{$DB_DATABASE}' current")) {
        return;
    }
    foreach ($packages as $package) {
        $id = $package["id"];
        $name = $package["name"];
        $price = $package["price"];
        $active = $package["active"] ? 1 : 0;
        echo "Name: {$name}  --- Price: {$price}  --- Active: {$active}\n";
        $sql = "INSERT INTO packages (PKID, PackageName, Price,  Active) VALUES\n                                  ({$id},  \"{$name}\",   {$price}, {$active});";
        if (!execute($con, $sql, "filled database '{$DB_DATABASE}' with name='{$name}': price='{$price}': active={$active}")) {
            return;
        }
    }
    foreach ($pieces as $piece) {
        $id = $piece["id"];
        $name = $piece["name"];
        $abbrev = $piece["abbrev"];
        $active = $piece["active"] ? 1 : 0;
        $person = $piece["person"] ? 1 : 0;
        echo "Name: {$name}  --- Abbrev: {$abbrev}  --- Active: {$active}\n";
        $sql = "INSERT INTO pieces (PID, PieceName,      Abbrev,  Active, IsPersonality) VALUES\n                                  ({$id}, \"{$name}\", \"{$abbrev}\", {$active}, {$person});";
        if (!execute($con, $sql, "filled database '{$DB_DATABASE}' with name='{$name}' --  Abbrev='{$abbrev}' -- active={$active}")) {
            return;
        }
    }
    $sql = "INSERT INTO pvp (PKID, PID) VALUES\n                                  (1   , 1   ), # ChapR Bluetooth Assembled\n                                  (1   , 3   ), # USB Cable\n                                  (1   , 4   ), # 9V Battery\n                                  (1   , 6   ), # Cheat Sheet\n                                  (2   , 2   ), # ChapR WiFi Assembled\n                                  (2   , 3   ), # USB Cable\n                                  (2   , 4   ), # 9V Battery\n                                  (2   , 6   ), # Cheat Sheet\n                                  (3   , 7   ), # ChapR Bluetooth Kit\n                                  (3   , 3   ), # USB Cable\n                                  (3   , 4   ), # 9V Battery\n                                  (3   , 6   ), # Cheat Sheet\n                                  (4   , 8   ), # ChapR Wifi Kit\n                                  (4   , 3   ), # USB Cable\n                                  (4   , 4   ), # 9V Battery\n                                  (4   , 6   ), # Cheat Sheet\n                                  (5   , 5   ), # ChapR Arduino Programmer\n                                  (6   , 14   ),# Charity ChapR biz cards\n                                  (6   , 15   ),# Charity ChapR brochures\n                                  (6   , 16   ) # Chairty ChapR letter\n                                  ;";
    if (!execute($con, $sql, "filled database '{$DB_DATABASE}'")) {
        return;
    }
}
Beispiel #29
0
/**
 * Init function of API.
 */
function init()
{
    if ($paramArr = getParam()) {
        for ($i = 0; $i < 29; $i++) {
            $paramArr[0] = $paramArr[1];
            array_splice($paramArr[0], $i, 1);
            echo json_encode($paramArr[0]);
            echo '<br>';
            echo json_encode($paramArr[1]);
            echo '<br>';
            execute($paramArr[0], $paramArr[1], $paramArr[2]);
            echo '<br>';
        }
    } else {
        printParamErr();
    }
}
Beispiel #30
0
function ls($dir, $print = false) {
    $lines = explode("\n", execute('ls -lah --time-style long-iso "'.$dir.'"', array(), $print)[1]);

    array_walk($lines, function(&$line, $i) {
        $matches = array();
        $r = preg_match(
            '#^(?<file_type>[-dlpscbD])'.
            '(?<o_permissions>[-rwxstST]{3})'.
            '(?<g_permissions>[-rwxstST]{3})'.
            '(?<u_permissions>[-rwxstST]{3})'.
            '(?<suffix>[\.+@])?\s+'.
            '(?<n_hard_links>\d+)\s+'.
            '(?<owner>[^\s\0]+)\s+'.
            '(?<group>[^\s\0]+)\s+'.
            '(?<size>[^\s]+)\s+'.
            '(?<date>\d{4}-\d\d-\d\d)\s+'.
            '(?<time>\d\d:\d\d)\s+'.
            '(?<file_name>(?:[^\0\n\/]+?(?=[^\\\]\s+->\s)[^\s]?)|[^\0\n\/]+)(?:\s->\s)?(?<file_link>.*)$#',
            $line, $matches
        );
        if ($r !== 1) return array();

        $line = array_intersect_key($matches, array_flip(array(
            'file_type',
            'o_permissions',
            'g_permissions',
            'u_permissions',
            'suffix',
            'n_hard_links',
            'owner',
            'group',
            'size',
            'date',
            'time',
            'file_name',
            'file_link'
        )));
    });

    return $lines;
}