예제 #1
0
function sec(&$array)
{
    //如果是数组,遍历数组,递归调用
    if (is_array($array)) {
        foreach ($array as $k => $v) {
            $array[$k] = sec($v);
        }
    } else {
        if (is_string($array)) {
            //使用addslashes函数来处理
            $array = addslashes($array);
            str_check($array);
        } else {
            if (is_numeric($array)) {
                $array = intval($array);
            }
        }
    }
    return $array;
}
예제 #2
0
 /**
  * Convert this grid reference into a latitude and longitude
  *
  * @return
  */
 function toLatLng()
 {
     $airy1830 = new RefEll(6377563.396, 6356256.909);
     $OSGB_F0 = 0.9996012717;
     $N0 = -100000.0;
     $E0 = 400000.0;
     $phi0 = deg2rad(49.0);
     $lambda0 = deg2rad(-2.0);
     $a = $airy1830->maj;
     $b = $airy1830->min;
     $eSquared = $airy1830->ecc;
     $phi = 0.0;
     $lambda = 0.0;
     $E = $this->easting;
     $N = $this->northing;
     $n = ($a - $b) / ($a + $b);
     $M = 0.0;
     $phiPrime = ($N - $N0) / ($a * $OSGB_F0) + $phi0;
     do {
         $M = $b * $OSGB_F0 * ((1 + $n + 5.0 / 4.0 * $n * $n + 5.0 / 4.0 * $n * $n * $n) * ($phiPrime - $phi0) - (3 * $n + 3 * $n * $n + 21.0 / 8.0 * $n * $n * $n) * sin($phiPrime - $phi0) * cos($phiPrime + $phi0) + (15.0 / 8.0 * $n * $n + 15.0 / 8.0 * $n * $n * $n) * sin(2.0 * ($phiPrime - $phi0)) * cos(2.0 * ($phiPrime + $phi0)) - 35.0 / 24.0 * $n * $n * $n * sin(3.0 * ($phiPrime - $phi0)) * cos(3.0 * ($phiPrime + $phi0)));
         $phiPrime += ($N - $N0 - $M) / ($a * $OSGB_F0);
     } while ($N - $N0 - $M >= 0.001);
     $v = $a * $OSGB_F0 * pow(1.0 - $eSquared * sinSquared($phiPrime), -0.5);
     $rho = $a * $OSGB_F0 * (1.0 - $eSquared) * pow(1.0 - $eSquared * sinSquared($phiPrime), -1.5);
     $etaSquared = $v / $rho - 1.0;
     $VII = tan($phiPrime) / (2 * $rho * $v);
     $VIII = tan($phiPrime) / (24.0 * $rho * pow($v, 3.0)) * (5.0 + 3.0 * tanSquared($phiPrime) + $etaSquared - 9.0 * tanSquared($phiPrime) * $etaSquared);
     $IX = tan($phiPrime) / (720.0 * $rho * pow($v, 5.0)) * (61.0 + 90.0 * tanSquared($phiPrime) + 45.0 * tanSquared($phiPrime) * tanSquared($phiPrime));
     $X = sec($phiPrime) / $v;
     $XI = sec($phiPrime) / (6.0 * $v * $v * $v) * ($v / $rho + 2 * tanSquared($phiPrime));
     $XII = sec($phiPrime) / (120.0 * pow($v, 5.0)) * (5.0 + 28.0 * tanSquared($phiPrime) + 24.0 * tanSquared($phiPrime) * tanSquared($phiPrime));
     $XIIA = sec($phiPrime) / (5040.0 * pow($v, 7.0)) * (61.0 + 662.0 * tanSquared($phiPrime) + 1320.0 * tanSquared($phiPrime) * tanSquared($phiPrime) + 720.0 * tanSquared($phiPrime) * tanSquared($phiPrime) * tanSquared($phiPrime));
     $phi = $phiPrime - $VII * pow($E - $E0, 2.0) + $VIII * pow($E - $E0, 4.0) - $IX * pow($E - $E0, 6.0);
     $lambda = $lambda0 + $X * ($E - $E0) - $XI * pow($E - $E0, 3.0) + $XII * pow($E - $E0, 5.0) - $XIIA * pow($E - $E0, 7.0);
     return new LatLng(rad2deg($phi), rad2deg($lambda));
 }
예제 #3
0
<?php

include "header.php";
session_start();
$text = sec($_POST['text']);
$email = sec($_POST['email']);
$header = sec($_POST['header']);
$category = (int) $_POST['category'];
if ($_POST['scramble'] == $_SESSION['nonce']) {
    $query = "INSERT INTO advertisement SET header='{$header}', text='{$text}', category='{$category}', email='{$email}'";
    $result = mysql_query($query) or die(mysql_error());
    echo "Din annons ligger nu uppe. ";
    header("Refresh: 1; URL=advertisement.php");
} else {
    echo "Du hade angett fel verifieringskod.";
    // Avbryt registreringen
    header("Refresh: 2; URL=advertisement.php?header={$header}&text={$text}&category={$category}&email={$email}");
    include "footer.php";
    die;
}
include "footer.php";
			</tr>
	<?php 
$name = $email = $age = $gender = $password = $count = $count_id = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    function sec($data)
    {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
    $name = sec($_POST["n1"]);
    $email = sec($_POST["e1"]);
    $age = sec($_POST["a1"]);
    $gender = sec($_POST["g1"]);
    $password = sec($_POST["p1"]);
    //$query="INSERT INTO studs VALUES('$name','$email',$age);";
    //MySQL Magic :D
    //Getting Resource ID
    $res_id = MySQLi_Connect('localhost', 'root', '@connectme', 'shangout');
    if (MySQLi_Connect_Errno()) {
        echo "<tr align='center'> <td colspan='5'> Failed to connect to MySQL </td> </tr>";
    } else {
        $check_email = MySQLi_Query($res_id, "select name from students where email='" . $email . "'");
        $r_email = MySQLi_Fetch_Row($check_email);
        if ($r_email) {
            echo "<tr align='center'> <td colspan='5'> <font color='red'> Email already Registered, Registration Failed!  </font>  </td> </tr>";
        } else {
            $count = MySQLi_Query($res_id, "select (max(id)+1) as count  from students");
            $count_id = MySQLi_Fetch_Assoc($count);
            if ($count_id["count"]) {
					</form>
				</td>
			</tr>
			
			<?php 
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $email = $text = "";
        function sec($data)
        {
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
            return $data;
        }
        $email = sec($_POST["n1"]);
        $text = sec($_POST["t1"]);
        $resid = MySQLi_Connect('localhost', 'root', '@connectme', 'shangout');
        if (MySQLi_Connect_Errno()) {
            echo "<tr align='center'> <td colspan='5'> Failed to connect to MySQL </td> </tr>";
        } else {
            $count = MySQLi_Query($resid, "select id from students where email='" . $email . "'");
            $count_id = MySQLi_Fetch_Assoc($count);
            if ($count_id) {
                $receiver = $count_id["id"];
                $sender = $_SESSION["user_id"];
                $count = MySQLi_Query($resid, "select (max(id)+1) as count  from messages");
                $count_id = MySQLi_Fetch_Assoc($count);
                if ($count_id["count"]) {
                    $query = "insert into messages values (" . $count_id["count"] . "," . $sender . "," . $receiver . ",'{$text}')";
                } else {
                    $query = "insert into messages values (1," . $sender . "," . $receiver . ",'{$text}')";
예제 #6
0
<!-- content -->
<?php 
if ($config_perm_admcat != "all" && (!isset($perm) || !$perm->have_perm($config_perm_admcat))) {
    $be->box_full($t->translate("Error"), $t->translate("Access denied"));
} else {
    $bx->box_begin();
    $bx->box_title($t->translate("Category Administration"));
    $bx->box_body_begin();
    // Insert a new Category
    $bs->box_strip($t->translate("Insert a Category"));
    echo "<form action=\"" . $sess->url("inscat.php") . "\" method=\"POST\">\n";
    echo "<table border=0 cellspacing=0 cellpadding=3 width=100%>\n";
    echo "<tr><td align=right width=30%>" . $t->translate("Section") . ":</td><td width=70%>\n";
    echo "<select name=\"section\">\n";
    sec("Console");
    // We select the first one to avoid having a blank line
    echo "</select></td></tr>\n";
    echo "<tr><td align=right>" . $t->translate("New Category") . " (64):</td><td><input type=\"TEXT\" name=\"category\" size=40 maxlength=64>\n";
    echo "</td></tr>\n";
    echo "<tr><td>&nbsp;</td>\n";
    echo "<td><input type=\"submit\" value=\"" . $t->translate("Insert") . "\">";
    echo "</td></tr>\n";
    echo "</form>\n";
    echo "</table>\n";
    echo "<BR>\n";
    // Rename/Update a Category
    $bs->box_strip($t->translate("Rename a Category"));
    echo "<form action=\"" . $sess->url("inscat.php") . "\" method=\"POST\">\n";
    echo "<table border=0 cellspacing=0 cellpadding=3 width=100%>\n";
    echo "<tr><td align=right width=30%>" . $t->translate("Section") . "/" . $t->translate("Category") . ":</td><td width=70%>\n";
예제 #7
0
    $to = sec($_POST['to']);
} else {
    $to = "";
}
if (isset($_POST['cin'])) {
    $cin = sec($_POST['cin']);
} else {
    $cin = "";
}
if (isset($_POST['contact'])) {
    $contact = sec($_POST['contact']);
} else {
    $contact = "";
}
if (isset($_POST['act'])) {
    $act = sec($_POST['act']);
} else {
    $act = "0";
}
if ($nom != "" && $prenom != "" && $from != "" && $to != "" && $cin != "" && $contact != "" && strlen($cin) == 8 && is_numeric($cin) && check_class_correspondency($from, $to)) {
    if ($act == 1) {
        include_once "filtre.php";
        exit;
    }
    $ip = $_SERVER["REMOTE_ADDR"];
    $nom = ucwords(mb_strtolower($nom, 'UTF-8'));
    $prenom = ucwords(mb_strtolower($prenom, 'UTF-8'));
    $from = mb_strtoupper($from, 'UTF-8');
    $to = mb_strtoupper($to, 'UTF-8');
    $sql = "INSERT INTO etudiant (`cin`, `nom`, `prenom`, `from`, `to`,`contact`,`ip`, `systemdate`) VALUES ('" . $cin . "', '" . $nom . "', '" . $prenom . "', '" . $from . "','" . $to . "', '" . $contact . "', '" . $ip . "', NOW())";
    mysql_query($sql);
예제 #8
0
파일: index.php 프로젝트: orcoliver/oneye
function serviceLoading()
{
    //Loading the Security Service (sec) if oneye Security is turned on (by default is On)
    if (EYEOS_SECURITY == 1) {
        sec('start');
    }
    //Setting the Running Log check var to 0
    global $LOG_RUNNING;
    $LOG_RUNNING = 0;
}
예제 #9
0
<?php

/**
 * Server-side PHP script that generates a list of albums (in JSON format)
 */
// TODO
$albums = array('coldplay' => array('title' => 'A Rush of Blood to the Head', 'cover' => "images\\coldplay-cover.jpg", 'tracks' => array(array('track' => 'Politik', 'time' => sec(5, 19)), array('track' => 'In My Place', 'time' => sec(3, 46)), array('track' => 'God Put a Smile Upon Your Face', 'time' => sec(4, 57)), array('track' => 'The Scientist', 'time' => sec(5, 9)), array('track' => 'Clocks', 'time' => sec(5, 7)), array('track' => 'Daylight', 'time' => sec(5, 27)), array('track' => 'Green Eyes', 'time' => sec(3, 43)), array('track' => 'Warning Sign', 'time' => sec(5, 31)), array('track' => 'A Whisper', 'time' => sec(3, 58)), array('track' => 'A Rush of Blood to the Head', 'time' => sec(5, 51)), array('track' => 'Amsterdam', 'time' => sec(5, 19)))), 'gunsnroses' => array('title' => 'Greatest Hits', 'cover' => 'http://upload.wikimedia.org/wikipedia/en/3/36/GreatestHits_Guns%27n%27Roses.jpg', 'tracks' => array(array('track' => 'Welcome to the Jungle', 'time' => sec(4, 34)), array('track' => 'Sweet Child O\' Mine', 'time' => sec(3, 21)), array('track' => 'Patience', 'time' => sec(5, 56)), array('track' => 'Paradise City', 'time' => sec(6, 46)), array('track' => 'Knockin\' on Heaven\'s Door', 'time' => sec(5, 35)), array('track' => 'Civil War', 'time' => sec(7, 42)), array('track' => 'You Could Be Mine', 'time' => sec(5, 44)), array('track' => 'Don\'t Cry (original)', 'time' => sec(4, 43)), array('track' => 'November Rain', 'time' => sec(8, 56)), array('track' => 'Live & Let Die', 'time' => sec(3, 4)), array('track' => 'Yesterday\'s', 'time' => sec(3, 16)), array('track' => 'Ain\'t It Fun', 'time' => sec(5, 4)), array('track' => 'Since I Don\'t Have You', 'time' => sec(4, 19)), array('track' => 'Sympathy for the Devil', 'time' => sec(7, 18)))));
function sec($min, $sec)
{
    return $min * 60 + $sec;
}
function getTitles($albums)
{
    $titles['albums'] = array();
    foreach ($albums as $album) {
        array_push($titles['albums'], $album['title']);
    }
    return $titles;
}
$json = json_encode(getTitles($albums));
echo $json;
예제 #10
0
function cac_func($f, $s, $tqwe = 0)
{
    global $pi;
    $tma = 'Too many arguments';
    $tfa = 'Too few arguments';
    $a = explode(',', $s);
    $c = count($a);
    if ($tqwe == 0) {
        for ($i = 0; $i < $c; ++$i) {
            $a[$i] = substr($a[$i], 1, strlen($a[$i]) - 2);
        }
    }
    if ($f == 'count') {
        $r = $c;
    } elseif ($f == 'gcdr') {
        if ($a[1] == 0) {
            $r = $a[0];
        } else {
            $r = cac_func('gcdr', $a[1] . ',' . (bc() ? bcmod($a[0], $a[1]) : $a[0] % $a[1]), 1);
        }
    } elseif ($f == 'root') {
        $r = pow($a[0], 1 / $a[1]);
    } elseif ($f == 'gcd') {
        $q = $a[0];
        for ($i = 1; $i < $c; ++$i) {
            $q = cac_func('gcdr', $q . ',' . $a[$i], 1);
        }
        $r = $q;
    } elseif ($f == 'lcmc') {
        $gcd = cac_func('gcdr', $s, 1);
        $r = bc() ? bcmul(bcdiv($a[0], $gcd), $a[1]) : $a[0] / $gcd * $a[1];
    } elseif ($f == 'lcm') {
        $r = $a[0];
        for ($i = 1; $i < $c; ++$i) {
            $r = cac_func('lcmc', $r . ',' . $a[$i], 1);
        }
    } elseif ($f == 'plus') {
        $r = bc() ? bcadd($a[0], $a[1]) : $a[0] + $a[1];
    } elseif ($f == 'minus') {
        $r = bc() ? bcsub($a[0], $a[1]) : $a[0] - $a[1];
    } elseif ($f == 'multiply') {
        $r = bc() ? bcmul($a[0], $a[1]) : $a[0] * $a[1];
    } elseif ($f == 'divide') {
        if ($a[1] == 0) {
            addmsg(ERR, 'Divided by zero');
        }
        $r = bc() ? bcdiv($a[0], $a[1]) : $a[0] / $a[1];
    } elseif ($f == 'sum') {
        $r = 0;
        for ($i = 0; $i < $c; ++$i) {
            $r = bc() ? bcadd($r, $a[$i]) : $r + $a[$i];
        }
    } elseif ($f == 'average') {
        $r = cac_func('sum', implode(',', $a), 1);
        $r = bc() ? bcdiv($r, $c) : $r / $c;
    } elseif ($f == 'avedev') {
        $ave = cac_func('average', implode(',', $a), 1);
        $r = '0';
        if (bc()) {
            for ($i = 0; $i < $c; ++$i) {
                $tmp = bcsub($a[$i], $ave);
                if (substr($tmp, 0, 1) == '-') {
                    $tmp = substr($tmp, 1);
                }
                $r = bcadd($r, $tmp);
                $r = bcdiv($r, $c);
            }
        } else {
            for ($i = 0; $i < $c; ++$i) {
                $tmp = $a[$i] + $ave;
                if ($tmp < 0) {
                    $tmp *= -1;
                }
                $r += $tmp;
                $r /= $c;
            }
        }
    } elseif ($f == 'stdev') {
        $ave = cac_func('average', implode(',', $a), 1);
        $r = 0;
        for ($i = 0; $i < $c; ++$i) {
            $r = bc() ? bcadd($r, bcpow(bcsub($a[$i], $ave), '2')) : $r + pow($a[$i] - $ave, 2);
        }
        $r = bc() ? bcsqrt(bcdiv($r, $c - 1)) : sqrt($r / ($c - 1));
    } elseif ($f == 'stdevp') {
        $ave = cac_func('average', implode(',', $a), 1);
        $r = 0;
        for ($i = 0; $i < $c; ++$i) {
            $r = bc() ? bcadd($r, bcpow(bcsub($a[$i], $ave), '2')) : $r + pow($a[$i] - $ave, 2);
        }
        $r = bc() ? bcsqrt(bcdiv($r, $c)) : sqrt($r / $c);
    } elseif ($f == 'min') {
        if ($a[0] > $a[1]) {
            $r = $a[1];
        } else {
            $r = $a[0];
        }
    } elseif ($f == 'max') {
        if ($a[0] > $a[1]) {
            $r = $a[0];
        } else {
            $r = $a[1];
        }
    } elseif ($f == 'fac') {
        if ($c > 1) {
            addmsg(WARN, $tma);
        }
        if (floor($a[0]) != $a[0]) {
            addmsg(ERR, 'Argument should be an integer');
        }
        $i = 1;
        for ($j = 1; $j <= $a[0]; ++$j) {
            if (bc()) {
                $i = bcmul($i, $j);
            } else {
                $i *= $j;
            }
        }
        $r = $i;
    } elseif ($f == 'c') {
        if ($c > 2) {
            addmsg(WARN, $tma);
        }
        if ($c < 2) {
            addmsg(WARN, $tfa);
        }
        $r = cac_func('fac', $a[0], 1) / cac_func('fac', $a[1], 1) / cac_func('fac', cac_func('minus', $a[0] . ',' . $a[1], 1), 1);
    } elseif ($f == 'abs') {
        for ($i = 0; $i < $c; ++$i) {
            if (substr($a[$i], 0, 1) == '-') {
                $a[$i] = substr($a[$i], 1);
            }
        }
        $r = implode(',', $a);
    } elseif ($f == 'ceil') {
        for ($i = 0; $i < $c; ++$i) {
            $a[$i] = ceil($a[$i]);
        }
        $r = implode(',', $a);
    } elseif ($f == 'floor') {
        for ($i = 0; $i < $c; ++$i) {
            $a[$i] = floor($a[$i]);
        }
        $r = implode(',', $a);
    } elseif ($f == 'round') {
        if ($c > 2) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        if ($c == 1) {
            $a[1] = 0;
        }
        $r = round($a[0], $a[1]);
    } elseif ($f == 'radians') {
        $r = bc() ? bcdiv(bcmul($a[0], $pi), 180) : $a[0] * $pi / 180;
    } elseif ($f == 'degrees') {
        $r = bc() ? bcdiv(bcmul($a[0], 180), $pi) : $a[0] * 180 / $pi;
    } elseif ($f == 'log') {
        if ($c > 2) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        if ($c == 1) {
            $a[1] = '10';
        }
        $r = log($a[0], $a[1]);
    } elseif ($f == 'ln') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = log($a[0]);
    } elseif ($f == 'pow') {
        if ($c > 2) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        if ($c < 2) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        if (strpos($a[1], '.') === false) {
            $r = bc() ? bcpow($a[0], $a[1]) : pow($a[0], $a[1]);
        } else {
            $r = pow($a[0], $a[1]);
        }
    } elseif ($f == 'sqrt') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = bc() ? bcsqrt($a[0]) : sqrt($a[0]);
    } elseif ($f == 'exp') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = exp($a[0]);
    } elseif ($f == 'mod') {
        if ($c > 2) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        if ($c < 2) {
            addmsg(WARN, $tfa);
            $r = 0;
        }
        $r = bc() ? bcmod($a[0], $a[1]) : $a[0] % $a[1];
    } elseif ($f == 'sin') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = sin($a[0]);
    } elseif ($f == 'cos') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = cos($a[0]);
    } elseif ($f == 'tan') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = tan($a[0]);
    } elseif ($f == 'cot') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = cot($a[0]);
    } elseif ($f == 'sec') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = sec($a[0]);
    } elseif ($f == 'csc') {
        if ($c > 1) {
            addmsg(WARN, $tma);
            $r = 0;
        }
        $r = csc($a[0]);
    } elseif ($f == 'analyze') {
        if ($c > 1) {
            addmsg(WARN, $tma);
        }
        $r = $a[0];
        $t = $r;
        $b = array();
        $e = array();
        $z = 0;
        $i = 2;
        $m = '';
        if (bc()) {
            if (substr($r, 0, 1) == '-') {
                $m .= '&nbsp;-1';
                $t = bcmul($t, '-1');
            }
            while ($t != '1') {
                if (bcmod($t, $i) == '0') {
                    $z = count($b);
                    $t = bcdiv($t, $i);
                    $b[$z] = $i;
                    $e[$z] = 1;
                }
                while (bcmod($t, $i) == '0') {
                    ++$e[$z];
                    $t = bcdiv($t, $i);
                }
                $i = bcadd($i, 1);
            }
        } else {
            if (substr($r, 0, 1) == '-') {
                $m .= '&nbsp;-1';
                $t *= -1;
            }
            while ($t != 1) {
                $bak = $t;
                if ($t % $i == 0) {
                    $z = count($b);
                    $t /= $i;
                    $b[$z] = $i;
                    $e[$z] = 1;
                }
                while ($t % $i == 0) {
                    ++$e[$z];
                    $t = $t / $i;
                }
                ++$i;
                if ($bak == $t) {
                    addmsg(ERR, 'The number might be too large.');
                    break;
                }
            }
        }
        for ($i = 0; $i <= $z; ++$i) {
            $b[$i] = preg_replace('/\\.0+$/', '', $b[$i]);
            $m .= '&nbsp;&nbsp;' . $b[$i] . ($e[$i] > 1 ? '<sup>' . $e[$i] . '</sup>' : '');
        }
        addmsg(INFO, $r . '&nbsp;=' . $m);
    }
    if ($tqwe == 0) {
        $r = '<' . $r . '>';
    }
    return $r;
}