<?php
/* 
----------------------------------------------------------
  MODULE : APP CONFIG 
  V1.0 / 2018
  AUTHOR : SGHAIER MAHMOUD  
----------------------------------------------------------
*/

error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

/* 
---  db constants   --- 
*/
/*
const db_host = 'localhost';
const db_database = 'helpdesk';
const db_login = 'root';
const db_pass = '9ia56P9XLh73Nxw'; */
const db_host = 'ms153545-003.eu.clouddb.ovh.net:35770';
const db_database = 'preprod_tffs_db';
const db_login = 'tffs_usr';
const db_pass = 'tffs55hpWd9';
const db_coding = 'utf8mb4';

 
/* 
---  pages url  admin  --- 
*/
const page_home = 'home';
const page_login = 'login';
const page_login_authoriser = 'login-authoriser';

const page_user_grid = 'user-grid';
const page_user_edit = 'user-edit';

const page_employee_grid = 'employee-grid';
const page_employee_edit = 'employee-edit';

const page_folder_grid = 'folder-grid';
const page_folder_edit = 'folder-edit';

const page_documents_grid = 'documents-grid';
const page_document_edit = 'document-edit';

const page_global_notifications_grid = 'global-notifications-grid';
const global_notifications_edit = 'global-notifications-edit';

/* 
---  pages url  admin  --- 
*/
const user_home = "dashboard" ; 
const user_login = "user-login" ; 
const user_login_authoriser = "user-login-authoriser" ; 
const user_listing = "user-listing" ; 
 
/* 
---  ajax url   --- 
*/
const ajax_activator = 'ajax/ajax-activator';
const ajax_delete = 'ajax/ajax-delete';
/* 
---  grid/edit  --- 
*/
const default_rec_by_page = 100 ;
const default_folder_depth = 2 ;
/* 
---  key for crypt/decrypt len->16/24/32 --- 
*/
const key_salt = "topsecretkeyappstore223R";
/* 
---  paths  --- 
*/
const app_domain_hostname =  "https://tffs.preprod.web2code.com"; // application host name / root / domain with https/http 
const app_path =  "/adminfs/"; // application base directory 
const files_base =  "/"; // files base directory relative to root 
const files_upload_path =  "../medias/files/"; // upload path relative to app_path
/* 
---  sessions  --- 
*/
const session_path     = "_sessions";       // dossier relatif à app_path
const session_lifetime = 86400;             // 24h
// chemin absolu vers le dossier de sessions
$sessionDir = $_SERVER['DOCUMENT_ROOT'] . app_path . session_path;
if (!is_dir($sessionDir)) mkdir($sessionDir, 0777, true);
// fonctions
function generateSessionId() {
    return md5(uniqid(rand(), true));
}
function getSessionData($sessionId, $key = null) {
    global $sessionDir;
    $sessionFile = $sessionDir . '/sess_' . $sessionId;
    if (file_exists($sessionFile)) {
        $sessionData = json_decode(file_get_contents($sessionFile), true);
        if ($key) return $sessionData[$key] ?? null;
        return $sessionData;
    }
    return null;
}
function storeSession($sessionId, $data) {
    global $sessionDir;
    file_put_contents($sessionDir . "/sess_$sessionId", json_encode($data));
}
function destroySession($sessionId) {
    global $sessionDir;
    $file = $sessionDir . "/sess_$sessionId";
    if (file_exists($file)) unlink($file);
}
/* 
---  misc  --- 
*/
global $allow_remove;
$refresh_value = uniqid(); 
$soft_name = "FILE SHARE <b>PRO </b>";
$soft_info = "Administrator -  Version 1.0";
$allow_remove = true;  // only for admin 


/* 
---  mailer constants   --- 
*/
 
define('EMAIL_FROM_EMAIL', 'techfuse@mailservice.w2csolutions.com');
define('EMAIL_FROM_NAME', 'TECH FUSE');
define('SMTP_ENABLED', true);
define('SMTP_HOST', 'mailservice.w2csolutions.com');
define('SMTP_PORT', 587);
define('SMTP_USERNAME', 'techfuse');
define('SMTP_PASSWORD', 'Ad7o9x/');
define('SMTP_SECURE', 'ssl'); // 'tls', 'ssl', or ''

 
/* 
---  sms constants   --- 
*/
define('SMS_API_BASE', 'https://api.l2t.io/tn/v0/api/api.aspx');
define('SMS_API_KEY', 'JZ0nzJVBzwWyRMx5yLhbvrj/lxWMDGy//9SsUyydLxws4X8V0fs0PR3gwJyoQU3sm08Igfg0rfjhw2Wc0IoVssyGWBRuhIeoeHQWUAb01V4=');
define('SMS_SENDER', 'Tech Fuse');
define('SMS_MAX_LENGTH', 160);
define('SMS_CURL_TIMEOUT', 30);

 


/* 
---  naming conventions  --- 
*/
/* 
=PHP
ClassName 
methodName
propertyName
function_name (meant for global functions)
$variable_name
constant_name
=CSS
class-name
element-id
=MYSQL TBL
field_name
=HTML FORMS
name = input_name 
id = input_name 
*/
/*
 $hash=password_hash("digipass", PASSWORD_DEFAULT);
 echo $hash;
  <notify class="notify-alert"> Lorem ipsum dolor sit amet agains building stripes.</notify>
  <notify class="notify-warning"> Lorem ipsum dolor sit amet agains building stripes.</notify>
  <notify class="notify-info"> Lorem ipsum dolor sit amet agains building stripes.</notify>
  <notify class="notify-success"> Lorem ipsum dolor sit amet agains building stripes.</notify>
  */   
?>