PHP Classes
elePHPant
Icontem

File: examples/cache.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of tokkara  >  Simphple  >  examples/cache.php  >  Download  
File: examples/cache.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simphple
Process templates compiling into PHP code
Author: By
Last change: simphple version 1.1.0
Date: 1 year ago
Size: 1,292 bytes
 

Contents

Class file image Download
<?php

include '../simphple/template/template_code.class.php';
include
'../simphple/template/template.class.php';
include
'../simphple/template/template_function.class.php';
include
'../simphple/data_store/data_store.intfc.php';
include
'../simphple/data_store/data_store_file.class.php';

$options = array('template_dir_path' => 'templates/', 'vars_without_keys' => Sphp_Template::VARS_WK_ENABLED, 'debug' =>false);
$dsf = new Sphp_Data_Store_File('cache/', true, true);
$tpl = new Sphp_Template($dsf, $options);


$created = false;
$loaded = false;
$deleted = false;
$name = '';
$value = '';
$exists = false;

if(isset(
$_POST['send'])){
   
$name = $_POST['name'];
   
$value = $_POST['value'];
   
$ttl = (int) $_POST['ttl'];
   
$created = true;
   
   
$dsf->set_data($name, $value, $ttl);
}

if(isset(
$_POST['send_load'])){
   
$name = $_POST['name'];
   
$loaded = true;
   
$exists = $dsf->get_data($name, $value);
}

if(isset(
$_POST['send_delete'])){
   
$name = $_POST['name'];
   
$deleted = true;
   
$exists = $dsf->delete_data($name);
}

$vars = array( 'created' => $created,
               
'deleted' => $deleted,
               
'exists' => $exists,
               
'loaded' => $loaded,
               
'name' => $name,
               
'value' => $value

);

$tpl->add_variables($vars);
$tpl->display_file('cache.html');