Example #1
0
 public function create($title, $body)
 {
     //モデルを呼び込む
     $blog = new Blog();
     $this->createOption = $blog->create($title, $body);
     header('Location: /seed_blog/blogs/index');
 }
Example #2
0
 public function create($post)
 {
     $blog = new Blog();
     $blog->create($post);
     // indexへ遷移
     header('Location: /seed_blog/blogs/index/');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('blogs')->delete();
     Blog::create(array('id' => 1, 'title' => 'How to earn the first million', 'description' => 'Get up in the morning and go to work!', 'user_id' => 1, 'tags' => '#first million'));
     Blog::create(array('id' => 2, 'title' => 'Work on the Internet', 'description' => 'Choice is good, but you need to know a lot!', 'user_id' => 2, 'tags' => '#Work, Internet'));
     Blog::create(array('id' => 3, 'title' => 'What do you do with a daily income of 500$', 'description' => 'It remains to multiply profits and develop the company', 'user_id' => 2, 'tags' => '#company'));
     $this->command->info('Blog table seeded!');
 }
 public function _new($blog)
 {
     if (!empty($blog)) {
         $Blog = new Blog($this->table_name, $this->action);
         $sql = $Blog->create($blog);
         mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
         header("Location: index");
     }
 }
Example #5
0
 /**
  * Store a newly created resource in storage.
  *
  * POST /
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $r)
 {
     $this->validate($r, ['title' => 'required', 'link' => 'required', 'content' => '']);
     $res = Blog::create(['title' => $r->get('title'), 'link' => $r->get('link'), 'content' => $r->get('content')]);
     if ($res) {
         $r->session()->flash('global', 'Запись сохранена');
         return $this->index();
     }
     return view('pages.blog.create')->withInput();
 }
 public function _new($blog)
 {
     // 予約語
     // プログラミング言語には、言語ごとにあらかじめ使われている変数や関数の名前があり、
     // 同じ名前を開発者が使用することができません。
     // こういった名前のことを予約語と言う。
     if (!empty($blog)) {
         $Blog = new Blog($this->plural_resource);
         $sql = $Blog->create($blog);
         mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
         header("Location: index");
     }
 }
 public function insertArticle()
 {
     $postData = Input::all();
     $rules = array('title' => 'required', 'content' => 'required');
     $messages = array('title.required' => 'Lütfen makale başlığını girin', 'content.required' => 'Lütfen makale detaylarını girin');
     $validator = Validator::make($postData, $rules, $messages);
     if ($validator->fails()) {
         return Redirect::route('addArticle')->withInput()->withErrors($validator->messages());
     }
     $insert = Blog::create(array('user_id' => Auth::user()->id, 'title' => e($postData['title']), 'content' => e($postData['content'])));
     if (!$insert) {
         return Redirect::route('addArticle')->withInput()->withErrors(array('Makaleniz eklenirken teknik bir sorun oluştu...'));
     }
     return Redirect::route('articles');
 }
Example #8
0
 public function createAction()
 {
     if (!empty($_POST['submit'])) {
         $Blog = new Blog($this->_db, new User($this->_db, $_SESSION['user']['id']));
         $bind = array();
         foreach ($Blog->columns() as $key => $val) {
             if (isset($_POST[$val])) {
                 $bind[$val] = $_POST[$val];
             }
         }
         $bind['unixtime'] = time();
         if ($Blog->create($bind)) {
             $this->forward('index', array('class' => 'success', 'message' => 'Post created!'));
         } else {
             $this->_template->hud = array('class' => 'error', 'message' => 'There was an error creaging the post!');
         }
     }
 }
 public function _new()
 {
     // まずユーザーから送られてきた情報をチェック
     if (isset($_POST['title'])) {
         if ($_POST['title'] == '') {
             $error['title'] = 'empty';
             // たぶん本当はやっちゃいけないヤツ
             $_POST['title'] = 'empty';
         }
         if ($_POST['body'] == '') {
             $error['body'] = 'empty';
             $_POST['body'] = 'empty';
         }
         if (empty($error)) {
             // 問題なければmodelを呼び出してSQL文を発行して実行する
             $Blog = new Blog($this->plural_resorce, $this->option, $this->db);
             $sql = $Blog->create();
             mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
             header('Location:index');
             exit;
         }
     }
 }
Example #10
0
<?php

require_once 'common.php';
$viewAutoLoader = (include '../../library/Nbml/sandbox_runtime.php');
echo Blog::create();
Example #11
0
<?php

require 'common.php';
$viewAutoLoader = (include '../../library/Nbml/sandbox_runtime.php');
echo Blog::create()->formState(true);
Example #12
0
<?php

$CI->load->model('Blog');
$blog = new Blog();
$blog_id = $blog->create(array("category_id" => 1, "title" => "testing"));
// $blog = new Blog($blog_id);
print_r($blog);
Example #13
0
    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            // Save IP Range and user counter
            antispam_increase_counter('user');
        }
        $DB->commit();
        return $result;
    }
Example #14
0
     $current_User->check_perm('blogs', 'create', true);
     $edited_Blog = new Blog(NULL);
     $edited_Blog->set('owner_user_ID', $current_User->ID);
     param('kind', 'string', true);
     $edited_Blog->init_by_kind($kind);
     if (!$current_User->check_perm('blog_admin', 'edit', false, $edited_Blog->ID)) {
         // validate the urlname, which was already set by init_by_kind() function
         // It needs to validated, because the user can not set the blog urlname, and every new blog would have the same urlname without validation.
         // When user has edit permission to blog admin part, the urlname will be validated in load_from_request() function.
         $edited_Blog->set('urlname', urltitle_validate($edited_Blog->get('urlname'), '', 0, false, 'blog_urlname', 'blog_ID', 'T_blogs'));
     }
     param('skin_ID', 'integer', true);
     $edited_Blog->set_setting('normal_skin_ID', $skin_ID);
     if ($edited_Blog->load_from_Request(array())) {
         // create the new blog
         $edited_Blog->create($kind);
         // We want to highlight the edited object on next list display:
         // $Session->set( 'fadeout_array', array( 'blog_ID' => array($edited_Blog->ID) ) );
         header_redirect($dispatcher . '?ctrl=coll_settings&tab=features&blog=' . $edited_Blog->ID);
         // will save $Messages into Session
     }
     break;
 case 'delete':
     // ----------  Delete a blog from DB ----------
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('collection');
     // Check permissions:
     $current_User->check_perm('blog_properties', 'edit', true, $blog);
     if (param('confirm', 'integer', 0)) {
         // confirmed
         // Delete from DB:
Example #15
0
    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            /* Save IP Range -- start */
            $ip = int2ip(ip2int($_SERVER['REMOTE_ADDR']));
            // Convert IPv6 to IPv4
            if (preg_match('#^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$#i', $ip)) {
                // Check IP for correct format
                $ip_24bit_start = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.0', $ip));
                $ip_24bit_end = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.255', $ip));
                if ($iprange = get_ip_range($ip_24bit_start, $ip_24bit_end)) {
                    // Update ip range
                    $DB->query('UPDATE T_antispam__iprange
									SET aipr_user_count = ' . $DB->quote($iprange->aipr_user_count + 1) . '
									WHERE aipr_ID = ' . $DB->quote($iprange->aipr_ID));
                } else {
                    // Insert new ip range
                    $DB->query('INSERT INTO T_antispam__iprange ( aipr_IPv4start, aipr_IPv4end, aipr_user_count )
									VALUES ( ' . $DB->quote($ip_24bit_start) . ', ' . $DB->quote($ip_24bit_end) . ', ' . $DB->quote('1') . ' ) ');
                }
            }
            /* Save IP Range -- end */
        }
        $DB->commit();
        return $result;
    }