Compose Page

Encrypted Messenger PHP

trim

The trim() function removes whitespace and other predefined characters from both sides of a string.
Related functions:
ltrim() – Removes whitespace or other predefined characters from the left side of a string
rtrim() – Removes whitespace or other predefined characters from the right side of a string

time

The time() function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

unset

The unset() function destroys a given variable

Create a file named index.php


<?php
function secured_error () { die("Secured By Omid Bahrami"); }
set_error_handler("secured_error");

require '../secured/secured-structure.php';
require '../secured/secured-database.php';
require '../secured/secured-encryption.php';
require '../secured/secured-validation.php';

session_start();
gns_check_https();

if(!isset($_SESSION["secured"]))
header('location:../sign-in/');

$e1=$e2=$e3=FALSE;

if(isset($_POST["send"]))
{

$gt=array("taker"=>"user" , "subject"=>"sub" , "msg"=>"txt" );
if(gns_check_form($gt))
{

$xkx=gns_hash_fix($_POST["taker"]);
if(!gns_check_user($xkx))
{

$xsx=gns_hash_fix($_SESSION["secured"]);
$xjx=gns_encode( trim($_POST["subject"]) );
$xmx=gns_encode( trim($_POST["msg"]) );
$xdx=gns_encode(time());
$xxsx=gns_encode($_SESSION["secured"]);
$xxkx=gns_encode($_POST["taker"]);

gns_new($xsx,$xkx,$xjx,$xmx,$xdx,$xxsx,$xxkx);
$e1=TRUE;
unset($_POST);

}

else
$e3=TRUE;

}

else
$e2=TRUE;

}

?>
<?php
$t=$_SESSION["secured"];
gns_head_pro($t);
?>
<div class="jumbotron">
<?php

if($e1)
echo '<p class="text-primary text-center"> Message Has Been Sent </p>';

else if($e2)
echo '<p class="text-primary text-center"> Check your Input </p>';

else if($e3)
echo '<p class="text-primary text-center"> Username Not Found </p>';

else
gns_welcome("Compose");

?>
</div>
<div class="jumbotron">
<form id="form1" name="form1" method="post">
<table class="table table-condensed" style="max-width: 500px" align="center">
<tbody>
<tr>
<td>
<input type="text" name="taker" id="taker" class="form-control" placeholder="<?php if(!gns_show_error("taker")) echo "To"; ?>" value="<?php if(!$e3) gns_show_value("taker"); ?>">
</td>
</tr>
<tr>
<td>
<input type="text" name="subject" id="subject" class="form-control" placeholder="<?php if(!gns_show_error("subject")) echo "Subject"; ?>" value="<?php gns_show_value("subject"); ?>">
</td>
</tr>
<tr>
<td>
<textarea name="msg" id="msg" class="form-control" placeholder="<?php if(!gns_show_error("msg")) echo "Message"; ?>">
<?php gns_show_value("msg"); ?>
</textarea>
</td>
</tr>
<tr>
<td> <input type="submit" name="send" id="send" value="Send" class=" btn btn-primary"> </td>
</tr>
</tbody>
</table>
</form>
</div>
<?php gns_foot(); ?>

Full structure is available at Encrypted Messenger PHP