public function Calculate()
 {
     /// Calculate number of users, etc...
     $this->stats['Users'] = sizeof(Account::findAll());
     $this->stats['Groups'] = sizeof(Group::findAll());
     $this->stats['Items'] = sizeof(Menu::list_files(Settings::$photos_dir, true));
     $this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir, true));
     $this->stats['Albums'] = sizeof(Menu::list_dirs(Settings::$photos_dir, true));
     $this->accounts = array_reverse(Account::findAll());
     $commentsfile = Settings::$conf_dir . "/comments.xml";
     if (is_file($commentsfile)) {
         $xml = simplexml_load_file($commentsfile);
         $this->comments = $xml->children();
     }
 }
Beispiel #2
0
 /**
  * Creates a new account in the base
  *
  * @param string $login 
  * @param string $password 
  * @author Thibaud Rohmer
  */
 public static function create($login, $password, $verif, $groups = array(), $name = '', $email = '')
 {
     // Check if login already exists
     if (Account::exists($login) || !CurrentUser::$admin && Settings::$noregister || $password != $verif) {
         return false;
     }
     // All users belong to the "user" group
     $groups[] = "user";
     $xml_infos = CurrentUser::$accounts_file;
     if (!file_exists($xml_infos) || sizeof(Account::findAll()) == 0) {
         // No account
         // Create accounts file
         $xml = new SimpleXMLElement('<accounts></accounts>');
         $xml->asXML($xml_infos);
         // Set this account as root
         $groups[] = "root";
     }
     if (preg_match("/[^a-z0-9]/i", $login) || strlen($password) < 6) {
         return false;
     }
     $acc = new Account();
     $acc->login = $login;
     $acc->password = Account::password($password);
     $acc->groups = $groups;
     $acc->name = $name;
     $acc->email = $email;
     $acc->save();
     return true;
 }
Beispiel #3
0
 public function toHTML()
 {
     $groupaccounts = array();
     echo "<div class='header'><h1>Groups</h1></div>";
     echo "<form class='pure-form pure-form-aligned' method='post' action='?t=Adm&a=GC'>\r\n\t\t\t<h2>" . Settings::_("jsaccounts", "addgroup") . "</h2>\r\n\t\t\t<div class='pure-control-group'>\r\n\t\t\t<label>Group name : </label><input type='text' name='group' placeholder='" . Settings::_("jsaccounts", "groupname") . "' />\r\n\t\t\t</div>\r\n\t\t\t<div class='pure-controls'>\r\n\t\t\t<input type='submit' class='pure-button button-success' value='" . Settings::_("jsaccounts", "addgroup") . "' />\r\n\t\t\t</div>\r\n\t\t\t</form>";
     echo "<form class='pure-form pure-form-aligned' method='post' action='?t=Adm&a=GEd'>";
     echo "<h2>" . Settings::_("jsaccounts", "groups") . "</h2>";
     foreach (Group::findAll() as $g) {
         $gn = $g['name'];
         $group = htmlentities($gn, ENT_QUOTES, 'UTF-8');
         echo "<div class='pure-g' style='border-bottom: 1px solid #ccc; padding-bottom: 15px; margin: 20px;'>";
         echo "<div class='pure-u-1-1 pure-u-md-1-3'>";
         echo "<h3><a href=\"?t=Adm&a=GDe&g=" . urlencode($gn) . "\" class='pure-button button-error button-small'><i class='fa fa-trash-o '></i></a> " . htmlentities($gn, ENT_QUOTES, 'UTF-8') . "</h3>";
         echo "</div>";
         echo "<div class='pure-u-1-1 pure-u-md-2-3'>";
         foreach (Account::findAll() as $acc) {
             $login = htmlentities($acc["login"], ENT_QUOTES, 'UTF-8');
             $checked = in_array($gn, $acc["groups"]) ? "checked" : "";
             echo "<div class='pure-controls'>";
             echo "<label><input type='checkbox' name=\"{$group}" . "[]\" value=\"{$login}\" {$checked} > {$login}</label>";
             echo "</div>";
         }
         echo "</div>";
         echo "</div>";
     }
     echo "<div class='pure-controls'><input type='submit' class='pure-button pure-button-primary'></div>";
     echo "</form>";
 }
Beispiel #4
0
 /**
  * Display the rights on website, and let
  * the admin edit them.
  * 
  * @author Thibaud Rohmer
  */
 public function toHTML()
 {
     echo "<div class='adminrights'>\n";
     echo "<h3>" . htmlentities($this->filename, ENT_QUOTES, 'UTF-8') . "</h3>\n";
     if ($this->public) {
         echo "<form action='?t=Pri&f={$this->webpath}' method='post'>\n";
         echo Settings::_("judge", "public");
         echo "<input type='submit' class='button blue' value='" . Settings::_("judge", "gopriv") . "' />";
         echo "</form>";
         echo "</div>";
         return;
     } else {
         echo "<form action='?t=Pub&f={$this->webpath}' method='post'>\n";
         echo Settings::_("judge", "priv");
         echo "<input type='submit' class='button blue' value='" . Settings::_("judge", "gopub") . "' />";
         echo "</form>";
     }
     echo "<form action='?t=Rig&f={$this->webpath}' method='post'>\n";
     echo "<h3>" . Settings::_("judge", "accounts") . "</h3>";
     foreach (Account::findAll() as $account) {
         if (in_array($account['login'], $this->users)) {
             $checked = "checked";
         } else {
             $checked = "";
         }
         echo "<label><input type='checkbox' value='" . $account['login'] . "' name='users[]' {$checked} >" . htmlentities($account['login'], ENT_QUOTES, 'UTF-8') . "</label>";
     }
     echo "<h3>" . Settings::_("judge", "groups") . "</h3>";
     foreach (Group::findAll() as $group) {
         if ($group['name'] == "root") {
             continue;
         }
         if (in_array($group['name'], $this->groups)) {
             $checked = "checked";
         } else {
             $checked = "";
         }
         echo "<label><input type='checkbox' value='" . $group['name'] . "' name='groups[]' {$checked} > " . htmlentities($group['name'], ENT_QUOTES, 'UTF-8') . " </label>";
     }
     echo "</br><input type='submit' class='button blue' value='" . Settings::_("judge", "set") . "'>\n";
     echo "</form>\n";
     echo "</div>\n";
 }
Beispiel #5
0
 /**
  * Display the rights on website, and let
  * the admin edit them.
  * 
  * @author Thibaud Rohmer
  */
 public function toHTML()
 {
     echo "<div class='adminrights'>\n";
     echo "<h3>Infos</h3>";
     echo $this->infos;
     echo "<h3>Access</h3>";
     if ($this->public) {
         echo "<div class='pure-g'><div class='pure-u-1-3'>";
         echo "<a href='?t=Pri{$this->webpath}'class='button-round button-success'><i class='fa fa-unlock'></i></a></div>";
         echo "<div class='pure-u-2-3'>" . Settings::_("judge", "public") . "</div></div>";
     } else {
         echo "<div class='pure-g'><div class='pure-u-1-3'>";
         echo "<a href='?t=Pub{$this->webpath}'class='button-round button-error'><i class='fa fa-lock'></i></a></div>";
         echo "<div class='pure-u-2-3'>" . Settings::_("judge", "priv") . "</div></div>";
     }
     echo "<form action='?t=Rig{$this->webpath}' method='post' class='pure-form pure-form-aligned'>";
     if (!$this->public) {
         echo "<h3>" . Settings::_("judge", "accounts") . "</h3>";
         echo "<ul>";
         foreach (Account::findAll() as $account) {
             if (in_array($account['login'], $this->users)) {
                 $checked = "checked";
             } else {
                 $checked = "";
             }
             echo "<label class='pure-checkbox'><input type='checkbox'  value='" . $account['login'] . "' name='users[]' {$checked} > " . htmlentities($account['login'], ENT_QUOTES, 'UTF-8') . "</label>";
         }
         echo "</ul>";
         echo "<h3>" . Settings::_("judge", "groups") . "</h3>";
         echo "<ul>";
         foreach (Group::findAll() as $group) {
             if ($group['name'] == "root") {
                 continue;
             }
             if (in_array($group['name'], $this->groups)) {
                 $checked = "checked";
             } else {
                 $checked = "";
             }
             echo "<label class='pure-checkbox'><input type='checkbox'   value='" . $group['name'] . "' name='groups[]' {$checked} > " . htmlentities($group['name'], ENT_QUOTES, 'UTF-8') . " </label>";
         }
         echo "<input type='submit' class='pure-button pure-button-primary button-small' value='" . Settings::_("judge", "set") . "'>\n";
         echo "</ul>";
         echo "<h3>Guest Tokens</h3>";
         if (!$this->multi) {
             // Token creation
             $tokens = GuestToken::find_for_path($this->file);
             if ($tokens && !empty($tokens)) {
                 echo "<ul>";
                 $i = 0;
                 foreach ($tokens as $token) {
                     $i++;
                     echo "<a class='pure-button button-small button-warning' href='" . GuestToken::get_url($token['key']) . "' >Guest Token {$i}</a><br />\n";
                 }
                 echo "</ul>";
             }
             echo "<ul><a href='?t=CTk{$this->webpath}' class='pure-button button-secondary button-small'>" . Settings::_("token", "createtoken") . "</a></ul>";
         }
     }
     echo "</form>\n";
     echo "</div>\n";
 }
Beispiel #6
0
 public function __construct()
 {
     $this->accounts = Account::findAll();
     $this->groups = Group::findAll();
 }
Beispiel #7
0
 /**
  * Display upload page on website
  * 
  * @author Thibaud Rohmer
  */
 public function toHTML()
 {
     echo "<h1>Upload</h1>";
     echo "<form action='?t=Adm&a=Upl' method='post' enctype='multipart/form-data'>";
     echo "<fieldset><span>Images</span><div><input  name='images[]' type='file' multiple /></div></fieldset>";
     echo "<fieldset><span>Location</span><div><select name='path'>";
     echo "<option value='.'>.</option>";
     foreach ($this->dirs as $dir) {
         if ($dir == $this->selected_dir) {
             $selected = "selected";
         } else {
             $selected = "";
         }
         echo "<option value='" . htmlentities($dir, ENT_QUOTES, 'UTF-8') . "' {$selected}>" . htmlentities($dir, ENT_QUOTES, 'UTF-8') . "</option>\n";
     }
     echo "</select></div></fieldset>";
     echo "<fieldset><span>New Dir</span><div><input name='newdir' type='text' /></div></fieldset>";
     echo "<fieldset><span>Rights</span><div><label><input type='checkbox' name='inherit' checked /> Inherit</label></div></fieldset>";
     echo "<fieldset><span>Public</span><div><label><input type='checkbox' name='public' checked /> Public</label></div></fieldset>";
     echo "<fieldset><span>Groups</span><div>";
     foreach (Group::findAll() as $group) {
         echo "<label><input type='checkbox' name='groups[]' value='" . htmlentities($group['name'], ENT_QUOTES, 'UTF-8') . "' checked /> " . htmlentities($group['name'], ENT_QUOTES, 'UTF-8') . " </label>";
     }
     echo "</div></fieldset>";
     echo "<fieldset><span>Users</span><div>";
     foreach (Account::findAll() as $account) {
         echo "<label><input type='checkbox' name='users[]' value='" . htmlentities($account['login'], ENT_QUOTES, 'UTF-8') . "' checked /> " . htmlentities($account['login'], ENT_QUOTES, 'UTF-8') . " </label>";
     }
     echo "</div></fieldset>";
     echo "<fieldset><input type='submit' class='button blue' /></fieldset>";
     echo "</form>";
 }