Skip to content
Snippets Groups Projects
Commit 7515e2c5 authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

day 39

parent af79c71b
No related branches found
No related tags found
No related merge requests found
/home/sibidharan/htdocs/photogram/js/test2.txt
\ No newline at end of file
...@@ -6,31 +6,37 @@ include 'libs/load.php'; ...@@ -6,31 +6,37 @@ include 'libs/load.php';
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<? load_template('_head'); ?> <?php load_template('_head'); ?>
<body> <body>
<? <?php
Session::start(); if (Session::isset('session_token')) {
if (Session::isset('session_token')){ $token = Session::get('session_token');
$token = Session::get('session_token'); if (UserSession::authorize($token)) {
if (UserSession::authorize($token)){ ?>
?> <main>
<main> <?php load_template('_calltoaction');
<? load_template('_calltoaction'); load_template("_photogram"); ?>
load_template("_photogram");?> </main>
</main> <?php load_template('_footer');
<? load_template('_footer'); } else {
?><script>
} window.location.href =
else{ "<?=get_config('base_path')?>login.php"
?><script>window.location.href = "<?=get_config('base_path')?>login.php"</script><? </script>
<?php
} }
}else{ } else {
?><script>window.location.href = "<?=get_config('base_path')?>login.php"</script><? ?>
<script>
window.location.href =
"<?=get_config('base_path')?>login.php"
</script><?php
} }
?> ?>
<script src="<?=get_config('base_path')?>assets/dist/js/bootstrap.bundle.min.js"></script> <script
src="<?=get_config('base_path')?>assets/dist/js/bootstrap.bundle.min.js">
</script>
</body> </body>
......
Hello World
\ No newline at end of file
File moved
<?php
class WebAPI
{
public function __construct()
{
if (php_sapi_name() == "cli") {
global $__site_config;
$__site_config_path = "/home/sibidharan/photogramconfig.json";
$__site_config = file_get_contents($__site_config_path);
//print($__site_config);
} elseif (php_sapi_name() == "apache2handler") {
global $__site_config;
$__site_config_path = dirname(is_link($_SERVER['DOCUMENT_ROOT']) ? readlink($_SERVER['DOCUMENT_ROOT']) : $_SERVER['DOCUMENT_ROOT']).'/photogramconfig.json';
$__site_config = file_get_contents($__site_config_path);
}
Database::getConnection();
}
public function initiateSession()
{
//Session::start();
// $__base_path = get_config('base_path');
}
}
<?php <?php
include_once 'includes/Session.class.php'; include_once 'includes/Session.class.php';
include_once 'includes/User.class.php'; include_once 'includes/Mic.class.php';
include_once 'includes/Database.class.php'; include_once 'includes/User.class.php';
include_once 'includes/UserSession.class.php'; include_once 'includes/Database.class.php';
include_once 'includes/UserSession.class.php';
include_once 'includes/WebAPI.class.php';
function load_template($template) { global $__site_config;
$templatePath = __DIR__."/../_templates/$template.php"; /*
if (file_exists($templatePath)) { Note: Location of configuration
include "$templatePath"; in lab : /home/user/phtogramconfig.json
} else { in server: /var/www/photogramconfig.json
die("Template not found: $templatePath"); */
}
};
function get_config($key){
$configPath = __DIR__."/../photogramconfig.json";
$json = file_get_contents($configPath);
if (file_exists($configPath)){
$array = json_decode($json, true);
if (isset($array[$key])) {
return $array[$key];
} else {
return false;
}
}else{
die("File Not Found: $configPath");
}
$wapi = new WebAPI();
$wapi->initiateSession();
function get_config($key, $default=null)
{
global $__site_config;
$array = json_decode($__site_config, true);
if (isset($array[$key])) {
return $array[$key];
} else {
return $default;
} }
}
function validate_credentials($username, $password){
function load_template($name)
{
include $_SERVER['DOCUMENT_ROOT'] . get_config('base_path'). "_templates/$name.php"; //not consistant.
}
function validate_credentials($username, $password)
{
if ($username == "sibi@selfmade.ninja" and $password == "password") { if ($username == "sibi@selfmade.ninja" and $password == "password") {
return true; return true;
} else { } else {
return false; return false;
} }
} }
?>
\ No newline at end of file
<?php
include_once 'includes/Session.class.php';
include_once 'includes/Mic.class.php';
include_once 'includes/User.class.php';
include_once 'includes/Database.class.php';
include_once 'includes/UserSession.class.php';
global $__site_config;
// global $__base_path;
//Note: Change this path if you run this code outside lab.
/*
Note: Location of configuration
in lab : /home/user/phtogramconfig.json
in server: /var/www/photogramconfig.json
*/
$__site_config_path = dirname(is_link($_SERVER['DOCUMENT_ROOT']) ? readlink($_SERVER['DOCUMENT_ROOT']) : $_SERVER['DOCUMENT_ROOT']).'/photogramconfig.json';
$__site_config = file_get_contents($__site_config_path);
// $__base_path = get_config('base_path');
Session::start();
function get_config($key, $default=null)
{
global $__site_config;
$array = json_decode($__site_config, true);
if (isset($array[$key])) {
return $array[$key];
} else {
return $default;
}
}
function load_template($name)
{
include $_SERVER['DOCUMENT_ROOT'] . get_config('base_path'). "_templates/$name.php"; //not consistant.
}
function validate_credentials($username, $password)
{
if ($username == "sibi@selfmade.ninja" and $password == "password") {
return true;
} else {
return false;
}
}
<?php <?php
include 'libs/load.php'; include 'libs/load.php';
$user = "fooboo1"; $user = "sibi";
$pass = isset($_GET['pass']) ? $_GET['pass'] : ''; $pass = isset($_GET['pass']) ? $_GET['pass'] : '';
$result = null; $result = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment