public function generateAvatarUrl($id = null, $path = 'uploads/avatar') { $id === null and $id = $this->getId(); $subPath = substr(base62encode(crc32($id) + 62), 0, 2); $fileName = base62encode($id); $url = $path . '/' . $subPath . '/' . $fileName . '.png'; return $url; }
public function testBase62encode() { $this->assertEquals('Z', base62encode('61'), 'Bad base62encode value for 61'); $this->assertEquals('10', base62encode('62'), 'Bad base62encode value for 62'); }
} if (!empty($_POST['botcheck'])) { $botcheck = 1; } else { $botcheck = 0; } // VAILD POLL - DATA AT THIS POINT - #YOLO $_SESSION['captcha_ans'] = time(); $database = new medoo(); $id = $database->insert("polls", ["ip" => sha1($_SERVER["HTTP_X_FORWARDED_FOR"]), "title" => $data['q'], "type" => (int) $_POST['type'], "botcheck" => $botcheck, "ipcheck" => $ipcheck, "created" => time()]); foreach ($data['c'] as $c) { $cid = $database->insert("questions", ["text" => $c, "pid" => $id]); //insert cache $database->insert("results", ["pid" => $id, "qid" => $cid, "amount" => 0]); } $oid = base62encode($id); echo "<h3>Your Poll has been submitted</h3><br><h4>You can find your new poll at <a href=http://jrwr.space/p/{$oid}>http://jrwr.space/p/{$oid}</a></h4><br><br>Polls only last one month starting when the poll started<br>Polls and their votes are removed after two months."; } else { ?> <h1>Make a New Poll</h1><br><small>All fleids are maxed at 255 characters</small><br><br><br> <form action="makepoll.php" method="POST"> Poll Question: <br> <input type="text" maxlength="255" name="question" value=""><br><br> <br> <b>Poll Type</b><br> <input type="radio" name="type" value="1" checked>Multiple Choice <br> <input type="radio" name="type" value="2">Single Choice<br><br> <br><br> <?php for ($x = 1; $x <= 9; $x++) {