";
exit;
}
$user_title = $_POST["title"];
$create_para = $paragraph;
$FileName = $book . "_" . $paragraph . "_" . time() . ".pcs";
$sFullFileName = _DIR_USER_DOC_ . "/" . $USER_ID . _DIR_MYDOCUMENT_ . "/" . $FileName;
echo "filename:" . $sFullFileName;
$myfile = fopen($sFullFileName, "w") or die("Unable to open file!");
$strXml = "
";
for ($iRes = 0; $iRes < count($res); $iRes++) {
$get_res_type = $res[$iRes]->type;
echo "iRes: $iRes,type:$get_res_type
";
$res_album_id = $res[$iRes]->album_id;
$res_book = $res[$iRes]->book;
$get_par_begin = $res[$iRes]->parNum;
$language = $res[$iRes]->language;
$author = $res[$iRes]->author;
PDO_Connect(_FILE_DB_RESRES_INDEX_);
$query = "select guid,owner from 'album' where id='{$res_album_id}'";
$Fetch = PDO_FetchAll($query);
if (count($Fetch) > 0) {
$res_album_guid = $Fetch[0]["guid"];
$res_album_owner = $Fetch[0]["owner"];
} else {
$res_album_guid = UUID::v4();
$res_album_owner = 0;
}
switch ($get_res_type) {
case "1": //pali text
{
PDO_Connect(_FILE_DB_PALITEXT_);
$query = "SELECT * FROM pali_text WHERE \"book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) ";
$sth = $PDO->prepare($query);
$sth->execute();
echo $query . "
";
{
while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
$text = $result["text"];
$paragraph = $result["paragraph"];
$strXml = "
";
$sth = $PDO->prepare($query);
$sth->execute();
echo "para:{$iPar} row:" . $sth->rowCount();
if ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
$lang = $sLang["{$result["language"]}"];
$info_id = $result["id"];
$strXml = "
";
//查询翻译经文内容
$FetchText = PDO_FetchAll($query);
$iFetchText = count($FetchText);
echo "iFetchText:{$iFetchText}
";
if ($iFetchText > 0) {
for ($i = 0; $i < $iFetchText; $i++) {
$currParNo = $FetchText[$i]["paragraph"];
$language = $FetchText[$i]["language"];
$language = $sLang["{$language}"];
if ($res_album_owner == $UID) {
$power = "write";
} else {
$power = "read";
}
//输出数据头
$strXml = "
save ok
";
$filesize = filesize($sFullFileName);
//服务器端文件列表
PDO_Connect(_FILE_DB_FILEINDEX_);
$query = "INSERT INTO fileindex ('id',
'parent_id',
'user_id',
'book',
'paragraph',
'file_name',
'title',
'tag',
'status',
'create_time',
'modify_time',
'accese_time',
'file_size',
'share',
'doc_info',
'doc_block',
'receive_time'
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = $PDO->prepare($query);
$doc_id = UUID::v4();
$newData = array($doc_id,
"",
$uid,
$book,
$create_para,
$FileName,
$user_title,
$tag,
1,
mTime(),
mTime(),
mTime(),
$filesize,
0,
"",
"",
mTime(),
);
$stmt->execute($newData);
if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
$error = PDO_ErrorInfo();
echo "error - $error[2]
";
} else {
echo "updata 1 recorders.";
}
echo "正在跳转";
echo "";
break;
}
case "open":
{
/*打开工程文件
三种情况
1.自己的文档
2.别人的共享文档,自己以前没有打开过。复制到自己的空间,再打开。
3.别人的共享文档,自己以前打开过。直接打开
*/
if ($_COOKIE["uid"]) {
$uid = $_COOKIE["uid"];
} else {
echo "
"; exit; } PDO_Connect(_FILE_DB_FILEINDEX_); if (isset($_GET["doc_id"])) { $doc_id = $_GET["doc_id"]; $query = "select * from fileindex where id='$doc_id' "; $Fetch = PDO_FetchAll($query); $iFetch = count($Fetch); if ($iFetch > 0) { //文档信息 $owner = $Fetch[0]["user_id"]; $filename = $Fetch[0]["file_name"]; $title = $Fetch[0]["title"]; $tag = $Fetch[0]["tag"]; $mbook = $Fetch[0]["book"]; $paragraph = $Fetch[0]["paragraph"]; $doc_head = $Fetch[0]["doc_info"]; if ($owner == $uid) { //自己的文档 echo "
"; $my_doc_id = $doc_id; echo "{$_local->gui->open_doc}"; echo ""; } else { //别人的文档 //查询自己是否以前打开过 $query = "select * from fileindex where parent_id='$doc_id' and user_id='$uid' "; $FetchSelf = PDO_FetchAll($query); $iFetchSelf = count($FetchSelf); if ($iFetchSelf > 0) { //以前打开过 echo "已经复制的文档 Already Copy"; $my_doc_id = $FetchSelf[0]["id"]; echo "{$_local->gui->edit_now}"; echo ""; } else { //以前没打开过 //询问是否打开 if (isset($_GET["openin"])) { $open_in = $_GET["openin"]; } else { ?>
gui->co_doc ?>,gui->open ?>?
gui->open_with ?>:
源文件{$source}"; echo "
";
if (copy($source, $dest)) {
echo "复制文件成功";
$my_file_name = $filename;
//插入记录到文件索引
$filesize = filesize($dest);
//服务器端文件列表
PDO_Connect(_FILE_DB_FILEINDEX_);
//$query="INSERT INTO fileindex ('id','userid','parent_id','doc_id','book','paragraph','file_name','title','tag','create_time','modify_time','accese_time','file_size')
// VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?)";
//$stmt = $PDO->prepare($query);
//$newData=array($uid,$doc_id,UUID::v4(),$mbook,$paragraph,$filename,$title,$tag,time(),time(),time(),$filesize);
$query = "INSERT INTO fileindex ('id',
'parent_id',
'user_id',
'book',
'paragraph',
'file_name',
'title',
'tag',
'status',
'create_time',
'modify_time',
'accese_time',
'file_size',
'share',
'doc_info',
'doc_block',
'receive_time'
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = $PDO->prepare($query);
$newdoc_id = UUID::v4();
$newData = array(
$newdoc_id,
$doc_id,
$uid,
$mbook,
$paragraph,
$filename,
$title,
$tag,
1,
mTime(),
mTime(),
mTime(),
$filesize,
0,
"",
"",
mTime(),
);
$stmt->execute($newData);
if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
$error = PDO_ErrorInfo();
echo "error - $error[2]
";
$my_doc_id = "";
} else {
$my_doc_id = newdoc_id;
echo "updata 1 recorders.";
}
} else {
echo "复制文件失败";
$my_doc_id = "";
}
} else {
echo "错误-无法识别的操作:open in:{$open_in}";
$my_doc_id = "";
}
}
}
/*
if($my_doc_id!=""){
echo "";
}
*/
} else {
echo "未知的文档。可能该文件已经被删除。";
}
}
}
break;
case "openfile":
break;
case "save":
break;
}
?>