public function add() { $name = $_POST["name"]; $lastname = $_POST["lastname"]; $email = $_POST["email"]; $pass = $_POST["pass"]; $conf = $_POST["conf"]; if ($name == null or $lastname == null or $email == null or $pass == null or $conf == null) { header("location: Unirse.php?error=1"); } else { if ($pass != $conf) { header("location: Unirse.php?error=2"); } else { $sql = "select * from usuario where Email='" . $email . "'"; $result = $this->cone->procedure($sql); if ($result) { if (!$result->fetch_assoc()) { $sql = "select (count(idUsuario)+1) as 'newId' from usuario"; $result = $this->cone->procedure($sql); if ($result) { if ($row = $result->fetch_assoc()) { $sql = "insert into Usuario values (" . $row['newId'] . ",'" . $name . "','" . $lastname . "','" . $email . "','" . $pass . "',null)"; $rs = $this->cone->procedure($sql); if ($rs) { $ses = new Sessions(); $ses->init(); $ses->set("user", $email); header("location: ../User/index.php"); } else { header("location: Unirse.php?error=3"); } } } } else { header("location: Unirse.php?error=4"); } } } } }
public function login_in2($datos = FALSE) { $objdata = new Database(); $sth = $objdata->prepare('SELECT * FROM users U inner join profiles P ' . 'ON U.idProf = P.idProfile ' . 'WHERE U.idUser = :id'); $sth->execute(array(':id' => $datos)); $data = $sth->fetch(); $count = $sth->rowCount(); if ($count > 0) { require 'sessions.php'; $objSess = new Sessions(); $objSess->init(); $objSess->set('login', $data['logUser']); $objSess->set('idpro', $data['idProf']); $objSess->set('profi', $data['profName']); switch ($data['profName']) { case 'Admin': header('location: ' . URL . 'admin/'); break; case 'Standard': header('location: ' . URL . 'dashboard/'); break; } } }
<?php include "../../../../bdConnection.php"; require '../extras/class/sessions.php'; $objses = new Sessions(); $objses->init(); $user = isset($_SESSION['user']) ? $_SESSION['user'] : null; $sql = "SELECT Type FROM user, role WHERE user.Name = '{$user}' AND user.Role = role.Type"; $cs = mysql_query($sql, $cn); while ($resul = mysql_fetch_array($cs)) { $consul1 = $resul[0]; } $sql1 = "SELECT lab.id_lab FROM user,lab WHERE user.Name ='{$user}' AND user.lab=lab.id_lab"; $cs1 = mysql_query($sql1, $cn); while ($resul = mysql_fetch_array($cs1)) { $consul2 = $resul[0]; } ?> <script type="text/javascript"> <!-- function mostrarReferencia(){ //Si la opcion con id Conocido_1 (dentro del documento > formulario con name fcontacto > y a la vez dentro del array de Conocido) esta activada if (document.frm_per.nom_per[4].checked == true) { //muestra (cambiando la propiedad display del estilo) el div con id 'desdeotro' document.getElementById('desdeotro').style.display='block'; //por el contrario, si no esta seleccionada } else {
<?php require "Sessions.php"; $ses = new Sessions(); $ses->init(); $user = isset($_SESSION['user']) ? $_SESSION['user'] : null; if ($user != null) { $ses->destroy(); header("location: ../Index.php"); }
<?php //llamamos la constante URL require '../util/constants.php'; //controlamos que se haya iniciado session. require '../class/sessions.php'; $objSes = new Sessions(); $objSes->init(); $profile = $objSes->get('profi'); if (!isset($profile) && $profile != 'Admin') { header('location: ' . URL); } if (isset($_POST['nombre'])) { require '../class/books.php'; $objBook = new Books(); $objBook->insert_book(); } else { header('location: ' . URL . 'admin/'); }
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ class Sessions { public static function init($ini_tweaks = true) { //// // Execute ini tweaks for sessions //// if ($ini_tweaks) { ini_set('session.cookie_lifetime', 0); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 100); //// // Use SHA-1 //// ini_set('hash_function', 1); //// // 1 Hour //// ini_set('session.gc_maxlifetime', 3600); } session_start(); } } Sessions::init();