$id = intval($_GET['id']); $TEMPLATE['data'] = $data = $task->get($id); if ($data['uid'] != Passport::GetLoginUid()) { echo '没有权限!'; exit; } switch ($_POST['action']) { case '修改': $TEMPLATE['data'] = array_merge($data, $_POST); if (!validate()) { } else { $tableInfo = array('title' => $_POST['title'], 'content' => $_POST['content']); if ($data['cat'] == 'weibo') { if ($_FILES['image']['tmp_name']) { @mkdir(UPLOAD_PATH, 0777, true); $save_file = $upload_file = UPLOAD_PATH . microtime(true) . '_' . Pinyin::get($_FILES['image']['name']); move_uploaded_file($_FILES['image']['tmp_name'], $save_file); $tableInfo['pic'] = $save_file; } } if ($_POST['time'] == 'on') { $tableInfo['status'] = Task::TASK; $tableInfo['send_time'] = strtotime($_POST['send_time']); } $task->update($tableInfo, array('id' => $id)); $item = $task->get($id); $TEMPLATE['report']['edit'] = array('status' => true, 'msg' => '修改成功,<a href="' . $_POST['return_url'] . '"><返回</a>(<span id="countdown">5</span>) <script> var countd = 5; var tt = setInterval(function(){ if (--countd == 0) {
/** * keywords输入中文 * @param type $keywords * @return * keywords:中国 return:zhongguo * keywords:中国 中国 return:zhongguo zhongguo */ public static function getEnKeywords($keywords) { $enKeywords = ''; if (strpos($keywords, ' ') && ($keywords = explode(' ', $keywords))) { foreach ($keywords as $value) { if ($value) { $enKeywords .= Pinyin::get($value) . ' '; } } $enKeywords = rtrim($enKeywords, ' '); } else { $enKeywords = Pinyin::get($keywords); } return $enKeywords; }
<?php include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../../../init.php'; Passport::RequireLogin(); if ($_FILES) { $ret = array(); foreach ($_FILES as $file) { $success = false; $errReason = ""; if ($file['size'] == 0) { $errReason = "文件大小为 0 字节。"; } else { @mkdir(UPLOAD_PATH, 0777, true); $new_filename = microtime(true) . '_' . Pinyin::get(str_replace(' ', '-', $file['name'])); $upload_file = UPLOAD_PATH . $new_filename; if (move_uploaded_file($file['tmp_name'], $upload_file)) { $success = true; } } $ret[] = array('Success' => $success, 'ErrReason' => $errReason, 'NewFileName' => UPLOAD_PATH_WWW . $new_filename); } echo json_encode($ret); exit; } ?> <form enctype="multipart/form-data" method="post"> <input type="file" name="file1"> <input type="submit" value="上传"> </form>
public function tag($data, $keywords) { $memkey = MEMPREFIX . 'tag' . $keywords; //$tag = $this->memcache->get($memkey); if ($tag) { return $tag; } foreach ($data as $v) { if (strpos($v['keywords'], ' ')) { $_keywords = explode(' ', $v['keywords']); foreach ($_keywords as $value) { if (strcmp(Pinyin::get($value), $keywords) === 0) { $tag = $value; //$this->memcache->set($memkey, $tag, MEMCACHE_COMPRESSED, 108000); return $tag; } } } else { if (strcmp(Pinyin::get($v['keywords']), $keywords) === 0) { $tag = trim($v['keywords']); //$this->memcache->set($memkey, $tag, MEMCACHE_COMPRESSED, 108000); return $tag; } } } }