Example #1
0
     $addonfields = explode(';', $dede_addonfields);
     $inadd_f = '';
     $inadd_v = '';
     if (is_array($addonfields)) {
         foreach ($addonfields as $v) {
             if ($v == '') {
                 continue;
             }
             $vs = explode(',', $v);
             if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
                 ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
             } else {
                 if (!isset(${$vs[0]})) {
                     ${$vs[0]} = '';
                 }
                 ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
             }
             $inadd_f .= ",`{$vs[0]}` = '" . ${$vs[0]} . "'";
         }
     }
 }
 //处理图片文档的自定义属性
 if ($litpic != '' && !preg_match("#p#", $flag)) {
     $flag = $flag == '' ? 'p' : $flag . ',p';
 }
 if ($redirecturl != '' && !preg_match("#j#", $flag)) {
     $flag = $flag == '' ? 'j' : $flag . ',j';
 }
 //跳转网址的文档强制为动态
 if (preg_match("#j#", $flag)) {
     $ismake = -1;
if(!empty($dede_addonfields))
{
  $addonfields = explode(";",$dede_addonfields);
  $inadd_f = "";
  if(is_array($addonfields))
  {
    foreach($addonfields as $v)
    {
	     if($v=="") continue;
	     $vs = explode(",",$v);
	     //HTML文本特殊处理
	     if($vs[1]=="htmltext"||$vs[1]=="textdata")
	     {
		     include_once(DEDEADMIN.'/inc/inc_arc_makeauto.php');
	     }else{
		     ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
	     }
	     $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
    }
  }
}

$addQuery = "Update `{$cts['addtable']}` set typeid='$typeid',
message='$message',contact='$contact',phone='$phone',
fax='$fax',email='$email',qq='$qq',msn='$msn',address='$address'{$inadd_f}
where aid='{$ID}' ";

if(!$dsql->ExecuteNoneQuery($addQuery)){
	$gerr = $dsql->GetError();
	$dsql->Close();
	ShowMsg("更新数据库附加表 `{$cts['addtable']}` 时出错,请把相关信息提交给DedeCms官方。".$gerr,"javascript:;");
Example #3
0
 //分析处理附加表数据
 $inadd_f = $inadd_v = '';
 if (!empty($dede_addonfields)) {
     $addonfields = explode(';', $dede_addonfields);
     $inadd_f = '';
     $inadd_v = '';
     if (is_array($addonfields)) {
         foreach ($addonfields as $v) {
             if ($v == '') {
                 continue;
             }
             $vs = explode(',', $v);
             if (!isset(${$vs[0]})) {
                 ${$vs[0]} = '';
             }
             ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], 0);
             $inadd_f .= ',' . $vs[0];
             $inadd_v .= " ,'" . ${$vs[0]} . "' ";
         }
     }
 }
 if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields . $cfg_cookie_encode)) {
     showMsg('数据校验不对,程序返回', '-1');
     exit;
 }
 // 这里对前台提交的附加数据进行一次校验
 $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'], 'autofield', FALSE);
 if ($fontiterm != $inadd_f) {
     ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
     exit;
 }
/**
 * 处理HTML文本
 * 删除非站外链接、自动摘要、自动获取缩略图
 *
 * @access    public
 * @param     string  $body  内容
 * @param     string  $description  描述
 * @param     string  $litpic  缩略图
 * @param     string  $keywords  关键词
 * @param     string  $dtype  类型
 * @return    string
 */
function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = '')
{
    global $autolitpic, $remote, $dellink, $autokey, $cfg_basehost, $cfg_auot_description, $id, $title, $cfg_soft_lang;
    $autolitpic = empty($autolitpic) ? '' : $autolitpic;
    $body = stripslashes($body);
    //远程图片本地化
    if ($remote == 1) {
        $body = GetCurContent($body);
    }
    //删除非站内链接
    if ($dellink == 1) {
        $allow_urls = array($_SERVER['HTTP_HOST']);
        // 读取允许的超链接设置
        if (file_exists(DEDEDATA . "/admin/allowurl.txt")) {
            $allow_urls = array_merge($allow_urls, file(DEDEDATA . "/admin/allowurl.txt"));
        }
        $body = Replace_Links($body, $allow_urls);
    }
    //自动摘要
    if ($description == '' && $cfg_auot_description > 0) {
        $description = cn_substr(html2text($body), $cfg_auot_description);
        $description = trim(preg_replace('/#p#|#e#/', '', $description));
        $description = addslashes($description);
    }
    //自动获取缩略图
    if ($autolitpic == 1 && $litpic == '') {
        $litpic = GetDDImgFromBody($body);
    }
    //自动获取关键字
    if ($autokey == 1 && $keywords == '') {
        $subject = $title;
        $message = $body;
        include_once DEDEINC . '/splitword.class.php';
        $keywords = '';
        $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
        $sp->SetSource($subject, $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
        $sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
        if (is_array($allindexs) && is_array($titleindexs)) {
            foreach ($titleindexs as $k => $v) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (strlen($k) <= 2) {
                        continue;
                    }
                    $keywords .= $k . ',';
                }
            }
            foreach ($allindexs as $k => $v) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (!in_array($k, $titleindexs)) {
                        if (strlen($k) <= 2) {
                            continue;
                        }
                        $keywords .= $k . ',';
                    }
                }
            }
        }
        $sp = null;
    }
    $body = GetFieldValueA($body, $dtype, $id);
    $body = addslashes($body);
    return $body;
}
function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = '')
{
    global $autolitpic, $remote, $dellink, $autokey, $cfg_basehost, $cfg_auot_description, $id, $title, $cfg_soft_lang;
    $autolitpic = empty($autolitpic) ? '' : $autolitpic;
    $body = stripslashes($body);
    //远程图片本地化
    if ($remote == 1) {
        $body = GetCurContent($body);
    }
    //删除非站内链接
    if ($dellink == 1) {
        $basehost = "http://" . $_SERVER['HTTP_HOST'];
        $body = str_replace($cfg_basehost, '#basehost#', $body);
        $body = str_replace($basehost, '#2basehost2#', $body);
        $body = preg_replace("/(<a[ \t\r\n]{1,}href=[\"']{0,}http:\\/\\/[^\\/]([^>]*)>)|(<\\/a>)/isU", "", $body);
        $body = str_replace('#basehost#', $cfg_basehost, $body);
        $body = str_replace('#2basehost2#', $basehost, $body);
    }
    //自动摘要
    if ($description == '' && $cfg_auot_description > 0) {
        $description = cn_substr(html2text($body), $cfg_auot_description);
        $description = trim(preg_replace('/#p#|#e#/', '', $description));
        $description = addslashes($description);
    }
    //自动获取缩略图
    if ($autolitpic == 1 && $litpic == '') {
        $litpic = GetDDImgFromBody($body);
    }
    //自动获取关键字
    if ($autokey == 1 && $keywords == '') {
        $subject = $title;
        $message = $body;
        if ($cfg_soft_lang == 'utf-8') {
            $subject = utf82gb($title);
            $message = utf82gb($message);
        }
        include_once DEDEINC . '/splitword.class.php';
        $keywords = '';
        $sp = new SplitWord();
        $titleindexs = explode(' ', preg_replace("/#p#|#e#/", '', $sp->GetIndexText($subject)));
        $allindexs = explode(' ', preg_replace("/#p#|#e#/", '', $sp->GetIndexText(Html2Text($message), 500)));
        if (is_array($allindexs) && is_array($titleindexs)) {
            foreach ($titleindexs as $k) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    $keywords .= $k . ',';
                }
            }
            foreach ($allindexs as $k) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (!in_array($k, $titleindexs)) {
                        $keywords .= $k . ',';
                    }
                }
            }
        }
        $sp->Clear();
        $sp = null;
    }
    $body = GetFieldValueA($body, $dtype, $id);
    $body = addslashes($body);
    return $body;
}
$addtable = $tables['addtable'];
if(empty($addtable)) $addtable = "";
if(empty($dede_addonfields)) $dede_addonfields = "";
$addonfields = explode(";",$dede_addonfields);
$upfield = "";

if(is_array($addonfields))
{
  foreach($addonfields as $v)
  {
	  if($v=="") continue;
	  $vs = explode(",",$v);
	  if($vs[1]=="textdata"){
		  $vok = GetFieldValueA(${$vs[0]},$vs[1],$ID,'edit',${$vs[0].'_file'});
	  }else{
		  $vok = GetFieldValueA(${$vs[0]},$vs[1]);
	  }
	  $upfield .= ($upfield=='' ? " {$vs[0]} = '{$vok}' " : " ,{$vs[0]} = '{$vok}' ");
  }
}

$addQuery = "Update `".$addtable."` set $upfield where aid='$ID'";

if(!$dsql->ExecuteNoneQuery($addQuery)){
	$gerr = $dsql->GetError();
	$dsql->Close();
	ShowMsg("更新数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCms官方。".$gerr,"javascript:;");
	exit();
}

//更新HTML