63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace web\docs;
|
|
|
|
class edit {
|
|
static function verify($pant) {
|
|
$cfg = webini('mock');
|
|
if ($pant == $cfg['docpass'])
|
|
return true;
|
|
return false;
|
|
}
|
|
public static function json_init() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$id = getint('id');
|
|
$vkey = getint('key');
|
|
$csql = new \ciy\sql('doc_help');
|
|
$csql->where('id', $id);
|
|
$mrow = $db->getone($csql);
|
|
if (!is_array($mrow))
|
|
return errjson('数据不存在');
|
|
if ($vkey != $mrow['vkey'])
|
|
return errjson('您无权管理');
|
|
$ret['data'] = $mrow;
|
|
return succjson($ret);
|
|
}
|
|
|
|
public static function json_uptxt() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$updata = array();
|
|
$id = $post->getint('id');
|
|
$vkey = getint('key');
|
|
$csql = new \ciy\sql('doc_help');
|
|
$csql->where('id', $id);
|
|
$mrow = $db->getone($csql);
|
|
if (!is_array($mrow))
|
|
return errjson('数据不存在');
|
|
if ($vkey != $mrow['vkey'])
|
|
return errjson('您无权管理');
|
|
$content = $post->get('content', '', 'all');
|
|
$uptimes = time();
|
|
try {
|
|
$db->begin();
|
|
$updata = array();
|
|
$updata['uptimes'] = $uptimes;
|
|
$csql = new \ciy\sql('doc_help');
|
|
$csql->where('id', $id);
|
|
if ($db->update($csql, $updata) === false)
|
|
throw new \Exception('更新失败:' . $db->error);
|
|
$updata['id'] = $id;
|
|
$db->commit();
|
|
} catch (\Exception $ex) {
|
|
$db->rollback();
|
|
savelogfile('err_db', $ex->getMessage());
|
|
return errjson($ex->getMessage());
|
|
}
|
|
file_put_contents(PATH_WEB . 'ud/docs/' . $id . '_' . $uptimes . '.txt', $content);
|
|
$ret['uptimes'] = $uptimes;
|
|
return succjson($ret);
|
|
}
|
|
}
|