/trunk/emlog/src/adm/add_log.php
PHP | 147 lines | 121 code | 7 blank | 19 comment | 19 complexity | 5ae4ad2142f885a6a90f8a976c3ec568 MD5 | raw file
- <?php
- /**
- * ????
- * @copyright (c) 2008, Emlog All Rights Reserved
- * @version emlog-2.6.0
- */
-
- require_once('./globals.php');
-
- $pid = isset($_GET['pid'])?$_GET['pid']:'';
-
- if($action == '')
- {
- include getViews('header');
- //??tags
- $query = $DB->query("select tagname from {$db_prefix}tag");
- $oldtags = '';
- while($tags = $DB->fetch_array($query))
- {
- $oldtags .=" <a href=\"javascript: inserttag('".$tags['tagname']."','tags');\">".$tags['tagname']."</a> " ;
- }
- //??
- $year = date('Y');
- $month = date('m');
- $day = date('d');
- $hour = date('H');
- $minute = date('i');
- $second = date('s');
-
- require_once(getViews('add_log'));
- include getViews('footer');cleanPage();
- }
- ##################????##################
- if($action== 'addlog')
- {
- if($pid == 'draft')
- {
- $ishide='y';
- $ok_msg = '???????';
- $ok_url = 'admin_log.php?pid=draft';
- }else
- {
- $ishide = 'n';
- $ok_msg = '???????';
- $ok_url = 'admin_log.php';
- }
- $title = isset($_POST['title'])?addslashes(trim($_POST['title'])):'';
- $tagstring = isset($_POST['tag'])?addslashes(trim($_POST['tag'])):'';
- $edittime = isset($_POST['edittime'])?intval(isset($_POST['edittime'])):'';
- $content = isset($_POST['content'])?addslashes(trim($_POST['content'])):'';
- $pingurl = isset($_POST['pingurl'])?addslashes($_POST['pingurl']):'';
- $allow_remark = isset($_POST['allow_remark'])?addslashes($_POST['allow_remark']):'';
- $allow_tb = isset($_POST['allow_tb'])?addslashes($_POST['allow_tb']):'';
- $tbmsg = ''; //define trackback msg
- if(!$title)
- {
- formMsg('???????','./add_log.php',0);
- }
- //????
- if($timezone!=8)
- {
- $oversec = ($timezone-8)*3600;
- $localtime = time()-$oversec;
- }else
- $localtime = time();
- if($edittime)
- {
- $newtime = @gmmktime(intval($_POST['newhour']),intval($_POST['newmin']),
- intval($_POST['newsec']),intval($_POST['newmonth']),
- intval($_POST['newday']),intval($_POST['newyear']))-$timezone*3600;
- if(empty($newtime))
- $newtime = $localtime;
- } else
- $newtime = $localtime;
-
- //???????????id ????
- //preg_match_all("/ematt:([0-9]+)/i",$content, $matches );
- //$cont_attid = serialize($matches[1]);
-
- //???????
- $sql="insert into {$db_prefix}blog (`title`,`date`,`content`,`hide`,`allow_remark`,`allow_tb`,`attcache`) values('$title','$newtime','$content','$ishide','$allow_remark','$allow_tb','')";
- $DB->query($sql);
- //????????ID
- $logid=$DB->insert_id();
- //??tag
- if (!empty($tagstring))
- {
- $tag = explode(',',$tagstring);
- $tag = formatArray($tag);
- for ($i = 0; $i < count($tag); $i++)
- {
- $result = $DB->fetch_one_array("SELECT tagname FROM {$db_prefix}tag WHERE `tagname`='".trim($tag[$i])."' ");
- if(empty($result)) {
- $query="INSERT INTO {$db_prefix}tag (`tagname`,`gid`) VALUES('".$tag[$i]."',',$logid,')";
- $DB->query($query);
- }else{
- $query="UPDATE {$db_prefix}tag SET `usenum`=`usenum`+1, `gid`=concat(`gid`,'$logid,') where `tagname` = '".$tag[$i]."' ";
- $DB->query($query);
- }
- }
- $MC->mc_tags('../cache/tags');
- }
- //????
- $attach = isset($_FILES['attach'])?$_FILES['attach']:'';
- if($attach){
- $des = $_POST['attdes'];
- for ($i = 0; $i < count($attach['name']); $i++)
- {
- if($attach['error'][$i]!=4){
- $ades = addslashes(trim($des[$i]));
- //$att_type ????????
- $upfname = uploadFile($attach['name'][$i],$attach['tmp_name'][$i],$attach['size'][$i],$att_type,$attach['type'][$i]);
- //??????
- $query="INSERT INTO {$db_prefix}attachment (`blogid`,`filename`,`attdes`,`filesize`,`filepath`,`addtime`) values ('".$logid."','".$attach['name'][$i]."','".$ades."','".$attach['size'][$i]."','".$upfname."','".time()."')";
- $DB->query($query);
- }
- }
- }
- // ??Trackback??
- if(!empty($pingurl))
- {
- $url = $blogurl."index.php?action=showlog&gid=".$logid;
- $hosts = explode("\n", $pingurl);
- $tbmsg = '';
- foreach ($hosts as $key => $value)
- {
- $host = trim($value);
- if(strstr(strtolower($host), "http://") || strstr(strtolower($host), "https://"))
- {
- $data ="url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blogname)."&excerpt=".rawurlencode($content);
- $result = strtolower(sendPacket($host, $data));
- if (strstr($result, "<error>0</error>") === false) {
- $tbmsg .= "(??{$key}:????)";
- } else {
- $tbmsg .= "(??{$key}:????)";
- }
- }
- }
- }
- $MC->mc_sta('../cache/sta');
- $MC->mc_record('../cache/records');
- $MC->mc_logtags('../cache/log_tags');
- $MC->mc_logatts('../cache/log_atts');
- formMsg("$ok_msg\t$tbmsg",$ok_url,1);
-
- }//end add log
- ?>