Beispiel #1
0
 function __construct($params)
 {
     parent::__construct($params);
     // clause and character used for LIKE escape sequences
     if (strpos($this->hostname, 'mysql') !== FALSE) {
         $this->_like_escape_str = '';
         $this->_like_escape_chr = '';
         //Prior to this version, the charset can't be set in the dsn
         if (is_php('5.3.6')) {
             $this->hostname .= ";charset={$this->char_set}";
         }
         //Set the charset with the connection options
         $this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
     } elseif (strpos($this->hostname, 'odbc') !== FALSE) {
         $this->_like_escape_str = " {escape '%s'} ";
         $this->_like_escape_chr = '!';
     } else {
         $this->_like_escape_str = " ESCAPE '%s' ";
         $this->_like_escape_chr = '!';
     }
     empty($this->database) or $this->hostname .= ';dbname=' . $this->database;
     $this->trans_enabled = FALSE;
     $this->_random_keyword = ' RND(' . Startup::getRequestTime() . ')';
     // database specific random keyword
 }
Beispiel #2
0
 /**
  * Save into cache
  *
  * @param 	string		unique key
  * @param 	mixed		data to store
  * @param 	int			length of time (in seconds) the cache is valid 
  *						- Default is 60 seconds
  * @return 	boolean		true on success/false on failure
  */
 public function save($id, $data, $ttl = 60)
 {
     $contents = array('time' => Startup::getRequestTime(), 'ttl' => $ttl, 'data' => $data);
     if (write_file($this->_cache_path . $id, serialize($contents))) {
         @chmod($this->_cache_path . $id, 0777);
         return TRUE;
     }
     return FALSE;
 }
Beispiel #3
0
 static function getRequestTime()
 {
     if (self::$request_time === '') {
         if (isset($_SERVER['REQUEST_TIME'])) {
             self::$request_time = floor($_SERVER['REQUEST_TIME']);
         } else {
             self::$request_time = time();
         }
     }
     return self::$request_time;
 }
 /**
  * Save
  *
  * @param 	string		unique identifier
  * @param 	mixed		data being cached
  * @param 	int			time to live
  * @return 	boolean 	true on success, false on failure
  */
 public function save($id, $data, $ttl = 60)
 {
     if (get_class($this->_memcached) == 'Memcached') {
         return $this->_memcached->set($id, array($data, Startup::getRequestTime(), $ttl), $ttl);
     } else {
         if (get_class($this->_memcached) == 'Memcache') {
             return $this->_memcached->set($id, array($data, Startup::getRequestTime(), $ttl), 0, $ttl);
         }
     }
     return FALSE;
 }
Beispiel #5
0
 /**
  * Constructor
  *
  * Loads the calendar language file and sets the default time reference
  */
 public function __construct($config = array())
 {
     $this->CI =& get_instance();
     if (!in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE)) {
         $this->CI->lang->load('calendar');
     }
     $this->local_time = Startup::getRequestTime();
     if (count($config) > 0) {
         $this->initialize($config);
     }
     log_message('debug', "Calendar Class Initialized");
 }
Beispiel #6
0
 /**
  * Random Hash for protecting URLs
  *
  * @return	string
  */
 public function xss_hash()
 {
     if ($this->_xss_hash == '') {
         mt_srand();
         $this->_xss_hash = md5(Startup::getRequestTime() + mt_rand(0, 1999999999));
     }
     return $this->_xss_hash;
 }
Beispiel #7
0
 /**
  * Constructor
  */
 public function __construct()
 {
     log_message('debug', "Zip Compression Class Initialized");
     $this->now = Startup::getRequestTime();
 }
Beispiel #8
0
 /**
  * Garbage collection
  *
  * This deletes expired session rows from database
  * if the probability percentage is met
  *
  * @access	public
  * @return	void
  */
 function _sess_gc()
 {
     if ($this->sess_use_database != TRUE) {
         return;
     }
     srand(Startup::getRequestTime());
     if (rand() % 100 < $this->gc_probability) {
         $expire = $this->now - $this->sess_expiration;
         $this->CI->db->where("last_activity < {$expire}");
         $this->CI->db->delete($this->sess_table_name);
         log_message('debug', 'Session garbage collection performed.');
     }
 }
Beispiel #9
0
 function __construct($params)
 {
     parent::__construct($params);
     $this->_random_keyword = ' RND(' . Startup::getRequestTime() . ')';
     // database specific random keyword
 }
<?php

require 'angelList/Startup.php';
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$Startup = new Startup();
if (isset($_GET['search'])) {
    $query = isset($_GET['query']) ? $_GET['query'] : null;
    $type = isset($_GET['type']) ? $_GET['type'] : 'Startup';
    $startups = $Startup->startupsWithRaising(array('query' => $query, 'type' => 'Startup', 'filter' => 'raising', 'page' => $page, 'per_page' => '3'));
} else {
    $startups = $Startup->raising($page)['startups'];
}
$pagination_markup = "";
if ($raising['total'] > 3) {
    require 'libs/Pagination.class';
    $pagination = new Pagination();
    $pagination->setCurrent($page);
    $pagination->setTotal($raising['total']);
    $pagination_markup = $pagination->parse();
}
?>

<?php 
include 'header.php';
?>

<div class="container">

 <div class="row">
  <div class="col-lg-12" align="center">
   <form action="search.php" method="get" class="form">
Beispiel #11
0
 /**
  * Database Backup
  *
  * @access	public
  * @return	void
  */
 function backup($params = array())
 {
     // If the parameters have not been submitted as an
     // array then we know that it is simply the table
     // name, which is a valid short cut.
     if (is_string($params)) {
         $params = array('tables' => $params);
     }
     // ------------------------------------------------------
     // Set up our default preferences
     $prefs = array('tables' => array(), 'ignore' => array(), 'filename' => '', 'format' => 'gzip', 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n");
     // Did the user submit any preferences? If so set them....
     if (count($params) > 0) {
         foreach ($prefs as $key => $val) {
             if (isset($params[$key])) {
                 $prefs[$key] = $params[$key];
             }
         }
     }
     // ------------------------------------------------------
     // Are we backing up a complete database or individual tables?
     // If no table names were submitted we'll fetch the entire table list
     if (count($prefs['tables']) == 0) {
         $prefs['tables'] = $this->db->list_tables();
     }
     // ------------------------------------------------------
     // Validate the format
     if (!in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE)) {
         $prefs['format'] = 'txt';
     }
     // ------------------------------------------------------
     // Is the encoder supported?  If not, we'll either issue an
     // error or use plain text depending on the debug settings
     if ($prefs['format'] == 'gzip' and !@function_exists('gzencode') or $prefs['format'] == 'zip' and !@function_exists('gzcompress')) {
         if ($this->db->db_debug) {
             return $this->db->display_error('db_unsuported_compression');
         }
         $prefs['format'] = 'txt';
     }
     // ------------------------------------------------------
     // Set the filename if not provided - Only needed with Zip files
     if ($prefs['filename'] == '' and $prefs['format'] == 'zip') {
         $prefs['filename'] = count($prefs['tables']) == 1 ? $prefs['tables'] : $this->db->database;
         $prefs['filename'] .= '_' . date('Y-m-d_H-i', Startup::getRequestTime());
     }
     // ------------------------------------------------------
     // Was a Gzip file requested?
     if ($prefs['format'] == 'gzip') {
         return gzencode($this->_backup($prefs));
     }
     // ------------------------------------------------------
     // Was a text file requested?
     if ($prefs['format'] == 'txt') {
         return $this->_backup($prefs);
     }
     // ------------------------------------------------------
     // Was a Zip file requested?
     if ($prefs['format'] == 'zip') {
         // If they included the .zip file extension we'll remove it
         if (preg_match("|.+?\\.zip\$|", $prefs['filename'])) {
             $prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
         }
         // Tack on the ".sql" file extension if needed
         if (!preg_match("|.+?\\.sql\$|", $prefs['filename'])) {
             $prefs['filename'] .= '.sql';
         }
         // Load the Zip class and output it
         $CI =& get_instance();
         $CI->load->library('zip');
         $CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
         return $CI->zip->get_zip();
     }
 }
Beispiel #12
0
 /**
  * Update/serve a cached file
  *
  * @access	public
  * @param 	object	config class
  * @param 	object	uri class
  * @return	void
  */
 function _display_cache(&$CFG, &$URI)
 {
     $cache_path = $CFG->item('cache_path') == '' ? APPPATH . 'cache/' : $CFG->item('cache_path');
     // Build the file path.  The file name is an MD5 hash of the full URI
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     $filepath = $cache_path . md5($uri);
     if (!@file_exists($filepath)) {
         return FALSE;
     }
     if (!($fp = @fopen($filepath, FOPEN_READ))) {
         return FALSE;
     }
     flock($fp, LOCK_SH);
     $cache = '';
     if (filesize($filepath) > 0) {
         $cache = fread($fp, filesize($filepath));
     }
     flock($fp, LOCK_UN);
     fclose($fp);
     // Strip out the embedded timestamp
     if (!preg_match("/(\\d+TS--->)/", $cache, $match)) {
         return FALSE;
     }
     // Has the file expired? If so we'll delete it.
     if (Startup::getRequestTime() >= trim(str_replace('TS--->', '', $match['1']))) {
         if (is_really_writable($cache_path)) {
             @unlink($filepath);
             log_message('debug', "Cache file has expired. File deleted");
             return FALSE;
         }
     }
     // Display the cache
     $this->_display(str_replace($match['0'], '', $cache));
     log_message('debug', "Cache file is current. Sending it to browser.");
     return TRUE;
 }
Beispiel #13
0
<?php

use micro\orm\DAO;
use micro\utils\StrUtils;
use micro\controllers\Autoloader;
error_reporting(E_ALL);
?>

<?php 
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__) . DS);
$config = (include_once ROOT . DS . 'config.php');
require_once ROOT . 'micro/log/Logger.php';
require_once ROOT . 'micro/controllers/Autoloader.php';
Autoloader::register();
$ctrl = new Startup();
$ctrl->run();
class Startup
{
    private $urlParts;
    public function run()
    {
        global $config;
        session_start();
        Logger::init();
        if ($config["test"]) {
            $config["siteUrl"] = "http://127.0.0.1:8090/";
        }
        extract($config["database"]);
        $db = $config["database"];
        DAO::connect($db["dbName"], @$db["serverName"], @$db["port"], @$db["user"], @$db["password"]);
Beispiel #14
0
<?php

/**
 * bmonitor
 *
 * PHP version 5.3
 *
 * @category Index
 * @package  Index
 * @author   Carlos Lazcano <*****@*****.**>
 * @link     http://www.baking.cl
 */
header('Content-type: text/html; charset=UTF-8');
ini_set('upload_max_filesize', '40M');
require 'core/startup.inc.php';
Startup::main();
//test
Beispiel #15
0
 /**
  * Set cookie
  *
  * Accepts six parameter, or you can submit an associative
  * array in the first parameter containing all the values.
  *
  * @access	public
  * @param	mixed
  * @param	string	the value of the cookie
  * @param	string	the number of seconds until expiration
  * @param	string	the cookie domain.  Usually:  .yourdomain.com
  * @param	string	the cookie path
  * @param	string	the cookie prefix
  * @param	bool	true makes the cookie secure
  * @return	void
  */
 function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
 {
     if (is_array($name)) {
         // always leave 'name' in last place, as the loop will break otherwise, due to $$item
         foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) {
             if (isset($name[$item])) {
                 ${$item} = $name[$item];
             }
         }
     }
     if ($prefix == '' and config_item('cookie_prefix') != '') {
         $prefix = config_item('cookie_prefix');
     }
     if ($domain == '' and config_item('cookie_domain') != '') {
         $domain = config_item('cookie_domain');
     }
     if ($path == '/' and config_item('cookie_path') != '/') {
         $path = config_item('cookie_path');
     }
     if ($secure == FALSE and config_item('cookie_secure') != FALSE) {
         $secure = config_item('cookie_secure');
     }
     if (!is_numeric($expire)) {
         $expire = Startup::getRequestTime() - 86500;
     } else {
         $expire = $expire > 0 ? Startup::getRequestTime() + $expire : 0;
     }
     setcookie($prefix . $name, $value, $expire, $path, $domain, $secure);
 }
<?php

require 'angelList/Startup.php';
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$Startup = new Startup();
if (isset($_GET['search'])) {
    $query = isset($_GET['query']) ? $_GET['query'] : null;
    $type = isset($_GET['type']) ? $_GET['type'] : null;
    $fundRaising = isset($_GET['fundRaising']) ? $_GET['fundRaising'] : null;
    $number = isset($_GET['number']) ? (int) $_GET['number'] : 0;
    $number2 = isset($_GET['number2']) ? (int) $_GET['number2'] : 0;
    if ($fundRaising != null) {
        $startups = $Startup->searchByFundraisingDetails($fundRaising, $number, $number2, array('filter' => 'raising'));
    } else {
        $startups = $Startup->startupsWithRaising(array('query' => $query, 'type' => 'Startup', 'filter' => 'raising', 'page' => $page, 'per_page' => '3'));
    }
} else {
    $startups = $Startup->raising($page)['startups'];
}
$pagination_markup = "";
if ($raising['total'] > 3) {
    require 'libs/Pagination.class';
    $pagination = new Pagination();
    $pagination->setCurrent($page);
    $pagination->setTotal($raising['total']);
    $pagination_markup = $pagination->parse();
}
if (isset($_GET['vd'])) {
    vd($startups);
}
?>
Beispiel #17
0
 /**
  * Dynamically outputs an image
  *
  * @access	public
  * @param	resource
  * @return	void
  */
 function image_display_gd($resource)
 {
     header("Content-Disposition: filename={$this->source_image};");
     header("Content-Type: {$this->mime_type}");
     header('Content-Transfer-Encoding: binary');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', Startup::getRequestTime()) . ' GMT');
     switch ($this->image_type) {
         case 1:
             imagegif($resource);
             break;
         case 2:
             imagejpeg($resource, '', $this->quality);
             break;
         case 3:
             imagepng($resource);
             break;
         default:
             echo 'Unable to display the image';
             break;
     }
 }
Beispiel #18
0
 /**
  * Cache Save
  *
  * @param 	string		Unique Key
  * @param 	mixed		Data to store
  * @param 	int			Length of time (in seconds) to cache the data
  *
  * @return 	boolean		true on success/false on failure
  */
 public function save($id, $data, $ttl = 60)
 {
     return apc_store($id, array($data, Startup::getRequestTime(), $ttl), $ttl);
 }
Beispiel #19
0
 function local_to_gmt($time = '')
 {
     if ($time == '') {
         $time = Startup::getRequestTime();
     }
     return mktime(gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
 }