public static function init($aid) { self::$aid = $aid; env::$dba = env::dbcon_by_app($aid); self::$xml = tag::create('osy_dump'); self::$xml->att('date', date('Y-m-d H:i:s')); }
private function pageView() { if ($this->__par['row_shw'] < 1) { return true; } try { $sql = env::replaceVariable($this->get_par('datasource-sql')); $sql = env::parseString($sql); $this->__par['datasource-sql'] = $sql; $this->__par['row_tot'] = env::$dba->exec_unique("SELECT COUNT(*) FROM (" . $this->__par['datasource-sql'] . ") a"); } catch (Exception $e) { echo $e->getMessage(); echo $this->__par['datasource-sql']; } $this->__par['pag_tot'] = ceil($this->__par['row_tot'] / $this->__par['row_shw']); if ($this->__par['pag_cur'] >= $this->__par['pag_tot'] && !empty($_REQUEST['ajax'])) { return false; } $where = ''; if ($filter = $this->get_par('filter')) { $where = 'where ' . implode(' AND ', $filter); } if (array_key_exists('osy', $_REQUEST) && !empty($_REQUEST['osy']['rid'])) { $where = (empty($where) ? 'WHERE ' : $where . ' AND ') . str_replace(array('pkey[', ']', '&'), array('', '', ' AND '), $_REQUEST['osy']['rid']); } $this->__par['datasource-sql'] = 'SELECT a.* FROM (' . $this->__par['datasource-sql'] . ') a ' . $where . ' ORDER BY 2 LIMIT ' . $this->__par['pag_cur'] * $this->__par['row_shw'] . ',' . $this->__par['row_shw']; return true; }
public static function resize($file, $w = 640, $h = 480) { if (($th = self::loadImage($file)) !== false) { $th->resize($w, $h)->save($file); } else { env::resp('error', 'Errore : ' . self::$err); } }
public function __construct() { $apiKey = env::_('apikey'); if (empty($apiKey)) { throw new RuntimeException('Tube API Exception: No API key provided'); } $this->apiKey = $apiKey; $this->urlBase = 'https://www.googleapis.com/youtube/v3/'; }
public static function exec_script($app, $cid, $cod) { env::$dba = env::dbcon_by_app($app); $msg = ($f = @create_function('', $cod)) ? $f() : print_r(error_get_last(), true); //update last execution env::$dbo->exec_cmd("INSERT INTO osy_obj_prp (o_id,p_id,p_ord,p_vl)\n VALUES\n (?,'exec-last-date',10,NOW())\n ON DUPLICATE KEY UPDATE p_vl = NOW();", array($cid)); //update last message env::$dbo->exec_cmd("INSERT INTO osy_obj_prp (o_id,p_id,p_ord,p_vl)\n VALUES\n (?,'exec-last-message',10,?)\n ON DUPLICATE KEY UPDATE p_vl = ?;", array($cid, $msg, $msg)); return $msg; }
public static function init() { $base = realpath(static::$ENV_CFG_FILE); if (!file_exists(static::$ENV_CFG_FILE)) { throw new RuntimeException('No config file found in . `' . static::$ENV_CFG_FILE . '`'); } $cfg = parse_ini_file(static::$ENV_CFG_FILE); if (!$cfg) { throw new ErrorException('No CFG file'); } if (empty($cfg['apikey'])) { throw new ErrorException('No API key in CFG file'); } self::$cfg = (object) $cfg; }
<?php if ($_SERVER["REQUEST_METHOD"] == "GET") { exit(file_get_contents("templates/login.html")); } // The request isn't GET, so it's probably POST. utils::require_params($_POST, ["username", "password"], "POST"); if (usertils::check_credentials($_POST["username"], $_POST["password"])) { env::$username = $_POST["username"]; env::$role = usertils::get_user($_POST["username"])["roles"]; http_response_code(302); // temporary redirect header("location: index.php?action=list&login=success"); // todo set an *appropriate* cookie here // todo output a nice login success page here? exit; } // The login failed! http_response_code(401); // todo output a nice login failed page here. header("content-type: text/plain"); exit("Login failed.");
/** * Exec test on php string and return the result * * @param string $str Contains sesssionid token * * @return bool */ public static function test($str) { $cod = str_replace('TEST', '$res = ', env::replaceVariable($str) . ';'); eval($cod); return $res; }
try { $options = getopt('vr:c:'); if (!empty($options['c']) && file_exists($options['c'])) { env::$ENV_CFG_FILE = $options['c']; } elseif (file_exists(__DIR__ . '/tubecacher.cfg')) { env::$ENV_CFG_FILE = __DIR__ . '/tubecacher.cfg'; } else { env::$ENV_CFG_FILE = __DIR__ . '/../tubecacher.cfg'; } env::$ENV_VERBOSE = isset($options['v']); if (isset($options['r'])) { env::$ENV_ITEMS_ROOT = realpath($options['r']); } _info('Config file: ' . realpath(env::$ENV_CFG_FILE)); _info('Items root: ' . env::$ENV_ITEMS_ROOT); $env = env::init(); _info('Looking for meta-files in ' . env::$ENV_ITEMS_ROOT); $meta = tubeAPI::getInstance()->searchMeta(); _echo(' > Found ' . count($meta) . ' playlists.'); foreach ($meta as $path) { $info = parse_ini_file($path, false, INI_SCANNER_RAW); if (empty($info['type'])) { continue; } switch ($info['type']) { case 'playlist': _info('Process playlist in `' . dirname($path) . '`'); if (empty($info['id'])) { _echo(' > No playlist ID specified. Skipping'); continue; }
protected static function excelBuild($sql) { $sql = env::parse_string($sql); require_once(OSY_PATH_LIB_EXT.'/phpexcel-1.8.0/PHPExcel.php'); require_once(OSY_PATH_LIB_EXT.'/phpexcel-1.8.0/PHPExcel/Writer/Excel2007.php'); $rs = env::$dba->exec_query($sql,null,'ASSOC'); $exc = new PHPExcel(); $exc->getProperties()->setCreator("Service Portal"); $exc->getProperties()->setLastModifiedBy("Service Portal"); $exc->getProperties()->setTitle("Order export"); $exc->getProperties()->setSubject("Order export"); $exc->getProperties()->setDescription("Esportazione ordini generata dal Service Portal"); $letters = array_unshift(range('A','Z'),''); $cell = ''; function calc_pos($n){ $l = range('A','Z'); if ($n <= 26) return $l[$n-1]; $r = ($n % 26); $i = (($n - $r) / 26) - (empty($r) ? 1 : 0); return calc_pos($i).(!empty($r) ? calc_pos($r) : 'Z'); } for ($i = 0; $i < count($rs); $i++) { $j = 0; foreach($rs[$i] as $k => $v) { if ($k[0] == '_') continue; $col = calc_pos($j+1); $cel = $col.($i+2); try{ if (empty($i)) { $exc->getActiveSheet()->SetCellValue($col.($i+1), str_replace(array('_X','!'),'',strtoupper($k))); } $exc->getActiveSheet()->SetCellValue($cel, str_replace('<br/>',' ',$v)); } catch (Exception $e){ } $j++; } } $exc->getActiveSheet()->setTitle('Ordini'); $objWriter = new PHPExcel_Writer_Excel2007($exc); $filename = OSY_PATH_VAR.'/tmp/'.str_replace(' ','-',strtolower(self::$__par['form-title'])).date('-Y-m-d-H-i-s').'.xlsx'; $objWriter->save($filename); die( str_replace(OSY_PATH_VAR,'/var',$filename )); }
function handler_ajax_timetable($page, $visibility = 'friends') { $day = env::t("showdate"); $type = env::t("viewtype"); $page->jsonAssign('day', $day); $phpTime = strtotime($day); switch ($type) { case "month": $st = mktime(0, 0, 0, date("m", $phpTime), 1, date("Y", $phpTime)); $et = mktime(0, 0, -1, date("m", $phpTime) + 1, 1, date("Y", $phpTime)); break; case "week": $monday = date("d", $phpTime) - date('N', $phpTime) + 1; $st = mktime(0, 0, 0, date("m", $phpTime), $monday, date("Y", $phpTime)); $et = mktime(0, 0, -1, date("m", $phpTime), $monday + 7, date("Y", $phpTime)); break; case "day": $st = mktime(0, 0, 0, date("m", $phpTime), date("d", $phpTime), date("Y", $phpTime)); $et = mktime(0, 0, -1, date("m", $phpTime), date("d", $phpTime) + 1, date("Y", $phpTime)); break; } $date = new FrankizDateTime(date('Y-m-d H:i:s', $st)); $date_n = new FrankizDateTime(date('Y-m-d H:i:s', $et)); if ($visibility == 'all') { $activities = new ActivityInstanceFilter(new PFC_And(new AIFC_CanBeSeen(S::user()), new AIFC_Period($date, $date_n))); } else { if ($visibility == 'participate') { $activities = new ActivityInstanceFilter(new PFC_And(new AIFC_Participants(S::user()), new AIFC_Period($date, $date_n))); } else { $activities = new ActivityInstanceFilter(new PFC_And(new PFC_Or(new AIFC_User(S::user(), 'restricted'), new AIFC_User(S::user(), 'everybody')), new AIFC_Period($date, $date_n))); } } $c = $activities->get(); $c->select(ActivityInstanceSelect::all()); $c->order('hour_begin', false); $page->jsonAssign('issort', true); $page->jsonAssign('start', date("m/d/Y H:i", $st)); $page->jsonAssign('end', date("m/d/Y H:i", $et)); $page->jsonAssign('error', null); $events = array(); foreach ($c as $e) { $events[] = array($e->id(), $e->title(), $e->begin()->format("m/d/Y H:i"), $e->end()->format("m/d/Y H:i"), 0, $e->begin()->format("m/d/Y") != $e->end()->format("m/d/Y"), $e->regular(), $e->activity()->origin() == false ? $e->writer()->id() % 15 - 1 : $e->origin()->id() % 15 - 1, 0, $e->description(), ''); } $page->jsonAssign('events', $events); return PL_JSON; }
<?php if (isset($_COOKIE["{$settings->cookie_prefix}-user"]) && isset($_COOKIE["{$settings->cookie_prefix}-session-key"])) { // The requester has attached a session key, we should probably take a look at it. if (sessions::lookup($_COOKIE["{$settings->cookie_prefix}-user"], $_COOKIE["{$settings->cookie_prefix}-session-key"])) { // The user's key was valid! Update the environment to reflect the user. env::$username = $_COOKIE["{$settings->cookie_prefix}-user"]; env::$key = $_COOKIE["{$settings->cookie_prefix}-session-key"]; env::$role = intval(usertils::get_user(env::$username)["roles"]); } }