Exemple #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;
    }
}
//print_r($cdata);
$secret = $cdata["t"];
if (isset($cdata["k"])) {
    // check, if this is reinitialisation
    $key = (int) $cdata["k"];
    $row = @pg_fetch_assoc(pg_query("select ihash from client where ikey={$key}"));
    $sk = "&schemakey=" . $key;
    $hash = $row["ihash"];
    if (strlen($hash) < 10) {
        // workaround
        $hash = generatehash();
        $sk = "";
        unset($key);
    }
} else {
    $hash = generatehash();
    $sk = "";
}
$parent_key = 0;
pg_prepare("query1", 'select * from client where sftplogin=$1 and iparent=0');
$result = pg_execute("query1", array($sftplog));
//$result=@pg_query("select * from client where sftplogin='******' and iparent=0");
if (@pg_num_rows($result) > 0) {
    $row = pg_fetch_assoc($result);
    //$eml=$row["ieml"];
    $hash = $row["ihash"];
    $parent_key = $row["ikey"];
    file_put_contents($my_data_dir . "/paypal_ds.log", date(DATE_ATOM) . "already registered. client [{$company_name}] {$contact_name} l: {$sftplog} \n", FILE_APPEND);
    //die("this client already registered, please contact user $eml for shared datasource");
}
// send progress bar to client