示例#1
0
function metaWeblog_newPost($values)
{
    global $config, $defualtcategoryid, $db_prefix, $mbconfig;
    $struct = $values['struct'];
    $userdetail = check_user($values['username'], $values['password']);
    if (!$struct['title']) {
        $title = "Untitled MetaWeblogAPI Entry";
    } else {
        $title = safe_convert($struct['title']);
    }
    if (!$struct['description']) {
        xml_error("You MUST provide a decription element in your post.");
    } else {
        $content = reduce_entities($struct['description']);
    }
    if ($struct['pubDate']) {
        $struct['dateCreated'] = $struct['pubDate'];
    }
    if ($struct['dateCreated']) {
        $time = get_time_unix($struct['dateCreated']);
    } else {
        $time = time();
    }
    $blog = new boblog();
    //writetofile ('text5.php', $struct['categories']); //For debug only
    if ($struct['categories'] != '') {
        $c_tmp = $blog->getgroupbyquery("SELECT cateid FROM `{$db_prefix}categories` WHERE `catename`='{$struct['categories']}'");
        $category = $c_tmp[0]['cateid'];
        if ($category == '') {
            $category = $defualtcategoryid;
        }
    } else {
        $category = $defualtcategoryid;
    }
    $html = 1;
    if ($struct['flNotOnHomePage'] == 1) {
        $property = 3;
    } else {
        $property = 0;
    }
    $maxrecord = $blog->getsinglevalue("{$db_prefix}maxrec");
    $currentid = $maxrecord['maxblogid'] + 1;
    $query = "INSERT INTO `{$db_prefix}blogs` VALUES ('{$currentid}', '{$title}','{$time}','{$userdetail['userid']}', 0, 0, 0, '{$property}','{$category}','','0','{$html}', '1', '1', '{$content}', '0', '0', 'blank', '0', '', '', '0', '', '0', '', '', '', '')";
    $blog->query($query);
    $newcym = gmdate("Ym", $time + $config['timezone'] * 3600);
    $newcd = gmdate("d", $time + $config['timezone'] * 3600);
    $blog->query("INSERT INTO `{$db_prefix}calendar` VALUES ('{$newcym}', '{$newcd}', '{$currentid}', '')");
    recache_latestentries();
    recache_currentmonthentries();
    recache_categories();
    //Update Category counter
    $blog->query("UPDATE `{$db_prefix}maxrec` SET maxblogid={$currentid}");
    $blog->query("UPDATE `{$db_prefix}counter` SET entries=entries+1");
    $xml_content = make_xml_piece("string", $currentid);
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
示例#2
0
    //Disable security code for some usergroups
    $config['validation'] = '0';
    $config['loginvalidation'] = '0';
    $config['applylinkvalidation'] = '0';
}
//Get IP
$ip_tmp = $_SERVER['REMOTE_ADDR'];
$ip_tmp1 = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($ip_tmp1 != "" && $ip_tmp1 != "unknown") {
    $userdetail['ip'] = $ip_tmp1;
} else {
    $userdetail['ip'] = $ip_tmp;
}
$userdetail['ip'] = addslashes($userdetail['ip']);
//Get Statistics
$statistics = $blog->getsinglevalue("{$db_prefix}counter");
//Who's online
if (!defined('noCounter')) {
    //trackback, rss, sitemap are not regarded as normal visits
    $afilename = "data/online.php";
    $onlineusers = $nowonline = array();
    //2006-11-22 Security fix, 2006-11-25 modified
    $online_all = @file($afilename);
    for ($i = 0; $i < count($online_all); $i++) {
        $oldip = explode("|", $online_all[$i]);
        if (trim($oldip[2]) == '') {
            continue;
        }
        if (gmdate("Ymd", $oldip[2] + $config['timezone'] * 3600 + 86400) == $nowtime['Ymd']) {
            savehistory(gmdate("Ymd", $oldip[2] + $config['timezone'] * 3600), $statistics['today']);
            $statistics['today'] = 0;