public function initiate() { $assign = new assign($this->application); if ($assign->host()->dir($this->configuration)) { $module = new module(); $module->loader(); if (module::request(support\configuration::class)->configuration()) { $rewrite = avail::configuration($this->rewrite)->request('rewrite'); if ($assign->rewrite($rewrite)) { if ($route = $module->route()) { module::request(support\validation::class)->extension('ASV'); module::request(support\authorization::class)->extension('ASA'); module::request(support\mail::class)->extension('ASM'); $ase = $module->environment(); if ($ase) { if (isset($ase['database'])) { if ($assign->database(array_merge(avail::$database, $ase['database']))) { return true; } else { unset($ase['database']); } } avail::configuration($ase)->merge(); } avail::authorization()->subscribe(); avail::directory()->set(avail::configuration($this->directory)->request('directory')); new verse(); $verso = new verso($route->page); $verso->set(); $verso->execute(); } } } } }
private function requestVisitsUpdate($insert, $update) { $column = array_filter(array('locale' => avail::session('sil')->has(), 'lang' => avail::session('sol')->has())); // if ($this->column) { // $column = array_merge($this->column,$column); // } return avail::$database->insert(array_merge($column, $insert))->to($this->table)->duplicateUpdate(array_merge($column, $update))->execute(); }
public function changepassword($Id = null) { if ($this->responseTerminal()) { $db = avail::$database->update($this->formPost)->to($this->table)->where($this->formId)->execute()->rowsAffected(); if ($db->rowsAffected) { avail::cookie()->user()->set(array_merge($this->formId, $this->formPost)); } $this->responseTask($db->rowsAffected, $Id, $db, array('Changed!', 'Unchanged!')); } return $this; }
public function connection($d) { if (is_array($d)) { if (strpos($d['host'], '/cloudsql/') !== false) { // NOTE: Google App Engine avail::$databaseConnection = new \mysqli(NULL, $d['username'], $d['password'], $d['database'], NULL, $d['host']); } else { avail::$databaseConnection = new \mysqli($d['host'], $d['username'], $d['password'], $d['database']); } // avail::$databaseConnection->set_charset("utf8"); } }
/** * support extension for configuration */ public function configuration() { $filename = avail::$config['ASC']; avail::$config['ASC'] = $this->nameExists($filename); if (avail::$config['ASC']) { if (is_subclass_of(avail::configuration(), $this->Id)) { return 1; } else { assign::template('configuration')->error(array('filename' => $filename, 'require' => 'require to extends!', 'root' => avail::$config['ARO'])); } } else { return avail::$config['ASC'] = $this->Id; } }
private function requestEngine($cluster, $v) { if ($this->requestContents($cluster)) { return preg_replace_callback(avail::$config['ATR'], function ($k) use($v) { if (isset($v[$k[1]])) { $vk = $v[$k[1]]; if (is_array($vk)) { if (count(array_filter(array_keys($vk), 'is_string')) > 0) { if (file_exists($this->requestTemplate($k[1]))) { return $this->requestEngine($k[1], $vk); } else { return $this->responseEngine($vk); } } elseif ($vk) { return implode(array_map(function ($child) use($k) { return $this->requestEngine($k[1], $child); }, $vk)); } elseif ($file = $this->requestChild($k[1])) { return file_get_contents($file); } else { return avail::content($k[1])->statics(); } } else { return avail::language($vk)->get(); } } elseif ($resolveContent = avail::content($k[1])->resolve()) { return $resolveContent; } elseif (avail::language($k[1])->has()) { return avail::language($k[1])->get(); } elseif (ctype_upper($k[1][0])) { return $k[1]; } elseif ($file = $this->requestChild($k[1])) { // TODO: check filetype(text,image) and process advanced features return file_get_contents($file); } elseif (preg_match('/\\s|\\r|;|:|#/', $k[0])) { return $k[0]; } else { // NOTE: when not match } }, $this->template); } }
private function setEngine($lang) { if ($this->sessionList->has() && $this->sessionName->has()) { avail::$langname = $this->sessionName->get(); avail::$langlist = $this->sessionList->get(); } else { $dir = avail::$dir->language; foreach ($this->setDirectory($dir) as $nameId) { if ($this->sessionSIL->same($nameId)) { $isCurrent = true; avail::$langname[$nameId] = true; } else { avail::$langname[$nameId] = false; } if (array_key_exists($nameId, $lang)) { foreach ($this->setDirectory($dir . $nameId) as $fileName) { $filePath = $dir . $nameId . avail::SlA . $fileName; $file = pathinfo($filePath); if ($file['extension'] == avail::$Extension['language']) { if ($tmp = parse_ini_file($filePath)) { $lang[$nameId] = array_merge_recursive($lang[$nameId], $tmp); } } } } } if (!isset($isCurrent)) { avail::$langname[avail::$config['language']] = true; } $this->sessionName->set(avail::$langname); foreach ($lang as $language) { if (is_array(avail::$langlist)) { avail::$langlist = array_merge(avail::$langlist, $language); } else { avail::$langlist = $language; } } $this->sessionList->set(avail::$langlist); } }
public function __get($name) { if (isset(avail::$content[$name])) { return avail::content($name)->get(); } }
private function customEncrypt($value) { return avail::assist(null)->sha1($value); }
public function merge($Id = array()) { if (is_array($this->Id)) { avail::$config = array_merge(avail::$config, $this->Id, $Id); } }
private function setArrange($v, $k) { if ($k && isset($v[$k[0]]) && is_array($y = $v[$k[0]])) { if (array_shift($k) && isset($k[0]) && ($i = $this->setArrangeItem($y, $k[0]))) { return array_replace($i, $this->setArrange($y, $k)); } else { return $y; } } else { // NOTE: Verso not Exists, update URI for VersoMenu, required for home! avail::$VersoURI = array(avail::$config['APH']); return array(); } }
private function responseMessageContainer($msg, $attr = 'message') { return avail::html('p')->text($msg)->attr(array('class' => $attr))->response(); }
public function request() { avail::content($this->requestOption['varName'] . 'language')->set(avail::html(array($this->requestOption['menu'] => array('text' => $this->requestContent, 'attr' => array('class' => array($this->requestOption['menuClass'], 'language')))))); }
public function responseTemplate($Id) { return avail::template(avail::$contextId); }
private function requestCustomhas($method) { if ($i = avail::assist(avail::validation())->is_callable($method)) { return $i; } else { return avail::assist($this)->is_callable('custom' . $method); } }
public function setting($state = array()) { $this->state = $state; $this->form = $this->requestMethod(); $this->submit = $this->requestPostset($this->formName); $this->table = $this->requestState('table'); $this->message = $this->requestState('msg'); $maskDefault = $this->requestState('mask'); $classDefault = $this->requestState('class'); $setting = $this->requestState('row'); // rows vals rowrows ssets rows input data key, val, rows vals sets gets post $support = $this->requestSupport(); foreach ($setting as $fillName => $is) { $valueName = $this->formName . '.value.' . $fillName; $selectName = $this->formName . '.select.' . $fillName; $maskName = $this->formName . '.mask.' . $fillName; $setting[$fillName]['maskName'] = $maskName; $className = $this->formName . '.class.' . $fillName; // $setting[$fillName]['className'] = $className; $visibilityName = $this->formName . '.visibility.' . $fillName; $classValue = array($fillName); if ($this->submit) { if ($this->requestPostset($fillName)) { $fillValue = $this->requestPostvalue($valueName, $this->requestPosthas($fillName)); } elseif (isset($is['select'])) { $fillValue = $this->requestPostvalue($valueName, array()); } else { $fillValue = $this->requestPostvalue($valueName, $is['value']); } $setting[$fillName]['value'] = $fillValue; } else { if (isset($_GET[$fillName])) { $fillValue = $this->requestPostvalue($valueName, $_GET[$fillName]); } elseif (isset($support[$fillName])) { $fillValue = $this->requestPostvalue($valueName, $support[$fillName]); } elseif (isset($is['value'])) { $fillValue = $this->requestPostvalue($valueName, $is['value']); } } /* 'value'=>array(), 'type'=>'radio', 'select'=>array( 'MA'=>'Male', 'FE'=>'Female' ) */ if (isset($is['select'])) { if (isset($is['type'])) { $typeValue = $is['type']; if ($typeValue == 'option') { $selectValue = $this->requestSelectOption($is['select'], $fillName, $fillValue); } elseif ($typeValue == 'radio') { $selectValue = $this->requestInputRadio($is['select'], $fillName, $fillValue); } elseif ($typeValue == 'checkbox') { $selectValue = $this->requestInputCheckbox($is['select'], $fillName, $fillValue); } } // $selectValue = avail::html('option')->text('Ok')->attr(array('value'=>'abc','checked'))->response(); // $selectValue = \letId\asset\avail::html('b')->selectOption($is['select']); // $selectValue = avail::html($fillValue)->selectOption($is['select']); // TODO: this has to improved if (isset($selectValue)) { avail::content($selectName)->set(avail::html($selectValue)); } } /* 'visibility'=>'readonly', 'visibility'=>array( 'readonly' ), 'visibility'=>array( 'email'=>'readonly' ) */ if (isset($is['visibility'])) { $this->requestVisibility($visibilityName, $is['visibility'], $fillName); } /* 'require'=>array( 'mask'=>'*', 'class'=>'required', 'status'=>'Username' ) */ if (isset($is['require']) && is_array($requireValue = $is['require'])) { if ($this->submit) { if (!$fillValue) { $this->error[] = $this->requestStatushas($fillName, $requireValue); $this->requestMaskhas($maskName, $requireValue); if ($classDefault) { array_push($classValue, $classDefault); } if (isset($requireValue['class'])) { array_push($classValue, $requireValue['class']); } } else { // print_r($fillValue); // echo $fillName; } } else { $this->requestMaskhas($maskName, $maskDefault); } } /* 'validate'=>array( 'filter'=>FILTER_VALIDATE_EMAIL, 'task'=>FILTER_FLAG_PATH_REQUIRED, 'task'=>array( 'flags' => FILTER_NULL_ON_FAILURE ), 'task'=>array( 'flags'=>FILTER_FLAG_ALLOW_OCTAL 'options' => array( 'default' => 3, 'min_range' => 0 ) ), 'mask'=>'Invalid', 'status'=>'a valid Email' ), 'validate'=>array( 'task'=>'method from app\validation', 'mask'=>'Invalid', 'status'=>'a valid Email' ), */ if (isset($is['validate']) && is_array($validateValue = $is['validate'])) { if ($this->submit && $fillValue) { if (isset($validateValue['filter'])) { // avail::filter(EMAIL)->email(); // call_user_func_array(array($foo, "bar"), array("three", "four")); // call_user_func_array(array(avail::filter(EMAIL), "bar"), array("three", "four")); // call_user_func_array(array(avail::filter($fillValue), "bar"), array("three", "four")); // TODO: need to do smarter if (!isset($validateValue['task'])) { $validateValue['task'] = array(); } if (avail::filter($fillValue)->response($validateValue['filter'], $validateValue['task']) == false) { $this->error[] = $this->requestStatushas($fillName, $validateValue); $this->requestMaskhas($maskName, $validateValue); if ($classDefault) { array_push($classValue, $classDefault); } if (isset($validateValue['class'])) { array_push($classValue, $validateValue['class']); } } } elseif (isset($validateValue['task'])) { $validateTaskValue = $validateValue['task']; if (s_scalar($validateTaskValue)) { if ($validateTaskObject = avail::assist(avail::validation())->is_callable($validateTaskValue)) { if (call_user_func_array($validateTaskObject, array($is['value'], $fillName)) == false) { $this->error[] = $this->requestStatushas($fillName, $validateValue); $this->requestMaskhas($maskName, $validateValue); if ($classDefault) { array_push($classValue, $classDefault); } if (isset($validateValue['class'])) { array_push($classValue, $validateValue['class']); } } } } } } } $this->requestClasshas($className, $classValue); } // NOTE: registration start if ($this->submit) { if ($this->error) { $this->message = avail::language('require VALUE')->get(array('value' => avail::arrays($this->error)->to_sentence())); } else { // NOTE: success validation, and begin custom Methods foreach ($setting as $fillName => $is) { if ($this->error) { break; } if (isset($is['id'])) { $this->formId[$fillName] = $is['value']; } else { $this->formPost[$fillName] = $is['value']; } /* 'custom'=>array( 'Duplicate'=>array( 'mask'=>'Exists', 'status'=>'* is already exists.' ), 'Encrypt'=>array( 'modify'=>true ) ) 'custom'=>array( 'Exists'=>array( 'task'=>array( array('userid',1) ), 'mask'=>'!', 'status'=>'Password is not correct.' ), 'Encrypt'=>array( 'modify'=>true ) ) */ if (isset($is['custom']) && is_array($is['custom'])) { // echo 'checking custom'; foreach ($is['custom'] as $customMethod => $customValue) { if (is_array($customValue)) { if (isset($customValue['task'])) { $customValue['task'] = array($is['value'], $fillName, $customValue['task']); } else { $customValue['task'] = array($is['value'], $fillName); } // TODO: check user class has callable, if not use here $customValidation = $this->requestCustomhas($customMethod); if ($customValidation) { $customValidationResponse = call_user_func_array($customValidation, $customValue['task']); if ($customValidationResponse) { if (isset($customValue['modify'])) { $is['value'] = $customValidationResponse; if (is_string($customValue['modify'])) { unset($this->formPost[$fillName]); unset($this->formId[$fillName]); $fillName = $customValue['modify']; } if (isset($is['id'])) { $this->formId[$fillName] = $is['value']; } else { $this->formPost[$fillName] = $is['value']; } } } else { $this->error = $this->requestStatushas($customMethod . ' returned null', $customValue); if (isset($customValue['mask'])) { $this->requestMaskhas($is['maskName'], $customValue); } break; } } } } } } if ($this->error) { // NOTE: feil custom Methods $this->message = $this->error; $this->formPost = array(); $this->formId = array(); } } } return $this; }
private function requestAttr($k) { $attr = array(); if (isset($k[avail::$config['APL']])) { $attr['href'] = $k[avail::$config['APL']]; if (avail::filter($k[avail::$config['APL']])->response(FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { $attr['target'] = '_blank'; } } else { $link = avail::SlA . implode($k['href'], avail::SlA); //avail::$http if ($this->requestOption['fullURL']) { $link = avail::$http . $link; } $attr['href'] = $link; } return $attr; }