本文整理汇总了PHP中Post::check_url方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::check_url方法的具体用法?PHP Post::check_url怎么用?PHP Post::check_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::check_url方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
public function submit()
{
if (empty($_POST['video'])) {
error(__("Error"), __("Video can't be blank."));
}
return Post::add(array("embed" => $this->embed_tag($_POST['video']), "video" => $_POST['video'], "caption" => $_POST['caption']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例2: submit
public function submit()
{
if (empty($_POST['quote'])) {
error(__("Error"), __("Quote can't be empty.", "quote"));
}
return Post::add(array("quote" => $_POST['quote'], "source" => $_POST['source']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例3: submit
public function submit()
{
if (empty($_POST['body'])) {
error(__("Error"), __("Body can't be blank."));
}
fallback($_POST['slug'], sanitize($_POST['title']));
return Post::add(array("title" => $_POST['title'], "body" => $_POST['body']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例4: submit
public function submit()
{
if (empty($_POST['source'])) {
error(__("Error"), __("URL can't be empty."));
}
if (!@parse_url($_POST['source'], PHP_URL_SCHEME)) {
$_POST['source'] = "http://" . $_POST['source'];
}
fallback($_POST['slug'], sanitize($_POST['name']));
return Post::add(array("name" => $_POST['name'], "source" => $_POST['source'], "description" => $_POST['description']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例5: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['photo']) and $_FILES['photo']['error'] == 0) {
$filename = upload($_FILES['photo'], array("jpg", "jpeg", "png", "gif", "bmp"));
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url'], array("jpg", "jpeg", "png", "gif", "bmp"));
} else {
error(__("Error"), __("Couldn't upload photo."));
}
} else {
$filename = $_POST['filename'];
}
return Post::add(array("filename" => $filename, "caption" => $_POST['caption']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例6: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['audio']) and $_FILES['audio']['error'] == 0) {
$filename = upload($_FILES['audio'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
} else {
error(__("Error"), __("Couldn't upload audio file.", "audio"));
}
} else {
$filename = $_POST['filename'];
}
return Post::add(array("title" => $_POST['title'], "filename" => $filename, "description" => $_POST['description']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例7: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['filename']) and $_FILES['filename']['error'] == 0) {
$filename = upload($_FILES['filename']);
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url']);
} else {
error(__("Error"), __("Couldn't upload file."));
}
} else {
$filename = $_POST['filename'];
}
# Prepend scheme if a URL is detected
if (preg_match('~^((([a-z]|[0-9]|\\-)+)\\.)+([a-z]){2,6}/~', @$_POST['option']['source'])) {
$_POST['option']['source'] = "http://" . $_POST['option']['source'];
}
return Post::add(array("filename" => $filename, "caption" => $_POST['caption'], "title" => $_POST['title']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例8: import_movabletype
/**
* Function: import_movabletype
* MovableType importing.
*/
public function import_movabletype()
{
if (empty($_POST)) {
redirect("/admin/?action=import");
}
if (!Visitor::current()->group->can("add_post")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
}
$config = Config::current();
$trigger = Trigger::current();
$dbcon = $dbsel = false;
if ($link = @mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) {
$dbcon = true;
$dbsel = @mysql_select_db($_POST['database'], $link);
}
if (!$dbcon or !$dbsel) {
Flash::warning(__("Could not connect to the specified MovableType database."), "/admin/?action=import");
}
mysql_query("SET NAMES 'utf8'");
$get_authors = mysql_query("SELECT * FROM mt_author ORDER BY author_id ASC", $link) or error(__("Database Error"), mysql_error());
$users = array();
while ($author = mysql_fetch_array($get_authors)) {
# Try to figure out if this author is the same as the person doing the import.
if ($author["author_name"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->full_name or $author["author_url"] == Visitor::current()->website or $author["author_email"] == Visitor::current()->email) {
$users[$author["author_id"]] = Visitor::current();
} else {
$users[$author["author_id"]] = User::add($author["author_name"], $author["author_password"], $author["author_email"], $author["author_nickname"] != $author["author_name"] ? $author["author_nickname"] : "", $author["author_url"], $author["author_can_create_blog"] == "1" ? Visitor::current()->group : null, $author["author_created_on"], false);
}
}
$get_posts = mysql_query("SELECT * FROM mt_entry ORDER BY entry_id ASC", $link) or error(__("Database Error"), mysql_error());
$posts = array();
while ($post = mysql_fetch_array($get_posts)) {
$posts[$post["entry_id"]] = $post;
}
foreach ($posts as $post) {
$body = $post["entry_text"];
if (!empty($post["entry_text_more"])) {
$body .= "\n\n<!--more-->\n\n" . $post["entry_text_more"];
}
$regexp_url = preg_quote($_POST['media_url'], "/");
if (!empty($_POST['media_url']) and preg_match_all("/{$regexp_url}([^\\.\\!,\\?;\"\\'<>\\(\\)\\[\\]\\{\\}\\s\t ]+)\\.([a-zA-Z0-9]+)/", $body, $media)) {
foreach ($media[0] as $matched_url) {
$filename = upload_from_url($matched_url);
$body = str_replace($matched_url, $config->url . $config->uploads_path . $filename, $body);
}
}
$status_translate = array(1 => "draft", 2 => "public", 3 => "draft", 4 => "draft");
$clean = oneof($post["entry_basename"], sanitize($post["entry_title"]));
if (empty($post["entry_class"]) or $post["entry_class"] == "entry") {
$new_post = Post::add(array("title" => $post["entry_title"], "body" => $body, "imported_from" => "movabletype"), $clean, Post::check_url($clean), "text", @$users[$post["entry_author_id"]], false, $status_translate[$post["entry_status"]], oneof(@$post["entry_authored_on"], @$post["entry_created_on"], datetime()), $post["entry_modified_on"], "", false);
$trigger->call("import_movabletype_post", $post, $new_post, $link);
} elseif (@$post["entry_class"] == "page") {
$new_page = Page::add($post["entry_title"], $body, null, 0, true, 0, $clean, Page::check_url($clean));
$trigger->call("import_movabletype_page", $post, $new_page, $link);
}
}
mysql_close($link);
Flash::notice(__("MovableType content successfully imported!"), "/admin/?action=import");
}
示例9: metaWeblog_newPost
public function metaWeblog_newPost($args)
{
$this->auth($args[1], $args[2], 'add');
global $user;
# Support for extended body
$body = $args[3]['description'];
if (!empty($args[3]['mt_text_more'])) {
$body .= '<!--more-->' . $args[3]['mt_text_more'];
}
# Add excerpt to body so it isn't lost
if (!empty($args[3]['mt_excerpt'])) {
$body = $args[3]['mt_excerpt'] . "\n\n" . $body;
}
if (trim($body) === '') {
return new IXR_Error(500, __("Body can't be blank."));
}
$clean = sanitize(oneof(@$args[3]['mt_basename'], $args[3]['title']));
$url = Post::check_url($clean);
$_POST['user_id'] = $user->id;
$_POST['feather'] = XML_RPC_FEATHER;
$_POST['created_at'] = oneof($this->convertFromDateCreated($args[3]), datetime());
if ($user->group->can('add_post')) {
$_POST['status'] = $args[4] ? 'public' : 'draft';
} else {
$_POST['status'] = 'draft';
}
$trigger = Trigger::current();
$trigger->call('metaWeblog_newPost_preQuery', $args[3]);
$post = Post::add(array('title' => $args[3]['title'], 'body' => $body), $clean, $url);
if ($post->no_results) {
return new IXR_Error(500, __("Post not found."));
}
$trigger->call('metaWeblog_newPost', $args[3], $post);
# Send any and all pingbacks to URLs in the body
if (Config::current()->send_pingbacks) {
send_pingbacks($args[3]['description'], $post);
}
return $post->id;
}
示例10: getMail
/**
* Gets the mail from the inbox
* Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
*/
function getMail()
{
$config = Config::current();
if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
$hostname = '{' . $config->emailblog_server . '}INBOX';
# this isn't working well on localhost
$username = $config->emailblog_address;
$password = $config->emailblog_pass;
$subjpass = $config->emailblog_subjpass;
$inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
$emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
if ($emails) {
rsort($emails);
foreach ($emails as $email_number) {
$message = imap_body($inbox, $email_number);
$overview = imap_headerinfo($inbox, $email_number);
imap_delete($inbox, $email_number);
$title = htmlspecialchars($overview->Subject);
$title = preg_replace($subjpass, "", $title);
$clean = strtolower($title);
$body = htmlspecialchars($message);
# The subject of the email is used as the post title
# the content of the email is used as the body
# not sure about compatibility with images or audio feathers
Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
}
}
# close the connection
imap_close($inbox, CL_EXPUNGE);
$config->set("emailblog_mail_checked", time());
}
}
示例11: admin_manage_dropbox
static function admin_manage_dropbox($admin)
{
if (!Visitor::current()->group->can("add_post", "add_draft")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to create posts."));
}
if (empty($_POST)) {
return $admin->display("manage_dropbox");
}
$config = Config::current();
if (!isset($config->module_dropbox["oauth_token"])) {
Flash::notice(__("You need to authorize Dropbox first.", "dropbox"), "/admin/?action=dropbox_settings");
}
$data = json_decode(file_get_contents("http://chyrp.net/api/1/dropboxsync.php?keys"), true);
$app_key = $data["key"];
$app_secret = $data["secret"];
$storage = new \Dropbox\OAuth\Storage\Session();
$OAuth = new \Dropbox\OAuth\Consumer\Curl($app_key, $app_secret, $storage);
$dropbox = new \Dropbox\API($OAuth);
$delta = $dropbox->delta();
$delta = $delta["body"];
if ($delta->cursor != $config->module_dropbox["cursor"]) {
if (count($delta->entries) > 0) {
foreach ($delta->entries as $entry) {
$tmpfname = tempnam("/tmp", "md");
$file = $dropbox->getFile(ltrim($entry[0], "/"), $tmpfname);
$post = new FrontMatter($file["name"]);
$date = explode(".", ltrim($entry[0], "/"));
$values = array("title" => $post->fetch("title"), "body" => $post->fetch("content"));
# Set defaults
fallback($clean, oneof($post->fetch("slug"), strtolower(str_replace(" ", "-", $post->fetch("title")))));
fallback($url, Post::check_url($clean));
fallback($pinned, oneof($post->fetch("pinned"), 0));
fallback($status, oneof($post->fetch("status"), "public"));
fallback($date, oneof(datetime($post->fetch("date")), datetime($date[0])));
$post = Post::add($values, $clean, $url, "text", 1, $pinned, $status, datetime($post->fetch("date")), datetime($post->fetch("date")), false);
}
}
$set = array($config->set("module_dropbox", array("oauth_token_secret" => $config->module_dropbox['oauth_token_secret'], "oauth_token" => $config->module_dropbox['oauth_token'], "uid" => $config->module_dropbox['uid'], "cursor" => $delta->cursor)));
if (!in_array(false, $set)) {
Flash::notice(__("Post imported successfully.", "dropbox"), "/admin/?action=manage_posts");
}
}
}