if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
session_start();
include_once 'config.php';
require('classes/Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'templates/templates';
$smarty->compile_dir = 'templates/templates_c';
$smarty->cache_dir = 'templates/cache';
$smarty->config_dir = 'templates/configurari';
//include clase noi
include 'classes/database.php';
include_once 'classes/employee.php';
include 'classes/shortcode.php';
include 'mailNew.php';
//end include clase noi
//define link location
$segment=explode("/",$_GET['var1']);
$tip=$segment[0];
$idp=$segment[1];
//end define link location
//default title
$title='CNI.ro - File Transfer';
//end default title
//init database
$db=new bazaDate();
$connect=$db->connect($dbhost,$dbname,$dbuser,$dbpass);
//init database
if ($tip=='download' and $idp!='')
{
include_once 'classes/download.php';
$dw=new download();
$content.=$dw->archiveAndDownload($db->cleanVar($idp));
$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->display('index.html');
die();
}
if ($tip=='invitationDownload' and $idp!='')
{
include_once 'classes/download.php';
$dw=new download();
$content.=$dw->archiveAndDownloadInvitation($db->cleanVar($idp));
$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->display('index.html');
die();
}
if ($tip=='invitation' and $idp!='')
{
include_once 'classes/invitation.php';
$dw=new invitation();
$content.=$dw->receive($db->cleanVar($idp));
$_SESSION['invitation']=$idp;
$customJS='';
$smarty->assign('rand', rand(999,99999));
$smarty->assign('dir', $dir);
$smarty->assign('customJS', $customJS);
$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->display('indexInvitation.html');
exit();
}
if ($tip=='successFileInvitation' and $idp=='')
{
$content='
Fisiere au fost trimise! Multumim
';
$title='Fisiere Trimise';
$smarty->assign('rand', rand(999,99999));
$smarty->assign('dir', $dir);
$smarty->assign('customJS', $customJS);
$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->display('indexInvitation.html');
exit();
}
if ($tip=='success' and $idp=='')
{
$content='
Fisiere au fost trimise! Multumim
';
$title='Fisiere Trimise';
}
if ($tip=='successInvitation' and $idp=='')
{
$content='
Invitatia a fost trimisa cu succes! Multumim
';
$title='Fisiere Trimise';
}
//login
if ($_SESSION['employee']<1)
{
if ($_POST['step']=='auth')
{
if (strlen($_POST['utilizator'])>5 and strlen($_POST['parola'])>5)
{
$employee=new employee();
if ($employee->login($_POST['utilizator'],$_POST['parola'])>0) header("Location: ".$dir.'');
else $smarty->assign('errorAuth', 'Eroare autentificare.');
} else $smarty->assign('errorAuth', 'Eroare autentificare');
}
$smarty->display('login.html');
exit();
}
//end login
//logout
if ($tip=='logout')
{
$employee=new employee();
$employee->logout();
}
//end logout
//admin angajati
if ($tip=='adminAngajati' and $_SESSION['employee']>0)
{
include_once 'classes/employee.php';
$user=new employee();
$content=$user->listare();
}
if ($tip=='adaugaAngajat' and $_SESSION['employee']>0)
{
include_once 'classes/employee.php';
$user=new employee();
$content=$user->adauga();
}
if ($tip=='editAngajat' and $_SESSION['employee']>0 and $idp>0)
{
include_once 'classes/employee.php';
$user=new employee();
$content=$user->edit($idp);
}
//end admin angajati
//new file transfer
if ($_SESSION['employee']>0 and $tip=='newFileTransfer')
{
include_once 'classes/fileTransfer.php';
$fileTransfer=new fileTransfer();
$content=$fileTransfer->adauga();
}
//end new file transfer
//sent
if ($_SESSION['employee']>0 and $tip=='sent')
{
include_once 'classes/fileTransfer.php';
$fileTransfer=new fileTransfer();
$content=$fileTransfer->trimise();
}
//end sent
//received
if ($_SESSION['employee']>0 and $tip=='primite')
{
include_once 'classes/fileTransfer.php';
$fileTransfer=new fileTransfer();
$content=$fileTransfer->primite();
}
//end received
//invite
if ($_SESSION['employee']>0 and $tip=='invite')
{
include_once 'classes/invitation.php';
$fileTransfer=new invitation();
$content=$fileTransfer->send();
}
//end invite
if ($_SESSION['employee']>0)
$customJS='';
else
if ($tip=='invitation')
$customJS='';
$smarty->assign('customJS', $customJS);
$smarty->assign('employeeName', $_SESSION['employeeName']);
$smarty->assign('postSearch', $_POST['search']);
$isAdmin=$db->getField("SELECT admin from employees where id='".$_SESSION['employee']."' LIMIT 1",'admin');
if ($isAdmin)
$smarty->assign('admin', '
Utilizatori');
$smarty->assign('rand', date("YmdHis"));
$smarty->assign('dir', $dir);
$smarty->assign('hour',date("H:i"));
$smarty->assign('title', $title);
$smarty->assign('content', $content);
switch ($tip) {
case 'invitation':
$smarty->display('indexInvitation.html');
break;
default:
$smarty->display('index.html');
}
?>