本文整理汇总了PHP中convert_str函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_str函数的具体用法?PHP convert_str怎么用?PHP convert_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db_init
function db_init($db_group = 'default')
{
IS_DB_ACTIVE or show_error('please check your database configration');
//数据库资源
$db = false;
$db_username = '';
$db_passwd = '';
$db_database = '';
$db_host = 'localhost';
$db_port = '3306';
$db_conf = get_conf('db_conf');
$charset = str_replace('-', '', CHARSET);
//将 utf-8 切换为 utf8
if (!$db_conf) {
show_error('none valid database configration!');
} else {
if (!array_key_exists($db_group, $db_conf)) {
show_error("invalid database group '{$db_group}' called!");
} else {
extract($db_conf[$db_group]);
$db = new mysqli($db_host, $db_username, $db_passwd, $db_database, $db_port);
if ($db->connect_errno) {
$error_msg = convert_str('database established error - error code: ' . $db->connect_errno . " | " . 'error msg: ' . $db->connect_error);
show_error($error_msg);
} else {
$db->set_charset($charset);
//由 set names xxx 升级为该行
}
}
}
return $db;
}
示例2: dir_form_path
/**
* Returns correct path for a directory
*
* @param str $aPath parent category path
* @param str $aTitle category title
*
* @return str
*/
function dir_form_path($aPath, $aTitle)
{
$params['string'] = $aTitle;
$title = convert_str($params);
$out = $aPath ? $aPath . '/' . $title : $title;
return $out;
}
示例3: convert_all_str
function convert_all_str($arr)
{
if ($arr == null) {
return null;
}
if (!is_array($arr)) {
return convert_str($arr);
}
foreach ($arr as $k => $a) {
if (is_array($a)) {
$arr[$k] = convert_all_str($a);
} else {
if ($k != "op_content") {
$arr[$k] = convert_str($a);
} else {
$arr[$k] = $a;
}
}
}
return $arr;
}
示例4: convert_str
<?php
$pagetitle = "Information of " . $_GET['name'];
include_once "header.php";
include_once "functions/users.php";
include_once "functions/sidebars.php";
$name = convert_str($_GET['name']);
$show_user = new User();
$show_user->load_info($name);
if ($show_user->is_valid()) {
?>
<div class="span8">
<h2>Information of <?php
echo $show_user->get_val('username');
?>
</h2>
<div id="userinfo">
<table class="table">
<tr><th class="span3">Username:</th><td class="span9"><?php
echo $show_user->get_val('username');
?>
</td></tr>
<tr><th>User ID:</th><td><?php
echo $show_user->get_val('uid');
?>
</td></tr>
<tr><th>Rank:</th><td><?php
echo $show_user->get_val('rank');
?>
</td></tr>
<tr><th>Nickname:</th><td><?php
示例5: dirname
<?php
include_once dirname(__FILE__) . "/../functions/problems.php";
$vname = convert_str($_GET['vname']);
$vid = convert_str($_GET['vid']);
$ret["code"] = 1;
if ($vname == "BNU") {
$ret["pid"] = $vid;
$ret["title"] = problem_get_title($ret["pid"]);
if ($ret["title"]) {
$ret["code"] = 0;
}
} else {
$ret["pid"] = problem_get_id_from_virtual($vname, $vid);
$ret["title"] = problem_get_title($ret["pid"]);
if ($ret["pid"] && $ret["title"]) {
$ret["code"] = 0;
}
}
if ($ret["code"] == 0 && problem_hidden($ret["pid"])) {
unset($ret);
$ret["code"] = 1;
}
echo json_encode($ret);
示例6: dirname
<?php
include_once dirname(__FILE__) . "/../functions/users.php";
include_once dirname(__FILE__) . "/../functions/contests.php";
$fid = intval(convert_str($_GET["fcid"]));
$tid = intval(convert_str($_GET["tcid"]));
$ret["code"] = 1;
if ($current_user->is_root()) {
if ($fid > $tid) {
$ret["msg"] = "CID {$fid} to {$tid} is invalid.";
die(json_encode($ret));
}
$ret["code"] = 0;
$ret["msg"] = "Contest [ ";
for ($cid = $fid; $cid <= $tid; $cid++) {
if (contest_get_val($cid, "isvirtual") == 1 && contest_get_val($cid, "type") == 99) {
$ret["msg"] .= $cid . " ";
contest_delete($cid);
}
}
$ret["msg"] .= "] have been successfully deleted.";
} else {
$ret["msg"] = "Permission denied.";
}
echo json_encode($ret);
示例7: dirname
<?php
include_once dirname(__FILE__) . "/../functions/users.php";
$ret = array();
$ret["code"] = 1;
if ($current_user->is_root()) {
$title = convert_str($_POST['title']);
$newsid = convert_str($_POST['newsid']);
$content = convert_str($_POST['content']);
if ($newsid == "") {
$sql_add_pro = "insert into news (title,content,author,time_added) values ('{$title}','{$content}','{$nowuser}', NOW())";
} else {
$sql_add_pro = "update news set title='{$title}',content='{$content}',author='{$nowuser}',time_added=NOW() where newsid='{$newsid}'";
}
$db->query($sql_add_pro);
$ret["code"] = 0;
if ($newsid == '') {
$currnid = $db->insert_id;
} else {
$currnid = $newsid;
}
$ret["msg"] = "Success! News ID: {$currnid}.";
} else {
$ret["msg"] = "Please login as root!";
}
echo json_encode($ret);
示例8: addslashes
$_POST['repassword'] = addslashes($_POST['repassword']);
$_POST['nickname'] = convert_str($_POST['nickname']);
$_POST['school'] = convert_str($_POST['school']);
$_POST['email'] = convert_str($_POST['email']);
$ret = array();
$ret["code"] = 1;
if (strlen($_POST['username']) == 0) {
$ret["msg"] = "Empty Username!";
} else {
if (strlen($_POST['username']) < 3) {
$ret["msg"] = "Username too short!";
} else {
if (strlen($_POST['username']) > 64) {
$ret["msg"] = "Username too long!";
} else {
$s = convert_str($_POST['username']);
for ($i = 0; $i < strlen($s); $i++) {
if ($s[$i] >= '0' && $s[$i] <= '9' || $s[$i] >= 'a' && $s[$i] <= 'z' || $s[$i] >= 'A' && $s[$i] <= 'Z' || $s[i] == '-' || $s[i] == '_') {
continue;
} else {
break;
}
}
if ($i != strlen($s)) {
$ret["msg"] = "Invalid Username!";
} else {
if (user_exist($_POST['username'])) {
$ret["msg"] = "Username Already Exists!";
} else {
if (strlen($_POST['password']) < 3) {
$ret["msg"] = "Password too short!";
示例9: convert_str
$hide = convert_str($_POST['p_hide']);
$description = convert_str($_POST['description']);
$input = convert_str($_POST['input']);
$output = convert_str($_POST['output']);
$sample_in = htmlspecialchars(convert_str($_POST['sample_in']));
$sample_out = htmlspecialchars(convert_str($_POST['sample_out']));
$hint = convert_str($_POST['hint']);
$source = convert_str($_POST['source']);
$author = convert_str($_POST['author']);
$memory_limit = convert_str($_POST['memory_limit']);
$time_limit = convert_str($_POST['time_limit']);
$special_judge_status = convert_str($_POST['special_judge_status']);
$case_time_limit = convert_str($_POST['case_time_limit']);
$basic_solver_value = convert_str($_POST['basic_solver_value']);
$noc = convert_str($_POST['noc']);
$ignore_noc = convert_str($_POST['p_ignore_noc']);
if ($pid == "") {
$sql_add_pro = "insert into problem (title,description,input,output,sample_in,sample_out,hint,source,hide,memory_limit,time_limit,special_judge_status,case_time_limit,basic_solver_value,number_of_testcase,vname,vid,ignore_noc,author) values ('{$title}','{$description}','{$input}','{$output}','{$sample_in}','{$sample_out}','{$hint}','{$source}','{$hide}','{$memory_limit}','{$time_limit}','{$special_judge_status}','{$case_time_limit}','{$basic_solver_value}','{$noc}', 'BNU', '{$pid}', '{$ignore_noc}','{$author}')";
} else {
$sql_add_pro = "update problem set title='{$title}',description='{$description}',input='{$input}',output='{$output}',sample_in='{$sample_in}',sample_out='{$sample_out}',hint='{$hint}',source='{$source}',hide='{$hide}',memory_limit='{$memory_limit}',time_limit='{$time_limit}',special_judge_status='{$special_judge_status}',case_time_limit='{$case_time_limit}',basic_solver_value='{$basic_solver_value}',number_of_testcase='{$noc}',ignore_noc='{$ignore_noc}',author='{$author}' where pid='{$pid}'";
}
$db->query($sql_add_pro);
$ret["code"] = 0;
if ($pid == '') {
$currpid = $db->insert_id;
$db->query("update problem set vid=pid where pid='{$currpid}'");
} else {
$currpid = $pid;
}
$ret["msg"] = "Success! PID: {$currpid}.";
} else {
示例10: dirname
<?php
include_once dirname(__FILE__) . "/../functions/discuss.php";
$id = convert_str($_GET['id']);
$tres = discuss_load_detail($id);
$res = discuss_load_detail($tres["rid"]);
discuss_load_subject_list($res);
$res["vis_sub"] = $tres;
echo json_encode($res);
?>
示例11: dirname
<?php
include_once dirname(__FILE__) . "/../functions/users.php";
include_once dirname(__FILE__) . "/../functions/problems.php";
include_once dirname(__FILE__) . "/../functions/contests.php";
$ret = array();
$ret["code"] = 1;
if ($current_user->is_root()) {
$cid = convert_str($_GET['cid']);
$pid = convert_str($_GET['pid']);
$rac = convert_str($_GET['rac']);
$type = convert_str($_GET['type']);
if ($pid == "") {
$ret["msg"] = "Invalid request.";
echo json_encode($ret);
exit;
}
if ($type == 2) {
if (!contest_exist($cid)) {
$ret["msg"] = "Invalid contest.";
echo json_encode($ret);
exit;
}
$pid = contest_get_pid_from_label($cid, $pid);
if ($pid == null) {
$ret["msg"] = "No such problem in this contest.";
echo json_encode($ret);
exit;
}
} else {
if (!problem_exist($pid)) {
示例12: dirname
<?php
include_once dirname(__FILE__) . "/../functions/global.php";
include_once dirname(__FILE__) . "/../functions/discuss.php";
$proid = convert_str($_GET['pid']);
$page = convert_str($_GET['page']);
if ($page == "") {
$page = 0;
}
$res = discuss_load_list($page, $proid);
//print_r($res);
echo json_encode($res);
?>
示例13: convert_str
<?php
include_once "functions/users.php";
include_once "functions/contests.php";
$cid = convert_str($_GET["cid"]);
$admin = convert_str($_GET["admin"]);
if ($admin == 1 && !$current_user->is_root() || !contest_exist($cid) || !($current_user->is_root() || contest_get_val($cid, "isprivate") == 0 || contest_get_val($cid, "isprivate") == 1 && $current_user->is_in_contest($cid) || contest_get_val($cid, "isprivate") == 2 && contest_get_val($cid, "password") == $_COOKIE[$config["cookie_prefix"] . "contest_pass_{$cid}"])) {
?>
<div class="span12">
<p class="alert alert-error">Contest Unavailable!</p>
</div>
<?php
die;
}
//var_dump($_GET);
function get_time($unix_time, $force = false)
{
global $ctype;
if ($ctype == 1 && !$force) {
return number_format($unix_time, 2, ".", "");
}
$first = floor($unix_time / 3600);
$mid = floor(($unix_time - $first * 3600) / 60);
$last = $unix_time % 60;
return $first . ":" . $mid . ":" . $last;
}
$maxrank = 1000000000;
if ($_GET['shownum'] != 0) {
$maxrank = $_GET['shownum'];
}
if ($_GET['anim'] == "on") {
示例14: dirname
<?php
include_once dirname(__FILE__) . "/../functions/users.php";
include_once dirname(__FILE__) . "/../functions/contests.php";
include_once dirname(__FILE__) . "/../functions/runs.php";
$runid = convert_str($_GET['runid']);
$cid = run_get_val($runid, "contest_belong");
$uname = run_get_val($runid, "username");
$ret["code"] = 1;
if (!($cid == "0" || contest_get_val($cid, "hide_others") == 0 || contest_passed($cid) || $current_user->match($uname) || $current_user->is_root())) {
$ret["msg"] = "Permission denined.";
} else {
$query = "select runid,result,memory_used,time_used from status where runid='{$runid}'";
$ret = $db->get_row($query, ARRAY_A);
$ret["code"] = 0;
}
echo json_encode($ret);
示例15: dirname
<?php
include_once dirname(__FILE__) . "/../functions/users.php";
include_once dirname(__FILE__) . "/../functions/problems.php";
require_once dirname(__FILE__) . "/../functions/excel_reader2.php";
require_once dirname(__FILE__) . "/../functions/simple_html_dom.php";
require_once dirname(__FILE__) . "/../functions/replays.php";
foreach ($_POST as $key => $value) {
$_POST[$key] = convert_str($_POST[$key]);
}
if (is_numeric($_POST['sfreq'])) {
$sfreq = intval($_POST['sfreq']);
} else {
$sfreq = 10;
}
if ($sfreq == "" || $sfreq < 10) {
$sfreq = 10;
}
$pnum = $mcid = 0;
$ret = array();
$ret["code"] = 1;
if ($current_user->is_root()) {
if ($_POST['name'] == "") {
$ret["msg"] = "No name!";
die(json_encode($ret));
}
$pnum = 0;
while ($_POST['pid' . $pnum] != "") {
if (!problem_exist($_POST['pid' . $pnum])) {
$ret["msg"] = "Invalid problem ID " . $_POST['pid' . $pnum] . ".";
die(json_encode($ret));