public function postIndex() { $validator = Validator::make(Input::all(), Javascript::$rules); if ($validator->passes()) { $blackwords_array = array(); foreach (Blackword::all() as $black) { $blackwords_array[] = $black->value; } $blackwords = implode(",", $blackwords_array); $blackwords = '"' . $blackwords . '"'; $porn_websites = json_encode(Blacklist::select('value')->get()); $safewebsites = json_encode(Safewebsite::select('url', 'topcode', 'leftcode', 'sidecode')->get()); $safe_accounts = Adsense::where('active', '=', true)->where('safe', '=', true)->get()->toJson(); $usafe_accounts = Adsense::where('active', '=', true)->where('safe', '=', false)->get()->toJson(); $jquery = file_get_contents('files/jquery.js', 'r'); $content = Input::get('javascript'); $content = str_replace("!porn_websites", $porn_websites, $content); $content = str_replace("!blackwords", $blackwords, $content); $content = str_replace("!safewebsites", $safewebsites, $content); $content = str_replace("!safe_accounts", $safe_accounts, $content); $content = str_replace("!unsafe_accounts", $usafe_accounts, $content); $minifiedCode = \JShrink\Minifier::minify($content); $result = $jquery . $minifiedCode; file_put_contents("files/app.js", $result); $Javascript = Javascript::find(1); $Javascript->code_version = date("Y-m-d H:i:s"); $Javascript->save(); return Redirect::action('JavascriptController@getIndex')->with('message', 'Javascript file updated!'); } if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } }
public function getAviv() { $i = 0; foreach (Blackword::all() as $b) { $temp = str_replace(array("\r", "\n"), "", $b->value); $b->value = $temp; $b->save(); $i++; } return $i; }