pastebin

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 444ce2efb7009fe3ecbe58013b0d29ccde2d8ae5
parent 2957fe6c050f45ab82bde21ccf80b4de27c50388
Author: Paul Longtine <paullongtine@gmail.com>
Date:   Fri Dec 20 10:40:07 2013

added stuffs

Diffstat:
 .htaccess                           |   4 +-
 default.page                        | 238 +++++++++++++++++++++++++++++++++++++-
 images/new.png                      | Bin 0 -> 3519 bytes
 images/new0.png                     | Bin 0 -> 18055 bytes
 images/open.jpg                     | Bin 0 -> 9198 bytes
 images/save.png                     | Bin 0 -> 3380 bytes
 images/save0.png                    | Bin 0 -> 10150 bytes
 index.php                           |  63 ++++++++++-
 paste.page                          | 150 +++++++++++++++++++++++-
 sqltable                            |   1 +-
 styles/Open_Sans/OpenSans-Light.ttf | Bin 0 -> 222412 bytes
 11 files changed, 456 insertions(+), 0 deletions(-)

diff --git a/.htaccess b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +#Converting alias to query +RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?id=$1 [QSA,L] +RewriteRule ^([A-Za-z0-9-]+)/?$/raw index.php?id=$1&raw=true [QSA,L] diff --git a/default.page b/default.page @@ -0,0 +1,238 @@ +<!DOCTYPE html> +<html> +<head> + <title>Paste stuff</title> + <link rel="shortcut icon" href="http://nanner.tk/images/favicon.png" type="image/png"> + <style type="text/css"> +@font-face { + font-family: OpenSans; + src: url('./styles/Open_Sans/OpenSans-Light.ttf'); +} +html,body { + width:100%; + height:100%; + background-color:#223344; + overflow-y:hidden; + overflow-x:hidden; +} +* { + padding:0; + margin:0; +} +.error { + z-index:1; + position: fixed; + top:5px; + margin-right:10px; + right:100px; + font-size:20px; + padding:1px; + color:#A9A9A9; + border: 2px solid #8B2323; + border-radius:5px; + background-color:#CC3232; +} +.error:after { + content: ''; + position: relative; + top:8px; + left:8px; + float:right; + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + border-left: 5px solid #8B2323; +} +#controlbox { + position:fixed; + right: 0; + top:0px; + width:100px; + height:42px; + z-index:2; + font-family:OpenSans; + background-color:rgba(26,26,26,0.5); +} +#save:hover:after { + display:inline; + font-size:15px; + padding-left:3px; + color:#EBF4F1; + background-color:#333; + background-color: rgba(0,0,0,.2); + border-bottom-left-radius: 5px; + content: "Save\A control + s"; + white-space: pre; + position: absolute; + top:42px; + right:-3px; + width:100px; + z-index: 99; +} +#save { + cursor:pointer; + margin:5px; + margin-right:11px; + width:32px; + height:32px; + display:inline-block; + background-image:url(./images/save.png); +} +#new:hover:after { + display:inline; + font-size:15px; + padding-left:3px; + color:#EBF4F1; + background-color:#333; + background-color: rgba(0,0,0,.2); + content: "New\A control + m"; + border-bottom-left-radius: 5px; + white-space: pre; + position: absolute; + top:42px; + right:-3px; + width:100px; + z-index: 99; +} +#new { + cursor:pointer; + margin:5px; + margin-left:10px; + width:32px; + height:32px; + display:inline-block; + background-image:url(./images/new.png) +} + +#pasteform { + position: relative; + bottom:12px; + height:100%; +} +#title { + display:inline-block; + position: relative; + top:16px; + height:25px; + background-color:#3A5C83; + border:0; + border-radius: 3px; + box-shadow:0px 0px 3px #223344 inset; + padding:3px; + outline:none; + font-size:20px; + font-family:OpenSans; + color:#BDBDBD; +} +#textarea { + font-family:OpenSans; + width:100%; + height:100%; +} +#textarea label { + position: relative; + top:16px; + font-size:20px; + margin-left:5px; + color:#A9A9A9; + width:100% px -50px; +} +#pastebox { + margin-top:15px; + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif; + z-index:0; + padding:5px; + background-color:#223344; + color:#A9A9A9; + width:100%; + height:100%; + resize:none; + border:none; + outline:none; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +/** Fancy webkit scrollbar for the strong! **/ +::-webkit-scrollbar { + width: 12px; + margin-right:2px; +} + +::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + border-radius: 10px; +} + +::-webkit-scrollbar-thumb { + border-radius: 10px; + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); +} +::-webkit-scrollbar-corner { + background-color:rgba(0,0,0,0); +} + </style> +</head> +<body> + <form id="pasteform" action="index.php" onsubmit="return validate()" method="post"> + <div id="controlbox"> + <div id="save" onclick="pastebin()"></div> + <div id="new" onclick="clearbox()"></div> + </div> + <div id="textarea"> + <label>Title:</label><input type="text" id="title" name="title" autocomplete="off" autocorrect="off" size=""/></span><span id="error"></span> + <textarea form="pasteform" id="pastebox" name="paste" placeholder="Paste something" spellcheck="false" autofocus>%text%</textarea> + </div> + </form> + <script type="text/javascript"> +//keycode things +var isCtrl = false; +document.onkeyup=function(e){ + if(e.keyCode == 17) { + isCtrl=false; + } +} + +document.onkeydown=function(e){ + if (e.keyCode == 17) { + isCtrl=true; + e.preventDefault(); + return false; + } + if (e.keyCode == 83 && isCtrl == true) { + pastebin(); + isCtrl = false; + e.preventDefault(); + return false; + } else if (e.keyCode == 77 && isCtrl == true) { + clearbox(); + isCtrl = false; + e.preventDefault(); + return false; + } +} +function pastebin() { + if (validate()) { + document.getElementById("pasteform").submit(); + } +} +function clearbox() { + document.getElementById("pastebox").value = ""; + document.getElementById("title").value = ""; +} +//Function to validate form +function validate() { + var retVal = true; + if (document.getElementById("pastebox").value == "") { + retVal = false; + document.getElementById("error").setAttribute("class","error"); + document.getElementById("error").innerHTML = "You can't paste nothing!"; + } else if (document.getElementById("title").value == "") { + retVal = false; + document.getElementById("error").setAttribute("class","error"); + document.getElementById("error").innerHTML = "A book needs its title!"; + } + return retVal; +} + </script> +</body> +</html> diff --git a/images/new.png b/images/new.png Binary files differ diff --git a/images/new0.png b/images/new0.png Binary files differ diff --git a/images/open.jpg b/images/open.jpg Binary files differ diff --git a/images/save.png b/images/save.png Binary files differ diff --git a/images/save0.png b/images/save0.png Binary files differ diff --git a/index.php b/index.php @@ -0,0 +1,63 @@ +<?php +if (empty($_POST) && empty($_GET)) { + echo str_replace("%text%", "", file_get_contents("./default.page")); +} else if (!empty($_GET)) { + if (isset($_GET['id'])) { + $con = mysqli_connect("localhost","nanner","6174sql","pastebin"); + $paste = mysqli_query($con,"SELECT paste, title FROM pastes WHERE id= ".mysql_real_escape_string($_GET['id'])); + $pasteContent = mysqli_fetch_array($paste); + $content = "<div class='text'>\n <ol>\n"; + $count = 0; + // Go through each line and print new List element + foreach(preg_split("/((\r?\n)|(\r\n?))/", $pasteContent['paste']) as $line) { + $line = str_replace("&","&amp;", $line); + $line = str_replace(" ","&nbsp;",$line); + $line = str_replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;",$line); + $line = str_replace("<","&#60;", $line); + $line = str_replace(">","&#62;", $line); + $content = $content . "<li><span class='textcontent'> $line </span></li>\n"; + $count = $count + 1; + } + $content = $content . " </ol>\n</div>\n"; + mysqli_close($con); + // Find out how wide the linenumber sidebar should be + $lineNumberWidth = (strlen("$count")*10)+12; + // replace some page variables and echo the result + echo str_replace("%pasteNum%",$_GET['id'], + str_replace("%title%",$pasteContent['title'], + str_replace("%lineNumberWidth%",$lineNumberWidth, + str_replace("%content%","$content",file_get_contents("paste.page"))))); + } else if (isset($_GET['new'])) { + $con = mysqli_connect("localhost","nanner","6174sql","pastebin"); + $paste = mysqli_query($con,"SELECT paste FROM pastes WHERE id= ".mysql_real_escape_string($_GET['new'])); + $pasteContent = mysqli_fetch_array($paste); + $content = ""; + // Go through each line and print new List element + foreach(preg_split("/((\r?\n)|(\r\n?))/", $pasteContent['paste']) as $line) { + $line = str_replace("&","&amp;", $line); + $line = str_replace(" ","&nbsp;",$line); + $line = str_replace("<","&#60;", $line); + $line = str_replace(">","&#62;", $line); + $content = $content . "$line\n"; + } + mysqli_close($con); + echo str_replace("%text%", $content, file_get_contents("./default.page")); + } +} else { + if (isset($_POST['paste']) && $_POST['title']) { + $con = mysqli_connect("localhost","nanner","6174sql","pastebin"); + $paste = mysql_real_escape_string($_POST['paste']); + $title = mysql_real_escape_string($_POST['title']); + $query = "INSERT INTO pastes ( paste, title ) VALUES ( '$paste' , '$title' );"; + if (!mysqli_query($con,$query)) { + die('Error: ' . mysqli_error($con)); + } + $id = mysqli_insert_id($con); + mysqli_close($con); + header("Location: /$id"); + } else { + echo "What did you do!?!??!"; + } +} + +?> diff --git a/paste.page b/paste.page @@ -0,0 +1,150 @@ +<!DOCTYPE html> +<html> +<head> + <title>%title%</title> + <link rel="shortcut icon" href="http://nanner.tk/images/favicon.png" type="image/png"> + <style type="text/css"> +@font-face { + font-family: OpenSans; + src: url('./styles/Open_Sans/OpenSans-Light.ttf'); +} +html,body { + width:100%; + height:100%; + background-color:#3A5C83; +} +* { + padding:0; + margin:0; +} +.text { + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif; + line-height: 21px; + margin-left:%lineNumberWidth%px; + padding-left:9px; + background-color:white; + border-left:1px solid #112233; + background-color:#223344; + color:#223344; +} +.textcontent { + word-wrap:break-word; + color:#A9A9A9; +} +#controlbox { + position:fixed; + right: 0; + width:100px; + height:42px; + z-index:2; + font-family:OpenSans; + background-color:rgba(26,26,26,0.5); +} +#save:hover:after { + display:inline; + font-size:15px; + padding-left:3px; + color:#EBF4F1; + background-color:#333; + background-color: rgba(0,0,0,.2);; + border-bottom-left-radius: 5px; + content: "Copy & Edit\A control + s"; + white-space: pre; + position: absolute; + top:42px; + right:-3px; + width:100px; + z-index: 99; +} +#save { + cursor:pointer; + margin:5px; + margin-right:11px; + width:32px; + height:32px; + display:inline-block; + background-image:url(./images/save.png); +} +#new:hover:after { + display:inline; + font-size:15px; + padding-left:2px; + color:#EBF4F1; + background-color:#333; + background-color: rgba(0,0,0,.2); + content: "New\A control + m"; + border-bottom-left-radius: 5px; + white-space: pre; + position: absolute; + top:42px; + right:-3px; + width:100px; + z-index: 99; +} +#new { + cursor:pointer; + margin:5px; + margin-left:10px; + width:32px; + height:32px; + display:inline-block; + background-image:url(./images/new.png) +} + +/** Fancy webkit scrollbar for the strong! **/ +::-webkit-scrollbar { + width: 12px; + margin-right:2px; + background-color:#223344; + +} + +::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + border-radius: 10px; +} + +::-webkit-scrollbar-thumb { + border-radius: 10px; + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); +} +::-webkit-scrollbar-corner { + background-color:rgba(0,0,0,0); +} + </style> +</head> +<body> + <p id="pastenum" style="display:none">%pasteNum%</p> + <div id="controlbox"> + <div id="save" onclick="pastebin()"></div> + <div id="new" onclick="clearbox()"></div> + </div> + %content% + <script type="text/javascript"> +//keycode things +var isCtrl = false; +document.onkeyup=function(e){ + if(e.keyCode == 17) { + isCtrl=false; + } +} +document.onkeydown=function(e){ + if (e.keyCode == 17) { + isCtrl=true; + } + if (e.keyCode == 83 && isCtrl == true) { + pastebin(); + isCtrl = false; + e.preventDefault(); + } else if (e.keyCode == 77 && isCtrl == true) { + window.location = "."; + isCtrl = false; + e.preventDefault(); + } +} +function pastebin() { + window.location = ".?new="+ document.getElementById("pastenum").innerHTML; +} + </script> +</body> +</html> diff --git a/sqltable b/sqltable @@ -0,0 +1 @@ +CREATE TABLE pastes ( id INT(11) NOT NULL AUTO_INCREMENT, paste LONGTEXT NOT NULL, title VARCHAR(20) NOT NULL, PRIMARY KEY (id) ); diff --git a/styles/Open_Sans/OpenSans-Light.ttf b/styles/Open_Sans/OpenSans-Light.ttf Binary files differ