Example #1
0
    echo '<tr><td></td><td colspan="3"><div><a href="#addrow" name="addrow" onclick="addrow(this, 0)" class="addtr">' . lang("plugin/dsu_amusign", "admin_s1") . '</a></div></td></tr>';
    showsubmit('submit', lang("plugin/dsu_amusign", "admin_s2"));
    showtablefooter();
    showformfooter();
} elseif ($_G['adminid'] == '1' && $_G['gp_formhash'] == FORMHASH) {
    $mrcs = array();
    //print_r($_G['gp_delete']);
    $max_i = max(count($_G['gp_days']), count($_G['gp_daycost']));
    for ($i = 0; $i < $max_i; $i++) {
        if (intval($_G['gp_days'][$i]) && intval($_G['gp_daycost'][$i] * 100) && !in_array($i, $_G['gp_delete'])) {
            $mrcs[$i]['days'] = intval($_G['gp_days'][$i]);
            $mrcs[$i]['daycost'] = intval($_G['gp_daycost'][$i] * 100) / 100;
        }
    }
    usort($mrcs, "cmp");
    array2file($file, $mrcs);
    cpmsg('dsu_amusign:admin_i', 'action=plugins&operation=config&identifier=dsu_amusign&pmod=admin', 'succeed');
}
//自定义函数
function array2file($file, $array)
{
    $fp = fopen($file, "wb");
    fwrite($fp, serialize($array));
    fclose($fp);
}
function file2array($file)
{
    if (!file_exists($file)) {
        //echo " does no exist";
    }
    $handle = fopen($file, "rb");
Example #2
0
<?php

function bar($x)
{
    if ($x > 0) {
        bar($x - 1);
    }
}
function foo()
{
    for ($idx = 0; $idx < 5; $idx++) {
        bar($idx);
        echo strlen($idx);
    }
}
xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
include __DIR__ . "/lib.php";
$a = '$a="bbb\\n";';
echo strlen($a);
echo str_replace($a, 'bbb', 'aaa');
eval($a);
echo $a;
foo();
$xhprof_data = xhprof_disable();
array2file($xhprof_data, __DIR__ . '/' . PHP_VERSION . '-enable-' . date('His') . '.out');
Example #3
0
function process_csvfile($filename, $languages, $sets)
{
    $results = array();
    $user = '******';
    $pass = '******';
    //$set_id = 3;
    $head = array();
    $row = 0;
    $added = 0;
    $maxlen = 0;
    $file = fopen($filename, "r");
    if (!$file) {
        return false;
    }
    $url = "http://{$user}:{$pass}@w3.amooma.de/xml-api/voiceprompts/create.xml";
    while (($data = fgetcsv($file, 1024, ";")) !== FALSE) {
        if (count($data) < 2) {
            continue;
        }
        if ($row == 0) {
            $head = $data;
            $row++;
            continue;
        }
        $row++;
        $params = array();
        foreach ($head as $index => $param) {
            //if (array_key_exists($index, $data)) $params[$param] = $data[$index];
            $params[$param] = array_key_exists($index, $data) ? $data[$index] : '';
        }
        $axml = array();
        $prompt = array();
        $prompt['filename'] = $params['filename'];
        $sets_a = explode(',', $sets);
        foreach (explode(',', $languages) as $key => $lang) {
            if (!($set_id = @$sets_a[$key])) {
                break;
            }
            if (@$lang == 'de') {
                $set_id = 3;
            } else {
                if ($lang == 'en') {
                    $set_id = 4;
                }
            }
            //$set_id = 3;
            $prompt['voiceprompt_set_id'] = $set_id;
            $prompt['text'] = $params[$lang];
            $prompt['lang'] = $lang;
            $axml['voiceprompt'] = $prompt;
            if ($prompt['text'] != '') {
                $data = array2xml($axml);
                $added++;
                echo $prompt['filename'], " : [{$set_id}] Processing \"" . $prompt['text'] . "\" ...\n";
                //$res = post_xml($url, $data);
                //sleep(2);
                $res = $data;
                $results[] = xml2array($res);
                if (strlen($prompt['text']) > $maxlen) {
                    $maxlen = strlen($prompt['text']);
                }
            } else {
                echo " - No string!\n";
            }
        }
    }
    fclose($file);
    array2file($results, 'res_out_' . time() . '.txt');
    echo "Longest string was {$maxlen} characters long.\n";
}