Example #1
0
 public static function getFile($location, $vars = array())
 {
     extract($vars);
     ob_start();
     require FS::loc($location);
     return ob_get_clean();
 }
Example #2
0
 public function __construct($id, $git_url, $cloud_id = null)
 {
     $this->id = $id;
     $this->git_url = $git_url;
     $this->git_dir = \Lobby\FS::loc("/contents/apps/lobby-server/src/data/git-cache/{$id}");
     $this->cloud_id = $cloud_id;
 }
Example #3
0
 public static function __constructStatic()
 {
     /**
      * Get DB config
      */
     $config = \Lobby::config(true);
     if (is_array($config)) {
         /**
          * Make DB credentials variables from the config.php file
          */
         self::$prefix = $config['prefix'];
         self::$type = $config['type'];
         $options = array(\PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
         try {
             if ($config['type'] === 'mysql') {
                 self::$dbh = new \PDO("mysql:dbname={$config['dbname']};host={$config['host']};port={$config['port']};charset=utf8;", $config['username'], $config['password'], $options);
                 /**
                  * Check if Lobby tables exist
                  */
                 $notable = false;
                 $tables = array("options", "data");
                 // The Tables of Lobby
                 foreach ($tables as $tableName) {
                     $results = self::$dbh->prepare("SHOW TABLES LIKE ?");
                     $results->execute(array(self::$prefix . $tableName));
                     if ($results->rowCount() == 0) {
                         $notable = true;
                     }
                 }
             } else {
                 if ($config['type'] === 'sqlite') {
                     self::$dbh = new \PDO("sqlite:" . \Lobby\FS::loc($config['path']), "", "", $options);
                     /**
                      * Enable Multithreading Read/Write
                      */
                     self::$dbh->exec("PRAGMA journal_mode=WAL;");
                     /**
                      * Check if Lobby tables exist
                      */
                     $sql = self::$dbh->query("SELECT COUNT(1) FROM `sqlite_master` WHERE `type` = 'table' AND (`name` = 'l_data' OR `name` = 'l_options')");
                     $notable = $sql->fetchColumn() === "2" ? false : true;
                 }
             }
             if ($notable === false) {
                 /* There are database tables */
                 parent::$installed = true;
             } else {
                 parent::log(array("fatal", "Tables required by Lobby was not found in the database. Check your <b>config.php</b> and database to fix the error. Or Install again by removing <b>config.php</b>."));
             }
         } catch (\PDOException $e) {
             parent::$installed = false;
             $error = $e->getMessage();
             parent::log(array("fatal", "Unable to connect to database server. Is the database credentials given in <b>config.php</b> correct ? <blockquote>{$error}</blockquote>"));
         }
     } else {
         self::$installed = false;
     }
 }
Example #4
0
 /**
  * List modules in a directory
  */
 public static function dirModules($location)
 {
     $location = FS::loc($location);
     $mods = array_diff(scandir($location), array('..', '.'));
     $validModules = array();
     foreach ($mods as $module) {
         $loc = "{$location}/{$module}";
         if (self::valid($module, $loc)) {
             $validModules[$module] = array("id" => $module, "location" => $loc, "url" => Lobby::getURL() . "/" . FS::rel($loc));
         }
     }
     return $validModules;
 }
Example #5
0
<?php

require "../../../../load.php";
$file = \Request::postParam('cx74e9c6a45', '');
$appID = \Request::postParam('s7c8csw91', '');
if ($file != "" && CSRF::check()) {
    if ($appID !== "") {
        $App = new \Lobby\Apps($appID);
        if ($App->exists && $App->enabled) {
            $AppClass = $App->run();
            $html = $AppClass->page("/ajax/{$file}");
            if ($html === "auto") {
                $html = $AppClass->inc("/src/ajax/{$file}");
            }
            echo $html;
        }
    } else {
        if (\Lobby\FS::exists($file)) {
            require_once \Lobby\FS::loc($file);
        } else {
            echo "fileNotFound";
        }
    }
}
Example #6
0
 public static function finish_software_update($admin_previously_installed = false)
 {
     FS::write("/upgrade.lobby", "1", "w");
     if ($admin_previously_installed) {
         FS::remove("/contents/modules/admin/disabled.txt");
     }
     $latest_version = DB::getOption("lobby_latest_version");
     self::log("Updated Lobby to version {$latest_version}");
     /**
      * Remove Depreciated Files
      */
     $deprecatedFilesInfoLoc = "/contents/update/removeFiles.php";
     if (FS::exists($deprecatedFilesInfoLoc)) {
         $files = FS::get($deprecatedFilesInfoLoc);
         $files = explode("\n", $files);
         if (count($files) !== 0) {
             $files = array_filter($files);
             foreach ($files as $file) {
                 $fileLoc = L_DIR . "/{$file}";
                 if (file_exists($fileLoc) && $fileLoc != L_DIR) {
                     FS::remove($fileLoc);
                     self::log("Removed Deprecated File: {$fileLoc}");
                 }
             }
             copy(FS::loc($deprecatedFilesInfoLoc), FS::loc("{$deprecatedFilesInfoLoc}.txt"));
             FS::remove($deprecatedFilesInfoLoc);
             self::log("Finished Removing Deprecated Files");
         }
     }
     /**
      * Database Update
      */
     if (FS::exists("/update/sqlExecute.sql")) {
         self::log("Upgrading Lobby Database");
         $sqlCode = FS::get("/update/sqlExecute.sql");
         $sql = \Lobby\DB::prepare($sqlCode);
         if (!$sql->execute()) {
             echo ser("Error", "Database Update Couldn't be made. <a href='update.php'>Try again</a>");
         } else {
             FS::remove("/update/sqlExecute.sql");
         }
         self::log("Updated Lobby Database");
     }
     FS::remove("/upgrade.lobby");
     self::log("Lobby is successfully Updated.");
 }
Example #7
0
<?php

include \Lobby\FS::loc("/src/Inc/load.php");
if (isset($_POST['id']) && isset($_POST['roll']) && isset($_POST['password'])) {
    $roll = $_POST['roll'];
    $voterID = strtoupper($_POST['id']);
    $passwords = unserialize(getData("student_passwords"));
    if ($passwords[$roll] == $_POST['password']) {
        if ($ELEC->didVote($voterID) == false) {
            $_SESSION['election-validated'] = "true";
            echo "true";
        } else {
            echo "voted";
        }
    } else {
        echo "false";
    }
}
Example #8
0
                                echo CSRF::getInput();
                                ?>
                </form>
            <?php 
                            } else {
                                if ($db_type === "sqlite") {
                                    ?>
                <h3>Database</h3>
                <form action="<?php 
                                    \Lobby::u();
                                    ?>
" method="POST">
                  <p>The location of the SQLite database file :</p>
                  <label>
                    <input type="text" name="db_location" id="db_location" value="<?php 
                                    echo \Lobby\FS::loc("/contents/extra/lobby_db.sqlite");
                                    ?>
" />
                  </label>
                  
                  <button name="submit" style="width:200px;font-size:15px;" class="btn green">Install Lobby</button>
                  <input type="hidden" name="db_type" value="sqlite" />
                  <?php 
                                    echo CSRF::getInput();
                                    ?>
                </form>
              <?php 
                                } else {
                                    echo ser("Error", "Uh... You didn't mention the DBMS to use");
                                }
                            }
Example #9
0
<?php

include \Lobby\FS::loc("/src/Inc/load.php");
include \Lobby\FS::loc("/src/Inc/graph.php");
$data = array();
// Set config directives
$cfg['title'] = 'Election Results';
$cfg['width'] = 600;
$cfg['height'] = 300;
$cfg['value-font-size'] = 4;
$cfg['key-font-size'] = 6;
$candidateNames = unserialize(getData("female_candidates")) + unserialize(getData("male_candidates"));
$votes = $ELEC->count($candidateNames);
foreach ($votes as $name => $votes) {
    $data[$name] = $votes;
}
$graph = new phpMyGraph();
ob_start();
$graph->parseVerticalColumnGraph($data, $cfg);
$img = ob_get_clean();
echo base64_encode($img);
?>