Beispiel #1
0
 function end_deal()
 {
     if (!empty($this->newvalue)) {
         if ($this->field['datatype'] == 'date') {
             $this->newvalue = strtotime($this->newvalue);
         } elseif ($this->field['datatype'] == 'htmltext') {
             html_atm2tag($this->newvalue);
         }
     }
     return;
 }
Beispiel #2
0
 function output_guid($guid = 0)
 {
     //禁止重复输出,未完结合辑需要输出辑内的内容
     global $db, $tblprefix, $gmodels, $curuser, $timestamp, $cotypes, $c_upload, $sid, $progress;
     if (!$guid || !($item = $db->fetch_one("SELECT * FROM {$tblprefix}gurls WHERE guid='{$guid}' AND gatherdate<>'0'"))) {
         return false;
     }
     if (!$item['outputdate']) {
         $archivenew = empty($item['contents']) ? array() : unserialize($item['contents']);
         unset($item['contents']);
         if (empty($this->fields)) {
             $this->gather_fields();
         }
         if (empty($this->oconfigs)) {
             $this->output_configs();
         }
         if (empty($this->fields) || empty($this->oconfigs)) {
             return false;
         }
         if (!empty($this->oconfigs['musts'])) {
             $mustsarr = explode(',', $this->oconfigs['musts']);
             foreach ($mustsarr as $k) {
                 if (empty($archivenew[$k])) {
                     return false;
                 }
                 //缺少必有字段内容,输出中止
             }
         }
         $c_upload->init();
         $aid = $item['aid'];
         $gmid = $this->gmission['gmid'];
         $chid = $gmodels[$gmid]['chid'];
         $channel = read_cache('channel', $chid);
         $fields = read_cache('fields', $chid);
         $sqlmain = "sid='{$item['sid']}',chid='{$chid}',mid='" . $curuser->info['mid'] . "',mname='" . $curuser->info['mname'] . "',createdate='{$timestamp}',refreshdate='{$timestamp}'";
         $sqlsub = $sqlcustom = '';
         empty($this->oconfigs['caid']) || ($sqlmain .= ",caid='" . $this->oconfigs['caid'] . "'");
         foreach ($cotypes as $k => $v) {
             $var = "ccid{$k}";
             empty($this->oconfigs[$var]) || ($sqlmain .= ",{$var}='" . $this->oconfigs[$var] . "'");
         }
         if ($fields['abstract']['available'] && !empty($this->oconfigs['autoabstract'])) {
             if (!empty($channel['autoabstract']) && !empty($archivenew[$channel['autoabstract']])) {
                 $sqlmain .= ($sqlmain ? ',' : '') . "abstract='" . addslashes(autoabstract($archivenew[$channel['autoabstract']])) . "'";
             }
         }
         if ($fields['thumb']['available'] && !empty($this->oconfigs['autothumb'])) {
             if (!empty($channel['autothumb']) && !empty($archivenew[$channel['autothumb']])) {
                 $sqlmain .= ($sqlmain ? ',' : '') . "thumb='" . $c_upload->thumb_pick($archivenew[$channel['autothumb']], $fields[$channel['autothumb']]['datatype'], $fields['thumb']['rpid']) . "'";
             }
         }
         if ($channel['autosize'] && !empty($archivenew[$channel['autosize']])) {
             include_once M_ROOT . '/include/fields.cls.php';
             $archivenew['atmsize'] = atm_size($archivenew[$channel['autosize']], $fields[$channel['autosize']]['datatype'], $channel['autosizemode']);
             $sqlmain .= ",atmsize='" . $archivenew['atmsize'] . "'";
         }
         if ($channel['autobyte'] && isset($archivenew[$channel['autobyte']])) {
             $archivenew['bytenum'] = atm_byte(stripslashes($archivenew[$channel['autobyte']]), $fields[$channel['autobyte']]['datatype']);
             $sqlmain .= ",bytenum='" . $archivenew['bytenum'] . "'";
         }
         foreach ($fields as $k => $v) {
             if ($v['available'] && isset($archivenew[$k])) {
                 if ($v['datatype'] == 'htmltext') {
                     $archivenew[$k] = addslashes($archivenew[$k]);
                     html_atm2tag($archivenew[$k]);
                     $archivenew[$k] = stripslashes($archivenew[$k]);
                 }
                 if (!empty($v['istxt'])) {
                     if ($aid) {
                         if (empty($oldval)) {
                             $oldval = $db->fetch_one("SELECT * FROM {$tblprefix}archives_{$chid} WHERE aid={$aid}");
                         }
                         saveastxt($archivenew[$k], $oldval[$k]);
                         continue;
                     } else {
                         $archivenew[$k] = saveastxt($archivenew[$k]);
                     }
                 }
                 ${'sql' . $v['tbl']} .= (${'sql' . $v['tbl']} ? ',' : '') . $k . "='" . addslashes($archivenew[$k]) . "'";
                 if ($arr = multi_val_arr($archivenew[$k], $v)) {
                     foreach ($arr as $x => $y) {
                         ${'sql' . $v['tbl']} .= (${'sql' . $v['tbl']} ? ',' : '') . $k . '_' . $x . "='{$y}'";
                     }
                 }
             }
         }
         unset($fields, $archivenew, $mustarr);
         if ($aid) {
             $sqlcustom && $db->query("UPDATE {$tblprefix}archives_{$chid} SET " . $sqlcustom);
         } else {
             $db->query("INSERT INTO {$tblprefix}archives SET {$sqlmain}");
             if (!($aid = $db->insert_id())) {
                 return false;
             } else {
                 $db->query("INSERT INTO {$tblprefix}archives_rec SET aid='{$aid}'");
                 $sqlsub = "aid='{$aid}'" . ($sqlsub ? ',' : '') . $sqlsub;
                 $needstatics = '';
                 for ($i = 0; $i <= $channel['addnum']; $i++) {
                     $needstatics .= $timestamp . ',';
                 }
                 $sqlsub .= ",needstatics='{$needstatics}'";
                 $db->query("INSERT INTO {$tblprefix}archives_sub SET " . $sqlsub);
                 $sqlcustom = "aid='{$aid}'" . ($sqlcustom ? ',' : '') . $sqlcustom;
                 $db->query("INSERT INTO {$tblprefix}archives_{$chid} SET " . $sqlcustom);
                 $curuser->basedeal('archive', 1, 1, 1);
             }
             $aedit = new cls_arcedit();
             $aedit->set_aid($aid);
             $aedit->set_arcurl();
             $aedit->set_cpid($aid);
             $curuser->pmautocheck($channel['autocheck']) && $aedit->arc_check(1, 0);
             $aedit->updatedb();
             //归辑设置,与文档数据库无关
             if (!empty($item['pid'])) {
                 $pid = $db->result_one("SELECT aid FROM {$tblprefix}gurls WHERE guid='{$item['pid']}'");
                 $pid && $aedit->set_album($pid);
             }
             if ($channel['autostatic']) {
                 arc_static($aid);
             }
             $ufids = $c_upload->ufids + explode(',', $item['ufids']);
             empty($ufids) || $db->query("UPDATE {$tblprefix}userfiles SET aid={$aid} WHERE ufid " . multi_str($ufids));
         }
         $db->query("UPDATE {$tblprefix}gurls SET aid='{$aid}',outputdate='{$timestamp}',contents='',ufids='' WHERE guid='{$item['guid']}'");
         $progress && $progress->output(1);
     }
     if ($this->gmission['sonid'] && !$item['abover']) {
         $this->output_sonid($guid, $this->gmission['sonid']);
     }
     //将合辑中的内容入库
     unset($aedit, $arc, $fields, $field, $item, $archivenew, $channel, $sqlmain, $sqlsub, $sqlcustom);
     return true;
 }