Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.25 KB | None | 0 0
  1. @media screen and (min-width: 641px) and (max-width: 1023px) { }----input[type="text"] s=11//a[href^="mailto:"] ξεκιναει//a[href$=".pdf"] ληγει//[attribute*=value] το περιεχει //a[rel~="tag"] κενα και μια εξ αυτων ειναι η value// p[lang|="en"] διαχ με παυλες----:visited αν εχει επισκευτει την σελιδα//:active αν ο χρηστης πχ εχει πατησει αριστερο κλικ και δεν το εχει// αφησει ακομα //:focus δεχεται πχ εισοδο απο το πληκτρολογιο---E > F goneas > paidi s=2//E F progonos apogonos//E + F επιλεγει τα φ που εχουν κοινο γονεα απο τα ε// και τα φ εινα δεξα απο τα ε//E ~ F διαλεγει τα φ που υπαρχει αριστερα τους τουλαχιστον ενα ε--::first-letter//::first-line//::before / ::after s=1----:nth-child(an+b)//s=10//:nth-last-child(an+b)//:nth-of-type()//:nth-last-of-type()//
  2. p:nth-of-type(even) ζυγα//το n ξεκιναει απο το 0----:foo, * { background: red; } den kanei tipota----s//a inline //b ids//c classes attributes pseudoclasses//d elements pseudo-elements----p#foo.error.message ειναι ρ KAI id="foo" ΚΑΙ την class "error" ΚΑΙ την class "message")----:not(simple_selector) δεχεται μονο απλους selectors//input:not([disabled])----Author stylesheets >User stylesheets >User Agent stylesheet////color:red !important;-> Authorstylesheets <User stylesheets <User Agent stylesheets----πρωτα προελευση και !important μετα specifisity and importnat! αλλιως παρε το τελευταιο/-----
  3. pt (72pt = 1in), pc (1pc = 12pt)//em σχετικο με το μεγεθος της γραμματοσειρας///vh, vw, vm: σχετικα με το μεγεθος του viewport----width kai height den ephreazoun inline elements/////position: absolute; μας δινει τον απολυτο ελεγχο της θεσης του στοιχειου στην σελιδα////// position: fixed οι συντεταγμενες του στοιχειου προσδιοριζονται βασει του παραθυρου του φυλλομετρητη---- Η clear ακυρωνει το φλοατ και παιρνει τιμες left right both none/-/-/-/-/-/-/-/--/--/--js
  4. var headings = document.querySelectorAll(‘h2:not(.no-toc)’)//document.querySelector()μονο το πρωτο στοιχειο// document.getElementsByTagName()// document.getElementById()--typeof Επιστρέφει τον τύπο μιας μεταβλητής ως string///η έκφραση 6, 5*4, typeof 3 επιστρέφει 'number'///'undefined', 'boolean', 'number', 'string', 'function', 'object'//typeof null; // 'object'//typeof new String('foo'); // 'object'---var obj = new Object();//obj.foo = 'bar';//'foo' in obj // true//delete obj.foo;//obj.foo; // undefined//'foo' in obj // false//'foo' in { foo: undefined } // true//---
  5. for(var property in object) {document.write(property + ': ' + object[property]);}---5 === new Number(5); // Επιστρέφει false//5 === (new Number(5)).valueOf(); // Επιστρέφει true---var foo = function() { return 5; };//typeof foo; // Επιστρέφει "function"//typeof foo(); // Επιστρέφει "number"//var bar = foo; bar(); // Επιστρέφει 5//foo instanceof Function; // Επιστρέφει true//(function(x) { return x % 2; })(3); // Επιστρέφει 1---var foo = function(x) { return arguments.length; };//foo(1, 2, 3); // Επιστρέφει 3//foo.length; // Επιστρέφει 1//----// Έλεγχος για RegExp//var foo = /^[a-z]+$/i;//typeof foo; // 'object'//Object.prototype.toString.call(foo) == '[object RegExp]'; // true//----document.createElement(tagName)//document.createTextNode(data)//document.createDocumentFragment()//----
  6. list.removeChild(listItem);//function removeNode(node) {//if(node && node.parentNode &&//node.parentNode.removeChild) {//return node.parentNode.removeChild(node);//}//}----container.innerHTML = 'Easy <abbr>HTML</abbr> creation';// versus:///
  7. container.appendChild(document.createTextNode('Easy '));var abbr = document.createElement('abbr');abbr.appendChild(document.createTextNode('HTML');
  8. container.appendChild(abbr);container.appendChild(document.createTextNode(' creation'));------item.addEventListener('mousedown', function() {//item.addEventListener('mousemove', callback, false);//}, false);//item.addEventListener('mouseup', function() {//item.removeEventListener('mousemove', callback, false);//}, false);//--------button.onclick = function() { alert('I was clicked'); };----¨dispatchEvent() για να πυροδοτησεις ενα εβεντ---
  9. Set-Cookie: style=minimal; expires=Sat, 17 Apr 2010 20:03:48 GMT;path=/; domain=.aueb.gr; secure///
  10. Cookie: style=minimal; productids=14841,435,28,2505---document.addEventListener('DOMContentLoaded', function () {//var headings = document.querySelectorAll('h2:not(.no-toc)'),// tocList = createElement({// tagName: 'ol',//properties: {className: 'toc'}//});//for (var i = 0; i < headings.length; i++) {// var tocItem = headings[i].textContent;// if (headings[i].id) {//tocItem = createElement({//tagName: 'a',// properties: {href: '#' + headings[i].id},//content: tocItem// });// }//createElement({//tagName: 'li',//content: tocItem,//parent: tocList//});//}//var toc = document.createDocumentFragment(); //createElement({//tagName: 'h2',//properties: {id: 'contents', className: 'no-toc'},//content: 'Table of contents',//parent: toc// });// toc.appendChild(tocList);//headings[0].parentNode.insertBefore(toc, headings[0]);//}, false);------function createElement(options) {var element = document.createElement(options.tagName);if (options.properties) {for (var i in options.properties) { element[i] = options.properties[i];}}if (options.content) {var content = typeof options.content === 'string' ?document.createTextNode(options.content): options.content;element.appendChild(content);}return options.parent ? options.parent.appendChild(element) : element;}//--/-/-/-/-/-/-//-/-/-/-/-/-/-/-/-/-ajax-/---/-/-/var http = new XMLHttpRequest(); //var params = "action=change&productId='" + ev.target.id + "'&quantity='" + index[0] + "'";//http.open("POST", url, true);//http.setRequestHeader ("Content-type", "application/x-www-form-urlencoded");//http.send(params);// http.onreadystatechange = function () {//Call a function when the state changes//if (http.readyState == 4 && http.status == 200) {//if ((http.responseText).startsWith("INFO:")) {//}}};----πρεπει readystate==4 και response =200-/-/-/-/-/-/patterns password="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,}" username ".{2,}" email "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" telephone "^\d{10}$"-/-/-/-/-/-svg-/-/-/--/-/--/
  11. <circle r="100" cx="50%" cy="50%" fill="rgb(165, 171, 129)" fill-opacity=".5" stroke="rgb(221, 128, 71)" stroke-opacity=".3" stroke-width="20" /><rect width="300" height="200" rx="10" /> <circle r="100" cx="50%" cy="50%" /> <ellipse rx="150" ry="100" cx="50%" cy="50%" /> <line x1="0" y1="0" x2="100%" y2="100%" stroke="black" /> <polyline points="0,0 100,25 0,50 100,75 0,100" stroke="gray" fill="none" /> <polygon points="100,100 0,100 100,0" />//////////<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="hot" x1="0%" y1="0%" x2="0%" y2="100%"> <stop offset="0%" style="stop-color:yellow;"/> <stop offset="100%" style="stop-color:red; "/> </linearGradient> </defs> <circle cx="200" cy="150" r="50" style="fill:url(#hot)" /> </svg>-/-/-/-/-/-/-/-/-/-/-/-/-/--/php/-/-/-/--/-/-/-/-/--/ιs_int()//is_float()//is_string()//--$stooges = array('Larry', 'Curly', 'Moe'); print $stooges[0];//--$foo = 'bar'; $$foo = 'funky'; # τώρα έχουμε $bar = 'funky'//$foo =& $bar # τώρα το $foo είναι alias για το $bar//$foo = "bar"; $foo2 =&$foo; unset($foo); print $foo2; # Εμφανίζει bar//define('THIS_SCRIPT', 'home'); define('THIS_SCRIPT', 'foo'); echo THIS_SCRIPT // τυπώνει home//--
  12. define('LUCKY_NUMBERS', [4, 8, 15, 16, 23, 42]);//--function foo() { static $a = 1; return $a++; // κάθε φορά αυξάνεται } echo $a; // Κενό//--unset($foo); για απελευθερωση μνημης //--$a = "5"; $b = (int) $a;//--τελεστή <=> για σύγκριση εκφράσεων: επιστρέφει -1, 0 και 1 αν το αριστερό μέλος είναι μικρότερο, ίσο ή μεγαλύτερο αντίστοιχα από το δεξί μέλος//--$username = $_GET['user'] ?? 'nobody';//επέστρεψε 'nobody' αν είναι NULL//--foreach ($array as &$value) { $value *= 2; }//χωρίς να απαιτείται σύνταξη τύπου $array[$key]//--$len = strlen("UCSD"); // $len = 4//--function add2($x) {// return $x+2; //} //$result = add2(5);// echo $result;//--function add($x, $y=1) { return $x + $y; } //echo add(5); // τυπώνει 6 //echo add(5, 10); // τυπώνει 15//--function foo() {// print 'I have ' . func_num_args(); //print 'First argument 1 = ' . func_get_arg(0); //print_r(func_get_args()); }//--$x = 'foo'; //$x(); // καλεί την foo()//----
  13. $add = function($y) { return function($x) use($y){return $x+$y;}; }; $add2 = $add(2); $add3 = $add(3); echo $add2(4); // 6 echo $add3(4); // 7//----
  14. αντικειμενοστρεφεια class BankAccount{ //private $balance; //public function setBalance($balance){ //$this->balance = $balance; //} //public function getBalance(){ //return $this->balance; //}// }//----σταθερες class BankAccount { //const MIN_BALANCE = 20; //public __construct($initial_balance){// if($initial_balance < self::MIN_BALANCE) { //throw new Exception('More money needed :('); //} } }//----κληρονομικοτητα class Father { public function printItem($string){ echo 'Father: ' . $string . PHP_EOL; } public function printHuman(){ echo 'I am human' . PHP_EOL; } } class Child extends Father { public function printItem($string){ echo 'Child: ' . $string . PHP_EOL; } } $father = new Father(); $child = new Child(); $father->printItem('abc'); // Output: 'Father: abc' $father->printHuman(); // Output: 'I am human' $child->printItem('abc'); // Output: 'Child: abc' $child->printHuman(); // Output: 'I am human'//----
  15. κατασκευαστης function __construct(){ $this->balance = 50; }//---- __get($property) και __set($property, $value) μαγικες μεθοδοι//----
  16. δημιουργια cookie <?php setcookie('name','Moe'); setcookie('numstooges','3'); ?> <html> <head><title>Simple Cookie</title></head> <body> <h1>I just "baked" a cookie</h1> <a href="cookie2.php">See what's in the cookie</a> <form> <input type="button" value="JS Cookie Check" onclick="alert(document.cookie);"> </form> </body> </html>///<html> <head><title>Show Cookie</title></head> <body> <?php print ("There are ". $_COOKIE['numstooges'] ." stooges and the main one is named " . $_COOKIE['name']); ?> </body> </html>/////-----// expires in 1 hour setcookie('color', 'green',time()+3600); // limit to admin directory path setcookie('userid', 'admin',time()+3600, '/admin'); // use security in transmit setcookie('userid', 'admin',time()+3600, '/admin', '', 1);////----
  17. παραδειγμα συνοδων //1//<?php session_start(); $_SESSION['fav_stooge']='Moe'; $_SESSION['num_stooges']=3; ?> <html <head> <title>Session Fun</title> </head> <body> <h1>Just set some session values</h1> <a href="session2.php">Next page</a> <!–- eventually read this later on session3.php --> </body> </html>///2//<html <head> <title>Session Fun</title> </head> <body> <h1>Reading session variables</h1> <?php session_start(); print "There are ".$_SESSION['num_stooges'] ." and my favorite is ". $_SESSION['fav_stooge']; ?> </body> </html>///--------παραδειγμα smarty//<?php require './smarty/libs/Smarty.class.php'; // Path to Smarty $smarty = new Smarty; $smarty->template_dir = './templates/'; // Path to templates $smarty->assign('Username', 'Mr. Smarty'); $smarty->display('index.tpl'); ?>///<!doctype html> <html> <head> <title>Hello Smarty</title> </head> <body> Hello world {$Username}! </body> </html>////----ασφαλεια---<?php $stmt = $dbConnection->prepare('SELECT * FROM users WHERE username = ? and password = ?'); $stmt->bind_param('ss', $user, $pwd); $stmt->execute(); $result = $stmt->get_result(); ?>///---αποτροπη xxsattack <?php // validate comment $comment = trim($_POST["comment"]); if (empty($comment)) { exit("You must provide a comment"); } // sanitize comment $comment = strip_tags($comment); file_put_contents("comments.txt", $comment, FILE_APPEND); // escape comments before display $comments = file_get_contents("comments.txt"); echo htmlspecialchars($comments); ?>/////---Cross-Site Request Forgery αντιμετρα Αποθήκευση της τιμής του token στον server. <?php $_SESSION['token'] = md5(uniqid(rand(), TRUE); ?>////Ενσωμάτωση του token στις φόρμες HTML, σε κρυφό πεδίο, και αποστολή του σε κάθε request στο server που αντιστοιχεί σε αλλαγή του sτατε///<form action= "transfer.php" method="post"> <input type="hidden" name="token" value="<?php echo $token; ?>" /> <input type="text" name="acct" /><br /> <input type="number" name="amount" min="0" /><br /> <input type="submit" value="Transfer" /> </form>////Σύγκριση και έλεγχος του token στον server έπειτα από κάθε request και πριν την εκτέλεσή του.///<?php if ($_POST['token'] == $_SESSION['token']) { /* Do transaction */ } ?> ///φορμα εμαιλ///----<form action="contact.php" method="post" id="contactform"> <ol> <li><label>Όνομα: <input type="text" name="name"></label></li> <li><label>Email: <input type="email" name="email"></label></li> <li><label>Website: <input type="url" name="website"></label></li> <li><label>Το μήνυμα σας: <textarea name="message"></textarea></label></li> <li> <label> <input type="checkbox" name="subscribe" value="1"> Θέλω να λάβω ένα αντίγραφο </label> </li> </ol> <button type="submit">Αποστολή</button> </form>//'; $message = $_POST['message'] . "\r\n\r\nWebsite:" . $_POST['website']; mail( 'auebweb@gmail.com' . ($_POST['subscribe']? ', ' . $sender : ''), 'New mail from contact form' // Subject $message, 'From:' . $sender; // Extra headers ); ?>//ολο το προηγουμενο το βαζεις μεσα σε αυτο για να ειναι user friendly και ασφαλες //<?php $errors = array(); // Υπάρχει όνομα; if(!$_POST['name']) { $errors[] = 'δεν συμπληρώσατε το όνομα σας'; } // Υπάρχει email; Μοιάζει με (ένα) email; if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = 'Το email δεν φαίνεται σωστό'; } // Υπάρχει μήνυμα; if(!$_POST['message']) { $errors[] = 'Δεν γράψατε μήνυμα'; }if(sizeof($errors) > 0) { // Υπάρχουν σφάλματα, εμφάνιση αυτών echo 'Συνέβησαν σφάλματα:<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; } else { // Δεν υπάρχουν σφάλματα // αποστολή email echo 'To email εστάλη επιτυχώς.'; } ?>///-----
  18. φορμα δημοτικοτητας μαθηματος <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>PHP Example</title> </head> <body> <h3>Do you like the class so far?</h3> <form name="survey" action="survey.php" method="POST" > Yes: <input type="radio" name="vote" value="0" /><br /> No: <input type="radio" name="vote" value="1" /><br /> <input type ="submit" value ="Submit" /> </form> </body> </html>////<?php $vote = $_REQUEST['vote']; //get content of textfile $filename = "survey_result.txt"; $content = file($filename); //put content in array $array = explode("||", $content[0]); $yes = $array[0]; $no = $array[1]; if ($vote == 0) { $yes = $yes + 1; } if ($vote == 1) { $no = $no + 1; } //insert votes to txt file $insertvote = $yes."||".$no; $fp = fopen($filename,"w"); fputs($fp,$insertvote); fclose($fp); ?>//… <h2>Result:</h2> <table> <tr> <td>Yes:</td> <td> <?php echo(100*round($yes/($no+$yes),2)); ?>% </td> </tr> <tr> <td>No:</td> <td> <?php echo(100*round($no/($no+$yes),2)); ?>% </td> </tr> </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement