コード例 #1
0
ファイル: photo.php プロジェクト: relisher/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['photo']) and $_FILES['photo']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['photo'], array("jpg", "jpeg", "png", "gif", "tiff", "bmp"));
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url'], array("jpg", "jpeg", "png", "gif", "tiff", "bmp"));
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $filename = $_POST['filename'];
     }
     $post->update(array("filename" => $filename, "caption" => $_POST['caption']));
 }
コード例 #2
0
ファイル: audio.php プロジェクト: betsyzhang/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['audio']) and $_FILES['audio']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['audio'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $filename = $_POST['filename'];
     }
     $post->update(array("title" => $_POST['title'], "filename" => $filename, "description" => $_POST['description']));
 }
コード例 #3
0
ファイル: file.php プロジェクト: betsyzhang/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['file']) and $_FILES['file']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['file']);
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url']);
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $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'];
     }
     $post->update(array("filename" => $filename, "caption" => $_POST['caption'], "title" => $_POST['title']));
 }
コード例 #4
0
ファイル: Admin.php プロジェクト: eadz/chyrp
 /**
  * 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");
 }
コード例 #5
0
ファイル: aggregator.php プロジェクト: homebru/bandb
 static function upload_image_from_content($html)
 {
     return upload_from_url(self::image_from_content($html));
 }