'.$_local->gui->not_login.''; exit; } switch($op){ case "create": //判断单词数量 太大的不能加载 $res=json_decode($data); $res_book = $res[0]->book; $paraList=$res[0]->parlist; $paraList=rtrim($paraList,","); $strQueryParaList=str_replace(",","','",$paraList); $strQueryParaList="('".$strQueryParaList."')"; PDO_Connect("sqlite:"._FILE_DB_PALITEXT_); $query="SELECT sum(lenght) as sum_str FROM pali_text WHERE \"book\" = ".$PDO->quote($res_book)." AND (\"paragraph\" in {$strQueryParaList} ) "; $Fetch = PDO_FetchAll($query); if(count($Fetch)>0){ if($Fetch[0]["sum_str"]>15000){ echo $_local->gui->oversize_to_load; exit; } } //判断单词数量 结束 if(isset($_POST["format"]) && $_POST["format"]=="db"){ $res=json_decode($data); $title=$res[0]->title; $title_en=pali2english($title); $book=$res[0]->book; if(substr($book,0,1)=="p"){ $book=substr($book,1); } $paragraph=$res[0]->parNum; $tag="[$title]"; $paraList=$res[0]->parlist; $paraList=rtrim($paraList,","); $strQueryParaList=str_replace(",","','",$paraList); $strQueryParaList="('".$strQueryParaList."')"; $aParaList=str_getcsv($paraList); $create_para=$aParaList[0]; echo $strQueryParaList; echo ""; $user_title=$_POST["title"]; $doc_head =" \n"; $doc_head.=" pcdsset\n"; $doc_head.=" package\n"; $doc_head.=" 1\n"; $doc_head.=" \n"; $doc_head.=" \n"; $doc_head.=" $user_title\n"; $doc_head.=" $tag\n"; $doc_head.=" $book\n"; $doc_head.=" $paragraph\n"; $doc_head.=" \n"; for($iRes=0;$iRestype; 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; $db_file = _FILE_DB_RESRES_INDEX_; PDO_Connect("sqlite:$db_file"); $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 "6"://逐词译模板 { $album_guid = UUID::v4(); $album_title = "title"; $album_author = "VRI"; $album_type=$get_res_type; //获取段落层级和标题 $para_title=array(); PDO_Connect("sqlite:"._FILE_DB_PALITEXT_); $query="SELECT * FROM pali_text WHERE \"book\" = ".$PDO->quote($res_book)." AND (\"paragraph\" in {$strQueryParaList} ) AND level>0 AND level<9"; $sth = $PDO->prepare($query); $sth->execute(); while($result = $sth->fetch(PDO::FETCH_ASSOC)) { $paragraph = $result["paragraph"]; $para_title["{$paragraph}"][0]=$result["level"]; $para_title["{$paragraph}"][1]=$result["text"]; } $db_file = _DIR_PALICANON_TEMPLET_."/p".$res_book."_tpl.db3"; PDO_Connect("sqlite:$db_file"); foreach($aParaList as $iPar){ $query="SELECT * FROM 'main' WHERE (\"paragraph\" = ".$PDO->quote($iPar)." ) "; $sth = $PDO->prepare($query); $sth->execute(); { if(isset($para_title["{$iPar}"])){ $level=$para_title["{$iPar}"][0]; $title=$para_title["{$iPar}"][1]; } else{ $level=100; $title=""; } $block_id=UUID::v4(); $block_data[] = array($block_id,"",$USER_ID,$book,$iPar,"_none_","zh-cn",1); $block_list[] = array("type"=>6,"block_id"=>$block_id); while($result = $sth->fetch(PDO::FETCH_ASSOC)) { if($result["gramma"]=="?"){ $wGrammar=""; } else{ $wGrammar=$result["gramma"]; } $strXml=""; $strXml.="{$result["word"]}"; $strXml.="{$result["real"]}"; $wordid = "p{$result["book"]}-{$result["paragraph"]}-{$result["wid"]}"; $strXml.="{$wordid}"; $strXml.="{$result["type"]}"; $strXml.="{$wGrammar}"; $strXml.=""; $strXml.="".mb_strtolower($result["part"], 'UTF-8').""; $strXml.=""; $strXml.="{$result["type"]}#{$wGrammar}"; $strXml.=""; $strXml.="0"; $strXml.=""; $wbw_data[] = array(UUID::v4(),$block_id,$book,$iPar,$result["wid"],$result["real"],$strXml,mTime(),mTime(),1,$USER_NAME); } } } //写入数据库 // 开始一个事务,关闭自动提交 PDO_Connect("sqlite:"._FILE_DB_USER_WBW_); $PDO->beginTransaction(); $query="INSERT INTO wbw_block ('id','parent_id','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?)"; $stmt = $PDO->prepare($query); foreach($block_data as $oneParam){ $stmt->execute($oneParam); } // 提交更改 $PDO->commit(); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error - $error[2]
"; } else{ $count=count($block_data); echo "updata $count recorders."; } // 开始一个事务,关闭自动提交 $PDO->beginTransaction(); $query="INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $PDO->prepare($query); foreach($wbw_data as $oneParam){ $stmt->execute($oneParam); } // 提交更改 $PDO->commit(); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error - $error[2]
"; } else{ $count=count($block_data); echo "updata $count recorders."; } //服务器端文件列表 $db_file = _FILE_DB_FILEINDEX_; PDO_Connect("sqlite:$db_file"); $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(); $file_name = $book . '_' . $create_para . '_' . time(); $newData=array( $doc_id, "", $uid, $book, $create_para, $file_name, $user_title, $tag, 1, mTime(), mTime(), mTime(), $filesize, 0, $doc_head, json_encode($block_list, JSON_UNESCAPED_UNICODE), mTime() ); $stmt->execute($newData); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error - $error[2]
"; } else{ echo "成功新建一个文件."; } echo "{$_local->gui->open}"; } break; } } } else { if(!isset($data)){ $dl_file_name=$dir_user_base.$USER_ID."/dl.json"; $data=file_get_contents($dl_file_name); } $res=json_decode($data); $title=$res[0]->title; $title_en=pali2english($title); $book=$res[0]->book; if(substr($book,0,1)=="p"){ $book=substr($book,1); } $paragraph=$res[0]->parNum; $tag="[$title]"; $paraList=$res[0]->parlist; $paraList=rtrim($paraList,","); $strQueryParaList=str_replace(",","','",$paraList); $strQueryParaList="('".$strQueryParaList."')"; $aParaList=str_getcsv($paraList); echo $strQueryParaList; echo ""; if(!isset($_POST["title"])){ $thisFileName=basename(__FILE__); echo "
"; echo "

新建工程

"; echo "
"; echo ""; echo ""; echo "Project Title:
"; echo "自动新建译文
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; exit; } $user_title=$_POST["title"]; $create_para=$paragraph; $FileName = $book."_".$paragraph."_".time().".pcs"; $sFullFileName=_DIR_USER_BASE_."/".$USER_ID._DIR_MYDOCUMENT_."/".$FileName; echo "filename:".$sFullFileName; $myfile = fopen($sFullFileName, "w") or die("Unable to open file!"); $strXml="\n"; $doc_head =" \n"; $doc_head.=" pcdsset\n"; $doc_head.=" package\n"; $doc_head.=" 1\n"; $doc_head.=" \n"; $doc_head.=" \n"; $doc_head.=" $user_title\n"; $doc_head.=" $tag\n"; $doc_head.=" $book\n"; $doc_head.=" $paragraph\n"; $doc_head.=" \n"; $strXml.=$doc_head; $strXml.=" \n"; $strXml.=" \n"; $strXml.=" \n"; fwrite($myfile, $strXml); echo "count res:".count($res)."
"; for($iRes=0;$iRestype; 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; $db_file = _FILE_DB_RESRES_INDEX_; PDO_Connect("sqlite:$db_file"); $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("sqlite:"._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 = ""; $strXml .= ""; $strXml .= "palitext"; $strXml .= "{$book}"; $strXml .= "{$result["paragraph"]}"; $strXml .= "{$result["album_index"]}"; $strXml .= "{$res_album_guid}"; $strXml .= "VRI"; $strXml .= "pali"; $strXml .= "4"; $strXml .= "CSCD4"; $strXml .= "{$result["level"]}"; $strXml .= "".UUID::v4().""; $strXml .= ""; $strXml .= "{$result["text"]}"; $strXml .= ""; fwrite($myfile, $strXml); if($result["level"]>0 && $result["level"]<9){ $strXml = ""; $strXml .= ""; $strXml .= "heading"; $strXml .= "{$book}"; $strXml .= "{$result["paragraph"]}"; $strXml .= "{$result["album_index"]}"; $strXml .= "{$res_album_guid}"; $strXml .= "VRI"; $strXml .= "pali"; $strXml .= "4"; $strXml .= "CSCD4"; $strXml .= "{$result["level"]}"; $strXml .= "".UUID::v4().""; $strXml .= ""; $strXml .= "{$result["text"]}"; $strXml .= ""; fwrite($myfile, $strXml); } else{ } } } break; } case "2"://wbw逐词解析 { //$res_album_id; $album_title = "title"; $album_author = $author; $album_type=$get_res_type; $db_file = _DIR_PALICANON_WBW_."/p{$res_book}_wbw.db3"; $table_info="p{$res_book}_wbw_info"; $table_data="p{$res_book}_wbw_data"; PDO_Connect("sqlite:$db_file"); foreach($aParaList as $iPar){ $query="SELECT * FROM '{$table_info}' WHERE paragraph = ".$PDO->quote($iPar)." and album_id=".$PDO->quote($res_album_id); //$FetchInfo = PDO_FetchAll($query); echo $query."
"; $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 = ""; $strXml .= ""; $strXml .= "wbw"; $strXml .= "{$res_book}"; $strXml .= "{$iPar}"; $strXml .= "{$result["level"]}"; $strXml .= "{$result["title"]}"; $strXml .= "{$res_album_id}"; $strXml .= "{$res_album_guid}"; $strXml .= "{$result["author"]}"; $strXml .= "{$lang}"; $strXml .= "{$result["version"]}"; $strXml .= "{$result["edition"]}"; $strXml .= "".UUID::v4().""; $strXml .= "\n"; $strXml .= ""; fwrite($myfile, $strXml); $query="SELECT * FROM \"{$table_data}\" WHERE info_id=".$PDO->quote($info_id); $sth = $PDO->prepare($query); $sth->execute(); while($result = $sth->fetch(PDO::FETCH_ASSOC)) { $wid="p{$res_book}-{$iPar}-{$result["sn"]}"; $strXml=""; $strXml.="{$result["word"]}"; $strXml.="{$result["real"]}"; $strXml.="{$wid}"; $strXml.="{$result["type"]}"; $strXml.="{$result["gramma"]}"; $strXml.="{$result["mean"]}"; $strXml.="{$result["note"]}"; $strXml.="{$result["part"]}"; $strXml.="{$result["partmean"]}"; $strXml.="{$result["type"]}#{$result["gramma"]}"; $strXml.=""; $strXml.="{$result["enter"]}"; $strXml.="0"; $strXml.="\n"; fwrite($myfile, $strXml); } $strXml="\n"; fwrite($myfile, $strXml); } } break; } case "3"://translate { //打开翻译数据文件 $db_file = _DIR_PALICANON_TRAN_."/p{$book}_translate.db3"; PDO_Connect("sqlite:$db_file"); $table="p{$book}_translate_info"; //部分段落 $query="SELECT * FROM {$table} WHERE paragraph in {$strQueryParaList} and album_id=$res_album_id"; echo $query."
"; //查询翻译经文内容 $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=""; $strXml.=""; $strXml.="translate"; $strXml.="{$res_book}"; $strXml.="{$currParNo}"; $strXml.="{$res_album_id}"; $strXml.="{$res_album_guid}"; $strXml.="{$FetchText[$i]["author"]}"; $strXml.="{$FetchText[$i]["editor"]}"; $strXml.="{$language}"; $strXml.="{$FetchText[$i]["version"]}"; $strXml.="{$FetchText[$i]["edition"]}"; $strXml.="{$FetchText[$i]["level"]}"; $strXml.="0"; $strXml.="{$power}"; $strXml.="".UUID::v4().""; $strXml.=""; $strXml.=""; fwrite($myfile, $strXml); //查另一个表,获取段落文本。一句一条记录。有些是一段一条记录 $table_data = "p{$book}_translate_data"; $query = "SELECT * FROM '{$table_data}' WHERE info_id={$FetchText[$i]["id"]}"; $aParaText = PDO_FetchAll($query); //输出数据内容 $par_text=""; foreach($aParaText as $sent){ $par_text .= "{$sent["begin"]} {$sent["end"]} {$sent["text"]}"; } fwrite($myfile, $par_text); //段落块结束 $strXml = ""; fwrite($myfile, $strXml); //获取段落文本结束。 } } break; } case "4"://note break; case "5": break; case "6"://逐词译模板 { $album_guid = UUID::v4(); $album_title = "title"; $album_author = "VRI"; $album_type=$get_res_type; //获取段落层级和标题 $para_title=array(); PDO_Connect("sqlite:"._FILE_DB_PALITEXT_); $query="SELECT * FROM pali_text WHERE \"book\" = ".$PDO->quote($res_book)." AND (\"paragraph\" in {$strQueryParaList} ) AND level>0 AND level<9"; $sth = $PDO->prepare($query); $sth->execute(); while($result = $sth->fetch(PDO::FETCH_ASSOC)) { $paragraph = $result["paragraph"]; $para_title["{$paragraph}"][0]=$result["level"]; $para_title["{$paragraph}"][1]=$result["text"]; } $db_file = _DIR_PALICANON_TEMPLET_."/p".$res_book."_tpl.db3"; PDO_Connect("sqlite:$db_file"); foreach($aParaList as $iPar){ $query="SELECT * FROM 'main' WHERE (\"paragraph\" = ".$PDO->quote($iPar)." ) "; $sth = $PDO->prepare($query); $sth->execute(); { if(isset($para_title["{$iPar}"])){ $level=$para_title["{$iPar}"][0]; $title=$para_title["{$iPar}"][1]; } else{ $level=100; $title=""; } $strXml=""; $strXml.=""; $strXml.="wbw"; $strXml.="{$book}"; $strXml.="{$iPar}"; $strXml.="{$level}"; $strXml.="{$title}"; $strXml.="-1"; $strXml.="{$album_guid}"; $strXml.="{$USER_NAME}"; $strXml.="{$USER_NAME}"; $strXml.="en"; $strXml.="1"; $strXml.=""; $strXml.="0"; $strXml.="".UUID::v4().""; $strXml.="\n"; $strXml.=""; fwrite($myfile, $strXml); while($result = $sth->fetch(PDO::FETCH_ASSOC)) { if($result["gramma"]=="?"){ $wGrammar=""; } else{ $wGrammar=$result["gramma"]; } $strXml=""; $strXml.="{$result["word"]}"; $strXml.="{$result["real"]}"; $strXml.="{$result["wid"]}"; $strXml.="{$result["type"]}"; $strXml.="{$wGrammar}"; $strXml.="?"; $strXml.="".mb_strtolower($result["part"], 'UTF-8').""; $strXml.="?"; $strXml.="{$result["type"]}#{$wGrammar}"; $strXml.=""; $strXml.="0"; $strXml.=""; fwrite($myfile, $strXml); } $strXml="\n"; fwrite($myfile, $strXml); } } break; } } /*查询结束*/ } /* 自动新建译文 */ if(isset($_POST["new_tran"])){ $new_tran=$_POST["new_tran"]; if($new_tran=="on"){ $album_guid = UUID::v4(); foreach($aParaList as $iPar){ $strXml=""; $strXml.=""; $strXml.="-1"; $strXml.="{$album_guid}"; $strXml.="translate"; $strXml.="{$iPar}"; $strXml.="{$book}"; $strXml.="{$author}"; $strXml.="en"; $strXml.="0"; $strXml.="0"; $strXml.="".UUID()::v4.""; $strXml.=""; $strXml.=""; $strXml.="new translate"; $strXml.=""; $strXml.="\n"; fwrite($myfile, $strXml); } } } $strXml=" \n"; $strXml.="
\n"; fwrite($myfile, $strXml); fclose($myfile); echo "

save ok

"; $filesize=filesize($sFullFileName); //服务器端文件列表 $db_file = _FILE_DB_FILEINDEX_; PDO_Connect("sqlite:$db_file"); $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 "

{$_local->gui->login}后才可以打开文档

"; exit; } $db_file = _FILE_DB_FILEINDEX_; PDO_Connect("sqlite:$db_file"); 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 "

{$_local->gui->my_document}

"; $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 "Open in Studio"; echo ""; } else{ //以前没打开过 //询问是否打开 if(isset($_GET["openin"])){ $open_in=$_GET["openin"]; } else{ ?>

gui->co_doc?>,gui->open?>?

文档信息:

gui->open_with?>:

源文件{$source}"; echo "
目标文件{$dest}
"; if(copy($source,$dest)){ echo "复制文件成功"; $my_file_name=$filename; //插入记录到文件索引 $filesize=filesize($dest); //服务器端文件列表 $db_file = _FILE_DB_FILEINDEX_; PDO_Connect("sqlite:$db_file"); //$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; } ?>