Esempio n. 1
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;
 }
Esempio n. 2
0
 function avg_price()
 {
     global $db, $tblprefix, $timestamp;
     if ($this->cclass != 'offer' || !isset($this->updatearr['oprice']) || !$this->info['checked'] || empty($this->commu['setting']['average']) || empty($this->commu['setting']['ptable']) || empty($this->commu['setting']['pename'])) {
         return;
     }
     $aedit = new cls_arcedit();
     $aedit->set_aid($this->aid);
     $aedit->basic_data(0);
     $average = $db->result_one("SELECT AVG(oprice) FROM {$tblprefix}offers WHERE aid='" . $this->aid . "' AND checked='1' AND (enddate='0' OR enddate>'{$timestamp}')");
     $aedit->updatefield($this->commu['setting']['pename'], $average, $this->commu['setting']['ptable']);
     $aedit->updatedb();
 }
Esempio n. 3
0
 function updatecopy($mode = 0)
 {
     //当更新文档时,同时更新其它的副本。
     global $cotypes, $timestamp, $db, $tblprefix, $arc;
     if (!$mode) {
         return false;
     }
     $cpids = array();
     $naid = $this->aid;
     $query = $db->query("SELECT aid FROM {$tblprefix}archives WHERE aid != '{$naid}' AND cpid='" . $this->archive['cpid'] . "'");
     while ($row = $db->fetch_array($query)) {
         $cpids[] = $row['aid'];
     }
     if (!$cpids) {
         return false;
     }
     $this->init();
     $this->set_aid($naid);
     $this->detail_data();
     $archivenew =& $this->archive;
     $archivenew = maddslashes($archivenew);
     $chid = $archivenew['chid'];
     $fields = read_cache('fields', $chid);
     $aedit = new cls_arcedit();
     foreach ($cpids as $aid) {
         $aedit->set_aid($aid);
         $aedit->detail_data();
         $aedit->updatefield('rpmid', $archivenew['rpmid'], 'main');
         $aedit->updatefield('dpmid', $archivenew['dpmid'], 'main');
         $aedit->updatefield('salecp', $archivenew['salecp'], 'main');
         $aedit->updatefield('fsalecp', $archivenew['fsalecp'], 'main');
         $aedit->sale_define();
         $aedit->updatefield('arctpls', $archivenew['arctpls'], 'sub');
         $aedit->updatefield('jumpurl', $archivenew['jumpurl'], 'sub');
         foreach ($fields as $k => $v) {
             if ($v['available'] && !$v['isfunc'] && (!in_array($k, array('subject', 'keywords', 'thumb', 'abstract')) || $mode == 1)) {
                 if (!empty($v['istxt'])) {
                     $txtname = saveastxt(stripslashes($archivenew[$k]), $aedit->namepres[$k]);
                     $aedit->updatefield($k, $txtname, $v['tbl']);
                 } else {
                     $aedit->updatefield($k, $archivenew[$k], $v['tbl']);
                     if ($arr = multi_val_arr($archivenew[$k], $v)) {
                         foreach ($arr as $x => $y) {
                             $aedit->updatefield($k . '_' . $x, $y, $v['tbl']);
                         }
                     }
                 }
             }
         }
         $aedit->updatedb();
         if ($this->channel['autostatic']) {
             arc_static($aid);
             unset($arc);
         }
         $aedit->init();
     }
     return true;
 }
Esempio n. 4
-1
                $aedit->basic_data();
                $aedit->archive['checked'] && $aedit->archive['needupdate'] && $aedit->updatefield('needupdate', 0, 'sub');
            }
            if (!empty($arcdeal['readd'])) {
                //重发布
                $aedit->readd();
            }
            if (!empty($arcdeal['abover'])) {
                $aedit->updatefield('abover', 1, 'main');
            }
            if (!empty($arcdeal['unabover'])) {
                $aedit->updatefield('abover', 0, 'main');
            }
            if (!empty($arcdeal['close'])) {
                $aedit->updatefield('closed', 1, 'main');
            }
            if (!empty($arcdeal['validperiod'])) {
                $arcvalidperiod = empty($arcvalidperiod) ? 0 : max(0, intval($arcvalidperiod));
                $aedit->reset_validperiod($arcvalidperiod);
            }
            $aedit->updatedb();
        }
        unset($aedit);
        if (!empty($arcdeal['ucid'])) {
            $db->query("UPDATE {$tblprefix}archives SET ucid='{$arcucid}' WHERE aid " . multi_str($selectid), 'SILENT');
        }
        mcmessage('archiveoperatefinish', axaction(2, "?action=archives{$filterstr}&page={$page}"));
    }
} else {
    include M_ROOT . $u_tplname;
}