Example #1
0
/**
 * Update on/off session setting
 */
function sessionUpdate($switch, $setting, &$val, &$oldval)
{
    if (isset($_POST[$switch]) && isset($_POST[$setting])) {
        $val = $_POST[$setting];
        $oldval = $_SESSION[$setting];
        if ($val != $oldval) {
            // TODO move update to daemon.php or after pushing worker task
            Session::update($setting, $val);
            return true;
        }
    }
    return false;
}
Example #2
0
 public static function write($sess_id, $data)
 {
     $s = new Session();
     $s->session_id = $sess_id;
     if ($s->find(true)) {
         $s->data = $data;
         if (isset($_SESSION['rememberMe']) && $_SESSION['rememberMe'] == true) {
             $s->remember_me = 1;
         }
         return $s->update();
     } else {
         return false;
     }
 }
Example #3
0
 static function write($id, $session_data)
 {
     self::logdeb("Writing session '{$id}'");
     $session = Session::staticGet('id', $id);
     if (empty($session)) {
         $session = new Session();
         $session->id = $id;
         $session->session_data = $session_data;
         $session->created = common_sql_now();
         return $session->insert();
     } else {
         $session->session_data = $session_data;
         return $session->update();
     }
 }
Example #4
0
 public static function write($sess_id, $data)
 {
     $s = new Session();
     $s->session_id = $sess_id;
     if ($s->find(true)) {
         $s->data = $data;
         if (isset($_SESSION['rememberMe']) && ($_SESSION['rememberMe'] == true || $_SESSION['rememberMe'] === "true")) {
             $s->remember_me = 1;
             setcookie(session_name(), session_id(), time() + self::$rememberMeLifetime, '/');
         } else {
             $s->remember_me = 0;
             session_set_cookie_params(0);
         }
         parent::write($sess_id, $data);
         return $s->update();
     } else {
         //No session active
         return false;
     }
 }
 public function process()
 {
     // check if session is active
     $session = new Session($this->sessionId);
     if ($session->sessionId > 0) {
         // update session
         $session->update();
         // process restricted functions
         switch ($this->f) {
             case 'checkLogin':
                 return Login::checkLogin($session->sessionId);
             case 'getSession':
                 return $session;
             case 'getWarehouse':
                 if (isset($this->data->update)) {
                     $warehouse = new Warehouse($session->warehouseId, $this->data->update);
                 } else {
                     $warehouse = new Warehouse($session->warehouseId);
                 }
                 $warehouse->dMail = $warehouse->getMail();
                 $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled();
                 $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled();
                 return $warehouse;
             case 'editWarehouse':
                 if (!$session->restricted) {
                     $data = $this->data;
                     $warehouse = new Warehouse($session->warehouseId);
                     // update warehouse data
                     if (isset($data->name)) {
                         $warehouse->name = $data->name;
                     }
                     if (isset($data->description)) {
                         $warehouse->description = $data->description;
                     }
                     if (isset($data->country)) {
                         $warehouse->country = $data->country;
                     }
                     if (isset($data->city)) {
                         $warehouse->city = $data->city;
                     }
                     if (isset($data->password)) {
                         $warehouse->setPassword($data->password);
                     }
                     if (isset($data->passwordRestricted)) {
                         $warehouse->setPasswordRestricted($data->passwordRestricted);
                     }
                     if (isset($data->mail)) {
                         $warehouse->setMail($data->mail);
                     }
                     if (isset($data->disableLocationLess)) {
                         $warehouse->setDisableLocationLess($data->disableLocationLess);
                     }
                     if (isset($data->disablePaletteLess)) {
                         $warehouse->setDisablePaletteLess($data->disablePaletteLess);
                     }
                     // update database entry
                     return $warehouse->edit();
                 }
                 break;
             case 'deleteWarehouse':
                 if (!$session->restricted) {
                     $warehouse = new Warehouse($session->warehouseId);
                     if ($warehouse->id > 0 && $warehouse->delete()) {
                         return $session->destroy();
                     }
                 }
                 break;
             case 'addCategory':
                 if (!$session->restricted && isset($this->data->name)) {
                     $category = new Category(null, $session->warehouseId);
                     $category->name = $this->data->name;
                     if (isset($this->data->parent)) {
                         $category->parent = $this->data->parent;
                     }
                     if ($category->edit()) {
                         return $category->id;
                     }
                 }
                 break;
             case 'getCategory':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Category($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Category($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteCategory':
                 if (!$session->restricted && isset($this->data->id)) {
                     $category = new Category($this->data->id, $session->warehouseId);
                     return $category->delete();
                 }
                 break;
             case 'editCategory':
                 if (isset($this->data->id)) {
                     $data = $this->data;
                     $category = new Category($this->data->id, $session->warehouseId);
                     if (!$session->restricted) {
                         if (isset($data->name)) {
                             $category->name = $data->name;
                         }
                         if (isset($data->parent)) {
                             $category->parent = $data->parent;
                         }
                         if (isset($data->male)) {
                             $category->male = $data->male;
                         }
                         if (isset($data->female)) {
                             $category->female = $data->female;
                         }
                         if (isset($data->children)) {
                             $category->children = $data->children;
                         }
                         if (isset($data->baby)) {
                             $category->baby = $data->baby;
                         }
                         if (isset($data->summer)) {
                             $category->summer = $data->summer;
                         }
                         if (isset($data->winter)) {
                             $category->winter = $data->winter;
                         }
                     }
                     if (isset($data->demand)) {
                         $category->demand = $data->demand;
                     }
                     if (isset($data->weight)) {
                         $category->weight = $data->weight;
                     }
                     return $category->edit();
                 }
                 break;
             case 'getCategories':
                 if (isset($this->data->parent)) {
                     return Category::getCategories($session->warehouseId, $this->data->parent);
                 } else {
                     return Category::getCategories($session->warehouseId);
                 }
             case 'addLocation':
                 if (!$session->restricted && isset($this->data->name)) {
                     $location = new Location(null, $session->warehouseId);
                     $location->name = $this->data->name;
                     if ($location->edit()) {
                         return $location->id;
                     }
                     return true;
                 }
                 break;
             case 'getLocation':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Location($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Location($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteLocation':
                 if (!$session->restricted && isset($this->data->id)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     return $location->delete();
                 }
                 break;
             case 'editLocation':
                 if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     $location->name = $this->data->name;
                     return $location->edit();
                 }
                 break;
             case 'getLocations':
                 return Location::getLocations($session->warehouseId);
             case 'addPalette':
                 $palette = new Palette(null, $session->warehouseId);
                 if (isset($this->data->locationId)) {
                     $palette->locationId = $this->data->locationId;
                 }
                 if ($palette->edit()) {
                     return $palette->id;
                 }
                 break;
             case 'getPalette':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Palette($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Palette($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deletePalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     return $palette->delete();
                 }
                 break;
             case 'editPalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     if (isset($this->data->locationId)) {
                         $palette->locationId = $this->data->locationId;
                     }
                     return $palette->edit();
                 }
                 break;
             case 'getPalettes':
                 return Palette::getPalettes($session->warehouseId);
             case 'getCarton':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Carton($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'addCarton':
                 $locationId = null;
                 $paletteId = null;
                 if (isset($this->data->location)) {
                     $locationId = $this->data->location;
                 }
                 if (isset($this->data->palette)) {
                     $paletteId = $this->data->palette;
                 }
                 $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId);
                 return $carton->id;
             case 'deleteCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     return $carton->delete();
                 }
                 break;
             case 'editCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     if (isset($this->data->location)) {
                         $carton->locationId = $this->data->location;
                     } else {
                         $carton->locationId = null;
                     }
                     if (isset($this->data->palette)) {
                         $carton->paletteId = $this->data->palette;
                     } else {
                         $carton->paletteId = null;
                     }
                     return $carton->edit();
                 }
                 break;
             case 'addArticle':
                 if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) {
                     return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0);
                 }
                 break;
             case 'getStock':
                 return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false);
             case 'getBarcodeUri':
                 if (isset($this->data->text)) {
                     // create barcode object
                     $bc = new Barcode39($this->data->text);
                     if (isset($this->data->textSize)) {
                         $bc->barcode_text_size = $this->data->textSize;
                     }
                     if (isset($this->data->barThin)) {
                         $bc->barcode_bar_thin = $this->data->barThin;
                     }
                     if (isset($this->data->barThick)) {
                         $bc->barcode_bar_thick = $this->data->barThick;
                     }
                     // generate barcode image
                     $img = "barcode_" . mt_rand(0, 100) . ".png";
                     $bc->draw($img);
                     // get data uri
                     $uri = Barcode39::getDataURI($img);
                     unlink($img);
                     return $uri;
                 }
                 break;
         }
     } else {
         // process unrestricted function
         switch ($this->f) {
             case 'getActiveSessions':
                 return Session::getActiveSessionsNumber();
             case 'getWarehouses':
                 return Warehouse::getWarehouses();
             case 'addWarehouse':
                 $data = $this->data;
                 if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) {
                     $warehouse = new Warehouse();
                     Log::debug('new warehouse' . $warehouse->id);
                     $warehouse->name = $data->name;
                     $warehouse->description = $data->description;
                     $warehouse->country = $data->country;
                     $warehouse->city = $data->city;
                     $warehouse->setPassword($data->password);
                     $warehouse->setMail($data->mail);
                     return $warehouse->edit();
                 }
                 break;
             case 'getCountries':
                 return getCountries();
                 break;
             case 'getCountryCode':
                 $data = $this->data;
                 if (isset($data->name)) {
                     return getCountryCode(null, $data->name);
                 }
                 return false;
         }
     }
     return false;
 }
Example #6
0
         //New template
         $template_id = Session::update_template($conn, $login . "_perms", $perms);
     }
     Session::insert($conn, $login, $login_method, $pass1, $user_name, $email, $template_id, $entities, $sel_sensors, $sel_assets, $company, $department, $language, $first_login, $tzone, $is_admin);
     User_config::copy_panel($conn, $login);
     $_SESSION['_user_vision'] = $pro ? Acl::get_user_vision($conn) : Session::get_user_vision($conn);
     Util::memcacheFlush();
     Session::log_pass_history($login, hash('sha256', $pass1));
 } else {
     $msg = 'updated';
     if ($insert_menu == TRUE) {
         Session::update_template($conn, $login . '_perms', $perms, $template_id);
     }
     $error = 0;
     if (($am_i_admin || $am_i_proadmin) && !$is_my_profile) {
         Session::update($conn, $login, $login_method, $user_name, $email, $template_id, $entities, $sel_sensors, $sel_assets, $company, $department, $language, $first_login, $tzone, $is_admin);
         Util::memcacheFlush();
     } else {
         $error = Session::update_user_light($conn, $login, $login_method, $user_name, $email, $company, $department, $language, $first_login, $is_admin, $tzone);
         if ($error == 0) {
             Util::memcacheFlush();
             if ($is_my_profile && $language != $_SESSION['_user_language']) {
                 $_SESSION['_user_language'] = $language;
                 ossim_set_lang($language);
                 $language_changed = TRUE;
             }
             $tzone_diff = Session::get_timezone($tzone);
             if ($is_my_profile && $_SESSION['_timezone'] != $tzone_diff) {
                 $_SESSION['_timezone'] = $tzone_diff;
                 $tzone_changed = TRUE;
             }
Example #7
0
    sysCmd("/var/www/command/unmute.sh pi-ampplus");
} elseif ($_SESSION['i2s'] == 'IQaudIO Pi-DigiAMP+') {
    sysCmd("/var/www/command/unmute.sh pi-digiampplus");
} else {
    sysCmd("/var/www/command/unmute.sh default");
}
// TC (Tim Curtis) 2015-04-29: store PCM (alsamixer) volume, picked up by settings.php ALSA volume field
// TC (Tim Curtis) 2015-06-26: set simple mixer name based on kernel version and i2s vs USB
$mixername = getMixerName(getKernelVer($_SESSION['kernelver']), $_SESSION['i2s']);
$rtn = "/var/www/tcmods/" . MOODE_RELEASE . "/cmds/tcmods.sh get-pcmvol " . $mixername;
$volume = substr($rtn[0], 0, 6) == 'amixer' ? 'none' : str_replace("%", "", $rtn[0]);
// update session and db
Session::wrap(function () use($_tcmods_conf, $volume) {
    Session::update('kernelver', $_tcmods_conf['sys_kernel_ver']);
    Session::update('procarch', $_tcmods_conf['sys_processor_arch']);
    Session::update('pcm_volume', $volume);
}, true);
/*
 * Worker main loop
 */
logWorker('[daemon] Loop');
while (1) {
    // TC (Tim Curtis) 2014-12-23: check clock radio for scheduled playback
    if ($_tcmods_conf['clock_radio_enabled'] == "Yes") {
        $current_time = date("hi A");
        if ($current_time == $clock_radio_starttime) {
            $clock_radio_starttime = '';
            // TC (Tim Curtis) 2015-06-26: new volume control with optional logarithmic mapping of knob 0-100 range to hardware range
            $_tcmods_conf = getTcmodsConf();
            // read in conf file
            $level = $_tcmods_conf['clock_radio_volume'];
Example #8
0
 /**
  * Write function that is called when session data is to be saved.
  *
  * @param string $sess_id The current session ID
  * @param string $data    The session data to write
  *
  * @return void
  * @access public
  */
 public static function write($sess_id, $data)
 {
     if (isset($_SESSION['no_store'])) {
         return true;
     }
     $s = new Session();
     $s->session_id = $sess_id;
     if ($s->find(true)) {
         $s->data = $data;
         return $s->update();
     } else {
         // in seconds - easier for calculating duration
         $s->last_used = time();
         // in date format - easier to read
         $s->created = date('Y-m-d h:i:s');
         $s->data = $data;
         return $s->insert();
     }
 }
Example #9
0
    echo "<pre>";
    print_r($data);
    echo "</pre>";
    ?>
		</div>
	</div>
	<?php 
}
function RandomString()
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randstring = '';
    for ($i = 0; $i < 10; $i++) {
        $randstring = $characters[rand(0, strlen($characters) - 1)];
    }
    return $randstring;
}
$html = new Frontend();
$db = new Session();
if (isset($_SESSION['userid'])) {
    $db->update("users", "last_seen", "CURRENT_TIMESTAMP", $_SESSION['userid']);
}
if (is_file("update.lock") or is_file("install.lock")) {
    if ($current_page != "lock.php" and $current_page != "update.php") {
        $html->redirection("lock.php");
    }
}
if (basename($_SERVER['PHP_SELF']) != "logon.php" and basename($_SERVER['PHP_SELF']) != "upload.php") {
    $html->navbar();
}
$alerts = new Alerts();
Example #10
0
 }
 $sensors = "";
 for ($i = 0; $i < $nsensors; $i++) {
     ossim_valid(POST("sensor{$i}"), OSS_LETTER, OSS_DIGIT, OSS_DOT, OSS_NULLABLE, 'illegal:' . _("sensor{$i}"));
     if (ossim_error()) {
         die(ossim_error());
     }
     if ($sensors == "") {
         $sensors = POST("sensor{$i}");
     } else {
         $sensors .= "," . POST("sensor{$i}");
     }
 }
 if (Session::am_i_admin()) {
     require_once "classes/Util.inc";
     Session::update($conn, $user, $name, $email, $perms, $nets, $sensors, $company, $department, $language, $kdbperms, $first_login, $is_admin, $tzone);
     Util::clean_json_cache_files("", $user);
 } else {
     Session::update_noperms($conn, $user, $name, $email, $company, $department, $language, $first_login, $is_admin, $tzone);
 }
 if ($user == Session::get_session_user() && $language != $_SESSION['_user_language']) {
     $_SESSION['_user_language'] = $language;
     ossim_set_lang($language);
     $langchanged = 1;
 }
 if ($user == Session::get_session_user() && $_SESSION['_timezone'] != $tzone) {
     $_SESSION['_timezone'] = $tzone;
 }
 // PASSWORD
 if (POST("pass1") && POST("pass2")) {
     /*