/** * Portably execute a command on any of the supported platforms. * * @author KnowledgeTree Team * @access public * @param string $aCmd * @param array $aOptions * @return array */ function pexec($aCmd, $aOptions = null) { if (is_array($aCmd)) { $sCmd = safeShellString($aCmd); } else { $sCmd = $aCmd; } $sAppend = arrayGet($aOptions, 'append'); if ($sAppend) { $sCmd .= " >> " . escapeshellarg($sAppend); } $sPopen = arrayGet($aOptions, 'popen'); if ($sPopen) { if (WINDOWS_OS) { $sCmd = "start /b \"kt\" " . $sCmd; } return popen($sCmd, $sPopen); } // for exec, check return code and output... $aRet = array(); $aOutput = array(); $iRet = ''; //if(WINDOWS_OS) { // $sCmd = 'call '.$sCmd; // } exec($sCmd, $aOutput, $iRet); $aRet['ret'] = $iRet; $aRet['out'] = $aOutput; return $aRet; }
private function configure($config) { $this->debug = arrayGet($config, "debug.sql"); if ($this->offline = arrayGet($config, "debug.offline")) { return; } $this->mysqlConfig = isset($config["_mysql"]) ? $config["_mysql"] : $config; //debug("config", $this->mysqlConfig); }
public function pluck($column) { $this->limit = 1; $this->selects = array($column); $stmt = $this->prepare('read'); $result = $stmt->fetch(); if ($result) { return arrayGet($result, $column); } else { return null; } }
public static function save($data) { $controller = arrayGet($data, 'output_controller'); $controller_id = \Work\Models\Controller::where('controller', '=', $controller)->pluck('controller_id'); $result = arrayGet($data, 'result'); $test_id = \Work\Models\Test::create(array('controller_id' => $controller_id, 'result' => $result)); foreach ($data as $name => $input) { if ($name == 'output_controller' || $name == 'result') { continue; } $input_id = \Work\Models\Input::where('input', '=', $name)->pluck('input_id'); \Work\Models\TestInput::create(array('test_id' => $test_id, 'input_id' => $input_id, 'input' => $input)); } return 'Test saved'; }
protected static function validate($data, $rules) { foreach ($rules as $name => $set) { $set = explode('|', $set); if (in_array('required', $set) && is_null(arrayGet($data, $name))) { throw new \Exception("{$name} attribute required"); } foreach ($set as $rule) { if ($rule == 'required') { continue; } \Work\Validation::$rule($data[$name]); } } }
public function init() { $this->view->config = context('config')->load('crudjson'); $guestActions = array('login', 'logout', 'lost'); $guestActions += arrayGet($this->view->config, 'guest.actions', array()); $this->view->isAuth = false; $this->view->items = isAke($this->view->config, 'tables'); $user = auth()->user(); if (!$user) { if (!Arrays::in($this->action(), $guestActions)) { $this->forward('login'); } } else { $this->view->isAuth = true; $this->view->user = $user; $this->isAdmin = auth()->is('admin'); if ($this->action() == 'login' || $this->action() == 'lost') { $this->forward('home', 'static'); } } }
function registry() { static $tab = array(); $args = func_get_args(); $nb = count($args); if ($nb == 1) { return arrayGet($tab, Arrays::first($args)); } elseif ($nb == 2) { $tab = arraySet($tab, Arrays::first($args), Arrays::last($args)); return Arrays::last($args); } return null; }
public function __construct($data) { $this->type = $data['type']; $this->parent_column = $data['parent_column']; $this->child = $data['child']; if (isset($data['child_column'])) { $this->child_column = $data['child_column']; } else { $child = $this->child; $this->child_column = $child::$primary_key; } if (isset($data['link'])) { $this->link = $data['link']; $this->link_config = arrayGet($data, 'link.link_config', 'default'); $this->link_table = arrayGet($data, 'link.link_table'); $this->link_primary_key = arrayGet($data, 'link.link_primary_key', $this->link_table . '_id'); $this->link_parent_column = arrayGet($data, 'link.link_parent_column', $this->parent_column); $this->link_child_column = arrayGet($data, 'link.link_child_column', $this->child_column); } }
/** * Get an item from the $_SERVER array. * * @param string $key * @param mixed $default * @return string */ public static function server($key = null, $default = null) { return arrayGet(static::foundation()->server->all(), Inflector::upper($key), $default); }
function fpCurrentUsername() { return arrayGet($_SESSION, "fp_user.username"); }
/** * Gets the crop points based on the configuration either set in the file * or overridden by user in their own config file, or on the fly. * @param int $optimalWidth The width of the image * @param int $optimalHeight The height of the image * @param int $newWidth The new width * @param int $newHeight The new height * @return array Array containing the crop x and y points. */ private function getCropPoints($optimalWidth, $optimalHeight, $newWidth, $newHeight) { $cropPoints = array(); $vertical_start = arrayGet($this->config, 'crop_vertical_start_point'); $horizontal_start = arrayGet($this->config, 'crop_horizontal_start_point'); // Where is our vertical starting crop point? switch ($vertical_start) { case 'top': $cropPoints['y'] = 0; break; case 'center': $cropPoints['y'] = $optimalHeight / 2 - $newHeight / 2; break; case 'bottom': $cropPoints['y'] = $optimalHeight - $newHeight; break; default: throw new Exception('Unknown value for crop_vertical_start_point: ' . $vertical_start . '. Please check config file in the Resizer bundle.'); break; } // Where is our horizontal starting crop point? switch ($horizontal_start) { case 'left': $cropPoints['x'] = 0; break; case 'center': $cropPoints['x'] = $optimalWidth / 2 - $newWidth / 2; break; case 'right': $cropPoints['x'] = $optimalWidth - $newWidth; break; default: throw new Exception('Unknown value for crop_horizontal_start_point: ' . $horizontal_start . '. Please check config file in the Resizer bundle.'); break; } return $cropPoints; }
<?php require_once "include/includes.php"; session_start(); //site title $fpUser = arrayGet($_SESSION, "fp_user"); $title = getConfig("defaultTitle"); //default meta tags $meta = array(); $meta["og:title"] = $title; $meta["og:site_name"] = $title; //get root dir title $meta["description"] = $meta["og:description"] = getConfig("description"); $meta["og:url"] = currentUrlDir(); ?> <!doctype html> <html ng-app="app"> <head> <title><?php echo $title; ?> </title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="mobile-web-app-capable" content="yes" /> <?php echo metaTagArray($meta); ?>
private static function cleanup($user_id = null) { if ($user_id && arrayGet($_REQUEST, 'clean')) { \Work\Models\Navigation::where('user_id', '=', $user_id)->whereNotIn('key', $_REQUEST['clean'])->delete(); \Work\Models\Store::where('user_id', '=', $user_id)->whereNotIn('key', $_REQUEST['clean'])->delete(); } \Work\Models\Navigation::where('user_id', '=', 0)->where('created_at', '<', date('Y-m-d H:i:s', strtotime('2 hours ago')))->delete(); \Work\Models\Store::where('user_id', '=', 0)->where('created_at', '<', date('Y-m-d H:i:s', strtotime('2 hours ago')))->delete(); }
public static function get($address) { return arrayGet(self::$conf, $address); }
/** * Get a specific segment of the request URI via a one-based index. * * <code> * // Get the first segment of the request URI * $segment = Uri::segment(1); * * // Get the second segment of the URI, or return a default value * $segment = Uri::segment(2, 'Taylor'); * </code> * * @param int $index * @param mixed $default * @return string */ public static function segment($index, $default = null) { static::current(); return arrayGet(static::$segments, $index - 1, $default); }
/** * Get the JSON payload for the request. * * @param string $key * @param mixed $default * @return mixed */ public function json($key = null, $default = null) { if (!isset($this->json)) { $this->json = new ParameterBag((array) json_decode($this->getContent(), true)); } if (is_null($key)) { return $this->json; } return arrayGet($this->json->all(), $key, $default); }
public static function get($key, $default = null) { return arrayGet(static::$vars, $key, $default); }
public function __get($key) { return arrayGet($this->values, $this->format($key)); }