diff --git a/code/assets/js/app.js b/code/assets/js/app.js
index 66276cd1edebe865c380e7105cdbe181b361d1ee..2b17d7d04821ef71bcbc7f69e308e6432e36c8a5 100644
--- a/code/assets/js/app.js
+++ b/code/assets/js/app.js
@@ -10,135 +10,3 @@ if( navigator.userAgent.match(/Android/i) ||
){
isMobile = true;
}
-
-$(document).ready(function() {
-
- // Global vars
- var $artHeaderInner = $('.art-header-inner');
- var $artHeader = $('.art-header');
- var $artTitle = $('.art-title');
- var $artSubtitle = $('.art-subtitle');
- var $artTime = $('.art-time');
- var artTitleFontSize = parseInt($artTitle.css('font-size'));
- var $nav = $('.nav');
- var windowScroll;
-
- // Apply Fittext to article titles to make it scale responsively in a smooth fashion
- $artTitle.fitText(1, { minFontSize: '34px' });
-
- // Identify if visitor has a large enough viewport for parallaxing title
- function isLargeViewport() {
- if($nav.css('position') == "relative") {
- return false;
- } else {
- return true;
- }
- }
-
- // If large viewport and not mobile, parallax the title
- if(!isMobile) {
- $(window).scroll(function() {
- if(isLargeViewport()) {
- slidingTitle();
- }
- });
- }
-
- // Window gets large enough, need to recalc all parallaxing title values
- $(window).resize(function() {
- if(isLargeViewport()) {
- slidingTitle();
- }
- });
-
- // Functional parallaxing calculations
- function slidingTitle() {
- //Get scroll position of window
- windowScroll = $(this).scrollTop();
-
- //Slow scroll of .art-header-inner scroll and fade it out
- $artHeaderInner.css({
- 'margin-top' : -(windowScroll/3)+"px",
- 'opacity' : 1-(windowScroll/550)
- });
-
- //Slowly parallax the background of .art-header
- $artHeader.css({
- 'background-position' : 'center ' + (-windowScroll/8)+"px"
- });
-
- //Fade the .nav out
- $nav.css({
- 'opacity' : 1-(windowScroll/400)
- });
- }
-
- // Link to top of page without changing URL
- $('.back-to-top a').click(function(e) {
- e.preventDefault();
- $(window).scrollTop(0);
- })
-
- // Cover image of the header
- var $postImage = $('img[alt="cover"]');
- if ( $postImage.length ) {
- var postImageURL = $postImage.attr('src');
- $('.art-header').css('background-image','url(' + postImageURL + ')');
- $('.art-header').css('background-size','100%');
-
- // Change color scheme to white
- $('#logo h1').css('color','white');
- $('.art-title').css('color','white');
- $('.art-subtitle').css('color','white');
- $('.art-time').css('color','white');
- $('.nav-primary li a').css('color','white');
-
- // Add Text Shadows
- $('.art-title').css('text-shadow','3px 3px 0 rgba(0,0,0,0.1), -1px -1px 0 rgba(0,0,0,0.1), 1px -1px 0 rgba(0,0,0,0.1), -1px 1px 0 rgba(0,0,0,0.1), 1px 1px 0 rgba(0,0,0,0.1)');
- $('.art-subtitle').css('text-shadow','3px 3px 0 rgba(0,0,0,0.1), -1px -1px 0 rgba(0,0,0,0.1), 1px -1px 0 rgba(0,0,0,0.1), -1px 1px 0 rgba(0,0,0,0.1), 1px 1px 0 rgba(0,0,0,0.1)');
- $('.art-time').css('text-shadow','3px 3px 0 rgba(0,0,0,0.1), -1px -1px 0 rgba(0,0,0,0.1), 1px -1px 0 rgba(0,0,0,0.1), -1px 1px 0 rgba(0,0,0,0.1), 1px 1px 0 rgba(0,0,0,0.1)');
-
- }
- $postImage.remove();
-
- // Subtitles
- var $subtitle = $('span[id="subtitle"]');
- if ( $subtitle.length ) {
- var subtitleText = $('#subtitle').text();
- $('.art-subtitle').html(subtitleText);
-
- }
- $subtitle.remove();
-
- // Make punctuation smarter
- jQuery.fn.smarten = (function() {
-
- function smartenNode(node) {
- if (node.nodeType === 3) {
- node.data = node.data
- .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // Opening singles
- .replace(/'/g, "\u2019") // Closing singles & apostrophes
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c") // Opening doubles
- .replace(/"/g, "\u201d") // Closing doubles
- .replace(/--/g, "\u2013") // En dashes
- .replace(/---/g, "\u2014") // Em dashes
- .replace(/\.{3}/g, "\u2026"); // Ellipsis
- } else if (node.nodeType === 1) {
- if (node = node.firstChild) do {
- smartenNode(node);
- } while (node = node.nextSibling);
- }
- }
-
- return function() {
- return this.each(function(){
- smartenNode(this);
- });
- };
-
- }());
-
- // Instantiation
- $('article').smarten();
-
-});
\ No newline at end of file
diff --git a/code/assets/js/deffiehelman.js b/code/assets/js/deffiehelman.js
index 86e984f32b0d564d1762fc84bc4a91da27a9edd6..d76041b714e1df94ddf7baae30cb478d553e6f53 100644
--- a/code/assets/js/deffiehelman.js
+++ b/code/assets/js/deffiehelman.js
@@ -1,4 +1,4 @@
-const MAX_RAND = 2000;
+const MAX_RAND = 50;
const MIN_RAND = 0;
@@ -36,19 +36,42 @@ function deffiehelman() {
sharedPublicServer = xhttp.responseText;
- alert("client sharedPublicServer = "+sharedPublicServer);
+ //alert("client sharedPublicServer = "+sharedPublicServer);
randomPrivate = generateNumber();
var sharedPublicClient = new BigNumber(computePublic(number1,randomPrivate,number2));
- alert("sharedPublicClient = "+sharedPublicClient);
+ //alert("sharedPublicClient = "+sharedPublicClient);
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "deffiehelman.php?action=2&sharedPublicClient="+sharedPublicClient, false);
xhttp.send();
sharedKey = sharedPrivate(sharedPublicServer,randomPrivate,number2);
- alert("sharedKey = "+sharedKey);
+ // alert("sharedKey = "+sharedKey);
// alert(xhttp.responseText);
return sharedKey;
}
+
+
+
+
+/*
+ * Returns the result of having each alphabetic letter of the given text string shifted forward
+ * by the given amount, with wraparound. Case is preserved, and non-letters are unchanged.
+ * Examples:
+ * caesarShift("abz", 0) = "abz"
+ * caesarShift("abz", 1) = "bca"
+ * caesarShift("abz", 25) = "zay"
+ * caesarShift("THe 123 !@#$", 13) = "GUr 123 !@#$"
+ */
+function caesarShift(text, shift) {
+ var result = "";
+ for (var i = 0; i < text.length; i++) {
+ var c = text.charCodeAt(i);
+ if (c >= 65 && c <= 90) result += String.fromCharCode((c - 65 + shift) % 26 + 65); // Uppercase
+ else if (c >= 97 && c <= 122) result += String.fromCharCode((c - 97 + shift) % 26 + 97); // Lowercase
+ else result += text.charAt(i); // Copy
+ }
+ return result;
+}
\ No newline at end of file
diff --git a/code/assets/js/fittext.js b/code/assets/js/fittext.js
index 035baa365fddc369c413720fdd4cd707f4f8e740..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/code/assets/js/fittext.js
+++ b/code/assets/js/fittext.js
@@ -1,46 +0,0 @@
-/*global jQuery */
-/*!
-* FitText.js 1.0
-*
-* Copyright 2011, Dave Rupert http://daverupert.com
-* Released under the WTFPL license
-* http://sam.zoy.org/wtfpl/
-*
-* Date: Thu May 05 14:23:00 2011 -0600
-*/
-$(document).ready(function() {
-
-(function( $ ){
-
- $.fn.fitText = function( kompressor, options ) {
-
- // Setup options
- var compressor = kompressor || 1,
- settings = $.extend({
- 'minFontSize' : Number.NEGATIVE_INFINITY,
- 'maxFontSize' : Number.POSITIVE_INFINITY
- }, options);
-
- return this.each(function(){
-
- // Store the object
- var $this = $(this);
-
- // Resizer() resizes items based on the object width divided by the compressor * 10
- var resizer = function () {
- $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
- };
-
- // Call once to set.
- resizer();
-
- // Call on resize. Opera debounces their resize by default.
- $(window).on('resize', resizer);
-
- });
-
- };
-
-})( jQuery );
-
-});
\ No newline at end of file
diff --git a/code/deffiehelman.php b/code/deffiehelman.php
index 62d45fd7f044283c7419186aaad1778ba7024bc6..f85b73a3b2b164b3477d16988d4def6f63505184 100644
--- a/code/deffiehelman.php
+++ b/code/deffiehelman.php
@@ -1,6 +1,6 @@
<?php
session_start();
- define ("MAX_INT",2000);
+ define ("MAX_INT",50);
// include 'mainviewer.php';
diff --git a/code/new_post.php b/code/new_post.php
index 1e13e69a81e8096c4b96692eb82b7b3f5a09aa78..cbcc79b1ab53bab2edcf2dcf2200f68964b62e4d 100644
--- a/code/new_post.php
+++ b/code/new_post.php
@@ -62,7 +62,7 @@
<div class="art-body-inner">
<h2 style="margin-top: 24px;">Tambah Post</h2>
<div id="contact-area">
- <form name="PostForm" method="post" onSubmit="return validateDate()" action="new_post_action.php" enctype="multipart/form-data">
+ <form name="PostForm" method="post" onSubmit="return createNewPost()" action="new_post_action.php" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>" />
<label for="Judul">Judul:</label>
<input type="text" name="Judul" id="Judul" required>
@@ -105,7 +105,44 @@
</div>
+<script type="text/javascript" src="assets/js/app.js"></script>
+<script type="text/javascript" src="assets/js/respond.min.js"></script>
+<script type="text/javascript" src="assets/js/newpost.js"></script>
+<script type="text/javascript" src="assets/js/deffiehelman.js"></script>
+<script type="text/javascript" src="assets/js/bignumber.js"></script>
<script>
+ var ga_ua = '{{! TODO: ADD GOOGLE ANALYTICS UA HERE }}';
+
+ (function(g,h,o,s,t,z){g.GoogleAnalyticsObject=s;g[s]||(g[s]=
+ function(){(g[s].q=g[s].q||[]).push(arguments)});g[s].s=+new Date;
+ t=h.createElement(o);z=h.getElementsByTagName(o)[0];
+ t.src='//www.google-analytics.com/analytics.js';
+ z.parentNode.insertBefore(t,z)}(window,document,'script','ga'));
+ ga('create',ga_ua);ga('send','pageview');
+</script>
+</body>
+</html>
+<?php
+ }else{
+ header("Location: login.php"); /* Redirect browser */
+ exit();
+ }
+ ?>
+
+<script>
+
+ function createNewPost(){
+ if (validateDate()){
+ var shared_key = deffiehelman();
+ // document.getElementById('Judul').textContent =
+ document.getElementById('Judul').value = (caesarShift(document.getElementById('Judul').value, shared_key%25));
+ document.getElementById('Konten').value = (caesarShift(document.getElementById('Konten').value, shared_key%25));
+
+ }else{
+ return false;
+ }
+ }
+
function validateDate()
{
var inputdate = document.forms["PostForm"]["Tanggal"].value;
@@ -151,26 +188,4 @@
}
}
}
-</script>
-<script type="text/javascript" src="assets/js/fittext.js"></script>
-<script type="text/javascript" src="assets/js/app.js"></script>
-<script type="text/javascript" src="assets/js/respond.min.js"></script>
-<script type="text/javascript" src="assets/js/newpost.js"></script>
-<script>
- var ga_ua = '{{! TODO: ADD GOOGLE ANALYTICS UA HERE }}';
-
- (function(g,h,o,s,t,z){g.GoogleAnalyticsObject=s;g[s]||(g[s]=
- function(){(g[s].q=g[s].q||[]).push(arguments)});g[s].s=+new Date;
- t=h.createElement(o);z=h.getElementsByTagName(o)[0];
- t.src='//www.google-analytics.com/analytics.js';
- z.parentNode.insertBefore(t,z)}(window,document,'script','ga'));
- ga('create',ga_ua);ga('send','pageview');
-</script>
-</body>
-</html>
-<?php
- }else{
- header("Location: login.php"); /* Redirect browser */
- exit();
- }
- ?>
+</script>
\ No newline at end of file
diff --git a/code/new_post_action.php b/code/new_post_action.php
index 6c173d34547aa08f9ff784921f096017083de2e7..297d7382cdca3f0a35eaea352a918da0f688e64f 100644
--- a/code/new_post_action.php
+++ b/code/new_post_action.php
@@ -40,32 +40,46 @@ if (isset($_SESSION["isLogin"]) && (isset($_POST['csrf_token']) && $_POST['csrf_
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.<br>";
- } else {
- echo "Sorry, there was an error uploading your file.<br>";
- }
- }
+ $con = phpsqlconnection();
- $con = phpsqlconnection();
+ $stmt = $con->prepare("INSERT INTO post (Post_Id, Creator_Id, Title, Date, Contents, Image)
+ VALUES (NULL,?,?,?,?,?)");
+ $stmt->bind_param('issss', $creatorid, $Judul, $Tanggal, $Konten, $target_file);
+ $stmt->execute();
+ // $result = $stmt->get_result();
- $stmt = $con->prepare("INSERT INTO post (Post_Id, Creator_Id, Title, Date, Contents, Image)
- VALUES (NULL,?,?,?,?,?)");
- $stmt->bind_param('issss', $creatorid, $Judul, $Tanggal, $Konten, $target_file);
- $stmt->execute();
- // $result = $stmt->get_result();
+ // $sql = "INSERT INTO post (Post_Id, Creator_Id, Title, Date, Contents, Image)
+ // VALUES (NULL".",".$creatorid.","."'".$Judul."'".","."'".$Tanggal."'".","."'".$Konten."'".","."'".$target_file."')";
+ if ($stmt->execute()) {
+ // echo "Huba";
+ header("Location: index.php");
+ } else {
+ echo "Error: " . $sql . "<br>" . mysqli_error($con);
+ }
- // $sql = "INSERT INTO post (Post_Id, Creator_Id, Title, Date, Contents, Image)
- // VALUES (NULL".",".$creatorid.","."'".$Judul."'".","."'".$Tanggal."'".","."'".$Konten."'".","."'".$target_file."')";
- if ($stmt->execute()) {
- // echo "Huba";
- header("Location: index.php");
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($con);
+ die();
+ } else {
+ echo "Sorry, there was an error uploading your file.<br>";
+ }
}
- die();
+
}else{
header("Location: login.php"); /* Redirect browser */
}
+
+function decryptCaesar($encrypted_text, $key){
+ $alphabet=array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
+ //positions of the letters in alphabet
+ $flip=array_flip($alphabet);
+
+ $decrypted_text='';
+ for ($i=0; $i<$n; $i++)
+ //decryption
+ $decrypted_text.=$alphabet[(26+$flip[$encrypted_text[$i]]-$key)%26];
+ return $decrypted_text;
+}
+
?>
\ No newline at end of file
diff --git a/code/post.php b/code/post.php
index 09f0f155b9ae88cf625078c0fff2407b57590f22..c39d4406510edd4d964f706425d2afd10c403478 100644
--- a/code/post.php
+++ b/code/post.php
@@ -102,7 +102,7 @@
?>
<label for="Komentar">Komentar:</label><br>
- <textarea name="Komentar" rows="20" cols="20" id="Komentar"></textarea>
+ <textarea name="Komentar" rows="20" cols="20" id="Komentar" required></textarea>
<input type="submit" name="submit" value="Kirim" class="submit-button">
</form>