<?php error_reporting(-1); ini_set('display_errors', 1); require "Bump.php"; echo "<pre>"; $rules = array('missing' => 'required', 'email' => 'valid_email', 'max_len' => 'max_len,1', 'min_len' => 'min_len,4', 'exact_len' => 'exact_len,10', 'alpha' => 'alpha', 'alpha_numeric' => 'alpha_numeric', 'alpha_dash' => 'alpha_dash', 'alpha_space' => 'alpha_space', 'numeric' => 'numeric', 'integer' => 'integer', 'boolean' => 'boolean', 'float' => 'float', 'valid_url' => 'valid_url', 'url_exists' => 'url_exists', 'valid_ip' => 'valid_ip', 'valid_ipv4' => 'valid_ipv4', 'valid_ipv6' => 'valid_ipv6', 'valid_name' => 'valid_name', 'contains' => 'contains,free pro basic'); $invalid_data = array('missing' => '', 'email' => "not a valid email\r\n", 'max_len' => "1234567890", 'min_len' => "1", 'exact_len' => "123456", 'alpha' => "*(^*^*&", 'alpha_numeric' => "abcdefg12345+\r\n\r\n\r\n", 'alpha_dash' => "ab<script>alert(1);</script>cdefg12345-_+", 'alpha_space' => 'abcdefg12345_$^%%&TGY', 'numeric' => "one, two\r\n", 'integer' => "1,003\r\n\r\n\r\n\r\n", 'boolean' => "this is not a boolean\r\n\r\n\r\n\r\n", 'float' => "not a float\r\n", 'valid_url' => "\r\n\r\nhttp://add", 'url_exists' => "http://asdasdasd354.gov", 'valid_ip' => "google.com", 'valid_ipv4' => "google.com", 'valid_ipv6' => "google.com", 'valid_name' => '*&((*S))(*09890uiadaiusyd)', 'contains' => 'premium'); $valid_data = array('missing' => 'This is not missing', 'email' => '*****@*****.**', 'max_len' => '1', 'min_len' => '1234', 'exact_len' => '1234567890', 'alpha' => 'ÈÉÊËÌÍÎÏÒÓÔasdasdasd', 'alpha_numeric' => 'abcdefg12345', 'alpha_dash' => 'abcdefg12345-_', 'alpha_space' => 'abcdefg12345 ', 'numeric' => 2.0, 'integer' => 3, 'boolean' => FALSE, 'float' => 10.1, 'valid_url' => 'https://wixelhq.com', 'url_exists' => 'https://wixelhq.com', 'valid_ip' => '69.163.138.23', 'valid_ipv4' => "255.255.255.255", 'valid_ipv6' => "2001:0db8:85a3:08d3:1319:8a2e:0370:7334", 'valid_name' => 'Sean Nieuwoudt', 'contains' => 'free'); $validator = new Bump($invalid_data, $rules); $validator->isValid(); print_r($validator->getErrors()); $validator = new Bump($valid_data, $rules); $validator->isValid(); print_r($validator->getErrors());
public static function shutdown($user_fp, $post_id) { $post = Post::findOrFail($post_id); if ($post->parent_id != 0) { $parent_post = Post::find($post->parent_id); } if ($post->user_fp == $user_fp || isset($parent_post) && $parent_post->user_fp == $user_fp) { if ($post->parent_id == 0) { //delete thread comments $comments = DB::table('posts')->where('parent_id', $post->id)->lists('id'); Bump::whereIn('post_id', $comments)->delete(); Post::where('parent_id', $post->id)->delete(); } Bump::where('post_id', $post->id)->delete(); $post->delete(); } else { App::abort(500, 'Illegal attempt'); } if (isset($parent_post)) { $parent_post->timestamps = false; $parent_post->replies -= 1; $parent_post->save(); return $parent_post->id; } else { return false; } }