本文整理汇总了PHP中u函数的典型用法代码示例。如果您正苦于以下问题:PHP u函数的具体用法?PHP u怎么用?PHP u使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
B('FilterString');
$data = M(MODULE_NAME)->create();
$log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("mail_server");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
if (!check_empty($data['smtp_server'])) {
$this->error(L("SMTP_SERVER_EMPTY_TIP"));
}
if (!check_empty($data['smtp_name'])) {
$this->error(L("SMTP_NAME_EMPTY_TIP"));
}
if (!check_empty($data['smtp_pwd'])) {
$this->error(L("SMTP_PWD_EMPTY_TIP"));
}
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例2: testOrderDesc
public function testOrderDesc()
{
$this->assertTrue(CComparator::orderDesc(u("Hello there!"), u("Hello there!")) == 0);
$this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
$this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
$this->assertTrue(CComparator::orderDesc(u("¡Hola señor!"), u("¡Hola señor!")) == 0);
$this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
$this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
$this->assertTrue(CComparator::orderDesc(a("a", "b", "c"), a("a", "b", "c")) == 0);
$this->assertTrue(CComparator::orderDesc(a("b", "b", "c"), a("a", "b", "c")) < 0);
$this->assertTrue(CComparator::orderDesc(m(["one" => "a", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) == 0);
$this->assertTrue(CComparator::orderDesc(m(["one" => "b", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) < 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1955 12:00:00 PST")) == 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) > 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1985 12:00:01 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) < 0);
$this->assertTrue(CComparator::orderDesc(true, true) == 0);
$this->assertTrue(CComparator::orderDesc(false, true) > 0);
$this->assertTrue(CComparator::orderDesc(true, false) < 0);
$this->assertTrue(CComparator::orderDesc(1234, 1234) == 0);
$this->assertTrue(CComparator::orderDesc(1234, 5678) > 0);
$this->assertTrue(CComparator::orderDesc(5678, 1234) < 0);
$this->assertTrue(CComparator::orderDesc(12.34, 12.34) == 0);
$this->assertTrue(CComparator::orderDesc(12.34, 56.78) > 0);
$this->assertTrue(CComparator::orderDesc(56.78, 12.34) < 0);
$this->assertTrue(CComparator::orderDesc(null, null) == 0);
$this->assertTrue(CComparator::orderDesc("Hello there!", "Hello there!") == 0);
$this->assertTrue(CComparator::orderDesc("A", "B") > 0);
$this->assertTrue(CComparator::orderDesc("C", "B") < 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("a", "b", "c")) == 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("b", "b", "c")) > 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("b", "b", "c"), CArray::fromElements("a", "b", "c")) < 0);
$this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) == 0);
$this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "b", "two" => "b", "three" => "c"]) > 0);
$this->assertTrue(CComparator::orderDesc(["one" => "b", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) < 0);
}
示例3: testWrite
public function testWrite()
{
$filePath = CFile::createTemporary();
CFile::write($filePath, "Hello there!");
$this->assertTrue(u(file_get_contents($filePath))->equals("Hello there!"));
CFile::delete($filePath);
}
示例4: post
public function post()
{
if (IS_POST) {
$data = json_decode(Request::post('keyword'), TRUE);
$data['rank'] = $data['istop'] == 1 ? 255 : min(255, intval($data['rank']));
$data['module'] = v('module.name');
$data['keywords'] = $data['keyword'];
$rid = service('WeChat')->rule($data);
//调用模块的执行方法
$module = new $this->moduleClass();
//字段验证
if ($msg = $module->fieldsValidate($rid)) {
message($msg, 'back', 'error');
}
//使模块保存回复内容
$module->fieldsSubmit($rid);
message('规则保存成功', u('post', ['rid' => $rid, 'm' => v('module.name')]));
}
//获取关键词回复
if ($rid = Request::get('rid')) {
$data = Db::table('rule')->find($rid);
if (empty($data)) {
message('回复规则不存在', 'back', 'error');
}
$data['keyword'] = Db::table('rule_keyword')->orderBy('id', 'asc')->where('rid', $rid)->get();
View::with('rule', $data);
}
$module = new $this->moduleClass();
$moduleForm = $module->fieldsDisplay($rid);
return view()->with('moduleForm', $moduleForm);
}
示例5: getAdminInterface
/**
* Build and return admin interface
*
* Any module providing an admin interface is required to have this function, which
* returns a string containing the (x)html of it's admin interface.
* @return string
*/
function getAdminInterface()
{
$this->addCSS('/modules/Templater/css/templates.css');
$templates = Template::getAllTemplates();
if (!isset($_REQUEST['template_id'])) {
$this->smarty->assign('curtemplate', $templates[0]);
} else {
if (isset($_REQUEST['save'])) {
$t = new Template($_REQUEST['template_id']);
$t->setData(u($_REQUEST['editor']));
$t->setTimestamp(date('Y-m-d H:i:s'));
$t->setId(null);
$t->save();
$this->smarty->assign('curtemplate', $t);
$templates = Template::getAllTemplates();
} else {
if (isset($_REQUEST['switch_template'])) {
$this->smarty->clear_assign('curtemplate');
$this->smarty->assign('curtemplate', new Template($_REQUEST['template']));
} else {
if (isset($_REQUEST['switch_revision'])) {
$this->smarty->clear_assign('curtemplate');
$this->smarty->assign('curtemplate', new Template($_REQUEST['revision']));
} else {
$this->smarty->assign('curtemplate', new Template($_REQUEST['template_id']));
}
}
}
}
$this->smarty->assign('templates', $templates);
return $this->smarty->fetch('admin/templates.tpl');
}
示例6: insert
public function insert()
{
B('FilterString');
$ajax = intval($_REQUEST['ajax']);
$data = M(MODULE_NAME)->create();
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/add"));
if (!check_empty($data['name'])) {
$this->error("请输入分类名称");
}
$user_level_list = M(MODULE_NAME)->where("point=" . intval($data['point']))->find();
if ($user_level_list) {
$this->error('已有相同的"所需信用值"');
}
// 更新数据
$log_info = $data['name'];
$list = M(MODULE_NAME)->add($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("INSERT_SUCCESS"), 1);
$this->success(L("INSERT_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("INSERT_FAILED"), 0);
$this->error(L("INSERT_FAILED"));
}
}
示例7: update
public function update()
{
$data = M(MODULE_NAME)->create();
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/add"));
if (!check_empty($data['name'])) {
$this->error(L("TAGNAME_EMPTY_TIP"));
}
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
$log_info = $data['name'];
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
M("TagGroupLink")->where("tag_group_id=" . $data['id'])->delete();
foreach ($_REQUEST['cate_id'] as $cate_id) {
if (intval($cate_id) > 0) {
$link_data = array();
$link_data['category_id'] = intval($cate_id);
$link_data['tag_group_id'] = $data['id'];
M("TagGroupLink")->add($link_data);
}
}
clear_auto_cache("store_filter_nav_cache");
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例8: update
public function update()
{
$data = M(MODULE_NAME)->create();
$log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("levelname");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
if (!check_empty($data['levelname'])) {
$this->error("请填写星级名称");
}
if (!preg_match('/^[0-9]*[1-9][0-9]*$/', $data['level'])) {
$this->error("请填写级别");
}
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
$dbErr = M()->getDbError();
save_log($log_info . L("UPDATE_FAILED") . $dbErr, 0);
$this->error(L("UPDATE_FAILED") . $dbErr);
}
}
示例9: update
public function update()
{
B('FilterString');
$data = M(MODULE_NAME)->create();
$log_info = $data['id'] . l("TOPIC_DATA");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
rm_auto_cache("recommend_forum_topic");
M("TopicCateLink")->where("topic_id=" . $data['id'])->delete();
foreach ($_REQUEST['cate_id'] as $cate_id) {
$link_data = array();
$link_data['cate_id'] = $cate_id;
$link_data['topic_id'] = $data['id'];
M("TopicCateLink")->add($link_data);
}
syn_topic_match($data['id']);
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例10: update
public function update()
{
$data = M(MODULE_NAME)->create();
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit"));
if (!check_empty($data['name'])) {
$this->error(L("POINTNAME_EMPTY_TIP"));
}
if (M(MODULE_NAME)->where("id<>" . $data['id'] . " and `name`='" . $data['name'] . "'")->count() > 0) {
$this->error(L("HAD_POINTGROUP"));
}
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
$log_info = $data['name'];
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例11: pagesList
function pagesList($type)
{
global $self, $PG_DIR;
$list = array();
$dir = opendir($PG_DIR);
while ($file = readdir($dir)) {
if (preg_match("/\\.txt\$/", $file)) {
$files[] = substr($file, 0, strlen($file) - 4);
}
}
if (is_array($files)) {
sort($files);
foreach ($files as $file) {
$list[] = "<a href=\"{$self}?page=" . u($file) . "\">" . h($file) . "</a>";
}
}
if ($type == "comma") {
$ret = implode(", ", $list);
} else {
if ($type == "list") {
$ret = "<ul><li>" . implode("</li><li>", $list) . "</li></ul>";
}
}
return $ret;
}
示例12: order_referer
/**
* 订单来路的图饼展示
*/
public function order_referer()
{
$where = " 1=1 ";
$where .= " and type <> 1";
$map['type'] = array("neq", 1);
$begin_time = strim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']);
$end_time = strim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']);
if ($end_time == 0) {
$where .= " and create_time > " . $begin_time;
$map['create_time'] = array("gt", $begin_time);
} else {
$where .= " and create_time between " . $begin_time . " and " . $end_time;
$map['create_time'] = array("between", array($begin_time, $end_time));
}
$sql = "select referer,count(id) as ct from " . DB_PREFIX . "deal_order where " . $where . " and referer <> '' group by referer having count(id) > 0 order by ct desc limit 8 ";
$total_sql = "select count(*) from " . DB_PREFIX . "deal_order where " . $where;
$colors = array("0xAAAAAA", "0x669999", "0xBBBB55", "0xCC6600", "0x9999FF", "0x0066CC", "0x99CCCC", "0x999999", "0xFFCC00", "0x009999", "0x99CC33", "0xFF9900", "0x999966", "0x66CCCC", "0x339966", "0xCCCC33");
$total = intval($GLOBALS['db']->getOne($total_sql));
$list = $GLOBALS['db']->getAll($sql);
$items = array();
foreach ($list as $k => $v) {
$total -= intval($v['ct']);
$items[] = array("value" => intval($v['ct']), "tip" => $v['referer'], "on-click" => "jump_to('" . u("DealOrder/deal_index", array("referer" => $v['referer'])) . "')");
}
$items[] = array("value" => $total, "tip" => "直接访问", "on-click" => "jump_to('" . u("DealOrder/deal_index", array("referer" => -1)) . "')");
$data['bg_colour'] = "#ffffff";
$data['elements'] = array(array("type" => "pie", "colours" => $colors, "alpha" => 1, "border" => 2, "start-angle" => 35, "values" => $items));
ajax_return($data);
}
示例13: update
public function update()
{
B('FilterString');
$data = M("ApnsMessages")->create();
$log_info = $data['id'];
//开始验证有效性
$this->assign("jumpUrl", u("MApns/edit", array("id" => $data['id'])));
if (!check_empty($data['content'])) {
$this->error(L("CONTENT_EMPTY_TIP"));
}
if ($data['send_time'] == '') {
$data['send_time'] = get_gmtime();
}
$data['send_time'] = to_timespan($data['send_time']);
if (intval($_REQUEST['resend']) == 1) {
$data['status'] = 0;
}
$list = M("ApnsMessages")->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例14: update
public function update()
{
B('FilterString');
$data = M(MODULE_NAME)->create();
$user_names = preg_split("/[ ,]/i", $data['user_names']);
$user_ids = "";
foreach ($user_names as $k => $v) {
$uid = M("User")->where("user_name = '" . $v . "'")->getField("id");
if ($uid) {
$user_ids .= $uid . "|";
}
}
$data['user_ids'] = $user_ids;
$data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']);
$log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("title");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
if (!check_empty($data['title'])) {
$this->error(L("MSY_TITLE_EMPTY_TIP"));
}
if (!check_empty($data['content'])) {
$this->error(L("MSY_CONTENT_EMPTY_TIP"));
}
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}
示例15: update
public function update()
{
B('FilterString');
$data = M(MODULE_NAME)->create();
$log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
if (!check_empty($data['name'])) {
$this->error(L("ATTR_NAME_EMPTY_TIP"));
}
if (!check_empty($data['preset_value']) && $data['input_type'] == 1) {
$this->error(L("PRESET_VALUE_EMPTY_TIP"));
}
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
}
}