public function testBannedWordsFromListFile() { // Setting a file to load black lists from $this->blackList->setListFile(__DIR__ . '/Resource/banned.txt'); $data = array('text' => 'this is a string with banned words loaded from the list file. [localhost]'); $this->assertTrue($this->blackList->detect($data)); }
/** * getInstanceメソッド * * このクラスのオブジェクトを生成する。 * 既に生成されていたら、前回と同じものを返す。 * * @return object $instance */ public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $input = Input::all(); $sessionId = Common::checkSessionLogin($input); $data_sent = ApiMessage::where('sent_id', $input['user_id'])->groupBy('receiver_id')->lists('receiver_id'); $data_recived = ApiMessage::where('receiver_id', $input['user_id'])->groupBy('sent_id')->lists('sent_id'); $total = array_diff($data_recived, $data_sent); $result = array_merge($total, $data_sent); if ($result) { foreach ($result as $key => $value) { $msg = Common::queryCommonMessage($input, $value); $msg = $msg->orderBy('created_at', 'desc')->first(); $block = BlackList::where('user_id', $input['user_id'])->where('black_id', $value)->first(); if ($msg) { if ($block) { $blockUser = true; } else { $blockUser = false; } $data[] = array('id' => $msg->id, 'chat_avatar' => url(USER_AVATAR . '/' . $value . '/' . User::find($value)->avatar), 'chat_id' => $value, 'chat_name' => User::find($value)->username, 'message' => $msg->message, 'status' => $msg->status, 'created_at' => date('Y-m-d', strtotime($msg->created_at)), 'block' => $blockUser); } else { $data = null; } } } else { $data = null; } return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId, $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($blackId) { $input = Input::all(); $sessionId = Common::checkSessionLogin($input); BlackList::where('user_id', $input['user_id'])->where('black_id', $blackId)->delete(); return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId); }
public function testBlackList() { $input = ["Ivo", "viu", "a", "Uva"]; $blacklist = ["viu"]; $expected = ["Ivo", "a", "Uva"]; $result = BlackList::get($input, ['words' => $blacklist]); $this->assertEquals($expected, $result); }
public function block($id) { $input = Input::all(); $sessionId = Common::checkSessionLogin($input); $checkInput = BlackList::where('user_id', $input['user_id'])->where('black_id', $id)->get(); if (!empty($checkInput)) { BlackList::create(['user_id' => $input['user_id'], 'black_id' => $id, 'kind' => 1]); } return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId); }
* * @copyright 2009 Fraise, Inc. * @author mitsuhiro nakamura */ mb_send_mail("*****@*****.**", "test", "test1", ""); // プロジェクトディレクトリの絶対パス define("D_BASE_DIR", dirname(dirname(__FILE__))); // Web側・管理側共通処理ファイルの読み込み require_once D_BASE_DIR . "/common/common.php"; // メンテナンスフラグのチェック if (Maintenance::checkMaintenance()) { exit; } // 標準入力からメール情報を取得し、解析する $ComMimeParserMailOBJ = ComMimeParserMail::getInstance(); $BlackListOBJ = BlackList::getInstance(); $AllowDomainOBJ = AllowDomain::getInstance(); // 登録オブジェクトの作成 $PreRegistOBJ = PreRegist::getInstance(); $UserOBJ = User::getInstance(); // メール文言取得 $AutoMailOBJ = AutoMail::getInstance(); $headers = $ComMimeParserMailOBJ->getHeaders(); // 携帯メールアドレスである if (ComValidation::isMobileAddress($headers["from"])) { $mbFlag = true; } // 送信元メアドの取得 $mailAddress = $headers["from"]; //black_userに該当する場合は登録拒否 $dangerFlag = FALSE;
public function report($id) { // Add to the flag list so an admin can approve or dissaprove it FlagList::markFlag($id); // If a video has been flagged more than 5 times, blacklist it $items = FlagList::where('url', $id)->get(); $i = 0; // Conunt the number of times the video is on the flag list foreach ($items as $item) { $i += 1; } // Check if it has been flagged more than 10 times if ($i > 10) { // Blacklist the video BlackList::enroll($id, 'Flagged too many times.'); Session::flash('info', 'The video has been blacklisted'); } header('Location: /'); exit; }
function postData($table, $post_parameters) { $blacklist = new BlackList(); /** * check the blacklist */ $values = ""; $columns = ""; $values_array = ""; $columns_array = ""; $first_iteration = true; $counter = 0; while (list($field, $value) = each($post_parameters)) { // Detect if it is a text or number $value = is_numeric($value) ? $value : "'" . $value . "'"; // join the string with (,) ie: value1,value2,value3 $values .= $first_iteration ? $value : "," . $value; $columns .= $first_iteration ? $field : "," . $field; $values_array[$counter] = $value; $columns_array[$counter] = $field; $first_iteration = false; $counter++; } if ($blacklist->existItem("G", $table, "*")) { die($this->JSONError(401)); } if (!empty($post_parameters)) { for ($i = 0; $i < count($columns_array); $i++) { if ($blacklist->existItem("G", $table, $columns_array[$i])) { die($this->JSONError(401)); } } } /** * Create the sql sentence with the post parameters */ if ($values != "") { $sql = "INSERT INTO {$table} ({$columns}) VALUES ({$values})"; } $function = "json"; if ($function == "json") { header('Content-Type: application/json'); $result = $this->setDataBySQL($sql); if (!$result) { die($this->JSONError(303)); } $indices = ""; $rawdata = ""; var_dump($columns_array); for ($i = 0; $i < count($columns_array); $i++) { $rawdata[0][$i] = $values_array[$i]; $rawdata[0][$columns_array[$i]] = $values_array[$i]; $indices[$i] = $columns_array[$i]; $i++; } $json["data"] = $rawdata; $json["dbInfo"] = $indices; echo json_encode($json); } else { if ($function == "xml") { } else { die($this->JSONError(301)); } } }
public static function checkBlackList($userId, $blackId) { if ($userId == $blackId) { return true; } $blacklist = BlackList::where('user_id', $userId)->where('black_id', $blackId)->first(); $blacklist2 = BlackList::where('user_id', $blackId)->where('black_id', $userId)->first(); if (isset($blacklist) || isset($blacklist2)) { return true; } return false; }
<?php /** * Automatic Api Rest * * @package Automatic Api Rest * @author Alejandro Esquiva Rodríguez [@alex_esquiva] <*****@*****.**> * @license Apache License, Version 2.0 * @link https://github.com/GeekyTheory/Automatic-API-REST */ require_once 'inc/functions.php'; $blacklist = new BlackList(); $objectTools = new Tools(); if (isset($_POST["t"])) { $table = $_POST["t"]; } if (isset($_POST["c"])) { $fields = $_POST["c"]; } if (isset($_POST["v"])) { $values = $_POST["v"]; } if (!isset($_POST["c"])) { die($objectTools->JSONError(301)); } if (!isset($_POST["v"])) { die($objectTools->JSONError(301)); } if (!isset($_POST["t"])) { die($objectTools->JSONError(301)); }
<?php /** * Automatic Api Rest * * @package Automatic Api Rest * @author Alejandro Esquiva Rodríguez [@alex_esquiva] <*****@*****.**> * @license Apache License, Version 2.0 * @link https://github.com/GeekyTheory/Automatic-API-REST */ require_once 'inc/functions.php'; require_once "inc/autentification.php"; require_once 'mod/header.php'; $blacklist = new BlackList(); $rawdata = $blacklist->getAllInfo(); if (empty($rawdata)) { $tool = new Tools(); $tool->displayError("Not Found", "Empty BlackList"); } else { $blacklist->displayTable($rawdata); } require_once 'mod/footer.php';
<?php /** * Automatic Api Rest * * @package Automatic Api Rest * @author Alejandro Esquiva Rodríguez [@alex_esquiva] <*****@*****.**> * @license Apache License, Version 2.0 * @link https://github.com/GeekyTheory/Automatic-API-REST */ include_once 'inc/functions.php'; require_once "inc/autentification.php"; $blacklist = new BlackList(); if (isset($_GET["a"])) { if ($_GET["a"] == "add") { $tool = new Tools(); $fields = $tool->getFieldsByTable($_GET["table"]); $num_fields = count($fields); if ($_GET["column"] == "*") { //Get all columns from table for ($i = 0; $i < count($fields); $i++) { if (!$blacklist->existItem($_GET["type"], $_GET["table"], $fields[$i])) { $blacklist->createItem($_GET["type"], $_GET["table"], $fields[$i]); } } $blacklist->createItem($_GET["type"], $_GET["table"], $_GET["column"]); } else { $blacklist->createItem($_GET["type"], $_GET["table"], $_GET["column"]); $num_fields_check = 0; for ($i = 0; $i < count($fields); $i++) { if ($blacklist->existItem($_GET["type"], $_GET["table"], $fields[$i])) {
public function __destruct() { parent::__destruct(); }