function save_soldier_code()
{
    $soldierCode = new SoldierCode();
    $db_enteries_limit = 1000;
    $unique_enteries = 0;
    $code;
    while ($unique_enteries < $db_enteries_limit) {
        $code = generate_random();
        if (!$soldierCode->codeExist($code)) {
            if ($soldierCode->insertCode($code)) {
                $unique_enteries++;
            }
        }
    }
}
Beispiel #2
0
     $uid = mysqli_real_escape_string($dblink, $_POST["uid"]);
     $name = mysqli_real_escape_string($dblink, $_POST["name"]);
     $os = intval($_POST["os"]);
     $brand = 0;
     // detect brand strings
     foreach (explode($separator, strtolower($gpu)) as $karta) {
         if (strpos($karta, "amd") !== false || strpos($karta, "ati ") !== false || strpos($karta, "radeon") !== false) {
             $brand = 2;
             break;
         }
         if (strpos($karta, "nvidia") !== false) {
             $brand = 1;
         }
     }
     // create access token
     $token = generate_random(10);
     // save the new agent to the db or update existing one with the same hdd-serial
     if (mysqli_query_wrapper($dblink, "INSERT INTO agents (name, uid, os, cputype, gpubrand, gpus, token, comment) VALUES ('{$name}', '{$uid}', {$os}, {$cpu}, {$brand},'{$gpu}','{$token}', '{$comment}') ON DUPLICATE KEY UPDATE name='{$name}',os={$os},cputype={$cpu},gpubrand={$brand},gpus='{$gpu}',token='{$token}',comment='{$comment}'")) {
         echo "reg_ok" . $separator . $token;
     } else {
         echo "reg_nok" . $separator . "Could not register you to server.";
         $failure = true;
     }
 } else {
     echo "reg_nok" . $separator . "Provided voucher does not exist.";
     $failure = true;
 }
 if ($failure) {
     mysqli_query_wrapper($dblink, "ROLLBACK");
 } else {
     mysqli_query_wrapper($dblink, "COMMIT");
<?php

include "../function.php";
if (($_FILES["file"]["type"] == "image/png" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg") && $_FILES["file"]["size"] < 50000) {
    if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    } else {
        $filename = generate_random();
        move_uploaded_file($_FILES["file"]["tmp_name"], "cache/" . $filename);
        $url = 'http://' . $_SERVER['HTTP_HOST'] . "/include/phpQRDeCode/zbar.php";
        //phpQRDeCode.php";  //调用接口的平台服务地址
        $post_string = array('filename' => $filename);
        //$post_string = array('url'=>'http://'.$_SERVER['HTTP_HOST']."/include/phpQRDeCode/cache/".$_FILES["file"]["name"]);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);
        unlink('cache/' . $filename);
        echo $result;
    }
} else {
    echo "The file is too large or the file isn't picture.";
}
function many_connections_test($category, $client_name, $num_connections, $rate, $total, $msg_per_call, $avg_size)
{
    if ($num_connections < 1) {
        print "you can't run the test with {$num_connections} connections\n";
    }
    if ($rate % $num_connections != 0 || $total % $num_connections != 0 || $total / $num_connections % $msg_per_call != 0) {
        print "Arguments don't divide evenly, so number of messages won't be accurate\n";
    }
    $rate_per_conn = $rate / $num_connections;
    $send_interval = $msg_per_call / $rate_per_conn;
    // open all the connections. This bypasses the normal client library because
    // we want to open a lot of connections simultaneously, which is something
    // a real client would never need to do.
    //
    $server_ips = array('localhost');
    $port = 1463;
    $socks = array();
    $trans = array();
    $prots = array();
    $scribes = array();
    $opened = array();
    try {
        for ($i = 0; $i < $num_connections; ++$i) {
            $socks[$i] = new TSocketPool($server_ips, $port);
            $socks[$i]->setDebug(1);
            $socks[$i]->setSendTimeout(250);
            $socks[$i]->setRecvTimeout(250);
            $socks[$i]->setNumRetries(1);
            $socks[$i]->setRetryInterval(30);
            $socks[$i]->setRandomize(true);
            $socks[$i]->setMaxConsecutiveFailures(2);
            $socks[$i]->setAlwaysTryLast(false);
            $trans[$i] = new TFramedTransport($socks[$i], 1024, 1024);
            $prots[$i] = new TBinaryProtocol($trans[$i]);
            $scribes[$i] = new scribeClient($prots[$i]);
            $trans[$i]->open();
            $opened[$i] = true;
        }
    } catch (Exception $x) {
        print "exception opening connection {$i}";
        // Bummer too bad so sad
        return;
    }
    // Send the messages, a few from each connection every loop
    //
    $random = generate_random($avg_size * 2);
    $last_send_time = microtime(true);
    $i = 0;
    while ($i < $total) {
        $messages = array();
        for ($conn = 0; $conn < $num_connections; ++$conn) {
            for ($j = 0; $j < $msg_per_call; ++$j) {
                $entry = new LogEntry();
                $entry->category = $category;
                $entry->message = make_message($client_name, $avg_size, $i, $random);
                $messages[] = $entry;
                ++$i;
            }
            $result = $scribes[$conn]->Log($messages);
            if ($result != OK) {
                print "Warning: Log returned {$result} \n";
            }
            $messages = array();
        }
        $now = microtime(true);
        $wait = $last_send_time + $send_interval - $now;
        $last_send_time = $now;
        if ($wait > 0) {
            print "going to sleep {$wait} ms\n";
            usleep($wait * 1000000);
        } else {
            print "backed up {$wait} ms\n";
        }
    }
    // Close the connections
    //
    for ($i = 0; $i < $num_connections; ++$i) {
        if ($opened[$i]) {
            try {
                $trans[$i]->close();
            } catch (Exception $x) {
                print "exception closing connection {$i}";
                // Ignore close errors
            }
        }
    }
}
 /**
  * Forgot Password screen
  */
 public function forgotpassword()
 {
     $this->_redirectIfLoggedIn();
     if (!Yii::app()->request->getPost('action')) {
         $this->_renderWrappedTemplate('authentication', 'forgotpassword');
     } else {
         $sEmailAddr = Yii::app()->request->getPost('email');
         $aFields = PL::model()->findAllByAttributes(array('email' => $sEmailAddr));
         if (count($aFields) < 1) {
             // wrong or unknown username and/or email
             $aData['errormsg'] = $this->getController()->lang->gT('Email address not found. Please check the email address you have provided or register for a new account');
             $aData['maxattempts'] = '';
             $this->_renderWrappedTemplate('authentication', 'error', $aData);
         } else {
             $Panellist_id = $aFields[0]['panel_list_id'];
             $activation_id = generate_random(20);
             //$activation_link = Yii::app()->getBaseUrl(true) . '/index.php/pl/registration/sa/activate/c/' . $NewPanellist . '*' . $activation_id;
             $activation_link = Yii::app()->createAbsoluteUrl('pl/registration/sa/activate/c/' . $Panellist_id . '*' . $activation_id);
             $sql_code = "INSERT INTO {{activation_temp}}\n                    (panelllist_id,code,activation_type)\n                    VALUES('{$Panellist_id}','{$activation_id}','forget_pass')";
             $result = Yii::app()->db->createCommand($sql_code)->query();
             $whitelist = array('127.0.0.1', '::1');
             if (!in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
                 $send = get_SendEmail::model()->SendEmailByTemplate($sEmailAddr, EMAIL_POINT_PL_ForgotPassword, $Panellist_id, array('activation_link' => "{$activation_link}"));
             } else {
                 echo $send = get_SendEmail::model()->SendEmailByTemplate($sEmailAddr, EMAIL_POINT_PL_ForgotPassword, $Panellist_id, array('activation_link' => "{$activation_link}"));
                 exit;
             }
             //$send = get_SendEmail::model()->SendEmailByTemplate($sEmailAddr, EMAIL_POINT_PL_ForgotPassword, $Panellist_id, array('activation_link' => "$activation_link"));
             if (!$send) {
                 $aData['message'] = 'Error in sending mail';
                 echo 'Error';
                 Yii::app()->setFlashMessage($clang->gT("Error in mail send"));
             } else {
                 $aData['message'] = 'A request to reset your password has just been sent to your email address. This email will come from ' . Yii::app()->getConfig("siteadminemail") . '. Simply click on "Link" within that email to complete your password change.
                 Please take this time to add ' . Yii::app()->getConfig("siteadminemail") . ' to your trusted or safe sender list to ensure that our emails are delivered to your Inbox.
                 If you do not receive this email within 15 minutes, please check your junk/spam folder and Contact Us.';
             }
             $this->_renderWrappedTemplate('authentication', 'message', $aData);
         }
     }
 }
Beispiel #6
0
         echo "Existing vouchers:<br>";
         echo "<table class=\"styled\"><tr><td>Voucher</td><td>Issued</td><td>Action</td></tr>";
         while ($erej = mysqli_fetch_array($kver, MYSQLI_ASSOC)) {
             $id = $erej["voucher"];
             echo "<tr><td>{$id}</td>";
             echo "<td>" . date($config["timefmt"], $erej["time"]) . "</td>";
             echo "<td><form action=\"{$myself}?a=voucherdelete\" method=\"POST\" onSubmit=\"if (!confirm('Really delete this voucher?')) return false;\">";
             echo "<input type=\"hidden\" name=\"return\" value=\"a=deploy\">";
             echo "<input type=\"hidden\" name=\"voucher\" value=\"{$id}\">";
             echo "<input type=\"submit\" value=\"Delete\"></form></td></tr>";
         }
         echo "</table>Used vouchers are automaticaly deleted to prevent double spending.<br><br>";
     }
     echo "<form action=\"{$myself}?a=deploy\" method=\"POST\">";
     echo "<table class=\"styled\"><tr><td>New voucher</td></tr>";
     echo "<tr><td><input type=\"text\" name=\"newvoucher\" value=\"" . generate_random(8) . "\"></td></tr>";
     echo "<tr><td><input type=\"submit\" value=\"Create\"></td></tr>";
     echo "</table></form>";
     break;
 case "logout":
     unset($_SESSION[$sess_name]);
     echo "<script>alert('Logged out.');location.href='{$myself}';</script>";
     break;
 case "manual":
     echo "<iframe src=\"manual.html\"></iframe>";
     break;
 case "custmenu":
     // custom menu
     $menu = $_GET["menu"];
     if (isset($custmenuitems[$menu])) {
         echo $custmenuitems[$menu]["name"] . ":<br>";
Beispiel #7
0
<A name="GE">
<H2>Send generic command:</H2>
<FORM action="fs20.php">
<?php 
echo "<INPUT type=\"textarea\" cols=\"80\" rows=\"5\" name=\"generic\"";
printf("value=\"%s\">", isset($_GET['generic']) ? $_GET['generic'] : "");
?>
<INPUT type="submit" name="submit" value="send">
</FORM>

<HR>

<A name="RA">
<?php 
generate_random();
//execute command
unset($cmdline);
if (isset($_GET['generic'])) {
    $cmdline = explode("\n", $_GET['generic']);
} elseif (isset($_GET['device']) && isset($_GET['state']) && isset($_GET['command'])) {
    $cmdline = array($_GET['command'] . " " . $_GET['device'] . " " . $_GET['state']);
}
if (isset($cmdline)) {
    array_push($cmdline, "quit");
    echo "<HR><H2>Last command</H2>";
    echo "<TABLE><TR valign=top><TD>send:</TD><TD>";
    foreach ($cmdline as $line) {
        echo "{$line}<br>";
    }
    echo "</TD></TR></TABLE>";
 public function DoRegistration()
 {
     $clang = Yii::app()->lang;
     $email_address = $_POST['email_address'];
     $pwd = $_POST['pwd'];
     //$spwd = hash('sha256', $pwd);
     $spwd = urlencode(base64_encode($pwd));
     $fname = $_POST['fname'];
     $lname = $_POST['lname'];
     $aData['display'] = false;
     $aViewUrls = array();
     if (PL::model()->find("email=:email", array(':email' => $email_address))) {
         //            Yii::app()->setFlashMessage($clang->gT("Error in mail send"));
         //$aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Failed to add Panellist"), $clang->gT("The Panellist Email already exists"), "warningheader", $clang->gT("The Panellist Email already exists"), $this->getController()->createUrl('/'), $clang->gT("Back"));//17/06/2014 Remove By Hari
         $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Failed to add Panellist"), $clang->gT("The Panellist Email already exists"), "warningheader", "", $this->getController()->createUrl('/'), $clang->gT("Back"));
         //17/06/2014 Add By Hari
         $this->_renderWrappedTemplate('', $aViewUrls, $aData);
         //Yii::app()->setFlashMessage($clang->gT("Error in mail send"));
         //$this->_redirectToIndex();
     }
     $NewPanellist = PL::model()->insertPanellist($email_address, $spwd, $lname, $fname);
     if ($NewPanellist) {
         $quelist = Question(get_question_categoryid('Registration'), '', true, false);
         $sql = "INSERT INTO {{panellist_answer}} SET panellist_id = '{$NewPanellist}' ";
         foreach ($quelist as $key => $value) {
             if ($value == 'CheckBox') {
                 $val = implode(',', $_POST[$key]);
                 $sql .= ", question_id_{$key} = '" . $val . "'";
             } elseif ($value == 'DOB') {
                 $birthdate = date('Y-m-d', strtotime($_POST[$key]));
                 $sql .= ", question_id_{$key} = '" . $birthdate . "'";
             } else {
                 $sql .= ", question_id_{$key} = '" . $_POST[$key] . "'";
             }
         }
         $result = Yii::app()->db->createCommand($sql)->query();
         $activation_id = generate_random(20);
         //$activation_link = Yii::app()->getBaseUrl(true) . '/index.php/pl/registration/sa/activate/c/' . $NewPanellist . '*' . $activation_id;
         $activation_link = Yii::app()->createAbsoluteUrl('pl/registration/sa/activate/c/' . $NewPanellist . '*' . $activation_id);
         $sql_code = "INSERT INTO {{activation_temp}}\n                    (panelllist_id,code,activation_type)\n                    VALUES('{$NewPanellist}','{$activation_id}','reg')";
         $result = Yii::app()->db->createCommand($sql_code)->query();
         $whitelist = array('127.0.0.1', '::1');
         if (!in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
             $send = get_SendEmail::model()->SendEmailByTemplate($email_address, EMAIL_POINT_PL_Registration, $NewPanellist, array('pwd' => "{$pwd}", 'activation_link' => "{$activation_link}"));
         } else {
             echo $send = get_SendEmail::model()->SendEmailByTemplate($email_address, EMAIL_POINT_PL_Registration, $NewPanellist, array('pwd' => "{$pwd}", 'activation_link' => "{$activation_link}"));
             exit;
         }
         //$send = get_SendEmail::model()->SendEmailByTemplate($email_address, EMAIL_POINT_PL_Registration, $NewPanellist, array('pwd' => "$pwd", 'activation_link' => "$activation_link"));
         if (!$send) {
             echo 'Error';
             Yii::app()->setFlashMessage($clang->gT("Error in mail send"));
         }
         $this->getController()->redirect(array("pl/registration/sa/process"));
     }
 }
Beispiel #9
0
    if (trim($login_input) != "") {
        $array = $cn->get_array("select use_id,use_email,use_login from ac_users where lower(use_login)=lower(\$1) ", array($login_input));
    } elseif (trim($email_input) != "") {
        $array = $cn->get_array("select use_id,use_email,use_login from ac_users where  " . "  lower(use_email)=lower(\$1) ", array($email_input));
    } else {
        return;
    }
    if ($cn->size() != 0) {
        list($user_id, $user_email, $user_login) = array_values($array[0]);
        if (trim($user_email) != " ") {
            $valid = true;
        }
    }
    if ($valid == true) {
        $request_id = generate_random(SIZE_REQUEST);
        $user_password = generate_random(10);
        /*
         * save the request into 
         */
        $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " . " values (\$1,\$2,\$3,now(),\$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR']));
        /*
         * send an email
         */
        $mail = new Sendmail();
        $mail->set_from(ADMIN_WEB);
        $mail->mailto($user_email);
        $mail->set_subject("NOALYSS : Réinitialisation de mot de passe");
        $message = <<<EOF
     Bonjour,
      
Une demande de réinitialisation de votre mot de passe a été demandée par {$_SERVER['REMOTE_ADDR']}
<?php

include "qrlib.php";
include dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'function.php';
$filepath = generate_random();
QRcode::png($_POST['info'], dirname(__FILE__) . DIRECTORY_SEPARATOR . 'usercache' . DIRECTORY_SEPARATOR . $filepath . '.png', 'L', 4, 2);
echo $filepath;