├── README.md ├── crawler ├── config.json └── main.go ├── demo ├── results.png └── search.png └── webserver ├── application ├── .htaccess ├── cache │ └── index.html ├── config │ ├── autoload.php │ ├── config.php │ ├── constants.php │ ├── database.php │ ├── doctypes.php │ ├── foreign_chars.php │ ├── hooks.php │ ├── index.html │ ├── memcached.php │ ├── migration.php │ ├── mimes.php │ ├── profiler.php │ ├── routes.php │ ├── smileys.php │ └── user_agents.php ├── controllers │ ├── Api.php │ ├── Search.php │ └── index.html ├── core │ └── index.html ├── helpers │ └── index.html ├── hooks │ └── index.html ├── index.html ├── language │ ├── english │ │ └── index.html │ └── index.html ├── libraries │ └── index.html ├── logs │ └── index.html ├── models │ └── index.html ├── third_party │ └── index.html └── views │ ├── errors │ ├── cli │ │ ├── error_404.php │ │ ├── error_db.php │ │ ├── error_exception.php │ │ ├── error_general.php │ │ ├── error_php.php │ │ └── index.html │ ├── html │ │ ├── error_404.php │ │ ├── error_db.php │ │ ├── error_exception.php │ │ ├── error_general.php │ │ ├── error_php.php │ │ └── index.html │ └── index.html │ ├── index.html │ ├── search_home.php │ ├── search_results.php │ └── welcome_message.php ├── assets ├── shards-extras.min.css └── shards.min.css ├── composer.json ├── contributing.md ├── db.sql ├── index.php ├── license.txt ├── readme.rst ├── system ├── .htaccess ├── core │ ├── Benchmark.php │ ├── CodeIgniter.php │ ├── Common.php │ ├── Config.php │ ├── Controller.php │ ├── Exceptions.php │ ├── Hooks.php │ ├── Input.php │ ├── Lang.php │ ├── Loader.php │ ├── Log.php │ ├── Model.php │ ├── Output.php │ ├── Router.php │ ├── Security.php │ ├── URI.php │ ├── Utf8.php │ ├── compat │ │ ├── hash.php │ │ ├── index.html │ │ ├── mbstring.php │ │ ├── password.php │ │ └── standard.php │ └── index.html ├── database │ ├── DB.php │ ├── DB_cache.php │ ├── DB_driver.php │ ├── DB_forge.php │ ├── DB_query_builder.php │ ├── DB_result.php │ ├── DB_utility.php │ ├── drivers │ │ ├── cubrid │ │ │ ├── cubrid_driver.php │ │ │ ├── cubrid_forge.php │ │ │ ├── cubrid_result.php │ │ │ ├── cubrid_utility.php │ │ │ └── index.html │ │ ├── ibase │ │ │ ├── ibase_driver.php │ │ │ ├── ibase_forge.php │ │ │ ├── ibase_result.php │ │ │ ├── ibase_utility.php │ │ │ └── index.html │ │ ├── index.html │ │ ├── mssql │ │ │ ├── index.html │ │ │ ├── mssql_driver.php │ │ │ ├── mssql_forge.php │ │ │ ├── mssql_result.php │ │ │ └── mssql_utility.php │ │ ├── mysql │ │ │ ├── index.html │ │ │ ├── mysql_driver.php │ │ │ ├── mysql_forge.php │ │ │ ├── mysql_result.php │ │ │ └── mysql_utility.php │ │ ├── mysqli │ │ │ ├── index.html │ │ │ ├── mysqli_driver.php │ │ │ ├── mysqli_forge.php │ │ │ ├── mysqli_result.php │ │ │ └── mysqli_utility.php │ │ ├── oci8 │ │ │ ├── index.html │ │ │ ├── oci8_driver.php │ │ │ ├── oci8_forge.php │ │ │ ├── oci8_result.php │ │ │ └── oci8_utility.php │ │ ├── odbc │ │ │ ├── index.html │ │ │ ├── odbc_driver.php │ │ │ ├── odbc_forge.php │ │ │ ├── odbc_result.php │ │ │ └── odbc_utility.php │ │ ├── pdo │ │ │ ├── index.html │ │ │ ├── pdo_driver.php │ │ │ ├── pdo_forge.php │ │ │ ├── pdo_result.php │ │ │ ├── pdo_utility.php │ │ │ └── subdrivers │ │ │ │ ├── index.html │ │ │ │ ├── pdo_4d_driver.php │ │ │ │ ├── pdo_4d_forge.php │ │ │ │ ├── pdo_cubrid_driver.php │ │ │ │ ├── pdo_cubrid_forge.php │ │ │ │ ├── pdo_dblib_driver.php │ │ │ │ ├── pdo_dblib_forge.php │ │ │ │ ├── pdo_firebird_driver.php │ │ │ │ ├── pdo_firebird_forge.php │ │ │ │ ├── pdo_ibm_driver.php │ │ │ │ ├── pdo_ibm_forge.php │ │ │ │ ├── pdo_informix_driver.php │ │ │ │ ├── pdo_informix_forge.php │ │ │ │ ├── pdo_mysql_driver.php │ │ │ │ ├── pdo_mysql_forge.php │ │ │ │ ├── pdo_oci_driver.php │ │ │ │ ├── pdo_oci_forge.php │ │ │ │ ├── pdo_odbc_driver.php │ │ │ │ ├── pdo_odbc_forge.php │ │ │ │ ├── pdo_pgsql_driver.php │ │ │ │ ├── pdo_pgsql_forge.php │ │ │ │ ├── pdo_sqlite_driver.php │ │ │ │ ├── pdo_sqlite_forge.php │ │ │ │ ├── pdo_sqlsrv_driver.php │ │ │ │ └── pdo_sqlsrv_forge.php │ │ ├── postgre │ │ │ ├── index.html │ │ │ ├── postgre_driver.php │ │ │ ├── postgre_forge.php │ │ │ ├── postgre_result.php │ │ │ └── postgre_utility.php │ │ ├── sqlite │ │ │ ├── index.html │ │ │ ├── sqlite_driver.php │ │ │ ├── sqlite_forge.php │ │ │ ├── sqlite_result.php │ │ │ └── sqlite_utility.php │ │ ├── sqlite3 │ │ │ ├── index.html │ │ │ ├── sqlite3_driver.php │ │ │ ├── sqlite3_forge.php │ │ │ ├── sqlite3_result.php │ │ │ └── sqlite3_utility.php │ │ └── sqlsrv │ │ │ ├── index.html │ │ │ ├── sqlsrv_driver.php │ │ │ ├── sqlsrv_forge.php │ │ │ ├── sqlsrv_result.php │ │ │ └── sqlsrv_utility.php │ └── index.html ├── fonts │ ├── index.html │ └── texb.ttf ├── helpers │ ├── array_helper.php │ ├── captcha_helper.php │ ├── cookie_helper.php │ ├── date_helper.php │ ├── directory_helper.php │ ├── download_helper.php │ ├── email_helper.php │ ├── file_helper.php │ ├── form_helper.php │ ├── html_helper.php │ ├── index.html │ ├── inflector_helper.php │ ├── language_helper.php │ ├── number_helper.php │ ├── path_helper.php │ ├── security_helper.php │ ├── smiley_helper.php │ ├── string_helper.php │ ├── text_helper.php │ ├── typography_helper.php │ ├── url_helper.php │ └── xml_helper.php ├── index.html ├── language │ ├── english │ │ ├── calendar_lang.php │ │ ├── date_lang.php │ │ ├── db_lang.php │ │ ├── email_lang.php │ │ ├── form_validation_lang.php │ │ ├── ftp_lang.php │ │ ├── imglib_lang.php │ │ ├── index.html │ │ ├── migration_lang.php │ │ ├── number_lang.php │ │ ├── pagination_lang.php │ │ ├── profiler_lang.php │ │ ├── unit_test_lang.php │ │ └── upload_lang.php │ └── index.html └── libraries │ ├── Cache │ ├── Cache.php │ ├── drivers │ │ ├── Cache_apc.php │ │ ├── Cache_dummy.php │ │ ├── Cache_file.php │ │ ├── Cache_memcached.php │ │ ├── Cache_redis.php │ │ ├── Cache_wincache.php │ │ └── index.html │ └── index.html │ ├── Calendar.php │ ├── Cart.php │ ├── Driver.php │ ├── Email.php │ ├── Encrypt.php │ ├── Encryption.php │ ├── Form_validation.php │ ├── Ftp.php │ ├── Image_lib.php │ ├── Javascript.php │ ├── Javascript │ ├── Jquery.php │ └── index.html │ ├── Migration.php │ ├── Pagination.php │ ├── Parser.php │ ├── Profiler.php │ ├── Session │ ├── Session.php │ ├── SessionHandlerInterface.php │ ├── Session_driver.php │ ├── drivers │ │ ├── Session_database_driver.php │ │ ├── Session_files_driver.php │ │ ├── Session_memcached_driver.php │ │ ├── Session_redis_driver.php │ │ └── index.html │ └── index.html │ ├── Table.php │ ├── Trackback.php │ ├── Typography.php │ ├── Unit_test.php │ ├── Upload.php │ ├── User_agent.php │ ├── Xmlrpc.php │ ├── Xmlrpcs.php │ ├── Zip.php │ └── index.html └── tests ├── Bootstrap.php ├── README.md ├── mocks ├── autoloader.php ├── ci_testcase.php ├── ci_testconfig.php ├── core │ ├── common.php │ ├── input.php │ ├── security.php │ ├── uri.php │ └── utf8.php ├── database │ ├── ci_test.sqlite │ ├── config │ │ ├── mysql.php │ │ ├── mysqli.php │ │ ├── pdo │ │ │ ├── mysql.php │ │ │ ├── pgsql.php │ │ │ └── sqlite.php │ │ ├── pgsql.php │ │ └── sqlite.php │ ├── db.php │ ├── db │ │ └── driver.php │ ├── drivers │ │ ├── mysql.php │ │ ├── mysqli.php │ │ ├── pdo.php │ │ ├── postgre.php │ │ └── sqlite.php │ └── schema │ │ └── skeleton.php ├── libraries │ ├── driver.php │ ├── encrypt.php │ ├── encryption.php │ ├── session.php │ └── table.php └── uploads │ └── ci_logo.gif └── phpunit.xml /README.md: -------------------------------------------------------------------------------- 1 | 2 | # YourSearch 3 | 4 | 5 | An Open Source search engine + web crawler. Can be used to cache specific websites or the entire web. This is part of a project for caching specific sites of the web on to a raspberry Pi and make information freely available in remote areas where internet access is difficult to provide. 6 | 7 | 8 | This is a work in progress and at it's very initial stages, not fit for production use. For single websites however this search engine works very well. 9 | 10 | 11 | ![search](https://raw.githubusercontent.com/fifthsegment/yoursearch/master/demo/search.png) 12 | 13 | 14 | Results 15 | 16 | 17 | ![results](https://raw.githubusercontent.com/fifthsegment/yoursearch/master/demo/results.png) 18 | 19 | 20 | 21 | ## How it works? 22 | 23 | 24 | The search engine has 2 components ; a crawler and the server. The crawler crawls the web and sends crawled page contents back to the server. The server stores these contents in a database. Whenever a user wants to search anything, the server performs a database search operation over the stored contents. 25 | 26 | 27 | ## Issues/TODO 28 | 29 | * Indexing is slow. 30 | * Change database backend from MySQL to something fast; maybe Mongodb. 31 | * Secure communication between server and crawler 32 | 33 | 34 | ## Requirements 35 | 36 | Server : PHP7 + MySQL. 37 | 38 | 39 | Client : Runs everywhere 40 | 41 | 42 | ## Getting Started 43 | 44 | 45 | * Build the main.go file in the crawler folder: `go build main.go` 46 | 47 | * Setup a LEMP server 48 | 49 | * Setup the webserver online, by copying contents from the webserver folder. 50 | 51 | * Import db.sql into your MySQL database. 52 | 53 | * Go to application/config/database.php to change database credentials to your db server. 54 | 55 | * Test to see if its working by visitng your-server-ip/index.php/Api 56 | 57 | * Change links in the `config.json` file to point to your server, change the starting url too. 58 | 59 | * Run the crawler : `./main ./` . The first argument to the crawler is the path to the directory which contains the config.json file. (PS: You can run multiple crawlers at once) 60 | 61 | * Visit your-server-ip to view the search page and see progress of the number of pages indexed. 62 | -------------------------------------------------------------------------------- /crawler/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "rurlep" : "http://your-server.com/index.php/Api/recordUrl" , 3 | "durlep" : "http://your-server.com/index.php/Api/recordData" , 4 | "curlep" : "http://your-server.com/index.php/Api/checkUrl", 5 | "gurlep" : "http://your-server.com/index.php/Api/getUrl", 6 | "test" : "https://moz.com/top500", 7 | "start_point" : "https://abdullahirfan.com/" 8 | } -------------------------------------------------------------------------------- /demo/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fifthsegment/yoursearch/19e527d56f8451b4fa2cfc5c7279d4805193eb0e/demo/results.png -------------------------------------------------------------------------------- /demo/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fifthsegment/yoursearch/19e527d56f8451b4fa2cfc5c7279d4805193eb0e/demo/search.png -------------------------------------------------------------------------------- /webserver/application/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Deny from all 6 | -------------------------------------------------------------------------------- /webserver/application/cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/config/constants.php: -------------------------------------------------------------------------------- 1 | '', 6 | 'xhtml1-strict' => '', 7 | 'xhtml1-trans' => '', 8 | 'xhtml1-frame' => '', 9 | 'xhtml-basic11' => '', 10 | 'html5' => '', 11 | 'html4-strict' => '', 12 | 'html4-trans' => '', 13 | 'html4-frame' => '', 14 | 'mathml1' => '', 15 | 'mathml2' => '', 16 | 'svg10' => '', 17 | 'svg11' => '', 18 | 'svg11-basic' => '', 19 | 'svg11-tiny' => '', 20 | 'xhtml-math-svg-xh' => '', 21 | 'xhtml-math-svg-sh' => '', 22 | 'xhtml-rdfa-1' => '', 23 | 'xhtml-rdfa-2' => '' 24 | ); 25 | -------------------------------------------------------------------------------- /webserver/application/config/foreign_chars.php: -------------------------------------------------------------------------------- 1 | 'ae', 14 | '/ö|œ/' => 'oe', 15 | '/ü/' => 'ue', 16 | '/Ä/' => 'Ae', 17 | '/Ü/' => 'Ue', 18 | '/Ö/' => 'Oe', 19 | '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A', 20 | '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a', 21 | '/Б/' => 'B', 22 | '/б/' => 'b', 23 | '/Ç|Ć|Ĉ|Ċ|Č/' => 'C', 24 | '/ç|ć|ĉ|ċ|č/' => 'c', 25 | '/Д/' => 'D', 26 | '/д/' => 'd', 27 | '/Ð|Ď|Đ|Δ/' => 'Dj', 28 | '/ð|ď|đ|δ/' => 'dj', 29 | '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E', 30 | '/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e', 31 | '/Ф/' => 'F', 32 | '/ф/' => 'f', 33 | '/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G', 34 | '/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g', 35 | '/Ĥ|Ħ/' => 'H', 36 | '/ĥ|ħ/' => 'h', 37 | '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I', 38 | '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i', 39 | '/Ĵ/' => 'J', 40 | '/ĵ/' => 'j', 41 | '/Ķ|Κ|К/' => 'K', 42 | '/ķ|κ|к/' => 'k', 43 | '/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L', 44 | '/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l', 45 | '/М/' => 'M', 46 | '/м/' => 'm', 47 | '/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N', 48 | '/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n', 49 | '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O', 50 | '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o', 51 | '/П/' => 'P', 52 | '/п/' => 'p', 53 | '/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R', 54 | '/ŕ|ŗ|ř|ρ|р/' => 'r', 55 | '/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S', 56 | '/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's', 57 | '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T', 58 | '/ț|ţ|ť|ŧ|т/' => 't', 59 | '/Þ|þ/' => 'th', 60 | '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U', 61 | '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u', 62 | '/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', 63 | '/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y', 64 | '/В/' => 'V', 65 | '/в/' => 'v', 66 | '/Ŵ/' => 'W', 67 | '/ŵ/' => 'w', 68 | '/Ź|Ż|Ž|Ζ|З/' => 'Z', 69 | '/ź|ż|ž|ζ|з/' => 'z', 70 | '/Æ|Ǽ/' => 'AE', 71 | '/ß/' => 'ss', 72 | '/IJ/' => 'IJ', 73 | '/ij/' => 'ij', 74 | '/Œ/' => 'OE', 75 | '/ƒ/' => 'f', 76 | '/ξ/' => 'ks', 77 | '/π/' => 'p', 78 | '/β/' => 'v', 79 | '/μ/' => 'm', 80 | '/ψ/' => 'ps', 81 | '/Ё/' => 'Yo', 82 | '/ё/' => 'yo', 83 | '/Є/' => 'Ye', 84 | '/є/' => 'ye', 85 | '/Ї/' => 'Yi', 86 | '/Ж/' => 'Zh', 87 | '/ж/' => 'zh', 88 | '/Х/' => 'Kh', 89 | '/х/' => 'kh', 90 | '/Ц/' => 'Ts', 91 | '/ц/' => 'ts', 92 | '/Ч/' => 'Ch', 93 | '/ч/' => 'ch', 94 | '/Ш/' => 'Sh', 95 | '/ш/' => 'sh', 96 | '/Щ/' => 'Shch', 97 | '/щ/' => 'shch', 98 | '/Ъ|ъ|Ь|ь/' => '', 99 | '/Ю/' => 'Yu', 100 | '/ю/' => 'yu', 101 | '/Я/' => 'Ya', 102 | '/я/' => 'ya' 103 | ); 104 | -------------------------------------------------------------------------------- /webserver/application/config/hooks.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/config/memcached.php: -------------------------------------------------------------------------------- 1 | array( 15 | 'hostname' => '127.0.0.1', 16 | 'port' => '11211', 17 | 'weight' => '1', 18 | ), 19 | ); 20 | -------------------------------------------------------------------------------- /webserver/application/config/migration.php: -------------------------------------------------------------------------------- 1 | migration->current() this is the version that schema will 69 | | be upgraded / downgraded to. 70 | | 71 | */ 72 | $config['migration_version'] = 0; 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Migrations Path 77 | |-------------------------------------------------------------------------- 78 | | 79 | | Path to your migrations folder. 80 | | Typically, it will be within your application path. 81 | | Also, writing permission is required within the migrations path. 82 | | 83 | */ 84 | $config['migration_path'] = APPPATH.'migrations/'; 85 | -------------------------------------------------------------------------------- /webserver/application/config/profiler.php: -------------------------------------------------------------------------------- 1 | my_controller/index 50 | | my-controller/my-method -> my_controller/my_method 51 | */ 52 | $route['default_controller'] = 'search'; 53 | $route['404_override'] = ''; 54 | $route['translate_uri_dashes'] = FALSE; 55 | -------------------------------------------------------------------------------- /webserver/application/config/smileys.php: -------------------------------------------------------------------------------- 1 | array('grin.gif', '19', '19', 'grin'), 21 | ':lol:' => array('lol.gif', '19', '19', 'LOL'), 22 | ':cheese:' => array('cheese.gif', '19', '19', 'cheese'), 23 | ':)' => array('smile.gif', '19', '19', 'smile'), 24 | ';-)' => array('wink.gif', '19', '19', 'wink'), 25 | ';)' => array('wink.gif', '19', '19', 'wink'), 26 | ':smirk:' => array('smirk.gif', '19', '19', 'smirk'), 27 | ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'), 28 | ':-S' => array('confused.gif', '19', '19', 'confused'), 29 | ':wow:' => array('surprise.gif', '19', '19', 'surprised'), 30 | ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'), 31 | ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'), 32 | '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'), 33 | ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'), 34 | ':P' => array('raspberry.gif', '19', '19', 'raspberry'), 35 | ':blank:' => array('blank.gif', '19', '19', 'blank stare'), 36 | ':long:' => array('longface.gif', '19', '19', 'long face'), 37 | ':ohh:' => array('ohh.gif', '19', '19', 'ohh'), 38 | ':grrr:' => array('grrr.gif', '19', '19', 'grrr'), 39 | ':gulp:' => array('gulp.gif', '19', '19', 'gulp'), 40 | '8-/' => array('ohoh.gif', '19', '19', 'oh oh'), 41 | ':down:' => array('downer.gif', '19', '19', 'downer'), 42 | ':red:' => array('embarrassed.gif', '19', '19', 'red face'), 43 | ':sick:' => array('sick.gif', '19', '19', 'sick'), 44 | ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'), 45 | ':-/' => array('hmm.gif', '19', '19', 'hmmm'), 46 | '>:(' => array('mad.gif', '19', '19', 'mad'), 47 | ':mad:' => array('mad.gif', '19', '19', 'mad'), 48 | '>:-(' => array('angry.gif', '19', '19', 'angry'), 49 | ':angry:' => array('angry.gif', '19', '19', 'angry'), 50 | ':zip:' => array('zip.gif', '19', '19', 'zipper'), 51 | ':kiss:' => array('kiss.gif', '19', '19', 'kiss'), 52 | ':ahhh:' => array('shock.gif', '19', '19', 'shock'), 53 | ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'), 54 | ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'), 55 | ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'), 56 | ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'), 57 | ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'), 58 | ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'), 59 | ':vampire:' => array('vampire.gif', '19', '19', 'vampire'), 60 | ':snake:' => array('snake.gif', '19', '19', 'snake'), 61 | ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'), 62 | ':question:' => array('question.gif', '19', '19', 'question') 63 | 64 | ); 65 | -------------------------------------------------------------------------------- /webserver/application/controllers/Api.php: -------------------------------------------------------------------------------- 1 | load->database(); 16 | } 17 | 18 | /** 19 | * Provides a new url to the crawler to index 20 | */ 21 | public function getUrl(){ 22 | $r = $this->db->select()->from('urlindex')->where(['saved' => 0 ])->count_all_results(); 23 | if ($r == 0){ 24 | echo "zero"; 25 | exit; 26 | } 27 | $d = $this->db->select()->from('urlindex')->where(['saved' => 0 ])->limit(1)->get()->result_array(); 28 | 29 | echo $d[0]['url']; 30 | exit; 31 | } 32 | 33 | /** 34 | * Checks if the url already exists in the cache 35 | */ 36 | public function checkUrl(){ 37 | 38 | $url = file_get_contents("php://input"); 39 | $data =json_decode($url, true); 40 | if (isset($_GET['inCache'])){ 41 | $c = $this->db->select()->from('pagecache')->where(['url' => $data['Url'] ])->count_all_results(); 42 | if ($c > 0){ 43 | echo "Have"; 44 | exit; 45 | } 46 | 47 | } 48 | $d = $this->db->select()->from('urlindex')->where(['url' => $data['Url'] ])->count_all_results(); 49 | if ($d > 0 ){ 50 | echo "Have"; 51 | exit; 52 | } 53 | echo "No"; 54 | exit; 55 | } 56 | 57 | /** 58 | * Records the page contents in our database 59 | */ 60 | public function recordData(){ 61 | $url = file_get_contents("php://input"); 62 | $data =json_decode($url, true); 63 | 64 | //var_dump($data); 65 | $d = $this->db->select()->from('urlindex')->where(['url' => $data['Url'] ])->count_all_results(); 66 | if ($d == 0 ){ 67 | echo "Donthave"; 68 | exit; 69 | }else{ 70 | $userurl = $data['Url']; 71 | $possiblematches = []; 72 | $possiblematches[] = $data['Url']; 73 | $b = $this->db->select()->from('urlindex')->where(['url' => $data['Url'] ])->get()->result_array(); 74 | $b = $b[0]; 75 | 76 | $c = $this->db->select()->from('pagecache')->where(['url' => $data['Url'] ])->count_all_results(); 77 | if ($c > 0){ 78 | echo "Have"; 79 | exit; 80 | } 81 | 82 | $this->db->reset_query(); 83 | $this->db->flush_cache(); 84 | 85 | $this->db->where("id", $b['id']); 86 | $this->db->update("urlindex", ["saved"=>1]); 87 | $str = $this->db->last_query(); 88 | echo $data['Url'] ; 89 | 90 | } 91 | $this->db->reset_query(); 92 | $this->db->flush_cache(); 93 | 94 | $data2 = ['url' => $data['Url'], 'data'=>$data['Data'], 'ref' => $b['id']]; 95 | $this->db->insert('pagecache', $data2); 96 | $data3 = ['revision' => 1, 'ref' => $b['id'], 'content'=> $data['Content']]; 97 | $this->db->insert('pagecontents', $data3); 98 | 99 | 100 | $this->db->reset_query(); 101 | $this->db->flush_cache(); 102 | echo "Ok"; 103 | exit; 104 | } 105 | 106 | /* 107 | * Basic guessing if the url is an image from it's url string 108 | */ 109 | private function isImage( $url ) 110 | { 111 | $pos = strrpos( $url, "."); 112 | if ($pos === false) 113 | return false; 114 | $ext = strtolower(trim(substr( $url, $pos))); 115 | $imgExts = array(".gif", ".jpg", ".jpeg", ".png", ".tiff", ".tif"); // this is far from complete but that's always going to be the case... 116 | if ( in_array($ext, $imgExts) ) 117 | return true; 118 | return false; 119 | } 120 | 121 | /** 122 | * Add url to our index 123 | */ 124 | public function recordUrl(){ 125 | 126 | $url = file_get_contents("php://input"); 127 | $data =json_decode($url, true); 128 | $urlt = $data['Url']; 129 | if ($this->isImage($urlt)){ 130 | echo "Wontrecord"; 131 | exit; 132 | } 133 | if (filter_var($urlt, FILTER_VALIDATE_URL)) { 134 | 135 | } else { 136 | echo "URL invalid"; 137 | exit; 138 | } 139 | $d = $this->db->select()->from('urlindex')->where(['url' => $data['Url'] ])->count_all_results(); 140 | if ($d > 0 ){ 141 | echo "Have"; 142 | exit; 143 | } 144 | 145 | $data = ['url' => $data['Url'], 'saved'=> 0]; 146 | $this->db->insert('urlindex', $data); 147 | 148 | echo "Ok"; 149 | exit; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /webserver/application/controllers/Search.php: -------------------------------------------------------------------------------- 1 | load->database(); 9 | } 10 | public function index() 11 | { 12 | 13 | $res = $this->db->select()->from("pagecontents")->count_all_results(); 14 | $this->load->view('search_home', ['res'=>$res]); 15 | } 16 | 17 | private function find_in_array($arr, $key, $value){ 18 | for ($i=0; $i < sizeof($arr); $i++) { 19 | $ar = $arr[$i]; 20 | if ($ar[$key] == $value){ 21 | return $i; 22 | } 23 | } 24 | return NULL; 25 | } 26 | 27 | private function internal_find($keyword, $str){ 28 | $filtered = array_filter( 29 | str_word_count($str,2), 30 | function($word) use($keyword) { 31 | return $word == $keyword; 32 | } 33 | ); 34 | return $filtered; 35 | } 36 | 37 | public function trim( $s ){ 38 | $max_length = 340; 39 | 40 | if (strlen($s) > $max_length) 41 | { 42 | $offset = ($max_length - 3) - strlen($s); 43 | $s = substr($s, 0, strrpos($s, ' ', $offset)) . '...'; 44 | } 45 | return $s; 46 | } 47 | 48 | public function results() 49 | { 50 | $keywords = $this->input->get("search"); 51 | // $this->load->database(); 52 | $matching = $this->db->select()->from("pagecontents")->like("content", $keywords)->count_all_results(); 53 | $resultsq = $this->db->select()->from("pagecontents")->like("content", $keywords)->limit(10)->get(); 54 | $ids = []; 55 | $results = []; 56 | foreach ($resultsq->result_array() as $result) { 57 | 58 | $ids[] = $result['ref']; 59 | $results[] = $result; 60 | } 61 | $this->db->reset_query(); 62 | // $this->db->clear_cache(); 63 | $results_urls = $this->db->select()->from("urlindex")->where_in("id", $ids)->get(); 64 | // $i = 0; 65 | foreach ($results_urls->result_array() as $result_url) { 66 | # code... 67 | $i = $this->find_in_array($results, 'ref', $result_url['id']); 68 | $results[$i]['url'] = $result_url['url']; 69 | 70 | 71 | } 72 | for ($i=0; $i < sizeof($results); $i++) { 73 | # code... 74 | if (!isset($results[$i]['url'])){ 75 | $results[$i]['host'] = 'Not found'; 76 | $results[$i]['url'] = 'Not found'; 77 | }else{ 78 | $parsed = parse_url($results[$i]['url']); 79 | $results[$i]['host'] = $parsed['host']; 80 | } 81 | $content_original = (strtolower($results[$i]['content'])); 82 | $keywords = strtolower($keywords); 83 | $pos = strpos($content_original, $keywords); 84 | $content = substr($content_original, $pos); 85 | $results[$i]['occurences'] = substr_count( $content_original , $keywords ); 86 | $results[$i]['content']=$this->trim($content); 87 | // $results[$i] 88 | } 89 | // $matching = $this->db->select()->from("pagecontents")->count_all_results(); 90 | // echo "Total pages cached = $res"; 91 | // exit; 92 | $this->load->view('search_results', ['res'=>$matching, 'results'=>$results]); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /webserver/application/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/language/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/logs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/third_party/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/views/errors/cli/error_404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | An uncaught Exception was encountered 4 | 5 | Type: 6 | Message: 7 | Filename: getFile(), "\n"; ?> 8 | Line Number: getLine(); ?> 9 | 10 | 11 | 12 | Backtrace: 13 | getTrace() as $error): ?> 14 | 15 | File: 16 | Line: 17 | Function: 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /webserver/application/views/errors/cli/error_general.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | A PHP Error was encountered 4 | 5 | Severity: 6 | Message: 7 | Filename: 8 | Line Number: 9 | 10 | 11 | 12 | Backtrace: 13 | 14 | 15 | File: 16 | Line: 17 | Function: 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /webserver/application/views/errors/cli/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/views/errors/html/error_404.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 404 Page Not Found 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /webserver/application/views/errors/html/error_db.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Database Error 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /webserver/application/views/errors/html/error_exception.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | 7 |

An uncaught Exception was encountered

8 | 9 |

Type:

10 |

Message:

11 |

Filename: getFile(); ?>

12 |

Line Number: getLine(); ?>

13 | 14 | 15 | 16 |

Backtrace:

17 | getTrace() as $error): ?> 18 | 19 | 20 | 21 |

22 | File:
23 | Line:
24 | Function: 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 |
-------------------------------------------------------------------------------- /webserver/application/views/errors/html/error_general.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Error 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /webserver/application/views/errors/html/error_php.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | 7 |

A PHP Error was encountered

8 | 9 |

Severity:

10 |

Message:

11 |

Filename:

12 |

Line Number:

13 | 14 | 15 | 16 |

Backtrace:

17 | 18 | 19 | 20 | 21 |

22 | File:
23 | Line:
24 | Function: 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
-------------------------------------------------------------------------------- /webserver/application/views/errors/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/views/errors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/application/views/search_results.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | YourSearch - Results 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |

Results

20 | 21 |
22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 |

30 |

Found occurence(s)

31 |

32 | 33 |

34 |
35 |
36 | 37 | 38 | 39 | 40 |
41 |
42 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /webserver/application/views/welcome_message.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Welcome to CodeIgniter 8 | 9 | 67 | 68 | 69 | 70 |
71 |

Welcome to CodeIgniter!

72 | 73 |
74 |

The page you are looking at is being generated dynamically by CodeIgniter.

75 | 76 |

If you would like to edit this page you'll find it located at:

77 | application/views/welcome_message.php 78 | 79 |

The corresponding controller for this page is found at:

80 | application/controllers/Welcome.php 81 | 82 |

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

83 |
84 | 85 | 86 |
87 | 88 | 89 | -------------------------------------------------------------------------------- /webserver/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The CodeIgniter framework", 3 | "name": "codeigniter/framework", 4 | "type": "project", 5 | "homepage": "https://codeigniter.com", 6 | "license": "MIT", 7 | "support": { 8 | "forum": "http://forum.codeigniter.com/", 9 | "wiki": "https://github.com/bcit-ci/CodeIgniter/wiki", 10 | "slack": "https://codeigniterchat.slack.com", 11 | "source": "https://github.com/bcit-ci/CodeIgniter" 12 | }, 13 | "require": { 14 | "php": ">=5.3.7" 15 | }, 16 | "suggest": { 17 | "paragonie/random_compat": "Provides better randomness in PHP 5.x" 18 | }, 19 | "require-dev": { 20 | "mikey179/vfsStream": "1.1.*", 21 | "phpunit/phpunit": "4.* || 5.*" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /webserver/db.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.8.3 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: Aug 25, 2018 at 07:37 AM 7 | -- Server version: 10.1.35-MariaDB-1~xenial 8 | -- PHP Version: 5.6.37-1+ubuntu16.04.1+deb.sury.org+1 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET AUTOCOMMIT = 0; 12 | START TRANSACTION; 13 | SET time_zone = "+00:00"; 14 | 15 | 16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 19 | /*!40101 SET NAMES utf8mb4 */; 20 | 21 | -- 22 | -- Database: `35_156_173_29_nip_io` 23 | -- 24 | 25 | -- -------------------------------------------------------- 26 | 27 | -- 28 | -- Table structure for table `pagecache` 29 | -- 30 | 31 | CREATE TABLE `pagecache` ( 32 | `id` double UNSIGNED NOT NULL, 33 | `url` mediumtext NOT NULL, 34 | `data` text NOT NULL, 35 | `saved_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 36 | `ref` double UNSIGNED NOT NULL 37 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 38 | 39 | -- -------------------------------------------------------- 40 | 41 | -- 42 | -- Table structure for table `pagecontents` 43 | -- 44 | 45 | CREATE TABLE `pagecontents` ( 46 | `id` double UNSIGNED NOT NULL, 47 | `ref` double NOT NULL, 48 | `content` text NOT NULL, 49 | `revision` int(11) NOT NULL DEFAULT '1', 50 | `added_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 51 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 52 | 53 | -- -------------------------------------------------------- 54 | 55 | -- 56 | -- Table structure for table `urlindex` 57 | -- 58 | 59 | CREATE TABLE `urlindex` ( 60 | `id` double UNSIGNED NOT NULL, 61 | `url` mediumtext NOT NULL, 62 | `saved` int(1) NOT NULL, 63 | `added_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 64 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 65 | 66 | -- 67 | -- Indexes for dumped tables 68 | -- 69 | 70 | -- 71 | -- Indexes for table `pagecache` 72 | -- 73 | ALTER TABLE `pagecache` 74 | ADD PRIMARY KEY (`id`); 75 | 76 | -- 77 | -- Indexes for table `pagecontents` 78 | -- 79 | ALTER TABLE `pagecontents` 80 | ADD PRIMARY KEY (`id`); 81 | 82 | -- 83 | -- Indexes for table `urlindex` 84 | -- 85 | ALTER TABLE `urlindex` 86 | ADD PRIMARY KEY (`id`); 87 | 88 | -- 89 | -- AUTO_INCREMENT for dumped tables 90 | -- 91 | 92 | -- 93 | -- AUTO_INCREMENT for table `pagecache` 94 | -- 95 | ALTER TABLE `pagecache` 96 | MODIFY `id` double UNSIGNED NOT NULL AUTO_INCREMENT; 97 | 98 | -- 99 | -- AUTO_INCREMENT for table `pagecontents` 100 | -- 101 | ALTER TABLE `pagecontents` 102 | MODIFY `id` double UNSIGNED NOT NULL AUTO_INCREMENT; 103 | 104 | -- 105 | -- AUTO_INCREMENT for table `urlindex` 106 | -- 107 | ALTER TABLE `urlindex` 108 | MODIFY `id` double UNSIGNED NOT NULL AUTO_INCREMENT; 109 | COMMIT; 110 | 111 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 112 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 113 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 114 | -------------------------------------------------------------------------------- /webserver/license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2018, British Columbia Institute of Technology 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /webserver/readme.rst: -------------------------------------------------------------------------------- 1 | ################### 2 | The Backend Server 3 | ################### 4 | 5 | The backend server is powered by PHP and based on CodeIgniter. Why Codeigniter? Because it requires minimal housekeeping and is extremely easy to setup. The crawlers interact with this server to store crawled data. This server also renders the search page and performs searches on gatehered data. 6 | 7 | -------------------------------------------------------------------------------- /webserver/system/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Deny from all 6 | -------------------------------------------------------------------------------- /webserver/system/core/Controller.php: -------------------------------------------------------------------------------- 1 | $class) 74 | { 75 | $this->$var =& load_class($class); 76 | } 77 | 78 | $this->load =& load_class('Loader', 'core'); 79 | $this->load->initialize(); 80 | log_message('info', 'Controller Class Initialized'); 81 | } 82 | 83 | // -------------------------------------------------------------------- 84 | 85 | /** 86 | * Get the CI singleton 87 | * 88 | * @static 89 | * @return object 90 | */ 91 | public static function &get_instance() 92 | { 93 | return self::$instance; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /webserver/system/core/Model.php: -------------------------------------------------------------------------------- 1 | $key; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /webserver/system/core/compat/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/cubrid/cubrid_utility.php: -------------------------------------------------------------------------------- 1 | db->data_cache['db_names'])) 57 | { 58 | return $this->db->data_cache['db_names']; 59 | } 60 | 61 | return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id); 62 | } 63 | 64 | // -------------------------------------------------------------------- 65 | 66 | /** 67 | * CUBRID Export 68 | * 69 | * @param array Preferences 70 | * @return mixed 71 | */ 72 | protected function _backup($params = array()) 73 | { 74 | // No SQL based support in CUBRID as of version 8.4.0. Database or 75 | // table backup can be performed using CUBRID Manager 76 | // database administration tool. 77 | return $this->db->display_error('db_unsupported_feature'); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/cubrid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/ibase/ibase_utility.php: -------------------------------------------------------------------------------- 1 | db->hostname, $this->db->username, $this->db->password)) 58 | { 59 | $res = ibase_backup($service, $this->db->database, $filename.'.fbk'); 60 | 61 | // Close the service connection 62 | ibase_service_detach($service); 63 | return $res; 64 | } 65 | 66 | return FALSE; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/ibase/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/mssql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/mssql/mssql_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/mysql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/mysqli/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/oci8/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/oci8/oci8_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/odbc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/odbc/odbc_forge.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/pdo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/pdo/pdo_forge.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/pdo/subdrivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/postgre/postgre_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlite/sqlite_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlite3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlite3/sqlite3_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlsrv/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/database/drivers/sqlsrv/sqlsrv_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /webserver/system/database/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/fonts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/fonts/texb.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fifthsegment/yoursearch/19e527d56f8451b4fa2cfc5c7279d4805193eb0e/webserver/system/fonts/texb.ttf -------------------------------------------------------------------------------- /webserver/system/helpers/array_helper.php: -------------------------------------------------------------------------------- 1 | input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly); 74 | } 75 | } 76 | 77 | // -------------------------------------------------------------------- 78 | 79 | if ( ! function_exists('get_cookie')) 80 | { 81 | /** 82 | * Fetch an item from the COOKIE array 83 | * 84 | * @param string 85 | * @param bool 86 | * @return mixed 87 | */ 88 | function get_cookie($index, $xss_clean = NULL) 89 | { 90 | is_bool($xss_clean) OR $xss_clean = (config_item('global_xss_filtering') === TRUE); 91 | $prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix'); 92 | return get_instance()->input->cookie($prefix.$index, $xss_clean); 93 | } 94 | } 95 | 96 | // -------------------------------------------------------------------- 97 | 98 | if ( ! function_exists('delete_cookie')) 99 | { 100 | /** 101 | * Delete a COOKIE 102 | * 103 | * @param mixed 104 | * @param string the cookie domain. Usually: .yourdomain.com 105 | * @param string the cookie path 106 | * @param string the cookie prefix 107 | * @return void 108 | */ 109 | function delete_cookie($name, $domain = '', $path = '/', $prefix = '') 110 | { 111 | set_cookie($name, '', '', $domain, $path, $prefix); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /webserver/system/helpers/directory_helper.php: -------------------------------------------------------------------------------- 1 | 0) && is_dir($source_dir.$file)) 86 | { 87 | $filedata[$file] = directory_map($source_dir.$file, $new_depth, $hidden); 88 | } 89 | else 90 | { 91 | $filedata[] = $file; 92 | } 93 | } 94 | 95 | closedir($fp); 96 | return $filedata; 97 | } 98 | 99 | return FALSE; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /webserver/system/helpers/email_helper.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/helpers/language_helper.php: -------------------------------------------------------------------------------- 1 | lang->line($line); 67 | 68 | if ($for !== '') 69 | { 70 | $line = ''; 71 | } 72 | 73 | return $line; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /webserver/system/helpers/number_helper.php: -------------------------------------------------------------------------------- 1 | lang->load('number'); 65 | 66 | if ($num >= 1000000000000) 67 | { 68 | $num = round($num / 1099511627776, $precision); 69 | $unit = $CI->lang->line('terabyte_abbr'); 70 | } 71 | elseif ($num >= 1000000000) 72 | { 73 | $num = round($num / 1073741824, $precision); 74 | $unit = $CI->lang->line('gigabyte_abbr'); 75 | } 76 | elseif ($num >= 1000000) 77 | { 78 | $num = round($num / 1048576, $precision); 79 | $unit = $CI->lang->line('megabyte_abbr'); 80 | } 81 | elseif ($num >= 1000) 82 | { 83 | $num = round($num / 1024, $precision); 84 | $unit = $CI->lang->line('kilobyte_abbr'); 85 | } 86 | else 87 | { 88 | $unit = $CI->lang->line('bytes'); 89 | return number_format($num).' '.$unit; 90 | } 91 | 92 | return number_format($num, $precision).' '.$unit; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /webserver/system/helpers/path_helper.php: -------------------------------------------------------------------------------- 1 | security->xss_clean($str, $is_image); 64 | } 65 | } 66 | 67 | // ------------------------------------------------------------------------ 68 | 69 | if ( ! function_exists('sanitize_filename')) 70 | { 71 | /** 72 | * Sanitize Filename 73 | * 74 | * @param string 75 | * @return string 76 | */ 77 | function sanitize_filename($filename) 78 | { 79 | return get_instance()->security->sanitize_filename($filename); 80 | } 81 | } 82 | 83 | // -------------------------------------------------------------------- 84 | 85 | if ( ! function_exists('do_hash')) 86 | { 87 | /** 88 | * Hash encode a string 89 | * 90 | * @todo Remove in version 3.1+. 91 | * @deprecated 3.0.0 Use PHP's native hash() instead. 92 | * @param string $str 93 | * @param string $type = 'sha1' 94 | * @return string 95 | */ 96 | function do_hash($str, $type = 'sha1') 97 | { 98 | if ( ! in_array(strtolower($type), hash_algos())) 99 | { 100 | $type = 'md5'; 101 | } 102 | 103 | return hash($type, $str); 104 | } 105 | } 106 | 107 | // ------------------------------------------------------------------------ 108 | 109 | if ( ! function_exists('strip_image_tags')) 110 | { 111 | /** 112 | * Strip Image Tags 113 | * 114 | * @param string 115 | * @return string 116 | */ 117 | function strip_image_tags($str) 118 | { 119 | return get_instance()->security->strip_image_tags($str); 120 | } 121 | } 122 | 123 | // ------------------------------------------------------------------------ 124 | 125 | if ( ! function_exists('encode_php_tags')) 126 | { 127 | /** 128 | * Convert PHP tags to entities 129 | * 130 | * @param string 131 | * @return string 132 | */ 133 | function encode_php_tags($str) 134 | { 135 | return str_replace(array(''), array('<?', '?>'), $str); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /webserver/system/helpers/typography_helper.php: -------------------------------------------------------------------------------- 1 | load->library('typography'); 64 | return $CI->typography->nl2br_except_pre($str); 65 | } 66 | } 67 | 68 | // ------------------------------------------------------------------------ 69 | 70 | if ( ! function_exists('auto_typography')) 71 | { 72 | /** 73 | * Auto Typography Wrapper Function 74 | * 75 | * @param string $str 76 | * @param bool $reduce_linebreaks = FALSE whether to reduce multiple instances of double newlines to two 77 | * @return string 78 | */ 79 | function auto_typography($str, $reduce_linebreaks = FALSE) 80 | { 81 | $CI =& get_instance(); 82 | $CI->load->library('typography'); 83 | return $CI->typography->auto_typography($str, $reduce_linebreaks); 84 | } 85 | } 86 | 87 | // -------------------------------------------------------------------- 88 | 89 | if ( ! function_exists('entity_decode')) 90 | { 91 | /** 92 | * HTML Entities Decode 93 | * 94 | * This function is a replacement for html_entity_decode() 95 | * 96 | * @param string 97 | * @param string 98 | * @return string 99 | */ 100 | function entity_decode($str, $charset = NULL) 101 | { 102 | return get_instance()->security->entity_decode($str, $charset); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /webserver/system/helpers/xml_helper.php: -------------------------------------------------------------------------------- 1 | ', '"', "'", '-'), 76 | array('&', '<', '>', '"', ''', '-'), 77 | $str 78 | ); 79 | 80 | // Decode the temp markers back to entities 81 | $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str); 82 | 83 | if ($protect_all === TRUE) 84 | { 85 | return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str); 86 | } 87 | 88 | return $str; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /webserver/system/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/language/english/calendar_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/language/english/migration_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/Cache/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/Cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/Javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/Session/SessionHandlerInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/Session/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/system/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webserver/tests/Bootstrap.php: -------------------------------------------------------------------------------- 1 | config[$key]) ? $this->config[$key] : FALSE; 12 | } 13 | 14 | public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) 15 | { 16 | $this->loaded[] = $file; 17 | return TRUE; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /webserver/tests/mocks/core/common.php: -------------------------------------------------------------------------------- 1 | ci_instance(); 11 | return $test; 12 | } 13 | } 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | if ( ! function_exists('get_config')) 18 | { 19 | function &get_config() 20 | { 21 | $test = CI_TestCase::instance(); 22 | $config = $test->ci_get_config(); 23 | return $config; 24 | } 25 | } 26 | 27 | if ( ! function_exists('config_item')) 28 | { 29 | function config_item($item) 30 | { 31 | $config =& get_config(); 32 | 33 | if ( ! isset($config[$item])) 34 | { 35 | return NULL; 36 | } 37 | 38 | return $config[$item]; 39 | } 40 | } 41 | 42 | if ( ! function_exists('get_mimes')) 43 | { 44 | /** 45 | * Returns the MIME types array from config/mimes.php 46 | * 47 | * @return array 48 | */ 49 | function &get_mimes() 50 | { 51 | static $_mimes = array(); 52 | 53 | if (empty($_mimes)) 54 | { 55 | $path = realpath(PROJECT_BASE.'application/config/mimes.php'); 56 | if (is_file($path)) 57 | { 58 | $_mimes = include($path); 59 | } 60 | } 61 | 62 | return $_mimes; 63 | } 64 | } 65 | 66 | // -------------------------------------------------------------------- 67 | 68 | /* 69 | if ( ! function_exists('load_class')) 70 | { 71 | function load_class($class, $directory = 'libraries', $prefix = 'CI_') 72 | { 73 | if ($directory !== 'core' OR $prefix !== 'CI_') 74 | { 75 | throw new Exception('Not Implemented: Non-core load_class()'); 76 | } 77 | 78 | $test = CI_TestCase::instance(); 79 | 80 | $obj =& $test->ci_core_class($class); 81 | 82 | if (is_string($obj)) 83 | { 84 | throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class); 85 | } 86 | 87 | return $obj; 88 | } 89 | } 90 | */ 91 | 92 | // Clean up error messages 93 | // -------------------------------------------------------------------- 94 | 95 | if ( ! function_exists('show_error')) 96 | { 97 | function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') 98 | { 99 | throw new RuntimeException('CI Error: '.$message); 100 | } 101 | } 102 | 103 | if ( ! function_exists('show_404')) 104 | { 105 | function show_404($page = '', $log_error = TRUE) 106 | { 107 | throw new RuntimeException('CI Error: 404'); 108 | } 109 | } 110 | 111 | if ( ! function_exists('_exception_handler')) 112 | { 113 | function _exception_handler($severity, $message, $filepath, $line) 114 | { 115 | throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); 116 | } 117 | } 118 | 119 | // We assume a few things about our environment ... 120 | // -------------------------------------------------------------------- 121 | if ( ! function_exists('is_loaded')) 122 | { 123 | function &is_loaded() 124 | { 125 | $loaded = array(); 126 | return $loaded; 127 | } 128 | } 129 | 130 | if ( ! function_exists('log_message')) 131 | { 132 | function log_message($level, $message) 133 | { 134 | return TRUE; 135 | } 136 | } 137 | 138 | if ( ! function_exists('set_status_header')) 139 | { 140 | function set_status_header($code = 200, $text = '') 141 | { 142 | return TRUE; 143 | } 144 | } 145 | 146 | if ( ! function_exists('is_cli')) 147 | { 148 | // In order to test HTTP functionality, we need to lie about this 149 | function is_cli() 150 | { 151 | return FALSE; 152 | } 153 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/core/input.php: -------------------------------------------------------------------------------- 1 | _allow_get_array = (config_item('allow_get_array') === TRUE); 15 | $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); 16 | $this->_enable_csrf = (config_item('csrf_protection') === TRUE); 17 | 18 | // Assign Security and Utf8 classes 19 | $this->security = $security; 20 | $this->uni = $utf8; 21 | 22 | // Sanitize global arrays 23 | $this->_sanitize_globals(); 24 | } 25 | 26 | public function fetch_from_array($array, $index = '', $xss_clean = FALSE) 27 | { 28 | return parent::_fetch_from_array($array, $index, $xss_clean); 29 | } 30 | 31 | /** 32 | * Lie about being a CLI request 33 | * 34 | * We take advantage of this in libraries/Session_test 35 | */ 36 | public function is_cli_request() 37 | { 38 | return FALSE; 39 | } 40 | 41 | public function __set($name, $value) 42 | { 43 | if ($name === 'ip_address') 44 | { 45 | $this->ip_address = $value; 46 | } 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/core/security.php: -------------------------------------------------------------------------------- 1 | {'_'.$property}) ? $this->{'_'.$property} : NULL; 17 | } 18 | 19 | public function remove_evil_attributes($str, $is_image) 20 | { 21 | return $this->_remove_evil_attributes($str, $is_image); 22 | } 23 | 24 | // Override inaccessible protected method 25 | public function __call($method, $params) 26 | { 27 | if (is_callable(array($this, '_'.$method))) 28 | { 29 | return call_user_func_array(array($this, '_'.$method), $params); 30 | } 31 | 32 | throw new BadMethodCallException('Method '.$method.' was not found'); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /webserver/tests/mocks/core/uri.php: -------------------------------------------------------------------------------- 1 | ci_core_class('cfg'); 9 | 10 | // set predictable config values 11 | $test->ci_set_config(array( 12 | 'index_page' => 'index.php', 13 | 'base_url' => 'http://example.com/', 14 | 'subclass_prefix' => 'MY_', 15 | 'enable_query_strings' => FALSE, 16 | 'permitted_uri_chars' => 'a-z 0-9~%.:_\-' 17 | )); 18 | 19 | $this->config = new $cls; 20 | 21 | if ($this->config->item('enable_query_strings') !== TRUE OR is_cli()) 22 | { 23 | $this->_permitted_uri_chars = $this->config->item('permitted_uri_chars'); 24 | } 25 | } 26 | 27 | public function _set_permitted_uri_chars($value) 28 | { 29 | $this->_permitted_uri_chars = $value; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/core/utf8.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => '', 8 | 'hostname' => 'localhost', 9 | 'username' => 'travis', 10 | 'password' => '', 11 | 'database' => 'ci_test', 12 | 'dbdriver' => 'mysql' 13 | ), 14 | 15 | // Database configuration with failover 16 | 'mysql_failover' => array( 17 | 'dsn' => '', 18 | 'hostname' => 'localhost', 19 | 'username' => 'not_travis', 20 | 'password' => 'wrong password', 21 | 'database' => 'not_ci_test', 22 | 'dbdriver' => 'mysql', 23 | 'failover' => array( 24 | array( 25 | 'dsn' => '', 26 | 'hostname' => 'localhost', 27 | 'username' => 'travis', 28 | 'password' => '', 29 | 'database' => 'ci_test', 30 | 'dbdriver' => 'mysql', 31 | ) 32 | ) 33 | ) 34 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/mysqli.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => '', 8 | 'hostname' => 'localhost', 9 | 'username' => 'travis', 10 | 'password' => '', 11 | 'database' => 'ci_test', 12 | 'dbdriver' => 'mysqli' 13 | ), 14 | 15 | // Database configuration with failover 16 | 'mysqli_failover' => array( 17 | 'dsn' => '', 18 | 'hostname' => 'localhost', 19 | 'username' => 'not_travis', 20 | 'password' => 'wrong password', 21 | 'database' => 'not_ci_test', 22 | 'dbdriver' => 'mysqli', 23 | 'failover' => array( 24 | array( 25 | 'dsn' => '', 26 | 'hostname' => 'localhost', 27 | 'username' => 'travis', 28 | 'password' => '', 29 | 'database' => 'ci_test', 30 | 'dbdriver' => 'mysqli', 31 | ) 32 | ) 33 | ) 34 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/pdo/mysql.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => 'mysql:host=localhost;dbname=ci_test', 8 | 'hostname' => 'localhost', 9 | 'username' => 'travis', 10 | 'password' => '', 11 | 'database' => 'ci_test', 12 | 'dbdriver' => 'pdo', 13 | 'subdriver' => 'mysql' 14 | ), 15 | 16 | // Database configuration with failover 17 | 'pdo/mysql_failover' => array( 18 | 'dsn' => '', 19 | 'hostname' => 'localhost', 20 | 'username' => 'not_travis', 21 | 'password' => 'wrong password', 22 | 'database' => 'not_ci_test', 23 | 'dbdriver' => 'pdo', 24 | 'subdriver' => 'mysql', 25 | 'failover' => array( 26 | array( 27 | 'dsn' => 'mysql:host=localhost;dbname=ci_test', 28 | 'hostname' => 'localhost', 29 | 'username' => 'travis', 30 | 'password' => '', 31 | 'database' => 'ci_test', 32 | 'dbdriver' => 'pdo', 33 | 'subdriver' => 'mysql' 34 | ) 35 | ) 36 | ) 37 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/pdo/pgsql.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;', 8 | 'hostname' => 'localhost', 9 | 'username' => 'postgres', 10 | 'password' => '', 11 | 'database' => 'ci_test', 12 | 'dbdriver' => 'pdo', 13 | 'subdriver' => 'pgsql' 14 | ), 15 | 16 | // Database configuration with failover 17 | 'pdo/pgsql_failover' => array( 18 | 'dsn' => '', 19 | 'hostname' => 'localhost', 20 | 'username' => 'not_travis', 21 | 'password' => 'wrong password', 22 | 'database' => 'not_ci_test', 23 | 'dbdriver' => 'pdo', 24 | 'subdriver' => 'pgsql', 25 | 'failover' => array( 26 | array( 27 | 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;', 28 | 'hostname' => 'localhost', 29 | 'username' => 'postgres', 30 | 'password' => '', 31 | 'database' => 'ci_test', 32 | 'dbdriver' => 'pdo', 33 | 'subdriver' => 'pgsql' 34 | ) 35 | ) 36 | ) 37 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/pdo/sqlite.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite', 8 | 'hostname' => 'localhost', 9 | 'username' => 'sqlite', 10 | 'password' => 'sqlite', 11 | 'database' => 'sqlite', 12 | 'dbdriver' => 'pdo', 13 | 'subdriver' => 'sqlite' 14 | ), 15 | 16 | // Database configuration with failover 17 | 'pdo/sqlite_failover' => array( 18 | 'dsn' => 'sqlite:not_exists.sqlite', 19 | 'hostname' => 'localhost', 20 | 'username' => 'sqlite', 21 | 'password' => 'sqlite', 22 | 'database' => 'sqlite', 23 | 'dbdriver' => 'pdo', 24 | 'subdriver' => 'sqlite', 25 | 'failover' => array( 26 | array( 27 | 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite', 28 | 'hostname' => 'localhost', 29 | 'username' => 'sqlite', 30 | 'password' => 'sqlite', 31 | 'database' => 'sqlite', 32 | 'dbdriver' => 'pdo', 33 | 'subdriver' => 'sqlite' 34 | ) 35 | ) 36 | ) 37 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/pgsql.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => '', 8 | 'hostname' => 'localhost', 9 | 'username' => 'postgres', 10 | 'password' => '', 11 | 'database' => 'ci_test', 12 | 'dbdriver' => 'postgre' 13 | ), 14 | 15 | // Database configuration with failover 16 | 'pgsql_failover' => array( 17 | 'dsn' => '', 18 | 'hostname' => 'localhost', 19 | 'username' => 'not_travis', 20 | 'password' => 'wrong password', 21 | 'database' => 'not_ci_test', 22 | 'dbdriver' => 'postgre', 23 | 'failover' => array( 24 | array( 25 | 'dsn' => '', 26 | 'hostname' => 'localhost', 27 | 'username' => 'postgres', 28 | 'password' => '', 29 | 'database' => 'ci_test', 30 | 'dbdriver' => 'postgre', 31 | ) 32 | ) 33 | ) 34 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/config/sqlite.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'dsn' => '', 8 | 'hostname' => 'localhost', 9 | 'username' => 'sqlite', 10 | 'password' => 'sqlite', 11 | 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', 12 | 'dbdriver' => 'sqlite3' 13 | ), 14 | 15 | // Database configuration with failover 16 | 'sqlite_failover' => array( 17 | 'dsn' => '', 18 | 'hostname' => 'localhost', 19 | 'username' => 'sqlite', 20 | 'password' => 'sqlite', 21 | 'database' => '../not_exists.sqlite', 22 | 'dbdriver' => 'sqlite3', 23 | 'failover' => array( 24 | array( 25 | 'dsn' => '', 26 | 'hostname' => 'localhost', 27 | 'username' => 'sqlite', 28 | 'password' => 'sqlite', 29 | 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', 30 | 'dbdriver' => 'sqlite3' 31 | ) 32 | ) 33 | ) 34 | ); -------------------------------------------------------------------------------- /webserver/tests/mocks/database/db.php: -------------------------------------------------------------------------------- 1 | config = $config; 29 | } 30 | 31 | /** 32 | * Build DSN connection string for DB driver instantiate process 33 | * 34 | * @param string Group name 35 | * @return string DSN Connection string 36 | */ 37 | public function set_dsn($group = 'default') 38 | { 39 | if ( ! isset($this->config[$group])) 40 | { 41 | throw new InvalidArgumentException('Group '.$group.' not exists'); 42 | } 43 | 44 | self::$dbdriver = $this->config[$group]['dbdriver']; 45 | if (isset($this->config[$group]['subdriver'])) 46 | { 47 | self::$subdriver = $this->config[$group]['subdriver']; 48 | } 49 | 50 | $params = array( 51 | 'dbprefix' => '', 52 | 'pconnect' => FALSE, 53 | 'db_debug' => FALSE, 54 | 'cache_on' => FALSE, 55 | 'cachedir' => '', 56 | 'char_set' => 'utf8', 57 | 'dbcollat' => 'utf8_general_ci', 58 | 'swap_pre' => '', 59 | 'stricton' => FALSE 60 | ); 61 | 62 | $config = array_merge($this->config[$group], $params); 63 | $dsnstring = empty($config['dsn']) ? FALSE : $config['dsn']; 64 | $subdriver = empty($config['subdriver']) ? FALSE: $config['subdriver']; 65 | $failover = empty($config['failover']) ? FALSE : $config['failover']; 66 | 67 | $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password'] 68 | .'@'.$config['hostname'].'/'.$config['database']; 69 | 70 | // Build the parameter 71 | $other_params = array_slice($config, 6); 72 | if ($dsnstring) $other_params['dsn'] = $dsnstring; 73 | if ($subdriver) $other_params['subdriver'] = $subdriver; 74 | if ($failover) $other_params['failover'] = $failover; 75 | 76 | return $dsn.'?'.http_build_query($other_params); 77 | } 78 | 79 | /** 80 | * Return a database config array 81 | * 82 | * @see ./config 83 | * @param string Driver based configuration 84 | * @return array 85 | */ 86 | public static function config($driver) 87 | { 88 | $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR; 89 | return include($dir.'config'.DIRECTORY_SEPARATOR.$driver.'.php'); 90 | } 91 | 92 | /** 93 | * Main DB method wrapper 94 | * 95 | * @param string Group or DSN string 96 | * @param bool 97 | * @return object 98 | */ 99 | public static function DB($group, $query_builder = FALSE) 100 | { 101 | // Create dummy driver and builder files to "load" - the mocks have 102 | // already triggered autoloading of the real files 103 | $case = CI_TestCase::instance(); 104 | $driver = self::$dbdriver; 105 | $subdriver = self::$subdriver; 106 | $case->ci_vfs_create(array( 107 | 'DB_driver.php' => '', 108 | 'DB_result.php' => '', 109 | 'DB_forge.php' => '', 110 | 'DB_query_builder.php' => '' 111 | ), '', $case->ci_base_root, 'database'); 112 | if (file_exists(SYSTEM_PATH.'database/drivers/'.$driver.'/'.$driver.'_driver.php')) 113 | { 114 | $case->ci_vfs_create(array( 115 | $driver.'_driver.php' => '', 116 | $driver.'_result.php' => '', 117 | $driver.'_forge.php' => '' 118 | ), '', $case->ci_base_root, 'database/drivers/'.$driver); 119 | } 120 | if ($subdriver) 121 | { 122 | $case->ci_vfs_create(array( 123 | $driver.'_'.$subdriver.'_driver.php' => '', 124 | $driver.'_'.$subdriver.'_forge.php' => '' 125 | ), '', $case->ci_base_root, 'database/drivers/'.$driver.'/subdrivers'); 126 | } 127 | 128 | include_once(SYSTEM_PATH.'database/DB.php'); 129 | 130 | try 131 | { 132 | $db = DB($group, $query_builder); 133 | } 134 | catch (Exception $e) 135 | { 136 | throw new RuntimeException($e->getMessage()); 137 | } 138 | 139 | return $db; 140 | } 141 | 142 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/database/db/driver.php: -------------------------------------------------------------------------------- 1 | ci_db_driver = new $driver_class($config); 22 | } 23 | } 24 | 25 | /** 26 | * Overloading method, emulate the actual driver method (multiple inheritance workaround) 27 | */ 28 | public function __call($method, $arguments) 29 | { 30 | if ( ! is_callable(array($this->ci_db_driver, $method))) 31 | { 32 | throw new BadMethodCallException($method. ' not exists or not implemented'); 33 | } 34 | 35 | return call_user_func_array(array($this->ci_db_driver, $method), $arguments); 36 | } 37 | 38 | } 39 | 40 | class CI_DB extends CI_DB_query_builder {} -------------------------------------------------------------------------------- /webserver/tests/mocks/database/drivers/mysql.php: -------------------------------------------------------------------------------- 1 | =')) 30 | { 31 | error_reporting(E_ALL & ~E_DEPRECATED); 32 | } 33 | 34 | $config = Mock_Database_DB::config($driver); 35 | $connection = new Mock_Database_DB($config); 36 | $db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE); 37 | 38 | CI_TestCase::instance()->ci_instance_var('db', $db); 39 | 40 | $loader = new CI_Loader(); 41 | $loader->dbforge(); 42 | $forge = CI_TestCase::instance()->ci_instance_var('dbforge'); 43 | 44 | self::$db = $db; 45 | self::$forge = $forge; 46 | self::$driver = $driver; 47 | } 48 | 49 | return self::$db; 50 | } 51 | 52 | /** 53 | * Create the dummy tables 54 | * 55 | * @return void 56 | */ 57 | public static function create_tables() 58 | { 59 | // User Table 60 | self::$forge->add_field(array( 61 | 'id' => array( 62 | 'type' => 'INTEGER', 63 | 'constraint' => 3 64 | ), 65 | 'name' => array( 66 | 'type' => 'VARCHAR', 67 | 'constraint' => 40 68 | ), 69 | 'email' => array( 70 | 'type' => 'VARCHAR', 71 | 'constraint' => 100 72 | ), 73 | 'country' => array( 74 | 'type' => 'VARCHAR', 75 | 'constraint' => 40 76 | ) 77 | )); 78 | self::$forge->add_key('id', TRUE); 79 | self::$forge->create_table('user', TRUE); 80 | 81 | // Job Table 82 | self::$forge->add_field(array( 83 | 'id' => array( 84 | 'type' => 'INTEGER', 85 | 'constraint' => 3 86 | ), 87 | 'name' => array( 88 | 'type' => 'VARCHAR', 89 | 'constraint' => 40 90 | ), 91 | 'description' => array( 92 | 'type' => 'TEXT' 93 | ) 94 | )); 95 | self::$forge->add_key('id', TRUE); 96 | self::$forge->create_table('job', TRUE); 97 | 98 | // Misc Table 99 | self::$forge->add_field(array( 100 | 'id' => array( 101 | 'type' => 'INTEGER', 102 | 'constraint' => 3 103 | ), 104 | 'key' => array( 105 | 'type' => 'VARCHAR', 106 | 'constraint' => 40 107 | ), 108 | 'value' => array( 109 | 'type' => 'TEXT' 110 | ) 111 | )); 112 | self::$forge->add_key('id', TRUE); 113 | self::$forge->create_table('misc', TRUE); 114 | } 115 | 116 | /** 117 | * Create the dummy datas 118 | * 119 | * @return void 120 | */ 121 | public static function create_data() 122 | { 123 | // Job Data 124 | $data = array( 125 | 'user' => array( 126 | array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'), 127 | array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'), 128 | array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'), 129 | array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK') 130 | ), 131 | 'job' => array( 132 | array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), 133 | array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'), 134 | array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), 135 | array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician') 136 | ), 137 | 'misc' => array( 138 | array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), 139 | array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%'), 140 | array('id' => 3, 'key' => 'spaces and tabs', 'value' => ' One two three tab') 141 | ) 142 | ); 143 | 144 | foreach ($data as $table => $dummy_data) 145 | { 146 | self::$db->truncate($table); 147 | 148 | foreach ($dummy_data as $single_dummy_data) 149 | { 150 | self::$db->insert($table, $single_dummy_data); 151 | } 152 | } 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /webserver/tests/mocks/libraries/driver.php: -------------------------------------------------------------------------------- 1 | valid_drivers; 15 | } 16 | 17 | $this->valid_drivers = (array) $drivers; 18 | } 19 | 20 | /** 21 | * Get library name 22 | */ 23 | public function get_name() 24 | { 25 | return $this->lib_name; 26 | } 27 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/libraries/encrypt.php: -------------------------------------------------------------------------------- 1 | _get_params($params); 13 | } 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | /** 18 | * get_key() 19 | * 20 | * Allows checking for key changes. 21 | */ 22 | public function get_key() 23 | { 24 | return $this->_key; 25 | } 26 | 27 | // -------------------------------------------------------------------- 28 | 29 | /** 30 | * __driver_get_handle() 31 | * 32 | * Allows checking for _mcrypt_get_handle(), _openssl_get_handle() 33 | */ 34 | public function __driver_get_handle($driver, $cipher, $mode) 35 | { 36 | return $this->{'_'.$driver.'_get_handle'}($cipher, $mode); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /webserver/tests/mocks/libraries/session.php: -------------------------------------------------------------------------------- 1 | _flashdata_sweep(); 13 | $this->_flashdata_mark(); 14 | $this->_tempdata_sweep(); 15 | } 16 | } 17 | 18 | /** 19 | * Mock cookie driver to overload cookie setting 20 | */ 21 | class Mock_Libraries_Session_cookie extends CI_Session_cookie { 22 | /** 23 | * Overload _setcookie to manage $_COOKIE values, since actual cookies can't be set in unit testing 24 | */ 25 | protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) 26 | { 27 | if (empty($value) OR $expire <= time()) 28 | { 29 | unset($_COOKIE[$name]); 30 | } 31 | else 32 | { 33 | $_COOKIE[$name] = $value; 34 | } 35 | } 36 | } 37 | 38 | class Mock_Libraries_Session_native extends CI_Session_native {} -------------------------------------------------------------------------------- /webserver/tests/mocks/libraries/table.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | ./codeigniter/core 15 | ./codeigniter/helpers 16 | ./codeigniter/libraries 17 | 18 | 19 | 20 | 21 | ../system/ 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------