diff --git a/.gitignore b/.gitignore index 68633fb..1898bff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea/* -grunt/node_modules/* \ No newline at end of file +grunt/node_modules/* +vendor/* +composer.lock \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a8c5b3e --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +PTEST +===== + +Задание +------- + +###Написать Доску объявлений + +Доска объявлений предоставляет возможность пользователям сайта оставлять +сообщения на сайте. + +Все данные введенные пользователем сохраняются в БД MySQL, так же в базе данных +сохраняются данные о IP пользователя и его браузере. + +Форма добавления записи на доску объявлений должна иметь следующие поля: + +* User Name (цифры и буквы латинского алфавита) – обязательное поле +* E-mail (формат email) — обязательное поле +* Homepage (формат url) – необязательное поле +* CAPTCHA (цифры и буквы латинского алфавита) – изображение и обязательное + поле (http://ru.wikipedia.org/wiki/CAPTCHA) +* Text (непосредственно сам текст сообщения, HTML тэги недопустимы) – + обязательное поле + +Сообщения должны выводится в виде таблицы, с возможностью сортировки по +следующим полям: User Name, e-mail, и дата добавления (как в порядке убывания, +так и в обратном). Сообщения должны разбиваться на страницы по 25 сообщений на +каждой. + +Приветствуется создания простейшего дизайна с использованием CSS. + +Развертывание +------------- + diff --git a/composer.json b/composer.json index 934cfcd..90c4c23 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ ], "autoload": { "psr-4": { - "PTEST\\": ["src/"] + "PTEST\\": ["src/"], + "PFRM\\": ["frm/"] } }, "require": { diff --git a/frm/App.php b/frm/App.php new file mode 100644 index 0000000..e5b79e9 --- /dev/null +++ b/frm/App.php @@ -0,0 +1,22 @@ +>> 0; + + // 4. If IsCallable(callback) is false, throw a TypeError exception. + // See: http://es5.github.com/#x9.11 + if (typeof callback !== "function") { + throw new TypeError(callback + ' is not a function'); + } + + // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + if (arguments.length > 1) { + T = thisArg; + } + + // 6. Let k be 0 + k = 0; + + // 7. Repeat, while k < len + while (k < len) { + + var kValue; + + // a. Let Pk be ToString(k). + // This is implicit for LHS operands of the in operator + // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk. + // This step can be combined with c + // c. If kPresent is true, then + if (k in O) { + + // i. Let kValue be the result of calling the Get internal method of O with argument Pk. + kValue = O[k]; + + // ii. Call the Call internal method of callback with T as the this value and + // argument list containing kValue, k, and O. + callback.call(T, kValue, k, O); + } + // d. Increase k by 1. + k++; + } + // 8. return undefined + }; +} \ No newline at end of file diff --git a/grunt/js/index.js b/grunt/js/index.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/grunt/js/index.js @@ -0,0 +1 @@ + diff --git a/grunt/js/xmlhttp.js b/grunt/js/xmlhttp.js new file mode 100644 index 0000000..f777219 --- /dev/null +++ b/grunt/js/xmlhttp.js @@ -0,0 +1,91 @@ +//xmlHttpConnect +//xH.conn(URL,Method,Vars,Function done) - assync +//xH.syn(URL,Method,Vars) - sync, return result query +function xH() +{ + var xmlhttp, bComplete = false; + try + { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + }catch (e) + { + try + { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + }catch (e) + { + try + { + xmlhttp = new XMLHttpRequest(); + }catch (e) + { + xmlhttp = false; + } + } + } + if (!xmlhttp) return null; + this.syn = function(sURL, sMethod, sVars) + { + if (!xmlhttp) return false; + sMethod = sMethod.toUpperCase(); + if (sMethod == "GET") + { + xmlhttp.open(sMethod,sURL+"?"+sVars,false); + xmlhttp.send(null); + if (xmlhttp.status == 200) + { + return xmlhttp.responseText; + } + return false; + } + else + { + xmlhttp.open(sMethod, sURL, false); + xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); + xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xmlhttp.send(sVars); + if (xmlhttp.status == 200) + { + return xmlhttp.responseText; + } + return false; + } + } + this.conn = function(sURL, sMethod, sVars, fnDone) + { + if (!xmlhttp) return false; + bComplete = false; + sMethod = sMethod.toUpperCase(); + try + { + if (sMethod == "GET") + { + xmlhttp.open(sMethod, sURL+"?"+sVars, true); + sVars = ""; + } + else + { + xmlhttp.open(sMethod, sURL, true); + xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); + xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xmlhttp.send(sVars); + } + xmlhttp.onreadystatechange = function() + { + if (xmlhttp.readyState == 4 && !bComplete) + { + bComplete = true; + fnDone(xmlhttp); + } + }; + xmlhttp.send(sVars); + } + catch(z) + { + return false; + } + return true; + }; + return this; +} + diff --git a/grunt/package.json b/grunt/package.json index 782f925..5199d4a 100644 --- a/grunt/package.json +++ b/grunt/package.json @@ -1,4 +1,12 @@ { "name": "ptest", - "version": "0.0.1" + "version": "0.0.1", + "devDependencies": { + "grunt": "~0.4.1", + "grunt-csso": "~0.5.0", + "grunt-contrib-stylus": "~1.2.0", + "grunt-contrib-jshint": "~1.0.0", + "grunt-contrib-internal": "~1.2.2", + "grunt-contrib-uglify": "~2.0.0" + } } diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..5fd07cf --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,6 @@ + + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php [QSA,L] + diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..a195944 --- /dev/null +++ b/public/css/style.css @@ -0,0 +1 @@ +html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template,[hidden]{display:none}a{color:#0063ff;text-decoration:none;border-bottom:1px solid rgba(0,99,255,.3)}a:visited{color:#cf00cf;border-bottom-color:rgba(207,0,207,.3)}a:hover,a:visited:hover{color:#ff475d;border-bottom-color:rgba(255,71,93,.24)}.page__container{max-width:800px} \ No newline at end of file diff --git a/public/css/style.raw.css b/public/css/style.raw.css new file mode 100644 index 0000000..0f4191f --- /dev/null +++ b/public/css/style.raw.css @@ -0,0 +1,215 @@ +/* normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */ +html { + font-family: sans-serif; + line-height: 1.15; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} +body { + margin: 0; +} +article, +aside, +footer, +header, +nav, +section { + display: block; +} +h1 { + font-size: 2em; + margin: 0.67em 0; +} +figcaption, +figure, +main { + display: block; +} +figure { + margin: 1em 40px; +} +hr { + box-sizing: content-box; + height: 0; + overflow: visible; +} +pre { + font-family: monospace, monospace; + font-size: 1em; +} +a { + background-color: transparent; + -webkit-text-decoration-skip: objects; +} +a:active, +a:hover { + outline-width: 0; +} +abbr[title] { + border-bottom: none; + text-decoration: underline; + text-decoration: underline dotted; +} +b, +strong { + font-weight: inherit; +} +b, +strong { + font-weight: bolder; +} +code, +kbd, +samp { + font-family: monospace, monospace; + font-size: 1em; +} +dfn { + font-style: italic; +} +mark { + background-color: #ff0; + color: #000; +} +small { + font-size: 80%; +} +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} +sub { + bottom: -0.25em; +} +sup { + top: -0.5em; +} +audio, +video { + display: inline-block; +} +audio:not([controls]) { + display: none; + height: 0; +} +img { + border-style: none; +} +svg:not(:root) { + overflow: hidden; +} +button, +input, +optgroup, +select, +textarea { + font-family: sans-serif; + font-size: 100%; + line-height: 1.15; + margin: 0; +} +button, +input { + overflow: visible; +} +button, +select { + text-transform: none; +} +button, +html [type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} +legend { + box-sizing: border-box; + color: inherit; + display: table; + max-width: 100%; + padding: 0; + white-space: normal; +} +progress { + display: inline-block; + vertical-align: baseline; +} +textarea { + overflow: auto; +} +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; + padding: 0; +} +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} +[type="search"] { + -webkit-appearance: textfield; + outline-offset: -2px; +} +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} +::-webkit-file-upload-button { + -webkit-appearance: button; + font: inherit; +} +details, +menu { + display: block; +} +summary { + display: list-item; +} +canvas { + display: inline-block; +} +template { + display: none; +} +[hidden] { + display: none; +} +/** ptest css */ +a { + color: #0063ff; + text-decoration: none; + border-bottom: 1px solid rgba(0,99,255,0.3); +} +a:visited { + color: #cf00cf; + border-bottom-color: rgba(207,0,207,0.3); +} +a:hover, +a:visited:hover { + color: #ff475d; + border-bottom-color: rgba(255,71,93,0.24); +} +.page__container { + max-width: 800px; +} diff --git a/public/index.php b/public/index.php index 4230403..77e2d0b 100644 --- a/public/index.php +++ b/public/index.php @@ -4,4 +4,6 @@ * User: Игорь * Date: 23.01.2017 * Time: 00:21 - */ \ No newline at end of file + */ + +require_once __DIR__ . '/../src/start.php'; \ No newline at end of file diff --git a/public/js/script.js b/public/js/script.js new file mode 100644 index 0000000..a70c11b --- /dev/null +++ b/public/js/script.js @@ -0,0 +1 @@ +function bindReady(a){function b(){d||(d=!0,a())}function c(){if(!d&&document.body)try{document.documentElement.doScroll("left"),b()}catch(a){setTimeout(c,0)}}var d=!1;document.addEventListener?document.addEventListener("DOMContentLoaded",function(){b()},!1):document.attachEvent&&(document.documentElement.doScroll&&window==window.top&&c(),document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&b()})),window.addEventListener?window.addEventListener("load",b,!1):window.attachEvent&&window.attachEvent("onload",b)}function xH(){var a,b=!1;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){try{a=new XMLHttpRequest}catch(b){a=!1}}}return a?(this.syn=function(b,c,d){return!!a&&(c=c.toUpperCase(),"GET"==c?(a.open(c,b+"?"+d,!1),a.send(null),200==a.status&&a.responseText):(a.open(c,b,!1),a.setRequestHeader("Method","POST "+b+" HTTP/1.1"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.send(d),200==a.status&&a.responseText))},this.conn=function(c,d,e,f){if(!a)return!1;b=!1,d=d.toUpperCase();try{"GET"==d?(a.open(d,c+"?"+e,!0),e=""):(a.open(d,c,!0),a.setRequestHeader("Method","POST "+c+" HTTP/1.1"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.send(e)),a.onreadystatechange=function(){4!=a.readyState||b||(b=!0,f(a))},a.send(e)}catch(a){return!1}return!0},this):null}Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;dusername; + } + + public function getEmail() { + return $this->email; + } + } \ No newline at end of file diff --git a/src/start.php b/src/start.php index 8b8bf83..ab1be18 100644 --- a/src/start.php +++ b/src/start.php @@ -4,4 +4,10 @@ * User: Игорь * Date: 23.01.2017 * Time: 00:07 - */ \ No newline at end of file + */ + +require_once __DIR__ . '/../vendor/autoload.php'; + +$app = new \FRM\App(); + +$app->run(); \ No newline at end of file