Esempio n. 1
0
 /**
  * Validates a number value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $required = get::array_def($this->attributes, 'required', false) == 'required';
     $integeronly = get::array_def($this->attributes, 'integeronly', false, array(true, false));
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($required && (!isset($value) || strlen(trim($value)) < 1)) {
         return sprintf('"%s" is a required field.', $msglbl);
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $value = trim($value);
         $valid = $integeronly ? preg_match('/^[+-]?\\d+$/', $value) ? (int) $value : false : is::float($value);
         $errorText = $integeronly ? 'integer' : 'number';
         $min = get::array_def($this->attributes, 'min', null);
         $max = get::array_def($this->attributes, 'max', null);
         if ($valid === false) {
             return sprintf('"%s" is not a valid %s.', $msglbl, $errorText);
         } elseif (isset($min) && $valid < $min) {
             return sprintf('"%s" is not allowed to be less than %s.', $msglbl, $min);
         } elseif (isset($max) && $valid > $max) {
             return sprintf('"%s" is not allowed to be greater than %s.', $msglbl, $max);
         }
         $value = $valid;
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Injects csrf tokens into each form found on a webpage.
  * 
  * @param string $data The page being output to the browser.
  * 
  * @return string The modified page to output to the browser.
  */
 public static function injector($data)
 {
     preg_match_all("/<form([^>]*)>(.*?)<\\/form>/is", $data, $matches, PREG_SET_ORDER);
     if (is_array($matches)) {
         self::removeExpiredTokens();
         //page name - used to invalidate other csrf tokens on the same page
         //if( self::$pageName === null )
         $name = self::generateName();
         //uniqid("csrf_".md5(mt_rand()), true);
         foreach ($matches as $m) {
             if (preg_match("/<input\\s+[^>]*(?:name\\=[\"']csrf_token[\"'])[^>]*>/is", $m[2]) || strpos($m[1], 'nocsrf') !== false) {
                 continue;
             }
             $token = self::generate_token($name);
             $data = str_replace($m[0], "<form{$m[1]}><input type=\"hidden\" name=\"csrf_token\" value=\"{$token}\" />{$m[2]}</form>", $data);
         }
     }
     preg_match_all("/<\\/body>/is", $data, $bmatches, PREG_SET_ORDER);
     if (is_array($bmatches)) {
         $kaTimeout = (self::$timeout - 30) * 1000;
         //generate keep alive javascript
         $js = sprintf('<script type="text/javascript"> function csrfKeepAlive(kurl, ktoken){ var config = {url:  kurl,data: "token="+ktoken}; var req; try{ req = new XMLHttpRequest(); }catch(e){ req = new ActiveXObject("Microsoft.XMLHTTP"); } var change = function(){ if( req.readyState == 4 && req.responseText != "false" && req.responseText.length > 0 ){ csrfKeepAliveToken = req.responseText; setTimeout(function(){ csrfKeepAlive(csrfKeepAliveUrl, csrfKeepAliveToken); }, %1$d); } }; req.open("POST", config.url, true); req.setRequestHeader("X_REQUESTED_WITH", "XMLHttpRequest"); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.onreadystatechange = change; req.send(config.data); } var csrfKeepAliveUrl = "%2$s"; var csrfKeepAliveToken = "%3$s"; setTimeout(function(){ csrfKeepAlive(csrfKeepAliveUrl, csrfKeepAliveToken); }, %1$d); </script>', $kaTimeout, get::url('csrf/keepalive/' . self::generateName()), self::generate_keepAlive());
         foreach ($bmatches as $m) {
             $data = str_replace($m[0], $js . '</body>', $data);
         }
     }
     return $data;
 }
Esempio n. 3
0
 /**
  * Validates a file value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $required = get::array_def($this->attributes, 'required', false) == 'required';
     $multiple = get::array_def($this->attributes, 'multiple', false) == 'multiple';
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($required && (!isset($value) || $value['error'] == 4)) {
         return sprintf('"%s" is a required field.', $msglbl);
     }
     if (isset($value)) {
         if ($multiple) {
             foreach ($value as &$file) {
                 $err = $this->checkFileForError($file);
                 if ($err !== true) {
                     return $err;
                 }
             }
         } else {
             $err = $this->checkFileForError($value);
             if ($err !== true) {
                 return $err;
             }
         }
     }
     return true;
 }
Esempio n. 4
0
 public final function render()
 {
     $this->lf = $this->layout !== null ? get::mvc_file('layout', $this->layout) : false;
     if ($this->lf === false && $this->layout != 'default') {
         $this->lf = get::mvc_file('layout', 'default');
     }
     $this->vf = $this->view !== null ? get::mvc_file('view', $this->view) : false;
     if ($this->lf === false) {
         throw new Exception('Unable to find layout: ' . $this->layout);
     }
     if ($this->vf === false) {
         throw new Exception('Unable to find view: ' . $this->view);
     }
     if (isset($this->params) && is_array($this->params) && is::assoc_array($this->params)) {
         extract($this->params);
     }
     $this->helpers = get::helpers('template');
     extract($this->helpers);
     ob_start();
     require $this->vf;
     $munla_view_data = ob_get_contents();
     ob_end_clean();
     if (!isset($page_title)) {
         $page_title = config::TITLE_DEFAULT;
     }
     if (!isset($page_class)) {
         $page_class = preg_replace('[^a-zA-Z0-9-_]', '', str_replace('/', '-', $this->view));
     }
     require $this->lf;
 }
Esempio n. 5
0
 function __construct()
 {
     $this->session = session::getInstance();
     $this->post = post::getInstance();
     $this->get = get::getInstance();
     $this->http = http::getInstance();
     $this->file = file::getInstance();
     $this->cookie = cookie::getInstance();
 }
Esempio n. 6
0
File: a.php Progetto: Borvik/Munla
 /**
  * Generates the HTML for the anchor element.
  * 
  * @return string
  */
 public function __toString()
 {
     $html = '';
     //if( strlen((string)$this->content) > 0 )
     $html = sprintf('<a%s>%s</a>', get::formattedAttributes($this->getAttributes()), $this->content);
     //else
     //$html = sprintf('<a%s />', get::formattedAttributes($this->getAttributes()));
     return $html;
 }
Esempio n. 7
0
 /**
  * Validates a checkbox value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $required = get::array_def($this->attributes, 'required', false) == 'required';
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($required && !isset($value)) {
         return sprintf('"%s" is a required field.', $msglbl);
     }
     return true;
 }
Esempio n. 8
0
 function __construct()
 {
     $this->session = session::getInstance();
     $this->post = post::getInstance();
     $this->get = get::getInstance();
     $this->http = http::getInstance();
     $this->file = new file();
     $this->cookie = new cookie(config('cookie'));
 }
Esempio n. 9
0
File: go.php Progetto: Borvik/Munla
 /**
  * Redirects the user to the requested page under the specified
  * security context (https or http).
  * 
  * If the current context matches the requested context, then processing will
  * continue as normal.
  * 
  * @param bool $ssl
  *   A boolean indicating whether to switch to https or http.
  */
 public static function ssl($ssl = true)
 {
     if (!is_bool($ssl)) {
         throw new InvalidArgumentException('Invalid argument passed to go::ssl().  Must be a boolean value.');
     }
     if (is::ssl() == $ssl) {
         return;
     }
     go::url(get::url($ssl));
 }
Esempio n. 10
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $this->attributes['type'] = $this->type;
     $html = sprintf('<input%s />', get::formattedAttributes($this->getAttributes()));
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Esempio n. 11
0
 /**
  * Validates a text value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $required = get::array_def($this->attributes, 'required', false) == 'required';
     $maxlength = get::array_def($this->attributes, 'maxlength', 0);
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($required && (!isset($value) || strlen(trim($value)) < 1)) {
         return sprintf('"%s" is a required field.', $msglbl);
     }
     if ($maxlength > 0 && strlen(trim($value)) > $maxlength) {
         return sprintf('"%s" has to many characters - the max length is %s.', $msglbl, $maxlength);
     }
     return true;
 }
Esempio n. 12
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $this->attributes['value'] = get::array_def($this->attributes, 'value', '');
     $this->attributes['type'] = $this->type;
     $content = get::array_def($this->attributes, 'content', $this->attributes['value']);
     $html = sprintf('<button%s>%s</button>', get::formattedAttributes($this->getAttributes()), $content);
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Esempio n. 13
0
 /**
  * Creates the HTML for the datalist element.
  * 
  * @return string
  */
 public function __toString()
 {
     $html = sprintf('<datalist id="%s">', get::encodedAttribute($this->getId()));
     if (is::assoc_array($this->list)) {
         foreach ($this->list as $value => $lbl) {
             $html .= sprintf('<option label="%s" value="%s" />', get::encodedAttribute($lbl), get::encodedAttribute($value));
         }
     } else {
         foreach ($this->list as $value) {
             $html .= sprintf('<option value="%s" />', get::encodedAttribute($value));
         }
     }
     $html .= '</datalist>';
     return $html;
 }
Esempio n. 14
0
 /**
  * Validates a text value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $required = get::array_def($this->attributes, 'required', false) == 'required';
     //$maxlength = get::array_def($this->attributes, 'maxlength', 0);
     //$pattern = get::array_def($this->attributes, 'pattern', null);
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($required && (!isset($value) || strlen(trim($value)) < 1)) {
         return sprintf('"%s" is a required field.', $msglbl);
     }
     //if( $maxlength > 0 && strlen(trim($value)) > $maxlength )
     //return sprintf('"%s" has to many characters - the max length is %s.', $msglbl, $maxlength);
     //if( $pattern != null && isset($value) && strlen(trim($value)) > 0 && !preg_match('/^(?:'.$pattern.')$/', $value) )
     //return sprintf('"%s" does not match the pattern defined for it.', $msglbl);
     return true;
 }
Esempio n. 15
0
File: url.php Progetto: Borvik/Munla
 /**
  * Validates a url value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $valid = is::url($value, true);
         if (!is_array($valid)) {
             $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
             return sprintf('"%s" has an invalid url. Urls start with http/https/ftp followed by "://" and then the domain and path.', $msglbl);
         }
         $value = $valid;
     }
     return true;
 }
Esempio n. 16
0
 /**
  * Validates a email value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $valid = is::email($value, get::array_def($this->attributes, 'multiple', false) == 'multiple');
         if (!is_object($valid) || !($valid instanceof emailAddressList || $valid instanceof emailAddress)) {
             $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
             return sprintf('"%s" has an invalid email address.', $msglbl);
         }
         $value = $valid;
     }
     return true;
 }
Esempio n. 17
0
 /**
  * Validates a text value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     $maxlength = get::array_def($this->attributes, 'maxlength', 0);
     $pattern = get::array_def($this->attributes, 'pattern', null);
     $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
     if ($maxlength > 0 && strlen(trim($value)) > $maxlength) {
         return sprintf('"%s" has to many characters - the max length is %s.', $msglbl, $maxlength);
     }
     if ($pattern != null && isset($value) && strlen(trim($value)) > 0 && !preg_match('/^(?:' . $pattern . ')$/', $value)) {
         return sprintf('"%s" does not match the pattern defined for it.', $msglbl);
     }
     return true;
 }
Esempio n. 18
0
File: tel.php Progetto: Borvik/Munla
 /**
  * Validates a telephone value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     $mode = get::array_def($this->attributes, 'validatemode', 'none');
     if (isset($value) && strlen(trim($value)) > 0 && $mode != 'none') {
         if (strtolower($mode) == 'us') {
             $return = false;
             if (preg_match('/^[\\(]?(\\d{0,3})[\\)]?[\\s]?[\\-]?(\\d{3})[\\s]?[\\-]?(\\d{4})([x\\s]{1,}(\\d*))?$/', trim($value), $matches)) {
                 $phoneNumber = '';
                 // we have a match, dump sub-patterns to $matches
                 $phone_number = $matches[0];
                 // original number
                 $area_code = $matches[1];
                 // 3-digit area code
                 $exchange = $matches[2];
                 // 3-digit exchange
                 $number = $matches[3];
                 // 4-digit number
                 $return = new phoneNumber();
                 $return->original = $matches[0];
                 if (isset($matches[1]) && strlen(trim($matches[1])) > 0) {
                     $return->areacode = trim($matches[1]);
                     $return->formatted .= '(' . $return->areacode . ') ';
                 }
                 $return->exchange = $matches[2];
                 $return->number = $matches[3];
                 $return->formatted .= $return->exchange . '-' . $return->number;
                 if (isset($matches[4]) && strlen(trim($matches[4])) > 0) {
                     $return->extension = trim($matches[5]);
                     $return->xformatted = $return->formatted . ' x' . $return->extension;
                 }
             }
             if ($return === false) {
                 $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
                 return sprintf('"%s" has an invalid phone format (###-#### with optional 3 digit area code, and/or extension).', $msglbl);
             }
             $value = $return;
         }
     }
     return true;
 }
Esempio n. 19
0
 /**
  * Validates a color value.  According to the W3C this field should ALWAYS have a value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (!isset($value) || strlen(trim($value)) < 1) {
         $value = '#000000';
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $valid = is::color($value);
         if ($valid === false) {
             $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
             return sprintf('"%s" has an invalid color (ex. #FFFFFF).', $msglbl);
         }
         $value = $valid;
     }
     return true;
 }
Esempio n. 20
0
 public static function init($paginationClass = "pagination", $pagiClass = "pagi")
 {
     self::$file = "app/Views/css/pagination.css";
     self::$init = true;
     self::$url = get::variable("url");
     self::$paginationClass = $paginationClass;
     self::$pClass = $pagiClass;
     add_action("include_style", "include_pagination_css_file");
     if (self::$url[0] == "") {
         self::$url = array('index', 1);
     } else {
     }
     if (count(self::$url) > 2) {
         $page = self::$url[2];
     } elseif (count(self::$url) == 2) {
         $page = self::$url[1];
     } else {
         $page = 1;
     }
     self::$activePage = $page;
 }
Esempio n. 21
0
File: log.php Progetto: Borvik/Munla
 /**
  * Triggers an error
  * 
  * Serializes data to be passed to the error handler, such as message, file and line number.
  * That data is then submitted to trigger_error - and the serialized message must be under 1024 bytes.
  * Long messages/file names could cause problems - though situations like that are not common.
  * 
  * @param int $level The designated error type for this error (use E_USER family of constants).
  * @param string $message The error message for this error (limited to 1024 bytes)
  * 
  * @return void
  */
 protected static function trigger_error($level, $message)
 {
     if (!config::DEBUG_MODE && in_array($level, array(E_USER_WARNING, E_USER_NOTICE))) {
         return;
     }
     if (!is_string($message)) {
         ob_start();
         var_dump($message);
         $message = ob_get_contents();
         ob_end_clean();
     }
     $caller = null;
     $nonLog = null;
     $nonMunla = null;
     $stack = debug_backtrace();
     next($stack);
     list($k, $v) = each($stack);
     do {
         if (!isset($v['file'])) {
             continue;
         }
         if (!isset($caller)) {
             $caller = $v;
         }
         if (!isset($nonLog) && $v['file'] != __FILE__ && (!array_key_exists('class', $v) || $v['class'] != 'log') && !in_array($v['function'], array('error', 'warning', 'notice', 'debug'))) {
             $nonLog = $v;
         }
         if (!isset($nonMunla) && strtolower(substr($v['file'], 0, strlen(MUNLA_CORE_DIR))) != MUNLA_CORE_DIR) {
             $nonMunla = $v;
             break;
         }
     } while (list($k, $v) = each($stack));
     $caller = get::notnull($nonMunla, $nonLog, $caller);
     //get::notnull($nonMunla, $nonLog, $caller);
     if (!isset($caller) && count($stack) > 0) {
         $caller = count($stack) > 1 ? $stack[1] : $stack[0];
     } elseif (!isset($caller)) {
         $caller = array('file' => __FILE__, 'line' => __LINE__);
     }
     //$errorMessage = serialize(array('message' => $message, 'file' => $caller['file'], 'line' => $caller['line']));
     //trigger_error($errorMessage, $level);
     self::error_handler($level, $message, $caller['file'], $caller['line'], true);
 }
Esempio n. 22
0
 public function __toString()
 {
     if (isset($this->params) && is_array($this->params) && is::assoc_array($this->params)) {
         extract($this->params);
     }
     $this->helpers = get::helpers('template');
     if (count($this->helpers) > 0) {
         extract($this->helpers);
     }
     ob_start();
     require $this->file;
     $data = ob_get_contents();
     ob_end_clean();
     return $data;
 }
Esempio n. 23
0
File: get.php Progetto: Borvik/Munla
 /**
  * Attempts to get the file path of the given directory (as relative to the URL).
  * 
  * @param string $file The relative path of the directory to find.
  * 
  * @return string|bool Returns the path to the local directory, or boolean FALSE on failure.
  */
 public static function cache_dir_path($file)
 {
     $docroot = strtr($_SERVER['DOCUMENT_ROOT'], '\\', '/');
     $self = strtr($_SERVER['PHP_SELF'], '\\', '/');
     if (substr($docroot, -1) != '/') {
         $docroot .= '/';
     }
     if (substr($self, 0, 1) == '/') {
         $self = substr($self, 1);
     }
     $base_dir = get::dirname($docroot . $self);
     if (substr($base_dir, -1) != '/') {
         $base_dir .= '/';
     }
     if (strlen($file) > strlen($docroot) && strtolower(substr($file, 0, strlen($docroot))) == strtolower($docroot)) {
         $file = substr($file, strlen($docroot));
     }
     //try relative (from basename of URL file, and server docroot)
     if (file_exists($base_dir . $file) && is_dir($base_dir . $file)) {
         $path = get::realpath($base_dir . $file);
         if ($path !== false && strtolower(substr($path, 0, strlen($docroot))) == strtolower($docroot)) {
             //file is within the website
             return $path;
         }
     }
     if (file_exists($docroot . $file) && is_dir($docroot . $file)) {
         $path = get::realpath($docroot . $file);
         if ($path !== false && strtolower(substr($path, 0, strlen($docroot))) == strtolower($docroot)) {
             //file is within the website
             return $path;
         }
     }
     //file is outside of the website - hacking attempt (or doesn't exist)
     return false;
 }
Esempio n. 24
0
    exit(0);
}
/**
 * moaDB front-end view-element
 */
//Change to local path or url
$headerArgs = ['title' => 'MoaDB', 'css' => ['//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', './resources/css/base.css', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css', 'http://fonts.googleapis.com/css?family=Exo:900'], 'js' => ['//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js', './resources/js/main.js', './resources/js/classyWiggle.js']];
//Load Google jQuery from URL.
echo $html->jsLoad(array('jquery', 'jqueryui'));
echo $html->header($headerArgs);
$baseUrl = $_SERVER['SCRIPT_NAME'];
$db = isset($_GET['db']) ? $_GET['db'] : (isset($_POST['db']) ? $_POST['db'] : 'admin');
//admin is in every Mongo DB
$dbUrl = urlencode($db);
if (isset($_GET['collection'])) {
    $collection = get::htmlentities($_GET['collection']);
    unset($_GET['collection']);
}
$showUserPassword = false;
if (isset($accessControl) && !isset($_SESSION['user'])) {
    if (isset($_POST['username'])) {
        $_POST = array_map('trim', $_POST);
        if (isset($accessControl[$_POST['username']]) && $accessControl[$_POST['username']] == $_POST['password']) {
            $_SESSION['user'] = $_POST['username'];
        } else {
            $_POST['errors']['username'] = '******';
        }
    }
    if (!isset($_SESSION['user'])) {
        $showUserPassword = true;
    }
Esempio n. 25
0
 /**
  * Validates a datetime value.
  * 
  * @param string $value The value to validate.
  * 
  * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure.
  */
 public function validate(&$value)
 {
     $return = parent::validate($value);
     if ($return !== true) {
         return $return;
     }
     if (isset($value) && strlen(trim($value)) > 0) {
         $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId()));
         $valid = is::datetime($value);
         if ($valid === false) {
             return sprintf('"%s" does not have a valid date/time. The format is YYYY-mm-ddThh:mm:ss.fff. "T" is a literal separator.', $msglbl);
         }
         $mode = get::array_def($this->attributes, 'datemode', 'html');
         $min = get::array_def($this->attributes, 'min', false);
         if (is_object($min) && $min instanceof cDateTime) {
             if ($valid->lessThan($min)) {
                 switch ($mode) {
                     case 'html':
                         break;
                     case 'us':
                         $min = $min->format_us();
                         break;
                     default:
                         $min = $min->format($mode);
                         break;
                 }
                 return sprintf('"%s" cannot be before "%s".', $msglbl, $min);
             }
         }
         $max = get::array_def($this->attributes, 'max', false);
         if (is_object($max) && $max instanceof cDateTime) {
             if ($max->lessThan($valid)) {
                 switch ($mode) {
                     case 'html':
                         break;
                     case 'us':
                         $max = $max->format_us();
                         break;
                     default:
                         $max = $max->format($mode);
                         break;
                 }
                 return sprintf('"%s" cannot be after "%s".', $msglbl, $max);
             }
         }
         $value = $valid;
     }
     return true;
 }
<section>
	<div class="main">
		<a href="<?php 
echo get::site();
?>
/BlogTest/Admin"><<</a>
		<form action="" method="post">
			<input type="text" name="yeni"/>
			<select name="alt">
				<option value="0">Alt Kategoriyi Seçin</option>
				<?php 
foreach ($Kategoriler as $kat) {
    ?>
					<option value="<?php 
    echo $kat["CategoryId"];
    ?>
"><?php 
    echo $kat["CategoryName"];
    ?>
</option>
					<?php 
}
?>
			</select>
			<input type="submit" value="Kaydet"/>
		</form>
		<form action="" method="post">
			<select name="sil">
				<option value="0">Silinecek Kategoriyi Seçin</option>
				<?php 
foreach ($Kategoriler as $kat) {
 /**
  * Returns a set of radio form elements
  *
  * array(
  * 'name' => '',
  * 'value' => '',
  * 'id' => '',
  * 'legend' => '',
  * 'options' => array('value1' => 'text1', 'value2' => 'text2', 'value3' => 'text3'),
  * 'options' => array('text1', 'text2', 'text3'), //also acceptable (cannot do half this, half above syntax)
  * )
  *
  * @param array $args
  * @return str
  */
 public function radios(array $args)
 {
     $id = isset($args['id']) ? $args['id'] : $args['name'];
     $properties = $this->_getProperties($args);
     if (isset($properties['value'])) {
         $checked = $properties['value'];
         unset($properties['value']);
     }
     $properties['type'] = isset($args['type']) ? $args['type'] : 'radio';
     $useValues = key($args['options']) !== 0 || isset($args['useValue']) && $args['useValue'];
     foreach ($args['options'] as $value => $text) {
         if (!$useValues) {
             $value = $text;
         }
         $properties['id'] = $id . '_' . preg_replace('/\\W/', '', $value);
         $properties['value'] = $value;
         if (isset($checked) && (($properties['type'] == 'radio' || !is_array($checked)) && $value == $checked || $properties['type'] == 'checkbox' && is_array($checked) && in_array((string) $value, $checked))) {
             $properties['checked'] = 'checked';
             $rowClass = !isset($properties['class']) ? 'checked' : $properties['class'] . ' checked';
         }
         $labelFirst = isset($args['labelFirst']) ? $args['labelFirst'] : false;
         $labelArgs = array('label' => $text, 'id' => $properties['id'], 'labelFirst' => $labelFirst);
         $input = '<input ' . htmlHelper::formatProperties($properties) . ' />';
         $row = $this->_getLabel($labelArgs, $input);
         if (isset($rowClass)) {
             $row = '<span class="' . $rowClass . '">' . $row . '</span>';
         }
         $radios[] = $row;
         unset($properties['checked'], $rowClass);
     }
     $this->{$properties['type'] == 'radio' ? 'radios' : 'checkboxes'} = $radios;
     $break = !isset($args['optionBreak']) ? '<br />' : $args['optionBreak'];
     $addFieldset = isset($args['addFieldset']) ? $args['addFieldset'] : isset($args['label']) && $args['label'] || count($args['options']) > 1;
     if ($addFieldset) {
         $return = '<fieldset id="' . $id . '">';
         if (isset($args['label'])) {
             $return .= '<legend>' . get::htmlentities($args['label']) . '</legend>';
         }
         $return .= implode($break, $radios) . '</fieldset>';
     } else {
         $return = implode($break, $radios);
     }
     if (isset($_POST['errors']) && isset($_POST['errors'][$id])) {
         $return = $this->getErrorMessageContainer($id, $_POST['errors'][$id]) . $return;
     }
     return $return;
 }
Esempio n. 28
0
	</div>

	<div id="new-database" class="hidden">
		<form method = "POST" data-type="database">
			<input type="hidden" name="db" value="new.database" />
			<input type="text" name="newdb" class="form-control input-lg" placeholder="Database name" />
		</form>
	</div>

	<ul id="export" class="hidden">
		<div>
			<?php 
echo $html->link(get::url(array('get' => true)) . '&export=limited', '<icon class="icon-download"></icon>&nbsp;Export exactly the results visible on this page', ['class' => "btn btn-success btn-lg btn-block"]);
?>
			<?php 
echo $html->link(get::url(array('get' => true)) . '&export=nolimit', '<icon class="icon-cloud-download"></icon>&nbsp;Export full results of this query <small>(ignoring limit and skip clauses)</small>', ['class' => "btn btn-default btn-lg btn-block"]);
?>
		</div>
	</ul>

	<div id="import" class="hidden">
		<?php 
echo $form->open(['upload' => true, 'role' => 'form']);
?>
		<fieldset>
			<div class="form-group">
				<label for="exampleInputFile">Browse / Choose your file</label>
				<input type="file" name="import" accept="application/json">
				<p class="help-block"><small>File ending with ".json".</small></p>
			</div>
			<div id="importmethod">
Esempio n. 29
0
 /**
  * Generates an image element.
  * 
  * @param string $src The path to the image.
  * @param string $alt 
  * @param int $width
  * @param int $height
  * @param string $class
  * @param array $attributes,... OPTIONAL Any number of associative arrays containing html attributes as the keys.
  */
 public function img($src)
 {
     if (!is_string($src)) {
         throw new Exception('First parameter expected to be a path string.');
     }
     $args = func_get_args();
     array_shift($args);
     $attributes = array();
     if (count($args) > 0) {
         $allowed = he_img::acceptedAttributes();
         // alt,  width, height, class, attributes
         //string, int,   int,  string,   array
         $argPos = 0;
         while (count($args) > 0) {
             $arg = array_shift($args);
             if (is_string($arg)) {
                 if ($argPos < 1) {
                     $attributes['alt'] = $arg;
                     $argPos = 1;
                     continue;
                 }
                 if ($argPos > 1) {
                     $attributes['class'] = $arg;
                     $argPos = 4;
                     continue;
                 }
             }
             if (is_int($arg)) {
                 if ($argPos < 2) {
                     $attributes['width'] = $arg;
                     $argPos = 2;
                     continue;
                 }
                 if ($argPos == 2) {
                     $attributes['height'] = $arg;
                     $argPos = 3;
                     continue;
                 }
             }
             if (is_array($arg)) {
                 if ($this->hasHtmlAttributes($arg, $allowed)) {
                     foreach ($arg as $n => $v) {
                         $n = strtolower($n);
                         if (!array_key_exists($n, $attributes)) {
                             if (array_key_exists($n, htmlElement::$enumAttributes) && !in_array($v, htmlElement::$enumAttributes[$n]) && array_key_exists($v, htmlElement::$enumAttributes[$n])) {
                                 $v = htmlElement::$enumAttributes[$n][$v];
                             } elseif (in_array($n, htmlElement::$boolAttributes)) {
                                 if (is_bool($v) && !$v || !is_bool($v) && $v !== 'true') {
                                     continue;
                                 }
                                 $v = $n;
                             }
                             $attributes[$n] = $v;
                         }
                     }
                 }
             }
         }
     }
     //get url
     $attributes['src'] = get::file_url($src);
     $e = new he_img($attributes);
     if (!$this->echoOff) {
         echo $e;
     }
     return $e;
 }
	<?php 
foreach ($Post as $p) {
    extract($p);
    $Images = $PostObject->GetPostImages($PostId);
    $Tags = $PostObject->GetPostTags($PostId);
    ?>
		<h2><?php 
    echo $PostTitle;
    ?>
</h2>
		<p><?php 
    echo $Post;
    ?>
</p>
		<br/>
		<br/>
		<br/>
		<br/>
		<div class="tags">
		<?php 
    $Ekle = "";
    foreach ($Tags as $t) {
        $Ekle .= '<a href="' . get::site() . '/BlogTest/Tag/' . $t["Tag"] . '">' . $t["Tag"] . '</a>,';
    }
    echo trim($Ekle, ",");
    ?>
		</div>
		<?php 
}
?>
</section>