function metaWeblog_newMediaObject($values) { //2006-12-2 add support for uploading files global $config, $defualtcategoryid, $db_prefix, $mbcon, $nowtime; $userdetail = check_user($values['username'], $values['password']); $struct = $values['struct']; //writetofile ('text1.php', $struct['bits']); //debug only if ($struct['bits'] && $struct['name']) { $writefilecontent = base64_decode($struct['bits']); $ext = strtolower(strrchr($struct['name'], '.')); $ext = str_replace(".", '', $ext); $upload_filename = time() . '_' . rand(1000, 9999) . substr(md5($struct['name']), 0, 4) . '.' . $ext; if ($mbcon['uploadfolders'] == '1') { $targetfolder_ym = date("Ym") . '/'; $targetfolder = "attachment/{$targetfolder_ym}"; if (!is_dir($targetfolder)) { $mktargetfolder = @mkdir($targetfolder, 0777); if (!$mktargetfolder) { xml_error("Sorry, uploading file ({$struct['name']}) failed because PHP was unable to create a new directory."); } } } else { $targetfolder_ym = ''; $targetfolder = 'attachment'; } $filenum = @fopen("{$targetfolder}/{$upload_filename}", "wb"); if (!$filenum) { xml_error("Sorry, uploading file ({$struct['name']}) failed."); } flock($filenum, LOCK_EX); fwrite($filenum, $writefilecontent); fclose($filenum); //DB updating, new function in 2.1.0 $blog = new boblog(); $blog->query("INSERT INTO `{$db_prefix}upload` (fid,filepath,originalname,uploadtime,uploaduser) VALUES (null, \"attachment/{$targetfolder_ym}{$upload_filename}\", \"{$struct['name']}\", {$nowtime['timestamp']}, {$userdetail['userid']})"); $currentid = db_insert_id(); if ($mbcon['wmenable'] == '1') { //Add watermark $imgext_watermark = array('jpg', 'gif', 'png'); if (in_array($ext, $imgext_watermark)) { create_watermark("attachment/{$targetfolder_ym}{$upload_filename}"); } } } $xml_content = make_xml_piece("struct", array('url' => "{$config['blogurl']}/attachment.php?fid={$currentid}")); $body_xml = xml_generate($xml_content); send_response($body_xml); }
//This will clear all visitors since yesterday, but will save visitors from today } $onlinetime = $nowtime['timestamp'] - $oldip[2]; if ($oldip[1] != $userdetail['ip'] && $onlinetime <= $config['onlinetime']) { $nowonline[] = $online_all[$i]; $onlineusers[] = array('userid' => $oldip[3], 'username' => $oldip[4], 'activetime' => $oldip[2], 'ip' => $oldip[1]); } elseif ($oldip[1] == $userdetail['ip']) { $nowonline[] = "<?PHP exit;?>|{$userdetail['ip']}|{$nowtime['timestamp']}|{$userdetail['userid']}|{$userdetail['username']}|\n"; $onlineusers[] = array('userid' => $oldip[3], 'username' => $oldip[4], 'activetime' => $nowtime['timestamp'], 'ip' => $oldip[1]); $tmp_checked_current = 1; } } if ($tmp_checked_current != 1) { $nowonline[] = "<?PHP exit;?>|{$userdetail['ip']}|{$nowtime['timestamp']}|{$userdetail['userid']}|{$userdetail['username']}|\n"; $onlineusers[] = array('userid' => $userdetail['userid'], 'username' => $userdetail['username'], 'activetime' => $nowtime['timestamp'], 'ip' => $userdetail['ip']); $blog->query("UPDATE `{$db_prefix}counter` SET `today`={$statistics['today']}+1"); $statistics['today'] += 1; } writetofile($afilename, @implode("", $nowonline)); $statistics['nowusers'] = count($nowonline); $statistics['total'] += $statistics['today']; } //Get Categories if (file_exists('data/cache_categories.php')) { $categories = $categorynames = array(); $cates_lines = @file('data/cache_categories.php'); for ($i = 0; $i < count($cates_lines); $i++) { @(list($unuse, $tmp_result['cateid'], $tmp_result['catename'], $tmp_result['catedesc'], $tmp_result['cateproperty'], $tmp_result['cateorder'], $tmp_result['catemode'], $tmp_result['cateurl'], $tmp_result['cateicon'], $tmp_result['catecount'], $tmp_result['parentcate'], $tmp_result['cateurlname']) = @explode('<|>', $cates_lines[$i])); if ($permission['SeeSecretCategory'] == 1 || $tmp_result['cateproperty'] != '1') { $result[$i] = $tmp_result; }