示例#1
0
文件: main.php 项目: jonaschl/polls
 $groups = json_decode($_POST['access_ids'])->groups;
 $users = json_decode($_POST['access_ids'])->users;
 // cancel, goto summary
 if ($groups === 'cancel') {
     break;
 }
 if ($access === 'select') {
     $access = '';
     foreach ($groups as $gid) {
         $access .= 'group_' . $gid . ';';
     }
     foreach ($users as $uid) {
         $access .= 'user_' . $uid . ';';
     }
 }
 $poll_id = UTIL::generateRandomBytes(16);
 $expire = '';
 if (isset($_POST['check_expire'])) {
     $expire = $_POST['expire_date'];
     if (isset($expire) && strlen($expire) > 0) {
         $expire = '' . (strtotime($expire) + 60 * 60 * 24);
         //add one day, so it expires at the end of a day
     }
 }
 if (!isset($desc) || !strlen($desc)) {
     $desc = '<_none_>';
 }
 if ($_POST['radio_type'] === 'text') {
     // --- text based poll ---
     // add entry to db; don't set 'created' yet!
     $query = DB::prepare('INSERT INTO *PREFIX*polls_events(id, type, title, description, OWNER, access, expire) VALUES (?,?,?,?,?,?,?)');
示例#2
0
 public static function configure_database(array $array)
 {
     $DBINUSE = Database\DATABASE::$database_in_use_ns . Database\DATABASE::$database_in_use;
     $make_table = [];
     if (self::has_attribute($array, "name", true)) {
         $make_column = [];
         $make_column["@attributes"] = [];
         foreach ($array as $col_key => $col_value) {
             if (self::startswith(strtolower($col_key), "column:")) {
                 if (self::has_attribute($col_value, "name", true) && self::has_attribute($col_value, "type", true)) {
                     $attributes = $col_value["@attributes"];
                     $autoincrement = self::has_attribute($col_value, "autoincrement");
                     $primarykey = self::has_attribute($col_value, "primarykey");
                     $autoincrementval = $autoincrement ? $DBINUSE::create_column_autoincrement() : "";
                     $primarykeyval = $primarykey ? $DBINUSE::create_column_primarykey($attributes["name"]) : "";
                     $type = $DBINUSE::create_column_type($attributes["type"]);
                     $length = self::has_attribute($col_value, "length", true) ? $DBINUSE::create_column_length($attributes["length"]) : "";
                     $null = self::has_attribute($col_value, "null", true) ? $DBINUSE::create_column_null(UTIL::bool_val($attributes["null"])) : "";
                     $default = self::has_attribute($col_value, "default", true) ? $DBINUSE::create_column_default($attributes["default"]) : "";
                     $create = ["type" => $type, "length" => $length, "null" => $null, "default" => $default, "autoincrementval" => $autoincrementval, "primarykeyval" => $primarykeyval, "primarykeyval" => $primarykeyval];
                     $make_column[$col_value["@attributes"]["name"]]["sql"] = $create;
                 }
             }
         }
         $make_column["@attributes"]["name"] = $array["@attributes"]["name"];
         $make_column["@attributes"]["create"] = self::has_attribute($array, "create", true) ? UTIL::bool_val($array["@attributes"]["create"]) : false;
         $make_column["@attributes"]["createcolumns"] = self::has_attribute($array, "createcolumns", true) ? UTIL::bool_val($array["@attributes"]["createcolumns"]) : false;
         $make_column["@attributes"]["dropcolumns"] = self::has_attribute($array, "dropcolumns", true) ? UTIL::bool_val($array["@attributes"]["dropcolumns"]) : false;
         $make_column["@attributes"]["tablespec"] = self::has_attribute($array, "tablespec", true) ? $array["@attributes"]["tablespec"] : "";
         $make_column["@attributes"]["createsequence"] = self::has_attribute($array, "createsequence", true) ? UTIL::bool_val($array["@attributes"]["createsequence"]) : false;
         $make_column["@attributes"]["sequencename"] = self::has_attribute($array, "sequencename", true) ? $array["@attributes"]["sequencename"] : "";
         $make_table[$array["@attributes"]["name"]] = $make_column;
     }
     if (!empty($make_table)) {
         $DBINUSE::create_table($make_table);
     }
 }
示例#3
0
 private static function returnval($value, $returntype)
 {
     if (is_int($returntype)) {
         return $value == "" ? 0 : intval($value);
     }
     if (is_bool($returntype)) {
         return $value == "" ? false : UTIL::bool_val($value);
     }
     if (is_array($returntype)) {
         return $value == "" ? [] : $value;
     }
     return strval($value);
 }