Exemplo n.º 1
0
function generateuniqid(&$used, $length = 20)
{
    // $used array contains used elements
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = generatehash($length);
    if (!isset($used[$randomString])) {
        $used[$randomString] = 1;
        return $randomString;
    } else {
        $randomString = generateuniqid($used);
        $used[$randomString] = 1;
        return $randomString;
    }
}
Exemplo n.º 2
0
    $key = $cdata["k"];
}
//construct dashboard json
$i = 0;
$sheets = "";
$datasources = "";
$usedkeys = array();
$ds_template = file_get_contents("cbr1-dst.json");
$sheet_template = file_get_contents("cbr1-st.json");
$jsondash = "{   \"Sources\":{  myfulldatasources },    \"CalcMembers\":null,   \"Sheets\":[ myfulldatasheets ],\n   \"ActiveSheetId\":\"myfirstsheetid\",   \"SheetsVisible\":true,   \"FixedSheetWidth\":false,   \"SheetWidth\":842,   \"Font\":{\"FontFamily\":\"DefaultFont\", \"Size\":12,\n\"Color\":\"#000000\",\"IsBold\":false,\"IsItalic\":false,\"IsUnderline\":false},\n   \"Name\":\"Currency generated\",   \"Description\":\"Currency dashboard\",   \"Version\":\"6\"} ";
$orig = array("currencyname", "mydatasourceid", "currencyvname", "mycapsideacomdatasetkey", "mysheetname", "mysheetid", "mydatablockid", "\$currency");
foreach ($cname as $value) {
    $kname = $value;
    $dskey = "ds_" . generateuniqid($usedkeys);
    $skey = "sheet_" . generateuniqid($usedkeys);
    $dbkey = "datablock_" . generateuniqid($usedkeys);
    $capsideaname = strtolower(str_replace(" ", "_", $kname));
    $repl = array($capsideaname, $dskey, $kname, $key, $kname, $skey, $dbkey, "\$usdcurrency");
    $this_ds = str_replace($orig, $repl, $ds_template);
    $this_s = str_replace($orig, $repl, $sheet_template);
    if (0 != $i) {
        $datasources = $datasources . ",";
        $sheets = $sheets . ",";
    } else {
        $first_sheet_id = $skey;
    }
    $datasources = $datasources . $this_ds;
    $sheets = $sheets . $this_s;
    $i++;
}
$orig = array("myfulldatasheets", "myfulldatasources", "myfirstsheetid");