function metaWeblog_getRecentPosts($values) { global $config, $db_prefix; $userdetail = check_user($values['username'], $values['password']); $blog = new boblog(); $values['numberOfPosts'] = floor($values['numberOfPosts']); $records = $blog->getgroupbyquery("SELECT * FROM `{$db_prefix}blogs` ORDER BY `pubtime` DESC LIMIT 0, {$values['numberOfPosts']}"); if ($records[0]['blogid'] == '') { xml_error("Entry does not exist."); } else { for ($i = 0; $i < count($records); $i++) { $record = $records[$i]; $time = get_time_unix($record['pubtime'], 'iso'); $value_body = array('dateCreated' => $time, 'userid' => $userdetail['userid'], 'postid' => $record['blogid'], 'description' => htmlspecialchars($record['content']), 'title' => htmlspecialchars($record['title']), 'link' => "{$config['blogurl']}/read.php?{$record['blogid']}", 'categories' => make_xml_piece('array', array("Category {$record['category']}"))); $value_bodys[] = make_xml_piece("struct", $value_body); } $body = make_xml_piece("array", $value_bodys); $body_xml = xml_generate($body); send_response($body_xml); } }
function blogger_newPost($values) { global $settingInfo, $defualtcategoryid, $DMC, $DBPrefix, $arrSideModule; global $strArrayMonth, $strArrayDay, $strYear, $strMonth, $arrWeek, $strDayLogs, $strCalendar; global $strModifyInfo, $strLogout, $strLoginSubmit, $strUserRegister; global $strSearchErr, $strKeyword, $strSearchTitle, $strSearchContent, $strSearchTitleContent, $strFind; $struct = $values['struct']; $userdetail = check_user_pw($values['username'], $values['password']); if (!$struct['title']) { $logTitle = "Untitled MetaWeblogAPI Entry"; } else { $logTitle = reduce_entities($struct['title']); } if (!$struct['description']) { xml_error("You MUST provide a decription element in your post."); } else { $logContent = reduce_entities($struct['description']); } if ($struct['pubDate']) { $struct['dateCreated'] = $struct['pubDate']; } if ($struct['dateCreated']) { $postTime = get_time_unix($struct['dateCreated']); } else { $postTime = time(); } if ($struct['categories'] != '') { if (strpos(";" . $struct['categories'], "|-") > 0) { $struct['categories'] = trim(substr($struct['categories'], 2)); } $c_tmp = $DMC->fetchArray($DMC->query("SELECT id FROM `{$DBPrefix}categories` WHERE `name`='{$struct['categories']}'")); $category = $c_tmp['id']; if ($category == '') { $category = $defualtcategoryid; } } else { $category = $defualtcategoryid; } $query = "INSERT INTO `{$DBPrefix}logs` (cateId,logTitle,logContent,author,quoteUrl,postTime,isComment,isTrackback,isTop,weather,saveType,tags,password,logsediter) VALUES ('{$category}','{$logTitle}','{$logContent}','{$userdetail['username']}','','{$postTime}','1','1','0','','1','','','tiny')"; $DMC->query($query); //echo $DMC->error(); $currentid = $DMC->insertId(); //更新缓存 $DMC->query("UPDATE " . $DBPrefix . "categories set cateCount=cateCount+1 WHERE id='{$category}'"); $DMC->query("UPDATE " . $DBPrefix . "setting set settValue=settValue+1 where settName='setlogs'"); //更新Cache settings_recache(); categories_recount(); categories_recache(); recentLogs_recache(); archives_recache(); calendar_recache(); logsTitle_recache(); logs_sidebar_recache($arrSideModule); $xml_logContent = make_xml_piece("string", $currentid); $body_xml = xml_generate($xml_logContent); //writetofile ("text2.xml", $body_xml); //For debug use send_response($body_xml); }