Esempio n. 1
0
 function onsubsave()
 {
     include_once admin_ROOT . adminfile . '/include/command_templatesdir.php';
     include_once admin_ROOT . 'public/class_pingying.php';
     parent::start_template();
     $inputclass = $this->fun->accept('inputclass', 'P');
     $lng = $this->sitelng;
     $lng = empty($lng) ? $this->CON['is_alonelng'] && !empty($this->CON['home_lng']) ? $this->CON['home_lng'] : $this->CON['default_lng'] : $lng;
     $mid = $this->fun->accept('mid', 'P');
     $mid = empty($mid) ? 0 : $mid;
     $pagemax = $this->fun->accept('pagemax', 'P');
     $pagemax = empty($pagemax) ? 0 : $pagemax;
     $subjectname = $this->fun->accept('subjectname', 'P');
     $content = $this->fun->accept('content', 'P');
     $content = empty($content) ? '' : $this->fun->Text2Html($content);
     $keywords = $this->fun->accept('keywords', 'P');
     $description = $this->fun->accept('description', 'P');
     $isdirname = $this->fun->accept('isdirname', 'P');
     $subpic = $this->fun->accept('subpic', 'P');
     $dirname = $this->fun->accept('dirname', 'P');
     $purview = $this->fun->accept('purview', 'P');
     $styleid = $this->fun->accept('styleid', 'P');
     $template = $this->fun->accept('template', 'P');
     $template = empty($template) ? $TEMPNAMELIST['subjectlist'] : $template;
     $indextemplates = $this->fun->accept('indextemplates', 'P');
     $indextemplates = empty($indextemplates) ? $TEMPNAMELIST['subjectindex'] : $indextemplates;
     $ishtml = $this->fun->accept('ishtml', 'P');
     $ishtml = empty($ishtml) ? 0 : $ishtml;
     $iswap = $this->fun->accept('iswap', 'P');
     $iswap = empty($iswap) ? 0 : $iswap;
     $waptempalte = $this->fun->accept('waptempalte', 'P');
     $waptempalte = empty($waptempalte) ? $TEMPNAMELIST['subjectlist'] : $waptempalte;
     $filenamestyle = $this->fun->accept('filenamestyle', 'P');
     $db_table = db_prefix . 'subjectlist';
     $date = time();
     if ($inputclass == 'add') {
         if ($isdirname) {
             $chinesespelit = new chineseSpell();
             $dirname = $chinesespelit->getFullSpell($subjectname);
         } else {
             if (!preg_match("/^[\\w-]+\$/i", $dirname)) {
                 exit('false');
             }
         }
         $db_table2 = db_prefix . 'typelist';
         $db_where = " WHERE dirname='{$dirname}' AND lng='{$lng}'";
         $countnum = $this->db_numrows($db_table, $db_where);
         if (!$isdirname) {
             if ($countnum > 0) {
                 exit('false');
             } else {
                 $countnum = $this->db_numrows($db_table2, $db_where);
                 if ($countnum > 0) {
                     exit('false');
                 }
             }
         } else {
             if ($countnum > 0) {
                 $dirname = $dirname . mt_rand(10, 99);
             } else {
                 $countnum = $this->db_numrows($db_table2, $db_where);
                 if ($countnum > 0) {
                     $dirname = $dirname . mt_rand(10, 99);
                 }
             }
         }
         $subpath = admin_ROOT . $this->CON['file_htmldir'];
         if (!$this->fun->filemode($subpath)) {
             exit('false');
         }
         if ($this->CON['is_alonelng']) {
             $subdir = $subpath . $dirname;
         } else {
             $lngdir = $this->get_lng_dirpack($lng);
             $subdir = $subpath . $lngdir . '/' . $dirname;
         }
         if (!is_dir($subdir)) {
             if (!@mkdir($subdir, 0777, true)) {
                 exit('false');
             }
         }
         $db_field = 'pid,mid,lng,subjectname,keywords,description,content,subpic,dirname,purview,isclass,styleid,indextemplates,template,filenamestyle,dirpath,addtime,ishtml,iswap,waptempalte,pagemax';
         $db_values = "50,{$mid},'{$lng}','{$subjectname}','{$keywords}','{$description}','{$content}','{$subpic}','{$dirname}',{$purview},1,{$styleid},'{$indextemplates}','{$template}','{$filenamestyle}','{$dirname}',{$date},{$ishtml},{$iswap},'{$waptempalte}',{$pagemax}";
         $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
         $this->writelog($this->lng['subjectmanage_add_log'], $this->lng['log_extra_ok'] . ' subjectname=' . $subjectname);
         $this->dbcache->clearcache('subjectlist_array_' . $lng, true);
         exit('true');
     } elseif ($inputclass == 'edit') {
         $sid = $this->fun->accept('sid', 'P');
         $db_where = 'sid=' . $sid;
         $db_set = "subjectname='{$subjectname}',keywords='{$keywords}',description='{$description}',content='{$content}',subpic='{$subpic}',purview={$purview},styleid={$styleid},indextemplates='{$indextemplates}',template='{$template}',filenamestyle='{$filenamestyle}',ishtml={$ishtml},iswap={$iswap},waptempalte='{$waptempalte}',pagemax={$pagemax}";
         $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
         $this->writelog($this->lng['subjectmanage_edit_log'], $this->lng['log_extra_ok'] . ' subjectname=' . $typename . ' sid=' . $sid);
         $this->dbcache->clearcache('subjectlist_view_' . $sid, true);
         $this->dbcache->clearcache('subjectlist_array_' . $lng, true);
         exit('true');
     }
 }
Esempio n. 2
0
    function ontypesave()
    {
        include_once admin_ROOT . adminfile . '/include/command_templatesdir.php';
        include_once admin_ROOT . 'public/class_pingying.php';
        parent::start_template();
        $inputclass = $this->fun->accept('inputclass', 'P');
        $inputupid = $this->fun->accept('inputupid', 'P');
        $lng = $this->sitelng;
        $lng = empty($lng) ? $this->CON['default_lng'] : $lng;
        $mid = $this->fun->accept('mid', 'P');
        $mid = empty($mid) ? 0 : $mid;
        $upid = $this->fun->accept('upid', 'P');
        $upid = empty($upid) ? 0 : $upid;
        $topid = $this->fun->accept('topid', 'P');
        $topid = empty($topid) ? 0 : $topid;
        $typename = $this->fun->accept('typename', 'P');
        $content = $this->fun->accept('content', 'P');
        $keywords = $this->fun->accept('keywords', 'P');
        $headtitle = $this->fun->accept('headtitle', 'P');
        $description = $this->fun->accept('description', 'P');
        $typepic = $this->fun->accept('typepic', 'P');
        $iseditdir = $this->fun->accept('iseditdir', 'P');
        $iseditdir = empty($iseditdir) ? 0 : $iseditdir;
        $dirname = $this->fun->accept('dirname', 'P');
        $newdirname = $this->fun->accept('newdirname', 'P');
        $purview = $this->fun->accept('purview', 'P');
        $purview = empty($purview) ? 0 : $purview;
        $ismenu = $this->fun->accept('ismenu', 'P');
        $ismenu = empty($ismenu) ? 0 : $ismenu;
        $isaccessory = $this->fun->accept('isaccessory', 'P');
        $isaccessory = empty($isaccessory) ? 0 : $isaccessory;
        $isdirname = $this->fun->accept('isdirname', 'P');
        $isdirname = empty($isdirname) ? 0 : $isdirname;
        $styleid = $this->fun->accept('styleid', 'P');
        $pageclass = $this->fun->accept('pageclass', 'P');
        $pageclass = empty($pageclass) ? 0 : $pageclass;
        $ispart = $this->fun->accept('ispart', 'P');
        $ispart = empty($ispart) ? 0 : $ispart;
        $gotoid = $this->fun->accept('gotoid', 'P');
        $gotoid = empty($gotoid) ? 0 : $gotoid;
        $isline = $this->fun->accept('isline', 'P');
        $isline = empty($isline) ? 0 : $isline;
        $gotoline = $this->fun->accept('gotoline', 'P');
        $gotoline = empty($gotoline) ? 0 : $gotoline;
        $template = $this->fun->accept('template', 'P');
        $template = empty($template) ? $TEMPNAMELIST['typelist'] : $template;
        $indextemplates = $this->fun->accept('indextemplates', 'P');
        $indextemplates = empty($indextemplates) ? $TEMPNAMELIST['typeindex'] : $indextemplates;
        $readtemplate = $this->fun->accept('readtemplate', 'P');
        $readtemplate = empty($readtemplate) ? $TEMPNAMELIST['typeread'] : $readtemplate;
        $filenamestyle = $this->fun->accept('filenamestyle', 'P');
        $readnamestyle = $this->fun->accept('readnamestyle', 'P');
        $typeurl = $this->fun->accept('typeurl', 'P');
        $iswap = $this->fun->accept('iswap', 'P');
        $iswap = empty($iswap) ? 0 : $iswap;
        $waptempalte = $this->fun->accept('waptempalte', 'P');
        $waptempalte = empty($waptempalte) ? $TEMPNAMELIST['typelist'] : $waptempalte;
        $wapreadtemplate = $this->fun->accept('wapreadtemplate', 'P');
        $wapreadtemplate = empty($wapreadtemplate) ? $TEMPNAMELIST['typeread'] : $wapreadtemplate;
        $pagemax = $this->fun->accept('pagemax', 'P');
        $pagemax = empty($pagemax) ? 0 : $pagemax;
        $isorderby = $this->fun->accept('isorderby', 'P');
        $isorderby = empty($isorderby) ? 0 : $isorderby;
        $ordertype = $this->fun->accept('ordertype', 'P');
        $ordertype = empty($ordertype) ? 1 : $ordertype;
        $db_table = db_prefix . 'typelist';
        $date = time();
        if ($inputclass == 'add') {
            if ($isdirname) {
                $chinesespelit = new chineseSpell();
                $dirname = $chinesespelit->getFullSpell($typename);
            } else {
                if (!preg_match("/^[\\w-]+\$/i", $dirname)) {
                    exit($this->lng['typemanage_js_dirname_empty']);
                }
            }
            if (!$upid) {
                $db_where = " WHERE upid=0 AND dirname='{$dirname}' AND lng='{$lng}'";
            } else {
                $db_where = " WHERE topid={$topid} AND dirname='{$dirname}' AND lng='{$lng}'";
            }
            $countnum = $this->db_numrows($db_table, $db_where);
            if (!$isdirname) {
                if ($countnum > 0) {
                    exit($this->lng['typemanage_js_type_dirname_check_no']);
                }
            } else {
                $dirname = $countnum > 0 ? $dirname . mt_rand(10, 99) : $dirname;
            }
            if (!$upid) {
                $db_where2 = " WHERE dirname='{$dirname}' AND lng='{$lng}'";
                $db_table2 = db_prefix . 'subjectlist';
                $countnum = $this->db_numrows($db_table2, $db_where2);
                if (!$isdirname) {
                    if ($countnum > 0) {
                        exit($this->lng['typemanage_js_type_dirname_check_no']);
                    }
                } else {
                    $dirname = $countnum > 0 ? $dirname . mt_rand(10, 99) : $dirname;
                }
            }
            $typepath = admin_ROOT . $this->CON['file_htmldir'];
            if (!$this->fun->filemode($typepath) && $styleid < 3) {
                exit($this->lng['filedir_err'] . '(' . $this->CON['file_htmldir'] . ')');
            }
            $lngdir = $this->get_lng_dirpack($lng);
            if ($upid == 0) {
                if ($this->CON['is_alonelng']) {
                    $typedir = $typepath . $dirname;
                } else {
                    $typedir = $typepath . $lngdir . '/' . $dirname;
                }
                $dirpath = '';
                $topid = 0;
                $exmid = 0;
            } else {
                $topid_read = $this->get_type($topid);
                $exmid = $topid_read['mid'] != $mid ? $topid_read['mid'] : 0;
                $topid_temp = $topid_read['dirname'];
                if ($this->CON['is_alonelng']) {
                    $typedir = $typepath . $topid_temp . '/' . $dirname;
                } else {
                    $typedir = $typepath . $lngdir . '/' . $topid_temp . '/' . $dirname;
                }
                $dirpath = $topid_temp;
            }
            if ($styleid != 3) {
                if (!is_dir($typedir)) {
                    if (!@mkdir($typedir, 0777, true)) {
                        exit($this->lng['filedircreat_err'] . '(' . $this->CON['file_htmldir'] . ')');
                    }
                }
            }
            $db_field = 'pid,mid,topid,upid,exmid,lng,typename,content,keywords,description,typepic,dirname,purview,ismenu,isaccessory,isclass,ispart,styleid,pageclass,
				indextemplates,template,readtemplate,filenamestyle,readnamestyle,typeurl,dirpath,addtime,iswap,waptempalte,wapreadtemplate,pagemax,isline,gotoline,isorderby,ordertype,headtitle';
            $db_values = "50,{$mid},{$topid},{$upid},{$exmid},'{$lng}','{$typename}','{$content}','{$keywords}','{$description}','{$typepic}','{$dirname}',{$purview},{$ismenu},{$isaccessory},1,{$ispart},{$styleid},{$pageclass},\n\t\t\t'{$indextemplates}','{$template}','{$readtemplate}','{$filenamestyle}','{$readnamestyle}','{$typeurl}','{$dirpath}',{$date},{$iswap},'{$waptempalte}','{$wapreadtemplate}',{$pagemax},{$isline},{$gotoline},{$isorderby},{$ordertype},'{$headtitle}'";
            $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
            if ($styleid == 4) {
                $insert_id = $this->db->insert_id();
                $db_table2 = db_prefix . 'document';
                if (empty($insert_id)) {
                    exit('true');
                }
                $aid = $this->esp_adminuserid;
                $isclass = $this->esp_inputclassid;
                $isclass = empty($isclass) ? 0 : $isclass;
                $entrance_file = empty($this->CON['entrance_file']) ? 'index' : $this->CON['entrance_file'];
                $db_field = 'lng,pid,mid,aid,tid,extid,sid,fgid,linkdid,isclass,islink,ishtml,ismess,isorder,ktid,purview,istemplates,recommend,tsn,title,longtitle,color,author,source,pic,tags,keywords,description,summary,link,oprice,bprice,click,addtime,uptime,template,filename,isbase';
                $db_values = "'{$lng}',50,{$mid},{$aid},{$insert_id},'0',0,0,'',{$isclass},0,1,0,0,0,0,0,'','','{$typename}','{$typename}','','','','','','','','','',0,0,0,{$date},{$date},'{$readtemplate}','{$entrance_file}',1";
                $this->db->query('INSERT INTO ' . $db_table2 . ' (' . $db_field . ') VALUES (' . $db_values . ')');
                $insert_id2 = $this->db->insert_id();
                $db_set = "linkid={$insert_id2}";
                $db_where = 'tid=' . $insert_id;
                $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
            }
            $this->writelog($this->lng['typemanage_add_log'], $this->lng['log_extra_ok'] . ' typename=' . $typename);
            $this->dbcache->clearcache('typelist_array', true);
            exit('true');
        } elseif ($inputclass == 'edit') {
            $tid = $this->fun->accept('tid', 'P');
            $topid = $this->fun->accept('topid', 'P');
            $topid = empty($topid) ? 0 : $topid;
            $beedit = $this->fun->accept('beedit', 'P');
            $beistemplatesedit = $this->fun->accept('beistemplatesedit', 'P');
            $editwap = $this->fun->accept('editwap', 'P');
            $db_where = 'tid=' . $tid;
            if ($inputupid > 0 && $upid != $inputupid) {
                $topid_temp = $this->get_type($upid);
                if ($topid_temp['topid'] == 0) {
                    $newtopid = $topid_temp['tid'];
                } else {
                    $newtopid = $topid_temp['topid'];
                }
                if ($newtopid != $topid) {
                    $topid = $newtopid;
                    $db_where2 = $this->get_typeid($tid, 'tid', $tid, $mid, 0, $lng);
                    $topid_dirtypeame = $this->get_type($topid, 'dirname');
                    if ($db_where2) {
                        $db_set = "topid={$topid},dirpath='{$topid_dirtypeame}'";
                        $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where2);
                    }
                    $db_set = "dirpath='{$topid_dirtypeame}'";
                    $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
                }
            }
            $db_set = null;
            if ($iseditdir && $inputupid == 0 && !empty($newdirname)) {
                $db_where2 = "topid={$tid}";
                $db_set2 = "dirpath='{$newdirname}'";
                $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set2 . ' WHERE ' . $db_where2);
                $db_set = "dirname='{$newdirname}',";
            } elseif ($iseditdir && $inputupid > 0 && !empty($newdirname)) {
                $db_set = "dirname='{$newdirname}',";
            }
            $db_set .= "topid={$topid},upid={$upid},gotoid={$gotoid},typename='{$typename}',content='{$content}',keywords='{$keywords}',description='{$description}',typepic='{$typepic}',purview={$purview},ismenu={$ismenu},\n\t\t\tisaccessory={$isaccessory},ispart={$ispart},styleid={$styleid},pageclass={$pageclass},template='{$template}',readtemplate='{$readtemplate}',filenamestyle='{$filenamestyle}',\n\t\t\treadnamestyle='{$readnamestyle}',typeurl='{$typeurl}',indextemplates='{$indextemplates}',iswap={$iswap},waptempalte='{$waptempalte}',wapreadtemplate='{$wapreadtemplate}',pagemax={$pagemax},isline={$isline},gotoline={$gotoline},isorderby={$isorderby},ordertype={$ordertype},headtitle='{$headtitle}'";
            $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
            if ($beedit || $beistemplatesedit || $editwap) {
                $db_where2 = $this->get_typeid($tid, 'tid', $tid, $mid, 0, $lng);
                if ($db_where2) {
                    $db_set = null;
                    if ($beistemplatesedit) {
                        $db_set .= "indextemplates='{$indextemplates}',template='{$template}',readtemplate='{$readtemplate}',filenamestyle='{$filenamestyle}',readnamestyle='{$readnamestyle}',pagemax={$pagemax},";
                    }
                    if ($beedit) {
                        $db_set .= "typepic='{$typepic}',";
                    }
                    if ($editwap) {
                        $db_set .= "waptempalte='{$waptempalte}',wapreadtemplate='{$wapreadtemplate}',";
                    }
                    $db_set = substr($db_set, 0, -1);
                    $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where2);
                }
            }
            $this->writelog($this->lng['typemanage_edit_log'], $this->lng['log_extra_ok'] . ' typename=' . $typename . ' tid=' . $tid);
            $this->dbcache->clearcache('typelist_view_' . $tid, true);
            $this->dbcache->clearcache('typelist_array_' . $lng, true);
            if ($lng == $this->CON['is_lancode']) {
                $this->dbcache->clearcache('typelist_array_big5', true);
            }
            exit('true');
        } elseif ($inputclass == 'shift') {
            $tid = $this->fun->accept('tid', 'P');
            $shifttid = $this->fun->accept('shifttid', 'P');
            if ($shifttid == $tid || $shifttid == 0) {
                exit('false');
            }
            $isshift = $this->fun->accept('isshift', 'P');
            $db_table_dc = db_prefix . 'document';
            if ($isshift) {
                $db_where = $this->get_typeid($tid, 'tid', 0, $mid, 0, $lng);
            } else {
                $db_where = "tid={$tid}";
            }
            $db_set = "tid={$shifttid}";
            $this->db->query('UPDATE ' . $db_table_dc . ' SET ' . $db_set . ' WHERE ' . $db_where);
            $this->writelog($this->lng['typemanage_shift_log'], $this->lng['log_extra_ok'] . ' old_tid=' . $tid . ' newtid=' . $isshift);
            exit('true');
        }
    }