function publishOneDoc($p_id, $t_id, $d_id) { global $root_path, $file_base; global $proj_data, $poly_data, $temp_data, $tempdef_data, $global_data; global $pub_mysql, $proj_mysql; global $this_doc; $this_doc = ""; $eval_Table = ""; $async_buf = ""; $outer_flag=0; printf("\n<br>=======================================================================================<br>\n开始发布文档[<a href=%s?p_id=%d&t_id=%d&d_id=%d>%d</a>]...<br>\n", "doc_edit.php", $p_id, $t_id, $d_id, $d_id); print("开始获取文档数据<br>\n"); $sqlstr = sprintf("select *, date_format(createdatetime, '%%Y-%%m-%%d') createdate, date_format(createdatetime, '%%H:%%i:%%s') createtime, date_format(savedatetime, '%%Y-%%m-%%d') savedate, date_format(savedatetime, '%%H:%%i:%%s') savetime from %s where d_id=$d_id", $temp_data[$t_id][t_name]); $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr . "\n" ); $this_doc = mysql_fetch_array($res, MYSQL_ASSOC); if($this_doc == "") exit("Doc not exist: $sqlstr\n"); printf("获取文档数据结束!<br><br>\n"); printf("开始发布模板域<br>\n"); $ret = publishDocField($p_id, $t_id, $d_id); if($ret < 0 ) { printf("%s\n", $error_message); return -1; } printf("发布模板域结束!<br><br>\n"); $mp = getMultiPage($t_id); $spos = doAboutMultiPage($mp); foreach($poly_data as $pm_id => $this_poly) { printf("开始发布二次开发模板域<br>\n"); $ret = publishDocField_poly($p_id, $t_id, $d_id, $pm_id); if($ret < 0 ) { printf("%s\n", $error_message); return -1; } printf("发布二次开发模板域结束!<br><br>\n"); $ret = doAboutURL($p_id, $t_id, $d_id, $pm_id); if($ret < 0 ) { printf("处理文档URL出错: %s", $error_message); continue; } $doc_url = $poly_data[$pm_id][doc_url]; if($doc_url == "") { printf("本文档[<a href=\"doc_edit.php?d_id=%d&t_id=%d&p_id=%d\">%d</a>]URL为空...不做发布!<br>\n", $d_id, $t_id, $p_id, $d_id); continue; } $pos =strpos($doc_url, "http://"); if($pos === 0) { printf("<a href=\"%s\" target=_blank>%s</a><br>\n", $doc_url, $doc_url); continue; } //---HUNXIAO_CODE<101>--- $doc_filename = sprintf("%s/%s", $this_poly[file_path], $doc_url); $doc_filename = str_replace("//", "/", $doc_filename); $doc_filepath = dirname($doc_filename); /* $command = sprintf("mkdir -p %s", $doc_filepath); system($command); */ pub_mkdir($doc_filepath); foreach($tempdef_data as $this_tempdef) { if($this_tempdef[type] != "File") continue; $f_value = $this_tempdef[f_value]; if($f_value != "") { $filename = sprintf("%s/%s", TMP_PATH, $f_value); if(file_exists($filename)) { /* $command = sprintf("cp \"%s/%s\" \"%s/%s\"", TMP_PATH, $f_value, $doc_filepath, $f_value); system($command); */ copy(TMP_PATH . "/" . $f_value, $doc_filepath . "/" . $f_value); } } } $html=$this_poly[html]; foreach($tempdef_data as $this_tempdef) { if($this_tempdef[type] == "PostInPage" ) continue; if($mp != "" && $mp[f_name] == $this_tempdef[f_name]) continue; $rep1 = sprintf('${%s}', $this_tempdef[cname]); $html = str_replace($rep1, $this_tempdef[f_output], $html); if($this_tempdef['type'] == "Php_List" ) { $rep1 = sprintf('${%s.内容}', $this_tempdef[cname]); $rep2 = sprintf( '<?php $php_list_ret=$php_ret_%s; if(is_array($php_list_ret)) echo $php_list_ret[php_list]; else echo $php_list_ret; ?>', $this_tempdef[f_id]); $html = str_replace($rep1, $rep2, $html); $rep1 = sprintf('${%s.分页页码}', $this_tempdef[cname]); $rep2 = sprintf( '<?php echo $php_ret_%s[page_list] ?>', $this_tempdef[f_id]); $html = str_replace($rep1, $rep2, $html); $rep1 = sprintf('${%s.分页提示}', $this_tempdef[cname]); $rep2 = sprintf( '<?php echo $php_ret_%s[page_notify] ?>', $this_tempdef[f_id]); $html = str_replace($rep1, $rep2, $html); } } $html = str_replace('${docid}', $d_id, $html); $html = str_replace('${tempid}', $t_id, $html); $html = str_replace('${projid}', $p_id, $html); //---HUNXIAO_CODE<102>--- $html = str_replace('${createdatetime}', $this_doc['createdatetime'], $html); $html = str_replace('${createdate}', $this_doc['createdate'], $html); foreach($global_data as $row_global) { $rep1 = sprintf('$G{%s}', $row_global[name]); if($row_global[type] == "js") { $rep2 = sprintf("<script type=\"text/javascript\">pub_global_vars('%s');</script>\n", $row_global[name]); $html = str_replace($rep1, $rep2, $html); } else { $html = str_replace($rep1, $row_global['content'], $html); } } if($mp) { genMuitiPageFile($mp, $spos, $html, $doc_filename, $doc_url); } else { writeFile($doc_filename, $html, 0); } $html_urlbase = $poly_data[$pm_id][html_urlbase]; $html_urlbase = trim_last_splash($html_urlbase); printf("<a href=\"%s%s%s\" target=_blank>%s</a><br>\n", $html_urlbase, $doc_url{0}=='/'?"":"/", $doc_url, $doc_url); } $sqlstr = sprintf("update %s set ", $temp_data[$t_id][t_name]); foreach($tempdef_data as $this_tempdef) { if($this_tempdef[type] != "Sql_Result" || $this_tempdef[if_into_db] != 'y' ) continue; $sqlstr .= sprintf("%s = '%s', ", $this_tempdef[f_name], mysql_escape_string($this_tempdef[f_value])); } $sqlstr .= sprintf("published='y' where d_id=%d", $d_id); $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr . "\n"); printf("发布完成<br>\n"); if($outer_flag) return 0; printf("开始相关发布<br>\n"); foreach($tempdef_data as $ii=>$pTF) { if($pTF[type] != "PostInPage") continue; if( doAboutPostInPage($p_id, $t_id, $d_id, $ii) < 0) { printf("发布错误: %s<br>\n", $error_message); return -1; } $i++; } printf("同步开始<br>\n"); asyncDoc($p_id, $t_id, $d_id); printf("\n<br>同步完成"); }
function upload_pic() { global $poly_data, $cgi; $year = date("Y"); $month = date("m"); $day = date("d"); $path_html = "/upload_pub/{$cgi['t_id']}/{$year}/{$month}/{$day}"; foreach ($poly_data as $pm_id => $this_poly) { $img_file_path = $this_poly[file_path] . $path_html; break; } $img_file_path = str_replace("//", "/", $img_file_path); pub_mkdir($img_file_path); foreach ($_FILES as $key => $this_file) { if ($this_file[name] == "") { continue; } $filename = "pic" . time() . "_" . urlencode($this_file[name]); $filename = str_replace('%', '', $filename); $cgi[$key] = "{$path_html}/{$filename}"; move_uploaded_file($this_file['tmp_name'], $img_file_path . "/" . $filename); } }
if($cgi[edit] != "" && $cgi[p_cname] != "") { $sqlstr = sprintf("update proj set p_cname='%s', updatedt=now() where p_id=$p_id", mysql_escape_string($cgi[p_cname])); $res = mysql_query($sqlstr, $pub_mysql) or sys_exit("系统忙, 请稍候再试。", $sqlstr . "\n" . mysql_error()); $sqlstr = sprintf("update polymorphic set html_urlbase='%s', file_path='%s' where pm_id=1", mysql_escape_string($cgi[domain]), mysql_escape_string($cgi[file_path]) ); $res = mysql_query($sqlstr, $proj_mysql) or sys_exit("系统忙, 请稍候再试。", $sqlstr . "\n" . mysql_error()); if($row_poly[file_path] != $cgi[file_path]) { $file_path = $cgi[file_path]; if($file_path == "") $file_path = "$file_base/$db_name/pc"; pub_mkdir("$file_path/upload"); $cmd = "cd $file_path; rm -f temp_view.php; ln -s $root_path/temp_view.php temp_view.php"; system($cmd); $cmd = "cd $file_path; rm -f addmess.php; ln -s $root_path/addmess.php addmess.php"; system($cmd); $cmd = "cd $file_path; ln -s $root_path/plib plib"; system($cmd); $cmd = "cd $file_path; ln -s $root_path/pagelib pagelib"; system($cmd); } system("cd $root_path; /usr/bin/php gen_domain.php");