function oencrypt($string, $key) { $method = 'aes-256-ofb'; $iv = substr(md5($key), 0, 16); $string = mt_rand() . ':' . $string . ':' . mt_rand(); $string = openssl_encrypt($string, $method, $key, OPENSSL_RAW_DATA, $iv); return url_base64_encode($string); }
function get_theme_files($extension = 'php', $directory = '/') { $theme_dir = CMS_ROOT . 'themes/' . $this->settings->theme . '/'; $pattern = $theme_dir . trim($directory, '/') . '/*.' . $extension; $file_array = array(); $files = glob_recursive($pattern, GLOB_BRACE); foreach ($files as $file) { $relative_path = str_replace(dirname($pattern) . '/', '', $file); $theme_path = str_replace($theme_dir, '', $file); $file_array[$relative_path] = array('hash' => url_base64_encode($theme_path), 'theme_path' => $theme_path, 'relative_path' => $relative_path, 'title' => ucwords(str_replace(array('_', '-'), ' ', basename($file, '.' . $extension)))); } return $file_array; }
public function testEncodeDecode() { $string = url_base64_encode("1234567890"); $this->assertTrue($string === "MTIzNDU2Nzg5MA"); // $string = url_base64_decode($string); $this->assertTrue($string === "1234567890"); // $key = '111'; $one = xencrypt("1234567890", $key); $two = xencrypt("1234567890", $key); $this->assertTrue($one and $two and $one != $two); $this->assertTrue(xdecrypt($one, $key) === "1234567890"); $this->assertTrue(xdecrypt($two, $key) === "1234567890"); $this->assertTrue(!xdecrypt($two, $key . '1')); // $string = base32_encode("1234567890"); $this->assertTrue(!!preg_match('~^[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]+$~', $string)); // $string = base32_decode($string); $this->assertTrue($string === "1234567890"); // $key = '111'; $one = oencrypt("1234567890", $key); $two = oencrypt("1234567890", $key); $this->assertTrue($one and $two and $one != $two); $this->assertTrue(odecrypt($one, $key) === "1234567890"); $this->assertTrue(odecrypt($two, $key) === "1234567890"); $this->assertTrue(!odecrypt($two, $key . '1')); }
function json_url_base64_encode($dados) { return url_base64_encode(json_encode($dados)); }
//list-1801-0-1-10000-w!bEpA-2.html $cache_id = 'list|' . md5(var_export($_GET, true)); $sp_view = new Sp_View('utf-8'); if (!$sp_view->isCached('list.html', $cache_id)) { $cid = isset($_GET['catid']) ? $_GET['catid'] : 0; $sort = isset($_GET['sort']) ? $_GET['sort'] : 1; $start_price = isset($_GET['sp']) ? $_GET['sp'] : Config::get('special.start_price'); $end_price = isset($_GET['ep']) ? $_GET['ep'] : Config::get('special.end_price'); $keyword = isset($_GET['sq']) ? $_GET['sq'] : ''; $page_no = isset($_GET['page']) ? $_GET['page'] : 1; $page_size = 36; //静态编码网址转码 if (Config::get('special.static') == '1') { $keyword = htmlspecialchars(url_base64_decode($keyword)); if ($keyword != '') { $encode_keyword = url_base64_encode($keyword); $url_format = "list-{$cid}-{$sort}-{$start_price}-{$end_price}-{$encode_keyword}-%d.html"; } else { $url_format = "list-{$cid}-{$sort}-{$start_price}-{$end_price}-%d.html"; } //$url_format = "?catid=$cid&page=%d&sq=$keyword":"?catid=$cid&page=%d"; } else { if ($keyword != '') { $url_format = "list.php?catid={$cid}&sortnum={$sort}&sp={$start_price}&ep={$end_price}&sq={$keyword}&page=%d"; } else { $url_format = "list.php?catid={$cid}&sortnum={$sort}&sp={$start_price}&ep={$end_price}&page=%d"; } } /* Array ( [catid] => 1801 [sortnum] => 0 [sp] => 1 [ep] => 10000 [sq] => w!bEpA [page] => 2 ) */
public static function search($tag) { if (!$tag) { return; } $dtags = self::$tags; $tag = url_base64_encode($tag); $dir = "{$dtags}{$tag}"; if (!is_dir($dir)) { return array(); } $return = array(); foreach (scandir($dir, SCANDIR_SORT_NONE) as $file) { if ($file === ".." or $file === ".") { continue; } list($file, $expire) = explode(".", $file); if (is_numeric($expire) and (!$expire or time() <= $expire)) { $return[] = url_base64_decode($file); } } return $return; }