/**
  * Loads metadata from the ESRI shape file header
  *
  * @return void
  * @see ShapeFile::_loadHeaders()
  */
 public function _loadHeaders()
 {
     ImportShp::readFromBuffer(24);
     $this->fileLength = loadData("N", ImportShp::readFromBuffer(4));
     ImportShp::readFromBuffer(4);
     $this->shapeType = loadData("V", ImportShp::readFromBuffer(4));
     $this->boundingBox = array();
     $this->boundingBox["xmin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->boundingBox["ymin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->boundingBox["xmax"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->boundingBox["ymax"] = loadData("d", ImportShp::readFromBuffer(8));
     if ($this->_isDbaseLoaded() && $this->_openDBFFile()) {
         $this->DBFHeader = $this->_loadDBFHeader();
     }
 }
Пример #2
0
function manage()
{
    $layout = explode('/', $_GET['page'])[1];
    $Data = loadData($layout);
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'show';
    switch ($action) {
        case 'show':
            show($Data, $layout);
            break;
        case 'set':
            $Data->set($_POST[$layout]);
            show($Data, $layout, ['result' => 'success']);
            break;
    }
}
Пример #3
0
function loadData()
{
    global $offset;
    $jsonString = getData("http://api.nytimes.com/svc/news/v2/all/last24hours.json?api-key=6a30bd922857352952ccfd11c2c6b81f:6:59193871&offset=" . $offset);
    $newsObj = json_decode($jsonString);
    echo "status: " . $newsObj->status;
    if ($newsObj->status == "OK") {
        echo "<br><br><br><br>";
        for ($i = 0; $i < count($newsObj->results); $i++) {
            checkNewsItem($newsObj->results[$i]);
        }
        // keep going till we get an error //
        $offset += 20;
        loadData();
    }
}
Пример #4
0
function start()
{
    if (!empty($_POST['nom'])) {
        addUser();
        $tableauPeople = getPeople();
        require '../views/list.php';
    } elseif (!isset($_GET['id'])) {
        // charge la page list
        $tableauPeople = getPeople();
        require '../views/list.php';
    } else {
        // avec l'id charge la page show
        $data = loadData();
        require '../views/show.php';
    }
}
Пример #5
0
$username;
$format;
$purpose;
$types;
$types_avoid;
$page;
$user_ident;
// The ident of the reader, used for validation reasons.
$reader_ident;
// Create variables used to build html
$from = 0;
$page = 0;
$results;
$resultcount;
// Load data from the GET variables & return.
loadData(&$readerhash, &$user_ident, &$username, &$format, &$purpose, &$types, &$types_avoid, &$page);
$page_owner = $user_ident;
// Run validation check.  if fail, -1 is returned.
if ($readerhash != '') {
    $reader_ident = folio_decodehash($readerhash);
    if ($reader_ident == -1) {
        error("Error, unable to validate your {$readerhash} value. Please log in and make sure you have the correct value.");
    }
} elseif (isloggedin()) {
    $reader_ident = $_SESSION['userid'];
} else {
    $reader_ident = -1;
}
// Build where condition
$where = buildWhere($purpose, $reader_ident, $user_ident, $types, $types_avoid);
// Get Data
Пример #6
0
 function _loadPolyLineRecord()
 {
     $this->SHPData = array();
     $this->SHPData["xmin"] = loadData("d", fread($this->SHPFile, 8));
     $this->SHPData["ymin"] = loadData("d", fread($this->SHPFile, 8));
     $this->SHPData["xmax"] = loadData("d", fread($this->SHPFile, 8));
     $this->SHPData["ymax"] = loadData("d", fread($this->SHPFile, 8));
     $this->SHPData["numparts"] = loadData("V", fread($this->SHPFile, 4));
     $this->SHPData["numpoints"] = loadData("V", fread($this->SHPFile, 4));
     for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
         $this->SHPData["parts"][$i] = loadData("V", fread($this->SHPFile, 4));
     }
     $firstIndex = ftell($this->SHPFile);
     $readPoints = 0;
     reset($this->SHPData["parts"]);
     while (list($partIndex, $partData) = each($this->SHPData["parts"])) {
         if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) {
             $this->SHPData["parts"][$partIndex] = array();
             $this->SHPData["parts"][$partIndex]["points"] = array();
         }
         while (!in_array($readPoints, $this->SHPData["parts"]) && $readPoints < $this->SHPData["numpoints"] && !feof($this->SHPFile)) {
             $this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
             $readPoints++;
         }
     }
     fseek($this->SHPFile, $firstIndex + $readPoints * 16);
 }
            print $mz . "\t\t" . $int . "\n";
        }
    }
    writeData($deIsoMzInt, $precursor, $out_file, $min_count);
} elseif (is_dir($filename)) {
    // print "DETECTED DTA DIRECTORY $filename\n";
    $files = array();
    foreach (glob($filename . "/*.dta") as $file) {
        $files[] = $file;
    }
    print count($files) . " files detected\n";
    foreach ($files as $curr) {
        $path_dir = pathinfo($curr);
        // print $curr." ".$path_dir['extension']."\n";
        if (is_readable($curr) && $path_dir['extension'] == 'dta') {
            list($inMzInt, $precursor, $charge) = loadData($curr);
            if ($major_debug) {
                print "Started with: \n";
                print $precursor . "\t" . $charge . "\n";
                foreach ($inMzInt as $mz => $int) {
                    print $mz . "\t\t" . $int . "\n";
                }
            }
            $deIsoMzInt = deisotope($inMzInt, $precursor, $charge);
            if ($major_debug) {
                print "Ended with: \n";
                print $precursor . "\t" . $charge . "\n";
                print "\n";
                foreach ($deIsoMzInt as $mz => $int) {
                    print $mz . "\t\t" . $int . "\n";
                }
Пример #8
0
$following_dao->countCommonFollowing(); //menghitung masing-masing common_friends dari following dan menyimpannya ke tabel following
$following_dao->countCommonFollower();  //menghitung masing-masing common_follower dari following dan menyimpannya ke tabel following
$following_dao->countSimilarity(); 
 */
$user_dao = new User_dao();
$user = $user_dao->getAll();
//mendapatkan data user
$following_dao = new Following_dao();
$datanya = $following_dao->getId();
//mendapatkan data id following
//var_dump($datanya);
// $column1 = "common_followers_count";
// $column2 = "common_friends_count";
$column1 = "similarity_followers";
$column2 = "similarity_friends";
$data = loadData($column1, $column2);
//mendapatkan data similarity dari tabel following
//var_dump($data);
//$data = array(array(0,0),array(0,2), array(2,0), array(2,2), array(5,0), array(5,2), array(7,0), array(7,2));
//$datanya = array("a","b","c","d","e","f","g","h");
$k = $_POST['k'];
//mendapatkan jumlah cluster yang telah diinput
//$k=2;
$results = kmeans($data, $k);
//melakukan clustering menggunakan k-means dan menghasilkan centroid dan cluster
//$result berupa array, terdiri dari 2 array: array pertama data centroid dan array kedua data cluster
//$jitter = addJitter($data);
// var_dump($data);
// echo "<br />";
// echo "<br />";
//var_dump($results);
Пример #9
0
 /**
  * Loads data from a polyline record
  *
  * @return void
  * @see ShapeRecord::_loadPolyLineRecord()
  */
 public function _loadPolyLineRecord()
 {
     $this->SHPData = array();
     $this->SHPData["xmin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["ymin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["xmax"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["ymax"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["numparts"] = loadData("V", ImportShp::readFromBuffer(4));
     $this->SHPData["numpoints"] = loadData("V", ImportShp::readFromBuffer(4));
     for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
         $this->SHPData["parts"][$i] = loadData("V", ImportShp::readFromBuffer(4));
     }
     $readPoints = 0;
     reset($this->SHPData["parts"]);
     while (list($partIndex, ) = each($this->SHPData["parts"])) {
         if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) {
             $this->SHPData["parts"][$partIndex] = array();
             $this->SHPData["parts"][$partIndex]["points"] = array();
         }
         while (!in_array($readPoints, $this->SHPData["parts"]) && $readPoints < $this->SHPData["numpoints"]) {
             $this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
             $readPoints++;
         }
     }
 }
Пример #10
0
function listOnlinePlayers()
{
    global $ffa_modes;
    global $clientsBlue;
    global $clientsRed;
    global $clientsSpec;
    global $team1;
    global $team2;
    global $spectators;
    global $onlineplayers_bgcolor;
    global $gametype_short;
    global $geoip_path;
    if (!isset($pll_noteams)) {
        $pll_noteams = 0;
    }
    loadData();
    echo "\n    <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">\n    <tr class=\"serverstatus\"><td align=\"center\" class=\"onlineplayers\">Online Players";
    echo " (" . (count($clientsBlue) + count($clientsRed) + count($clientsSpec)) . " Players)";
    echo "\n    </td></tr><tr class=\"serverstatus\"><td class=\"serverstatus\">\n    <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">\n    <tr class=\"serverstatus\">\n    <td class=\"playerstitle_exp\" align=\"center\" width=\"\">Lp.</td>\n    <td class=\"playerstitle_exp\" align=\"center\" width=\"\">Nick</td>\n    <td class=\"playerstitle_exp\" align=\"center\">Score</td>";
    if (file_exists($geoip_path . "GeoIP.dat")) {
        echo "<td class=\"playerstitle_exp\" align=\"center\">Cntry</td>";
    }
    echo "    <td class=\"playerstitle_exp\" align=\"center\">Level</td>\n    <td class=\"playerstitle_exp\" align=\"center\">Con</td>\n    </tr>";
    if (in_array($gametype_short, $ffa_modes) || $pll_noteams != 0) {
        echo "<tr class=\"serverstatus\"><td class=\"teams\" colspan=6 align=\"center\" class=\"status-spectators\">Players (" . count($clientsSpec) . ") </td></tr>";
        addClientsNew($clientsSpec, $onlineplayers_bgcolor);
    } else {
        echo "<tr class=\"serverstatus\"><td class=\"teams\" colspan=6 align=\"center\" class=\"status-blueteam\">{$team2} (" . count($clientsBlue) . ") </td></tr>";
        addClientsNew($clientsBlue, $onlineplayers_bgcolor);
        echo "<tr class=\"serverstatus\"><td class=\"teams\" colspan=6 align=\"center\" class=\"status-redteam\">{$team1} (" . count($clientsRed) . ") </td></tr>";
        addClientsNew($clientsRed, $onlineplayers_bgcolor);
        echo "<tr class=\"serverstatus\"><td class=\"teams\" colspan=6 align=\"center\" class=\"status-spectators\">{$spectators} (" . count($clientsSpec) . ") </td></tr>";
        addClientsNew($clientsSpec, $onlineplayers_bgcolor);
    }
    echo " \n         </table> \n       </table>";
}
Пример #11
0
function welcometext($pop = 0)
{
    global $func;
    global $currentconfig;
    include $currentconfig;
    $link = baselink();
    global $coddb;
    global $separatorline;
    global $t;
    //table names
    global $a_name;
    //award names
    global $a_desc;
    //award descriptions
    global $w;
    global $m;
    global $minkills;
    global $minrounds;
    global $bp_head;
    global $text;
    // test if the status file exists
    $fp = @fopen($b3_status_url, "r");
    if (!@fread($fp, 4096)) {
        return;
    }
    // load data from settings.xml
    loadData();
    $query = "SELECT SUM( kills ) AS kills FROM {$t['players']} WHERE 1";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $kills = $row['kills'];
    $result = null;
    $row = null;
    $query = "SELECT SUM(kills) as kills FROM {$t['playerbody']} WHERE bodypart_id IN {$bp_head}";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $headshots = $row['kills'];
    $result = null;
    $row = null;
    $hpk = 0;
    if ($kills > 0) {
        $hpk = sprintf("%.4f", $headshots / $kills);
    } else {
        $hpk = sprintf("%.4f", 0);
    }
    $query = "SELECT SUM( rounds ) AS rounds FROM {$t['maps']} WHERE 1 ";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $rounds = $row['rounds'];
    $result = null;
    $row = null;
    $query = " SELECT count( client_id ) AS players FROM {$t['players']} WHERE 1";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $players = $row['players'];
    $result = null;
    $row = null;
    //$statusgame = htmlspecialchars( rcon("status"));
    //$currentmap = getCurrentMapName($statusgame);
    global $clientsRed;
    global $clientsBlue;
    global $clientsSpec;
    global $sv_hostname;
    global $sv_privateClients;
    global $gameType;
    global $mapName;
    global $sv_maxclients;
    global $shortversion;
    $result = null;
    $row = null;
    $curnumplayers = count($clientsBlue) + count($clientsRed) + count($clientsSpec);
    $currentmap = $mapName;
    if ($game == 'moh') {
        $currentmap = strtolower($currentmap);
    }
    $maxPlayers = $sv_maxclients - $sv_privateClients;
    // Replace the mapname with a friendly name
    if (isset($m[$currentmap])) {
        $currentmap = $m[$currentmap];
    }
    $today = date('l jS \\of F Y h:i:s A');
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"outertable\">";
    if ($func != "server") {
        echo "<tr><td align=\"center\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $text["welcome"] . "&nbsp;&nbsp;&nbsp;<span class=\"tiny\">({$today})</span></td><td width=\"40px\">" . checklang($pop) . "<a href=\"http://xlrstatshelp.xlr8or.com\" target=\"_blank\"><img src=\"" . pathlink($pop) . "images/ico/help.png\" border=\"0\" align=\"absmiddle\" title=\"Need help on XLRstats?\"></a></td></tr>";
    }
    echo "<tr>\n      <td colspan=\"2\">\n        <table align=\"center\" bgcolor=\"#99aaaa\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">\n      \t<tr bgcolor=\"#cccccc\" valign=\"bottom\">\n      \t\t<td style=\"padding: 4px;\" width=\"37%\">\n            <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n            <tr><td><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["server"] . "</font></font></td>\n            <td><div align=\"right\">\n    ";
    echo gamelauncher('xfire');
    echo gamelauncher('qtracker');
    echo gamelauncher('gsc');
    echo gamelauncher('hlsw');
    echo "\n      </div></td><tr></table>\n      </td>\n  \t\t<td style=\"padding: 4px;\" width=\"18%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["address"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"14%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["map"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"10%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["playing"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"7%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["rounds"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"10%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["players"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"6%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["killed"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"6%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["headshots"] . "</font></font></td>\n  \t\t<td style=\"padding: 4px;\" align=\"center\" width=\"6%\"><font class=\"fontSmall\" size=\"1\"><font color=\"#000000\">&nbsp;" . $text["hpk"] . "</font></font></td>\n  \t</tr>";
    $flag = NULL;
    if (file_exists($geoip_path . "GeoIP.dat")) {
        $geocountry = $geoip_path . "GeoIP.dat";
        $ip = explode(":", $public_ip);
        $ip = $ip[0];
        $gi = geoip_open($geocountry, GEOIP_STANDARD);
        $countryid = strtolower(geoip_country_code_by_addr($gi, $ip));
        $country = geoip_country_name_by_addr($gi, $ip);
        if (!is_null($countryid) and $countryid != "") {
            $flag = "<img style=\"vertical-align: middle;\" src=\"images/flags/" . $countryid . ".gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        }
        geoip_close($gi);
    }
    echo "\n  \t<tr bgcolor=\"#cccccf\" valign=\"middle\">\n  \t\t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"left\"><font class=\"fontNormal\" size=\"2\"><img style=\"vertical-align: middle;\" src=\"images/ico/icon_{$game}.gif\">&nbsp;{$flag}&nbsp;<b><a class=info  href=\"#\">{$sv_hostname}<span>" . $text["serverversion"] . "{$shortversion}</span></a></b></font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"left\"><font class=\"fontNormal\" size=\"2\">{$public_ip}</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$currentmap} ({$gameType})</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$curnumplayers}/{$maxPlayers} ({$sv_maxclients})</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$rounds}</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$players}</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$kills}</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$headshots}</font></td>\n    \t<td style=\"background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black;\" align=\"center\"><font class=\"fontNormal\" size=\"2\">{$hpk}</font></td>\n  \t</tr>\n   </table> \n </td>\n </tr>\n </table>\n      ";
    flush();
}
Пример #12
0
    ini_set('display_errors', '1');
    $start = microtime(true);
}
if (isset($_GET['pc'])) {
    $pc = $_GET['pc'];
    $submitted = true;
} else {
    $pc = 5;
    $submitted = false;
}
isset($_GET['pl']) ? $pl = $_GET['pl'] : ($pl = 2);
isset($_GET['sl']) ? $sl = $_GET['sl'] : ($sl = 2);
isset($_GET['ln']) ? $ln = $_GET['ln'] : ($ln = 2);
isset($_GET['lf']) ? $lf = $_GET['lf'] : ($lf = '');
include "localipsum.php";
$array = loadData();
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?php 
if ($array["title"]) {
    echo $array["title"];
} else {
    echo "Local Ipsum";
}
?>
</title>
<style type="text/css">
Пример #13
0
function dispatch()
{
    $cmd = $_POST["cmd"];
    $cid = $_POST["cid"];
    $uid = $_POST["uid"];
    $data = $_POST["data"];
    if (!matchCredentials($uid, $cid)) {
        echo "Not allowed";
        //exit();
    } else {
        switch ($cmd) {
            case "load":
                return loadData($uid, $cid);
                break;
            case "save":
                return saveData($uid, $cid, $data);
                break;
            default:
                echo "42";
                break;
        }
    }
}
Пример #14
0
            if ($result === True) {
                //echo back the users new value to the UI
                echo $new_value;
            } else {
                echo "Error in update. Please reload";
            }
        }
    } elseif (!empty($_POST['playlist_adding']) && !empty($_POST['song_adding']) && !empty($_POST['artist_adding'])) {
        //get the ID of the song that matches title and artist, no need to strip tags here.
        $playlist = $_POST['playlist_adding'];
        $song_title = $_POST['song_adding'];
        $song_artist = $_POST['artist_adding'];
        $result = $mysqli->query("SELECT Songs.song_id\n\t\t\t\tFROM Songs\n\t\t\t\tINNER JOIN Artists \n\t\t\t\tON Songs.artist_id = Artists.artist_id\n\t\t\t\tWHERE Songs.title = '{$song_title}' AND Artists.artist = '{$song_artist}'\n\t\t\t\t");
        $song_id = "";
        while ($row = $result->fetch_assoc()) {
            $song_id = $row['song_id'];
        }
        //echo($song_id);
        $result = $mysqli->query("SELECT Playlists.playlist_id\n\t\t\t\tFROM Playlists\n\t\t\t\tWHERE Playlists.name = '{$playlist}'\n\t\t\t\t");
        $playlist_id = "";
        while ($row = $result->fetch_assoc()) {
            $playlist_id = $row['playlist_id'];
        }
        $sql = $mysqli->query("INSERT INTO Song_Playlist VALUES(\n\t\t\t\t'{$song_id}', \n\t\t\t\t'{$playlist_id}'\n\t\t\t\t);");
        echo "Song added to playlist";
    } else {
        echo "<p id='error'>There was an error in your request. Please try again.</p>";
    }
}
loadData();
Пример #15
0
function dispatch()
{
    $cmd = $_POST["cmd"];
    $cid = $_POST["cid"];
    $uid = $_POST["uid"];
    $data = $_POST["data"];
    if (!matchCredentials($uid, $cid)) {
        echo "Not allowed";
        //exit();
    } else {
        switch ($cmd) {
            case "load":
                return loadData($uid, $cid);
                break;
            case "save":
                $result = saveData($uid, $cid, $data);
                do_action("gnlms_user_course_data_saved", $uid, $cid, $data);
                return $result;
                break;
            default:
                echo "42";
                break;
        }
    }
}
Пример #16
0
        // Saving
        // Nota: a link may have multiple authors.
        if (!isset($currentLinks[$shortURL])) {
            $currentLinks[$shortURL] = array('url' => $url, 'views' => 0, 'ip' => array(hashIP($_SERVER['REMOTE_ADDR'])));
        } else {
            if (!in_array(hashIP($_SERVER['REMOTE_ADDR']), $currentLinks[$shortURL]['ip'])) {
                $currentLinks[$shortURL]['ip'][] = hashIP($_SERVER['REMOTE_ADDR']);
            }
        }
        saveData($currentLinks);
        return $shortURL;
    } else {
        return false;
    }
}
$data = loadData();
## Action
/* * * * * *   API   * * * * * */
// We want to add a new URL through the 'API'.
// call http://shortener/?url=<URLHere> (generate a random link), or
//      http://shortener/?url=<URLHere>&link=<linkHere> (link is "<linkHere>",
//              except if "<linkHere>" is already taken, then a random link is
//              generated).
//
// Displays the complete short URL in plain text as a response.
if (isset($_GET['url'])) {
    header('Content-type: text/plain; charset=UTF-8');
    $url = $_GET['url'];
    $link = isset($_GET['link']) ? $_GET['link'] : NULL;
    $shortURL = addLink($data, $url, $link);
    if ($shortURL === false) {
Пример #17
0
<?php

require_once 'data/init.php';
$request = $_GET["q"];
if ($request) {
    echo loadData($request);
}
function loadData($request)
{
    global $hostname_ISANdb;
    global $database_ISANdb;
    global $username_ISANdb;
    global $password_ISANdb;
    $mysqli = new mysqli($hostname_ISANdb, $username_ISANdb, $password_ISANdb, $database_ISANdb);
    if ($mysqli->connect_error) {
        die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
    }
    $mysqli->query("SET NAMES 'UTF8'");
    if ($request == "person") {
        if ($stmt = $mysqli->prepare("SELECT id, firstName, lastName, patrName FROM `{$request}` WHERE 1")) {
            $stmt->execute();
            $stmt->bind_result($id, $fname, $lname, $pname);
            while ($stmt->fetch()) {
                $result .= "<option value=\"{$id}\">{$lname} {$fname} {$pname}</option>";
            }
            $mysqli->close();
            return $result;
        }
    }
    if ($stmt = $mysqli->prepare("SELECT id, name FROM `{$request}` WHERE 1")) {
        $stmt->execute();