コード例 #1
0
ファイル: Image.php プロジェクト: nabble/updatemybrowser-v1
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'base64':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'html':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
             $controller->setImage($image);
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'image':
             return false;
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
コード例 #2
0
ファイル: Crud.php プロジェクト: nabble/ajde-core
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'list':
             $options = issetor($this->attributes['options'], array());
             $crud = new AjdeCrud($this->attributes['model'], $options);
             $crud->setAction('list');
             return $crud;
             break;
         case 'edit':
             $options = issetor($this->attributes['options'], array());
             $id = issetor($this->attributes['id'], null);
             $crud = new AjdeCrud($this->attributes['model'], $options);
             $crud->setId($id);
             $crud->setAction('edit/layout');
             return $crud;
             break;
         case 'mainfilter':
             $controller = Controller::fromRoute(new Route('_core/crud:mainfilter'));
             $controller->setCrud($this->attributes['crud']);
             $controller->setRefresh(issetor($this->attributes['refresh'], false));
             return $controller->invoke();
     }
     // TODO:
     throw new Exception();
 }
コード例 #3
0
ファイル: Image.php プロジェクト: nabble/ajde-core
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'base64':
             $image = new AjdeResourceImage($this->attributes['filename']);
             $image->setWidth(issetor($this->attributes['width']));
             $image->setHeight(issetor($this->attributes['height']));
             $image->setCrop(String::toBoolean(issetor($this->attributes['crop'], true)));
             $controller = Controller::fromRoute(new Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'html':
             return self::getImageTag($this->attributes['filename'], issetor($this->attributes['width']), issetor($this->attributes['height']), String::toBoolean(issetor($this->attributes['crop'], true)), issetor($this->attributes['class'], ''), issetor($this->attributes['lazy'], false), issetor($this->attributes['absoluteUrl'], false));
             break;
         case 'image':
             return false;
             break;
     }
     // TODO:
     throw new Exception('Missing required attributes for component call');
 }
コード例 #4
0
ファイル: functions_ade.php プロジェクト: IMR18/web
function updateRessources($db, $ressources, $startdate = null, $enddate = null, $GMT = "+1 hour")
{
    if ($startdate == null) {
        $startdate = date("Y-m-d");
    }
    if ($enddate == null) {
        $enddate = date("Y-m-d", strtotime("+30 days"));
    }
    $nb = array();
    foreach ($ressources as $ressource) {
        $ical = new ICal('https://planning.univ-rennes1.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=' . $ressource . '&projectId=1&calType=ical&firstDate=' . $startdate . '&lastDate=' . $enddate);
        $events = $ical->events();
        $insertNb = 0;
        purge_events($db, $ressource);
        if ($events) {
            foreach ($events as $event) {
                $export_d = date("Y/m/d H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTAMP'])));
                $start_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $start_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $end_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $end_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $description = desc2json($event['DESCRIPTION']);
                $req = $db->prepare('insert into events (UID,ressource, StartDate, StartTime, EndDate, EndTime, Title, Location, Description,Export) VALUES (?,?,?,?,?,?,?,?,?,?)');
                $res = $req->execute(array(issetor($event['UID']), $ressource, $start_d, $start_t, $end_d, $end_t, $event['SUMMARY'], issetor($event['LOCATION']), $description, $export_d));
                $insertNb += $res;
            }
        }
        $nb[$ressource] = $insertNb;
    }
    $req = $db->prepare("UPDATE ressources r inner join events e on r.number = e.ressource set r.last_sync = e.Export");
    $req->execute();
    return $nb;
}
コード例 #5
0
 public function invoke($action = null, $format = null)
 {
     $timerKey = Ajde::app()->addTimer((string) $this->_route);
     $action = issetor($action, $this->getAction());
     $format = issetor($format, $this->getFormat());
     $emptyFunction = $action;
     $defaultFunction = $action . "Default";
     $formatFunction = $action . ucfirst($format);
     if (method_exists($this, $formatFunction)) {
         $actionFunction = $formatFunction;
     } elseif (method_exists($this, $defaultFunction)) {
         $actionFunction = $defaultFunction;
     } elseif (method_exists($this, $emptyFunction)) {
         $actionFunction = $emptyFunction;
     } else {
         $exception = new Ajde_Exception(sprintf("Action %s for module %s not found", $this->getAction(), $this->getModule()), 90011);
         Ajde::routingError($exception);
     }
     $return = true;
     if (method_exists($this, 'beforeInvoke')) {
         $return = $this->beforeInvoke();
         if ($return !== true && $return !== false) {
             // TODO:
             throw new Ajde_Exception(sprintf("beforeInvoke() must return either TRUE or FALSE"));
         }
     }
     if ($return === true) {
         $return = $this->{$actionFunction}();
         if (method_exists($this, 'afterInvoke')) {
             $this->afterInvoke();
         }
     }
     Ajde::app()->endTimer($timerKey);
     return $return;
 }
コード例 #6
0
 public function validate($options = array())
 {
     $fieldsArray = $this->_model->getTable()->getFieldProperties();
     $fieldOptions = array();
     foreach ($fieldsArray as $fieldName => $fieldProperties) {
         $fieldOptions[$fieldName] = array_merge($fieldProperties, issetor($options[$fieldName], array()));
     }
     $valid = true;
     $errors = array();
     $this->_initValidators($fieldOptions);
     foreach ($this->_model->getValidators() as $fieldName => $fieldValidators) {
         foreach ($fieldValidators as $fieldValidator) {
             /* @var $validator Ajde_Model_ValidatorAbstract */
             $value = null;
             if ($this->_model->has($fieldName)) {
                 $value = $this->_model->get($fieldName);
             }
             $result = $fieldValidator->validate($fieldOptions[$fieldName], $value);
             if ($result['valid'] === false) {
                 if (!isset($errors[$fieldName])) {
                     $errors[$fieldName] = array();
                 }
                 $errors[$fieldName][] = $result['error'];
                 $valid = false;
             }
         }
     }
     $this->_errors = $errors;
     return $valid;
 }
コード例 #7
0
ファイル: Validator.php プロジェクト: nabble/ajde-core
 private function _initValidators($fieldOptions)
 {
     foreach ($fieldOptions as $fieldName => $fieldProperties) {
         switch (issetor($fieldProperties['type'])) {
             case Db::FIELD_TYPE_DATE:
                 $this->_model->addValidator($fieldName, new Date());
                 break;
             case 'sort':
             case Db::FIELD_TYPE_NUMERIC:
                 $this->_model->addValidator($fieldName, new Numeric());
                 break;
             case Db::FIELD_TYPE_TEXT:
                 $this->_model->addValidator($fieldName, new Text());
                 break;
             case Db::FIELD_TYPE_ENUM:
                 $this->_model->addValidator($fieldName, new Enum());
                 break;
             case Db::FIELD_TYPE_SPATIAL:
                 $this->_model->addValidator($fieldName, new Spatial());
                 break;
             default:
                 break;
         }
         if (issetor($fieldProperties['isRequired']) === true && issetor($fieldProperties['default']) == '') {
             $this->_model->addValidator($fieldName, new Required());
         }
         if (issetor($fieldProperties['isUnique']) === true) {
             $this->_model->addValidator($fieldName, new Unique());
         }
     }
 }
コード例 #8
0
ファイル: PDOStatement.php プロジェクト: nabble/ajde
 /**
  * When execute is called record the time it takes and
  * then log the query.
  *
  * @param array $input_parameters
  *
  * @throws Ajde_Db_Exception
  * @throws Ajde_Exception
  *
  * @return PDO result set
  */
 public function execute($input_parameters = null)
 {
     $log = ['query' => ''];
     if (config('app.debug') === true) {
         //$cache = Ajde_Db_Cache::getInstance();
         if (count($input_parameters)) {
             $log = ['query' => vsprintf(str_replace('?', '%s', $this->queryString), $input_parameters)];
         } else {
             $log = ['query' => '[PS] ' . $this->queryString];
         }
         // add backtrace
         $i = 0;
         $source = [];
         foreach (array_reverse(debug_backtrace()) as $item) {
             try {
                 $line = issetor($item['line']);
                 $file = issetor($item['file']);
                 $source[] = sprintf('%s. <em>%s</em>%s<strong>%s</strong> (%s on line %s)', $i, !empty($item['class']) ? $item['class'] : '&lt;unknown class&gt;', !empty($item['type']) ? $item['type'] : '::', !empty($item['function']) ? $item['function'] : '&lt;unknown function&gt;', $file, $line);
             } catch (Exception $e) {
             }
             $i++;
         }
         $hash = md5(implode('', $source) . microtime());
         $log['query'] = '<a href="javascript:void(0)" onclick="$(\'#' . $hash . '\').slideToggle(\'fast\');" style="color: black;">' . $log['query'] . '</a>';
         $log['query'] .= '<div id="' . $hash . '" style="display: none;">' . implode('<br/>', $source) . '</div>';
     }
     // start timer
     $start = microtime(true);
     try {
         //if (!$cache->has($this->queryString . serialize($input_parameters))) {
         $result = parent::execute($input_parameters);
         //$cache->set($this->queryString . serialize($input_parameters), $result);
         //	$log['cache'] = false;
         //} else {
         //	$result = $cache->get($this->queryString . serialize($input_parameters));
         //	$log['cache'] = true;
         //}
     } catch (Exception $e) {
         if (substr_count(strtolower($e->getMessage()), 'integrity constraint violation')) {
             throw new Ajde_Db_IntegrityException($e->getMessage());
         } else {
             if (config('app.debug') === true) {
                 if (isset($this->queryString)) {
                     dump($this->queryString);
                 }
                 dump('Go to ' . config('app.rootUrl') . '?install=1 to install DB');
                 throw new Ajde_Db_Exception($e->getMessage());
             } else {
                 Ajde_Exception_Log::logException($e);
                 die('DB connection problem. <a href="?install=1">Install database?</a>');
             }
         }
     }
     $time = microtime(true) - $start;
     $log['time'] = round($time * 1000, 0);
     Ajde_Db_PDO::$log[] = $log;
     return $result;
 }
コード例 #9
0
 public static function getLinkTemplateFilename($type, $format = 'null')
 {
     if (Ajde::app()->getDocument()->hasLayout()) {
         $layout = Ajde::app()->getDocument()->getLayout();
     } else {
         $layout = new Ajde_Layout(Config::get("layout"));
     }
     $format = issetor($format, 'html');
     return LAYOUT_DIR . $layout->getName() . '/link/' . $type . '.' . $format . '.php';
 }
コード例 #10
0
 public function formUploadHtml()
 {
     $options = $this->getOptions();
     $optionsId = md5(serialize($options));
     $session = new Ajde_Session('AC.Form');
     $session->set($optionsId, $options);
     $this->setAction('form/upload');
     $this->getView()->assign('name', $this->getName());
     $this->getView()->assign('optionsId', $optionsId);
     $this->getView()->assign('optionsMultiple', issetor($options['multiple'], false));
     $this->getView()->assign('inputId', $this->getInputId());
     $this->getView()->assign('extraClass', $this->getExtraClass());
     return $this->render();
 }
コード例 #11
0
ファイル: Dump.php プロジェクト: nabble/updatemybrowser-v1
 public static function dump($var, $collapse = false)
 {
     $i = 0;
     $line = null;
     foreach (debug_backtrace() as $item) {
         $source = sprintf("%s. dumped from <em>%s</em>%s<strong>%s</strong> (line %s)", count(self::$dump) + 1, !empty($item['class']) ? $item['class'] : '&lt;unknown class&gt; (in <span style=\'font-size: 0.8em;\'>' . $item['args'][0] . '</span>)', !empty($item['type']) ? $item['type'] : '::', !empty($item['function']) ? $item['function'] : '&lt;unknown function&gt;', $line);
         $line = issetor($item['line'], null);
         if ($i == 2) {
             break;
         }
         $i++;
     }
     self::$dump[$source] = array($var, $collapse);
 }
コード例 #12
0
ファイル: Js.php プロジェクト: nabble/ajde
 public function process()
 {
     //		TODO: check for required attributes
     //		if (!array_key_exists('library', $this->attributes) || !array_key_exists('version', $this->attributes)) {
     //			throw new Ajde_Component_Exception();
     //		}
     if (array_key_exists('library', $this->attributes)) {
         $this->requireJsLibrary($this->attributes['library'], $this->attributes['version']);
     } elseif (array_key_exists('action', $this->attributes)) {
         $this->requireResource(Ajde_Resource_Local::TYPE_JAVASCRIPT, $this->attributes['action'], issetor($this->attributes['format'], null), issetor($this->attributes['base'], null), issetor($this->attributes['position'], null), issetor($this->attributes['arguments'], ''));
     } elseif (array_key_exists('filename', $this->attributes)) {
         $this->requirePublicResource(Ajde_Resource_Local::TYPE_JAVASCRIPT, $this->attributes['filename'], issetor($this->attributes['position'], null), issetor($this->attributes['arguments'], ''));
     } elseif (array_key_exists('url', $this->attributes)) {
         $this->requireRemoteResource(Ajde_Resource_Local::TYPE_JAVASCRIPT, $this->attributes['url'], issetor($this->attributes['position'], null), issetor($this->attributes['arguments'], ''));
     }
 }
コード例 #13
0
ファイル: Css.php プロジェクト: nabble/updatemybrowser-v1
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'local':
             $this->requireResource(Ajde_Resource_Local::TYPE_STYLESHEET, $this->attributes['action'], issetor($this->attributes['format'], null), issetor($this->attributes['base'], null), issetor($this->attributes['position'], null), issetor($this->attributes['arguments'], ''));
             break;
         case 'public':
             $this->requirePublicResource(Ajde_Resource_Local::TYPE_STYLESHEET, $this->attributes['filename'], issetor($this->attributes['position'], null), issetor($this->attributes['arguments'], ''));
             break;
         case 'font':
             $url = Ajde_Resource_GWebFont::getUrl($this->attributes['fontFamily'], issetor($this->attributes['fontWeight'], array(400)), issetor($this->attributes['fontSubset'], array('latin')));
             $resource = new Ajde_Resource_Remote(Ajde_Resource::TYPE_STYLESHEET, $url);
             $this->getParser()->getDocument()->addResource($resource, Ajde_Document_Format_Html::RESOURCE_POSITION_TOP);
             break;
     }
 }
コード例 #14
0
ファイル: Dump.php プロジェクト: nabble/ajde
 public static function dump($var, $expand = true)
 {
     $i = 0;
     $line = null;
     foreach (debug_backtrace() as $item) {
         try {
             $source = sprintf('%s. dumped from <em>%s</em>%s<strong>%s</strong> (line %s)', count(self::$dump) + 1, isset($item['class']) ? is_object($item['class']) ? get_class($item['class']) : $item['class'] : '&lt;unknown class&gt; (in <span style=\'font-size: 0.8em;\'>' . print_r($item['args'][0]) . '</span>)', !empty($item['type']) ? $item['type'] : '::', !empty($item['function']) ? $item['function'] : '&lt;unknown function&gt;', $line);
             $line = issetor($item['line'], null);
         } catch (Exception $e) {
         }
         if ($i == 2) {
             break;
         }
         $i++;
     }
     self::$dump[$source] = [$var, $expand];
 }
コード例 #15
0
ファイル: Resource.php プロジェクト: nabble/ajde
 public static function getLinkTemplateFilename($type, $format = 'null')
 {
     if (Ajde::app()->getDocument()->hasLayout()) {
         $layout = Ajde::app()->getDocument()->getLayout();
     } else {
         $layout = new Ajde_Layout(config('layout.frontend'));
     }
     $format = issetor($format, 'html');
     $dirPrefixPatterns = [APP_DIR, CORE_DIR];
     foreach ($dirPrefixPatterns as $dirPrefixPattern) {
         $prefixedLayout = $dirPrefixPattern . LAYOUT_DIR;
         if (self::exist($prefixedLayout . $layout->getName() . '/link/' . $type . '.' . $format . '.php')) {
             return $prefixedLayout . $layout->getName() . '/link/' . $type . '.' . $format . '.php';
         }
     }
     return false;
 }
コード例 #16
0
ファイル: Embed.php プロジェクト: nabble/ajde-core
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'render':
             $image = new Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop(String::toBoolean($this->attributes['crop']));
             $controller = Controller::fromRoute(new Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Exception('Missing required attributes for component call');
 }
コード例 #17
0
ファイル: Form.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'form':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:form'));
             $controller->setFormAction($this->attributes['route']);
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'ajax':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:formAjax'));
             $formAction = new Ajde_Core_Route($this->attributes['route']);
             $formAction->setFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormAction($formAction->__toString());
             $controller->setFormFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'upload':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:formUpload'));
             if (!isset($this->attributes['options']) || !isset($this->attributes['options']['saveDir']) || !isset($this->attributes['options']['extensions'])) {
                 // TODO:
                 throw new Ajde_Component_Exception('Options saveDir and extensions must be set for AC.Form.Upload');
             }
             $controller->setName($this->attributes['name']);
             $controller->setOptions($this->attributes['options']);
             $controller->setInputId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'embed':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('form/view.html'));
             $controller->setId($this->attributes['id']);
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception();
 }
コード例 #18
0
ファイル: Crud.php プロジェクト: nabble/updatemybrowser-v1
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'list':
             $options = issetor($this->attributes['options'], array());
             $crud = new Ajde_Crud($this->attributes['model'], $options);
             $crud->setAction('list');
             return $crud;
             break;
         case 'edit':
             $options = issetor($this->attributes['options'], array());
             $id = issetor($this->attributes['id'], null);
             $crud = new Ajde_Crud($this->attributes['model'], $options);
             $crud->setId($id);
             $crud->setAction('edit');
             return $crud;
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception();
 }
コード例 #19
0
ファイル: Revision.php プロジェクト: nabble/ajde-core
 public function save()
 {
     // check all changed fields
     $modelName = get_class($this);
     $shadowModel = new $modelName();
     /* @var $shadowModel Ajde_Model */
     $shadowModel->loadByPK($this->getPK());
     if ($shadowModel->_hasMeta) {
         $shadowModel->populateMeta();
     }
     // old values
     $oldValues = $shadowModel->values();
     foreach ($oldValues as &$oldValue) {
         @($oldValue = (string) $oldValue);
     }
     // populate meta of current model, but don't override
     if ($this->_hasMeta) {
         $this->populateMeta(false, false);
     }
     // new values
     $newValues = $this->values();
     foreach ($newValues as $k => &$newValue) {
         if ($k == 'meta_4') {
             //                die('hier');
         }
         @($newValue = (string) $newValue);
     }
     // ignore fields
     foreach ($this->_ignoreFieldInRevision as $ignoreField) {
         unset($oldValues[$ignoreField]);
         unset($newValues[$ignoreField]);
     }
     // ignore fields
     foreach ($this->_ignoreFieldInRevisionIfEmpty as $ignoreField) {
         if (!isset($newValues[$ignoreField]) || empty($newValues[$ignoreField])) {
             unset($oldValues[$ignoreField]);
             unset($newValues[$ignoreField]);
         }
     }
     if ($diffs = array_diff_assoc($oldValues, $newValues)) {
         foreach ($diffs as $diffField => $diffValue) {
             $revision = new RevisionModel();
             $revision->model = $this->getModelName();
             $revision->foreignkey = $this->getPK();
             $revision->user = UserModel::getLoggedIn();
             $revision->field = $diffField;
             $revision->old = issetor($oldValues[$diffField]);
             $revision->new = issetor($newValues[$diffField]);
             $revision->insert();
         }
     }
     return parent::save();
 }
コード例 #20
0
ファイル: gzUser.php プロジェクト: phone1246/mikrotik
 function update($p)
 {
     $permSet = array();
     if (!empty($p['pm'])) {
         foreach ($p['pm'] as $k => $v) {
             $permSet[$k] = $v == 'on' ? true : cInt($v);
         }
     }
     $this->id = isPostor('id');
     $this->acr = cInt(isPostor('acr', 0));
     $this->acw = cInt(isPostor('acw', 0));
     if (!isset($permSet['esv.def']) && !isset($permSet['ews.def'])) {
         $permSet['esv.def'] = true;
     }
     if ($this->id == 1) {
         $this->acr = 99;
         $this->acw = 99;
         $adm = array('esv.def' => issetor($permSet['esv.def'], false), 'ews.def' => issetor($permSet['ews.def'], false));
         $permSet = $adm;
     }
     $this->name = trim(isPostor('name'));
     $this->desc = isPostor('desc');
     $this->props["pm"] = $permSet;
     if (empty($this->name)) {
         gzClient::begin()->eAlert("Error:!Name is not empty...")->send();
     }
     $data = array('userg_name' => $this->name, 'userg_description' => $this->desc, 'userg_acr' => $this->acr, 'userg_acw' => $this->acw, 'rec_update' => NOW, 'userg_props' => json_encode($this->props));
     if (empty($this->id)) {
         $data['rec_update'] = NOW;
         $data['rec_create'] = NOW;
         g::DB()->aInsert($data, 'sg_user_group');
     } else {
         g::DB()->aUpdate($data, 'sg_user_group', 'userg_id', $this->id);
         g::cacheSet('UGROUP' . $this->id, $this);
     }
     //gzData::uGroupInfo(true);
     gzClient::begin()->redirect("cpanel.usergroup")->endSend();
 }
コード例 #21
0
ファイル: Paypal.php プロジェクト: nabble/ajde-core
 public function updatePayment()
 {
     // PHP 4.1
     // read the post from PayPal system and add 'cmd'
     $req = 'cmd=_notify-validate';
     foreach ($_POST as $key => $value) {
         $value = urlencode(stripslashes($value));
         $req .= "&{$key}={$value}";
     }
     // post back to PayPal system to validate
     $header = '';
     $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
     $fp = fsockopen($this->isSandbox() ? 'ssl://www.sandbox.paypal.com' : 'ssl://www.paypal.com', 443, $errno, $errstr, 30);
     // assign posted variables to local variables
     $item_name = issetor($_POST['item_name']);
     $item_number = issetor($_POST['item_number']);
     $payment_status = issetor($_POST['payment_status']);
     $payment_amount = issetor($_POST['mc_gross']);
     $payment_currency = issetor($_POST['mc_currency']);
     $txn_id = issetor($_POST['txn_id']);
     $receiver_email = issetor($_POST['receiver_email']);
     $payer_email = issetor($_POST['payer_email']);
     Model::register('shop');
     $secret = issetor($_POST['custom']);
     $transaction = new TransactionModel();
     $changed = false;
     if (!$fp) {
         // HTTP ERROR
     } else {
         fputs($fp, $header . $req);
         while (!feof($fp)) {
             $res = fgets($fp, 1024);
             if (strcmp($res, "VERIFIED") == 0) {
                 if (!$transaction->loadByField('secret', $secret)) {
                     Log::log('Could not find transaction for PayPal payment with txn id ' . $txn_id . ' and transaction secret ' . $secret);
                     return array('success' => false, 'transaction' => null);
                 }
                 // check the payment_status is Completed
                 // accept Pending from PayPal (eChecks?)
                 $acceptPending = true;
                 if ($payment_status == 'Completed' || $acceptPending && $payment_status == 'Pending') {
                     $details = 'AMOUNT: ' . $payment_amount . PHP_EOL . 'CURRENCY: ' . $payment_currency . PHP_EOL . 'PAYER_EMAIL: ' . $payer_email . PHP_EOL . 'RECEIVER_EMAIL: ' . $receiver_email . PHP_EOL . 'TXN_ID: ' . $txn_id . PHP_EOL;
                     // update transaction only once
                     if ($transaction->payment_status != 'completed') {
                         $transaction->payment_details = $details;
                         $transaction->payment_status = 'completed';
                         $transaction->save();
                         $changed = true;
                     }
                     // Write pending to Log
                     if ($payment_status == 'Pending') {
                         Log::log('Status is Pending but accepting now. PayPal payment with txn id ' . $txn_id . ' and transaction secret ' . $secret);
                     }
                     return array('success' => true, 'changed' => $changed, 'transaction' => $transaction);
                 } else {
                     if ($transaction->payment_status != 'refused') {
                         $transaction->payment_status = 'refused';
                         $transaction->save();
                         $changed = true;
                     }
                     Log::log('Status is not Completed but ' . $payment_status . ' for PayPal payment with txn id ' . $txn_id . ' and transaction secret ' . $secret);
                 }
                 // check that txn_id has not been previously processed
                 // check that receiver_email is your Primary PayPal email
                 // check that payment_amount/payment_currency are correct
                 // process payment
             } else {
                 if (strcmp($res, "INVALID") == 0) {
                     if (!$transaction->loadByField('secret', $secret)) {
                         // secret not found anyway
                         $transaction = null;
                         Log::log('Could not find transaction for PayPal payment with txn id ' . $txn_id . ' and transaction secret ' . $secret);
                     } else {
                         // log for manual investigation
                         if ($transaction->payment_status != 'refused') {
                             $transaction->payment_status = 'refused';
                             $transaction->save();
                             $changed = true;
                         }
                         Log::log('Validation failed for PayPal payment with txn id ' . $txn_id);
                     }
                 }
             }
         }
         fclose($fp);
     }
     return array('success' => false, 'changed' => $changed, 'transaction' => $transaction);
 }
コード例 #22
0
ファイル: Image.php プロジェクト: nabble/ajde
 protected function extension()
 {
     $path_info = pathinfo($this->_source);
     return strtolower(issetor($path_info['extension']));
 }
コード例 #23
0
ファイル: agenda.php プロジェクト: IMR18/web
            $res = get_tasks($db, $group, $from);
            break;
        case "addTask":
            if (!isset($p->title)) {
                $res = array('status' => false, 'msg' => "NO PARAMETERS");
            } else {
                $res = array('status' => add_task($db, issetor($p->title), issetor($p->description), issetor($p->deadline), issetor($p->worklevel), issetor($p->groupe), issetor($p->UID)), 'msg' => "{$p->title} est ajouté");
            }
            break;
        case "deleteTask":
            if (!isset($p->id)) {
                $res = array('status' => false, 'msg' => "NO PARAMETERS");
            } else {
                $res = array('status' => deleteTask($db, issetor($p->id)), 'msg' => "{$p->title} est supprimée");
            }
            break;
        case "editTask":
            if (!isset($p->id)) {
                $res = array('status' => false, 'msg' => "NO PARAMETERS");
            } else {
                $res = array('status' => editTask($db, issetor($p->title), issetor($p->description), issetor($p->deadline), issetor($p->worklevel), issetor($p->groupe), issetor($p->UID), $p->id), 'msg' => "{$p->title} est modifiée");
            }
            break;
        default:
            $res = array("ACTION NOT FOUND");
    }
    echo json_encode($res);
} else {
    $res = array("NO ACTION SET");
    echo json_encode($res);
}
コード例 #24
0
ファイル: _coreCrudController.php プロジェクト: nabble/ajde
 private function submission($crudId, $id)
 {
     $session = new Ajde_Session('AC.Crud');
     /* @var $crud Ajde_Crud */
     $crud = $session->getModel($crudId);
     // verify that we have a valid crud model
     if (!$crud) {
         return ['success' => false];
     }
     /* @var $model FormModel */
     $model = $crud->getModel();
     $model->setOptions($crud->getOptions('model'));
     // Get POST params
     $post = Ajde_Http_Request::globalPost();
     $id = issetor($post['id']);
     // verify that we have a valid form model
     if (!$id) {
         return ['success' => false];
     }
     // load form
     $model->loadByPK($id);
     $model->populate($post);
     // validate form
     Ajde_Event::trigger($model, 'beforeCrudSave', [$crud]);
     if (!$model->validate($crud->getOptions('fields'))) {
         return ['operation' => 'save', 'success' => false, 'errors' => $model->getValidationErrors()];
     }
     // prepare submission
     $values = [];
     foreach ($post as $key => $value) {
         if (substr($key, 0, 5) === 'meta_') {
             $metaId = str_replace('meta_', '', $key);
             $metaName = MetaModel::getNameFromId($metaId);
             $values[$metaName] = $value;
         }
     }
     $entryText = '';
     foreach ($values as $k => $v) {
         $entryText .= $k . ': ' . $v . PHP_EOL;
     }
     $submission = new SubmissionModel();
     $submission->form = $id;
     $submission->ip = $_SERVER['REMOTE_ADDR'];
     $submission->user = Ajde_User::getLoggedIn();
     $submission->entry = json_encode($values);
     $submission->entry_text = $entryText;
     $success = $submission->insert();
     if ($success === true) {
         // Destroy reference to crud instance
         $session->destroy($crudId);
         // set message for next page
         Ajde_Session_Flash::alert(trans('Form submitted successfully'));
         $mailer = new Ajde_Mailer();
         // send email to administrator
         $body = 'Form: ' . $model->displayField() . '<br/><br/>' . nl2br($entryText);
         $mailer->SendQuickMail(config('app.email'), config('app.email'), config('app.title'), 'New form submission', $body);
         // send email to user
         $email = $model->getEmail();
         /* @var $email EmailModel */
         $email_to = $model->getEmailTo();
         /* @var $email MetaModel */
         $email_address = issetor($post['meta_' . $email_to->getPK()]);
         if ($email->hasLoaded() && $email_to->hasLoaded() && $email_address) {
             $mailer->sendUsingModel($email->getIdentifier(), $email_address, $email_address, ['entry' => nl2br($entryText)]);
         }
     }
     return ['operation' => 'save', 'id' => $model->getPK(), 'displayField' => $model->get($model->getDisplayField()), 'success' => $success];
 }
コード例 #25
0
ファイル: Crud.php プロジェクト: nabble/ajde
 public function getFieldOptions($fieldName, $fieldProperties = [])
 {
     $fieldsOptions = $this->getOptions('fields');
     $fieldOptions = issetor($fieldsOptions[$fieldName], []);
     return array_merge($fieldProperties, $fieldOptions);
 }
コード例 #26
0
ファイル: Request.php プロジェクト: nabble/ajde
 private static function _getHashFromSession($token)
 {
     $tokenDictionary = self::_getTokenDictionary();
     return issetor($tokenDictionary[$token], '');
 }
コード例 #27
0
ファイル: AbstractWriter.php プロジェクト: nabble/ajde-core
 public static function getRequest()
 {
     return issetor($_SERVER["REQUEST_URI"]);
 }
コード例 #28
0
ファイル: Controller.php プロジェクト: nabble/ajde
 /**
  * @param string|null $action
  * @param string|null $format
  *
  * @throws Ajde_Exception
  * @throws Exception
  *
  * @return mixed
  */
 public function invoke($action = null, $format = null)
 {
     $timerKey = Ajde::app()->addTimer((string) $this->_route);
     $action = issetor($action, $this->getAction());
     $format = issetor($format, $this->getFormat());
     $method = strtolower($_SERVER['REQUEST_METHOD']);
     $tryTheseFunctions = [];
     $formatFunction = $action . ucfirst($format);
     $defaultFunction = $action . 'Default';
     $emptyFunction = $action;
     $tryTheseFunctions[] = $formatFunction . ucfirst($method);
     $tryTheseFunctions[] = $defaultFunction . ucfirst($method);
     $tryTheseFunctions[] = $emptyFunction . ucfirst($method);
     $tryTheseFunctions[] = $formatFunction;
     $tryTheseFunctions[] = $defaultFunction;
     $tryTheseFunctions[] = $emptyFunction;
     $invokeFunction = '';
     foreach ($tryTheseFunctions as $tryFunction) {
         if (method_exists($this, $tryFunction)) {
             $invokeFunction = $tryFunction;
             break;
         }
     }
     //        dump(get_class($this) . '::' .  $invokeFunction);
     if (!$invokeFunction) {
         $exception = new Ajde_Core_Exception_Routing(sprintf('Action %s for module %s not found', $this->getAction(), $this->getModule()), 90011);
         Ajde::routingError($exception);
     }
     $return = true;
     if (method_exists($this, 'beforeInvoke')) {
         $return = $this->beforeInvoke();
         if ($return !== true && $return !== false) {
             // TODO:
             throw new Ajde_Exception(sprintf('beforeInvoke() must return either TRUE or FALSE'));
         }
     }
     if ($return === true) {
         $return = $this->{$invokeFunction}();
         if (method_exists($this, 'afterInvoke')) {
             $this->afterInvoke();
         }
     }
     Ajde::app()->endTimer($timerKey);
     return $return;
 }
コード例 #29
0
ファイル: Handler.php プロジェクト: nabble/updatemybrowser-v1
 public static function trace(Exception $exception, $output = self::EXCEPTION_TRACE_HTML)
 {
     if (Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
         $output = self::EXCEPTION_TRACE_LOG;
     }
     if ($exception instanceof ErrorException) {
         $type = "PHP Error " . self::getErrorType($exception->getSeverity());
     } elseif ($exception instanceof Ajde_Exception) {
         $type = "Uncaught application exception" . ($exception->getCode() ? ' ' . $exception->getCode() : '');
     } else {
         $type = "Uncaught PHP exception " . $exception->getCode();
     }
     switch ($output) {
         case self::EXCEPTION_TRACE_HTML:
             if (ob_get_level()) {
                 ob_clean();
             }
             $traceMessage = '<ol reversed="reversed">';
             self::$firstApplicationFileExpanded = false;
             foreach ($exception->getTrace() as $item) {
                 $arguments = null;
                 if (!empty($item['args'])) {
                     ob_start();
                     var_dump($item['args']);
                     $dump = ob_get_clean();
                     $arguments = sprintf(' with arguments: %s', $dump);
                 }
                 $traceMessage .= sprintf("<li><em>%s</em>%s<strong>%s</strong><br/>in %s<br/>&nbsp;\n", !empty($item['class']) ? $item['class'] : '&lt;unknown class&gt;', !empty($item['type']) ? $item['type'] : '::', !empty($item['function']) ? $item['function'] : '&lt;unknown function&gt;', self::embedScript(issetor($item['file'], null), issetor($item['line'], null), $arguments, false));
                 $traceMessage .= '</li>';
             }
             $traceMessage .= '</ol>';
             $exceptionDocumentation = '';
             if ($exception instanceof Ajde_Exception && $exception->getCode()) {
                 $exceptionDocumentation = sprintf("<div style='margin-top: 4px;'><img src='//" . Config::get('site_root') . "public/images/_core/globe_16.png' style='vertical-align: bottom;' title='Primary key' width='16' height='16' /> <a href='%s'>Documentation on error %s</a>&nbsp;</div>", Ajde_Core_Documentation::getUrl($exception->getCode()), $exception->getCode());
             }
             $exceptionMessage = sprintf("<div style='background-color:#F1F1F1;background-image: url(\"//" . Config::get('site_root') . "public/images/_core/warning_48.png\"); background-repeat: no-repeat; background-position: 10px 10px; border: 1px solid silver; padding: 10px 10px 10px 70px;'><h3 style='margin:0;'>%s:</h3><h2 style='margin:0;'>%s</h2> Exception thrown in %s%s</div><h3>Trace:</h3>\n", $type, $exception->getMessage(), self::embedScript($exception->getFile(), $exception->getLine(), $arguments, false), $exceptionDocumentation);
             $exceptionDump = '';
             if (class_exists("Ajde_Dump")) {
                 if ($dumps = Ajde_Dump::getAll()) {
                     $exceptionDump .= '<h2>Dumps</h2>';
                     foreach ($dumps as $dump) {
                         ob_start();
                         var_dump($dump[0]);
                         $exceptionDump .= ob_get_clean();
                     }
                 }
             }
             $style = false;
             if (file_exists(MODULE_DIR . '_core/res/css/debugger/handler.css')) {
                 $style = file_get_contents(MODULE_DIR . '_core/res/css/debugger/handler.css');
             }
             if ($style === false) {
                 // For shutdown() call
                 $style = 'body {font: 13px sans-serif;} a {color: #005D9A;} a:hover {color: #9A0092;} h2 {color: #005D9A;} span > a {color: #9A0092;}';
             }
             $style = '<style>' . $style . '</style>';
             $message = $style . $exceptionDump . $exceptionMessage . $traceMessage;
             break;
         case self::EXCEPTION_TRACE_LOG:
             $message = 'Request ' . $_SERVER["REQUEST_URI"] . " triggered:" . PHP_EOL;
             $message .= sprintf("%s: %s in %s on line %s", $type, $exception->getMessage(), $exception->getFile(), $exception->getLine());
             foreach (array_reverse($exception->getTrace()) as $i => $line) {
                 $message .= PHP_EOL;
                 $message .= $i . '. ' . issetor($line['file']) . ' on line ' . issetor($line['line']);
             }
             break;
     }
     return $message;
 }
コード例 #30
0
ファイル: micro_bench.php プロジェクト: cefalo19/php-src
$x->post_dec_prop(N);
$t = end_test($t, '$this->x--', $overhead);
$x->isset_prop(N);
$t = end_test($t, 'isset($this->x)', $overhead);
$x->empty_prop(N);
$t = end_test($t, 'empty($this->x)', $overhead);
$x->call(N);
$t = end_test($t, '$this->f()', $overhead);
$x->read_const(N);
$t = end_test($t, '$x = Foo::TEST', $overhead);
create_object(N);
$t = end_test($t, 'new Foo()', $overhead);
read_const(N);
$t = end_test($t, '$x = TEST', $overhead);
read_auto_global(N);
$t = end_test($t, '$x = $_GET', $overhead);
read_global_var(N);
$t = end_test($t, '$x = $GLOBALS[\'v\']', $overhead);
read_hash(N);
$t = end_test($t, '$x = $hash[\'v\']', $overhead);
read_str_offset(N);
$t = end_test($t, '$x = $str[0]', $overhead);
issetor(N);
$t = end_test($t, '$x = $a ?: null', $overhead);
issetor2(N);
$t = end_test($t, '$x = $f ?: tmp', $overhead);
ternary(N);
$t = end_test($t, '$x = $f ? $f : $a', $overhead);
ternary2(N);
$t = end_test($t, '$x = $f ? $f : tmp', $overhead);
total($t0, "Total");