示例#1
0
function getVar($name, $type = '', $order = array('get', 'post'))
{
    $output = '';
    if (!is_array($order)) {
        $order = @explode(',', (string) $order);
    }
    if (@count($order) == 0 || $order == '') {
        if ($order != '') {
            $order = array($order);
        } else {
            $order = array('get', 'post');
        }
    }
    # get vars
    foreach ($order as $v) {
        if ($v == 'get' && isset($_GET[$name])) {
            $output = @$_GET[$name];
        } elseif ($v == 'post' && isset($_POST[$name])) {
            $output = @$_POST[$name];
        } elseif ($v == 'cookie' && isset($_COOKIE[$name])) {
            $output = @$_COOKIE[$name];
        }
    }
    // convert type if set
    if ($type == 'str' || $type == 'string') {
        return (string) $output;
    } elseif ($type == 'int' || $type == 'integer') {
        return (int) $output;
    } elseif ($type == 'float' || $type == 'double') {
        return (double) $output;
    } elseif ($type == 'bool' || $type == 'boolean') {
        return toBoolean($output);
    }
    return $output;
}
 public static function getBoolean($name)
 {
     $value = self::getSetting($name);
     if ($value === NULL) {
         return NULL;
     } else {
         return toBoolean($value);
     }
 }
示例#3
0
function parse_outlookcsv($cal_file)
{
    global $errormsg, $tz;
    $outlookcsv_data = array();
    if (!($fd = @fopen($cal_file, 'r'))) {
        $errormsg .= 'Cannot read temporary file: ' . "{$cal_file}\n";
        exit;
    } else {
        # Burn First Row of Headers
        $data = fgetcsv($fd, @filesize($cal_file), ',');
        while ($data = fgetcsv($fd, @filesize($cal_file))) {
            $subject = addslashes($data[0]);
            $start = icaldate_to_timestamp(date('Ymd\\THis', strtotime($data[1] . ' ' . $data[2])));
            $end = icaldate_to_timestamp(date('Ymd\\THis', strtotime($data[3] . ' ' . $data[4])));
            $all_day_event = (int) toBoolean($data[5]);
            $remind_on_off = (int) toBoolean($data[6]);
            $reminder = icaldate_to_timestamp(date('Ymd\\THis', strtotime($data[7] . ' ' . $data[8])));
            $meeting_organizer = $data[9];
            $required_attendies = $data[10];
            $optional_attendies = $data[11];
            $meeting_resources = $data[12];
            $billing_information = $data[13];
            $categories = addslashes(str_replace(';', ',', $data[14]));
            $description = addslashes($data[15]);
            $location = addslashes($data[16]);
            $mileage = $data[17];
            $priority = $data[18];
            $class = (int) toBoolean($data[19]);
            $sensitivity = $data[20];
            $show_time_as = $data[21];
            /*
             * Start New Section For Outlook CSV
             */
            // $tmp_data['RecordID']  = ;
            $tmp_data['StartTime'] = $start;
            // In seconds since 1970 (Unix Epoch)
            $tmp_data['EndTime'] = $end;
            // In seconds since 1970 (Unix Epoch)
            $tmp_data['Summary'] = $subject;
            // Summary of event (string)
            $tmp_data['Duration'] = dateDifference($start, $end, 1);
            // How long the event lasts (in minutes)
            $tmp_data['Description'] = $description;
            // Full Description (string)
            $tmp_data['Location'] = $location;
            // Location (string)
            $tmp_data['AllDay'] = $all_day_event;
            // 1 = true  0 = false
            $tmp_data['Class'] = $class == 1 ? 'R' : 'P';
            $tmp_data['Categories'] = get_categories_id_byname($categories);
            $tmp_data['AlarmSet'] = $remind_on_off;
            // 1 = true  0 = false
            $tmp_data['ADate'] = $reminder;
            // Date/Time of Alarm
            $tmp_data['AAction'] = 'EMAIL';
            // The default action
            $tmp_data['CalendarType'] = 'VEVENT';
            // The default type
            $outlookcsv_data[] = $tmp_data;
        }
        // End while
        fclose($fd);
    }
    return $outlookcsv_data;
}
示例#4
0
                tablet_markSelectedDog(data.RowIndex);
            },
            onResize:function(){
                tbt_dg.datagrid('fixDetailRowHeight',index);
            },
            onLoadSuccess:function(data){
                if (!data.total) return; // subgrid returns an empty array. Do nothing
                // populate data entry datagrid with loaded data
                $('#tdialog-tnext').datagrid('loadData',data.rows);
                // show/hide team name
                if (isTeamByJornada(workingData.datosJornada) ) mySelf.datagrid('showColumn','NombreEquipo');
                else  mySelf.datagrid('hideColumn','NombreEquipo');
                // auto resize columns
                setTimeout(function(){ tbt_dg.datagrid('fixDetailRowHeight',index); },0);
                <?php 
if (toBoolean($config->getEnv('tablet_dnd'))) {
    ?>
                    mySelf.datagrid('enableDnd');
                    mySelf.datagrid('getPanel').panel('panel').attr('tabindex',0).focus();
                <?php 
} else {
    /* if dnd is off enable only on PC */
    ?>
                    if (! isMobileDevice() ) {
                        mySelf.datagrid('enableDnd');
                        mySelf.datagrid('getPanel').panel('panel').attr('tabindex',0).focus();
                    }
                <?php 
}
?>
            },
 public static function PaymentQuery($playerName, $playerUUID, $amount)
 {
     global $config;
     if (toBoolean($config['iConomy']['use'])) {
         $query = "UPDATE `" . mysql_san($config['iConomy']['table']) . "` SET " . "`balance` = `balance` + " . (double) $amount . " " . "WHERE LOWER(`username`)='" . mysql_san(strtolower($playerName)) . "' LIMIT 1;";
     } else {
         if (toBoolean($config['CC']['use'])) {
             $query = "UPDATE `" . mysql_san($config['CC']['prefix']) . "_balance` JOIN " . mysql_san($config['CC']['prefix']) . "_account ON " . mysql_san($config['CC']['prefix']) . "_account.id = " . mysql_san($config['CC']['prefix']) . "_balance.username_id " . "SET " . mysql_san($config['CC']['prefix']) . "_balance.balance = " . mysql_san($config['CC']['prefix']) . "_balance.balance + " . (double) $amount . " " . "WHERE " . mysql_san($config['CC']['prefix']) . "_account.uuid = '" . mysql_san($playerUUID) . "' AND " . "LOWER(" . mysql_san($config['CC']['prefix']) . "_balance.currency_id) = '" . mysql_san(strtolower($config['CC']['currency'])) . "' " . "AND LOWER(" . mysql_san($config['CC']['prefix']) . "_balance.worldName) = '" . mysql_san(strtolower($config['CC']['group'])) . "' LIMIT 1;";
         } else {
             $query = "UPDATE `" . $config['table prefix'] . "Players` SET " . "`money` = `money` + " . (double) $amount . " " . "WHERE `uuid`='" . mysql_san($playerUUID) . "' LIMIT 1;";
         }
     }
     $result = RunQuery($query, __FILE__, __LINE__);
     global $db;
     if (mysql_affected_rows($db) != 1) {
         echo '<p>Failed to make payment to/from: ' . $playerName . '!</p>';
     }
 }
示例#6
0
/**
 * get a variable from _REQUEST array
 * @param {string} $name variable name
 * @param {string} $type default type (i,s,b)
 * @param {string} $def default value. may be null
 * @param {boolean} $esc true if variable should be MySQL escape'd to avoid SQL injection
 * @return {object} requested value (int,string,bool) or null if invalid type
 */
function http_request($name, $type, $def, $esc = true)
{
    $a = $def;
    if (isset($_REQUEST[$name])) {
        $a = $_REQUEST[$name];
    }
    if ($a === null) {
        return null;
    }
    switch ($type) {
        case "s":
            if ($a === _('-- Search --')) {
                $a = "";
            }
            if ($esc) {
                return escapeString(strval($a));
            }
            return strval($a);
        case "i":
            return intval($a);
        case "b":
            if ($a === "") {
                return $def;
            }
            return toBoolean($a);
        case "d":
        case "f":
            return floatval(str_replace(",", ".", $a));
    }
    do_log("request() invalid type:{$type} requested");
    return null;
}
示例#7
0
 private function doValidate($username, $password = FALSE)
 {
     global $config;
     $this->Name = trim($username);
     if (empty($this->Name)) {
         return FALSE;
     }
     if ($password !== FALSE && empty($password)) {
         return FALSE;
     }
     // validate player
     $query = "SELECT `id`,`playerName`,`money`,`itemsSold`,`itemsBought`,`earnt`,`spent`,`Permissions`,`Locked` " . "FROM `" . $config['table prefix'] . "Players` " . "WHERE LOWER(`playerName`)='" . mysql_san(strtolower($this->Name)) . "' " . ($password === FALSE ? "" : "AND `password`='" . mysql_san($password) . "' ") . "LIMIT 1";
     $result = RunQuery($query, __FILE__, __LINE__);
     if ($result) {
         if (mysql_num_rows($result) == 0) {
             $_SESSION[$config['session name']] = '';
             $_GET['error'] = 'bad login';
             return FALSE;
         }
         $row = mysql_fetch_assoc($result);
         if (strtolower($row['playerName']) != strtolower($this->Name)) {
             return FALSE;
         }
         $this->UserId = (int) $row['id'];
         $this->Name = $row['playerName'];
         $this->Money = (double) $row['money'];
         $this->ItemsSold = (int) $row['itemsSold'];
         $this->ItemsBought = (int) $row['itemsBought'];
         $this->Earnt = (double) $row['earnt'];
         $this->Spent = (double) $row['spent'];
         foreach (explode(',', $row['Permissions']) as $perm) {
             $this->permissions[$perm] = TRUE;
         }
         $this->invLocked = (bool) $row['Locked'];
         $_SESSION[$config['session name']] = $this->Name;
     } else {
         $_SESSION[$config['session name']] = '';
         echo 'Error: ' . mysql_error();
         exit;
     }
     // use iconomy table
     if (toBoolean($config['iConomy']['use']) || $config['iConomy']['use'] === 'auto') {
         global $db;
         $result = mysql_query("SELECT `balance` FROM `" . mysql_san($config['iConomy']['table']) . "` WHERE " . "LOWER(`username`)='" . mysql_san(strtolower($this->Name)) . "' LIMIT 1", $db);
         if ($result) {
             $row = mysql_fetch_assoc($result);
             $this->Money = (double) $row['balance'];
             $config['iConomy']['use'] = TRUE;
         } else {
             // table not found
             if (mysql_errno($db) == 1146) {
                 $config['iConomy']['use'] = FALSE;
             } else {
                 echo mysql_error($db);
             }
         }
         unset($result, $row);
     }
     return $this->isOk();
 }
                 $aax = $ax + sin($bdir * pi() / 180) * $asize;
                 $aay = $ay + cos($bdir * pi() / 180) * $asize;
             } else {
                 $aax = $ax - sin($bdir * pi() / 180) * $asize;
                 $aay = $ay - cos($bdir * pi() / 180) * $asize;
             }
             /////////////imageline($img, $ax, $ay, $aax, $aay, $lineColor);
             /////////////imageline($img, $tx, $ty, $aax, $aay, $lineColor);
             /////////////imagefilledpolygon($img, array($tx, $ty, $ax, $ay, $aax, $aay), 3, $lineColor);
         }
     }
     //echo '<br />Double ' . $name . ' = ' . $value;
 }
 if ($type == 1) {
     //Boolean
     $value = toBoolean(fread($file, 1));
 }
 if ($type == 2) {
     //String
     $slength = toShort(fread($file, 2));
     if ($slength > 0) {
         $value = fread($file, $slength);
     }
     //echo '<br />String ' . $name . ' = ' . $value;
 }
 if ($type == 6) {
     //Undefined
     //echo '<br />Undefined ' . $name;
 }
 if ($type == 8) {
     //Array
示例#9
0
function getInfo($id, $infoname, $infotype = 2, $method = "sql")
{
    if ($method == "sql") {
        //More efficient database method
        $result = mysql_query("SELECT * FROM tracks WHERE id=" . $id);
        $tdata = mysql_fetch_array($result);
        return $tdata[$infoname];
    } else {
        //Raw data method (CAUTION values are not stored this way anymore as of 10/18/2007 with the exception of label)
        //This function will get the first item's value whose name is $infoname and type is $infotype
        if (file_exists("tracks/" . $id . ".track")) {
            $contents = file_get_contents("tracks/" . $id . ".track");
            $pos = strpos($contents, $infoname) + strlen($infoname);
            $type = toByte(substr($contents, $pos, 1));
            $pos++;
            if ($infotype == $type) {
                if ($type == 0) {
                    return toDouble(substr($contents, $pos, 8));
                } elseif ($type == 1) {
                    return toBoolean(substr($contents, $pos, 1));
                } elseif ($type == 2) {
                    $strlength = toShort(substr($contents, $pos, 2));
                    return substr($contents, $pos + 2, $strlength);
                } elseif ($type == 3) {
                    return true;
                } elseif ($type == 6) {
                    return true;
                } elseif ($type == 8) {
                    return toLong(substr($contents, $pos, 4));
                }
                //Return number of items in array
            }
        }
    }
}
示例#10
0
 $toiletSql->execute();
 $toilet = $toiletSql->fetchAll(PDO::FETCH_OBJ);
 if (!empty($toilet)) {
     $updateAttribute = '';
     switch ($sensorCommand) {
         case 'toilet':
             $updateAttribute = 'is_detected_sit_down';
             break;
         case 'lock':
             $updateAttribute = 'is_door_lock';
             break;
         default:
             throw new Exception('非法command' . $sensorCommand);
     }
     $updateToiletSql = $pdo->prepare("UPDATE toilet_realtime_status SET {$updateAttribute}=:sensor_value, updated_at=:updated_at WHERE id=:id");
     $updateToiletSql->bindValue(':sensor_value', toBoolean($sensorValue), PDO::PARAM_INT);
     $updateToiletSql->bindValue(':updated_at', date('Y-m-d H:i:s', $unixtime), PDO::PARAM_STR);
     $updateToiletSql->bindValue(':id', $toiletId, PDO::PARAM_INT);
     $updateToiletSql->execute();
     if ($updateToiletSql->rowCount() == 0) {
         throw new Exception("沒有記錄被update:\n" . $updateToiletSql->debugDumpParams());
     }
 } else {
     $insertToiletSql = $pdo->prepare("INSERT INTO toilet_realtime_status(id, is_door_lock, is_detected_sit_down, floor, updated_at) VALUES(:id, :is_door_lock, :is_detected_sit_down, :floor, :updated_at)");
     $insertToiletSql->bindValue(':id', $toiletId, PDO::PARAM_INT);
     $insertToiletSql->bindValue(':is_door_lock', $sensorCommand, PDO::PARAM_STR);
     $insertToiletSql->bindValue(':is_detected_sit_down', $sensorValue, PDO::PARAM_STR);
     $insertToiletSql->bindValue(':floor', $currentFloor = 0, PDO::PARAM_INT);
     $insertToiletSql->bindValue(':updated_at', date('Y-m-d H:i:s', $unixtime), PDO::PARAM_STR);
     $insertToiletSql->execute();
     if ($insertToiletSql->rowCount() == 0) {
示例#11
0
 private function storeRow($index, $row)
 {
     // compose insert sequence
     $str1 = "INSERT INTO {$this->tablename} (";
     $str2 = "ID ) VALUES (";
     // for each row evaluate field name and get content from provided row
     // notice that
     foreach ($this->fieldList as $key => $val) {
         if ($val[0] < 0 || $val[1] == 0) {
             continue;
         }
         // field not provided or to be evaluated by importer
         $str1 .= "{$val[3]}, ";
         // add field name
         $item = $row[$val[0]];
         if ($key === 'Grad') {
             $item = parseGrade($item);
         }
         if ($key === 'Cat') {
             $item = parseCategory($item);
         }
         if ($key === 'Gender') {
             $item = parseGender($item);
         }
         switch ($val[2]) {
             case "s":
                 // string
                 $a = mysqli_real_escape_string($this->myDBObject->conn, $item);
                 $str2 .= "'{$a}', ";
                 break;
             case "i":
                 $a = intval($item);
                 $str2 .= " {$a}, ";
                 // integer
                 break;
             case "b":
                 $a = toBoolean($item) ? 1 : 0;
                 $str2 .= " {$a}, ";
                 // boolean as 1/0
                 break;
             case "f":
                 $a = floatval($item);
                 $str2 .= " {$a}, ";
                 // float
                 break;
             default:
                 // escape to avoid sql injection issues
                 $a = mysqli_real_escape_string($this->myDBObject->conn, $item);
                 $str2 .= " {$a}, ";
         }
     }
     $str = "{$str1} {$str2} {$index} );";
     // compose insert string
     $res = $this->myDBObject->query($str);
     if (!$res) {
         $error = $this->myDBObject->conn->error;
         throw new Exception("ImportExcel(dogs)::populateTable(): Error inserting row {$index} " . json_encode($row));
     }
     return 0;
 }
示例#12
0
?>
/easyui.css" />
<link rel="stylesheet" type="text/css" href="/agility/lib/jquery-easyui-1.4.2/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/agility/css/style.css" />
<link rel="stylesheet" type="text/css" href="/agility/css/datagrid.css" />
<link rel="stylesheet" type="text/css" href="/agility/css/tablet.css" />
<script src="/agility/lib/HackTimer/HackTimer.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-1.12.3.min.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-easyui-1.4.2/jquery.easyui.min.js" type="text/javascript" charset="utf-8" ></script>
<script src="/agility/lib/jquery-easyui-1.4.2/locale/easyui-lang-<?php 
echo substr($config->getEnv('lang'), 0, 2);
?>
.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-easyui-1.4.2/extensions/datagrid-dnd/datagrid-dnd.js" type="text/javascript" charset="utf-8" > </script>
<?php 
if (toBoolean($config->getEnv('tablet_chrono'))) {
    ?>
<script src="/agility/lib/jquery-chronometer.js" type="text/javascript" charset="utf-8" > </script>
<?php 
}
?>
<script src="/agility/lib/jquery-easyui-1.4.2/extensions/datagrid-view/datagrid-detailview.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-easyui-1.4.2/extensions/datagrid-view/datagrid-groupview.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-easyui-1.4.2/extensions/datagrid-view/datagrid-scrollview.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/jquery-fileDownload-1.4.2.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/lib/sprintf.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/scripts/easyui-patches.js" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/scripts/datagrid_formatters.js.php" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/scripts/common.js.php" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/scripts/auth.js.php" type="text/javascript" charset="utf-8" > </script>
<script src="/agility/scripts/competicion.js.php" type="text/javascript" charset="utf-8" > </script>