Example #1
0
 static function resetPassword($data)
 {
     PDOSql::$pdobj = pdoConnect();
     $hash = Sql::esc($data['h']);
     $type = Sql::esc($data['t']);
     $email = Sql::esc($data['q']);
     $pass1 = Sql::esc($data['pass1']);
     $pass2 = Sql::esc($data['pass2']);
     if ($pass1 !== $pass2) {
         return array('success' => false, 'data' => '', 'msg' => 'Las contraseñas no coinciden');
     }
     if ($type == 'C') {
         $get_hash = "SELECT id, email, resetHash from clientes where email ='" . $email . "' AND resetHash = '" . $hash . "'";
         $delete_hash = "UPDATE clientes set password = MD5('" . $pass1 . "'), resetHash = null where email ='" . $email . "' AND resetHash = '" . $hash . "'";
     } elseif ($type == 'U') {
         $get_hash = "SELECT id, email, resetHash from usuarios where email ='" . $email . "' AND resetHash = '" . $hash . "'";
         $delete_hash = "UPDATE usuarios set password = MD5('" . $pass1 . "'), resetHash = null where email ='" . $email . "' AND resetHash = '" . $hash . "'";
     } else {
         return array('success' => false, 'data' => '', 'msg' => 'Problema con el reseteo');
     }
     $h = Sql::fetch($get_hash);
     if (count($h) == 1) {
         $u = Sql::update($delete_hash);
         return array('success' => true, 'data' => array('id' => $h[0]['id']), 'msg' => 'Se realizo la operacion con exito.');
     } else {
         return array('success' => false, 'data' => '', 'msg' => 'Codigo invalido');
     }
 }
Example #2
0
 static function deleteOld()
 {
     PDOSql::$pdobj = pdoConnect();
     $id = Sql::esc($id);
     $iduser = Sql::esc($_SESSION['userID']);
     $res = Sql::delete("DELETE from notifications WHERE  status = '1' AND view_date < NOW() - INTERVAL 1 month");
     return array('success' => true, 'data' => $res, 'msg' => '');
 }
Example #3
0
 static function getData($id)
 {
     PDOSql::$pdobj = pdoConnect();
     $d = PDOSql::select("SELECT name, bg_image, subtitle FROM users WHERE id = ?", array($id));
     if (count($d) > 0) {
         $data['name'] = $d[0]['name'];
         $data['bg_image'] = $d[0]['bg_image'];
         $data['subtitle'] = $d[0]['subtitle'];
         return M::cr(true, $data);
     } else {
         return M::cr(false, array('user' => array()), 'No se encontraron datos del usuario');
     }
 }
Example #4
0
 public static function edit($data)
 {
     $p = array('title' => array('required' => true, 'type' => 'string', 'maxlength' => 140, 'label' => 'Titulo'), 'text' => array('required' => true, 'type' => 'string', 'label' => 'Texto'), 'image' => array('required' => false, 'type' => 'thumbnail', 'label' => 'Imagen'), 'tags' => array('required' => false, 'type' => 'string', 'label' => 'Tags'));
     $v = new Validator();
     $response = $v->validate($data, $p);
     if (!$response['success']) {
         return M::cr(false, $data, $response['msg']);
     }
     PDOSql::$pdobj = pdoConnect();
     if (isset($_FILES['image']['name'])) {
         $response = File::up2Web($_FILES['image']);
         if ($response->success) {
             // remove old image...
             if (isset($data['old_image'])) {
                 File::unlinkWeb($data['old_image']);
             }
             $image = $response->data[0];
         } else {
             return M::cr(false, $data, $response->msg);
         }
     } else {
         $image = '';
     }
     $params = array($data['title'], $data['text'], $image, $data['tags'], $data['id'], $_SESSION['userNAME']);
     $where = array(' id = ?', 'author = ?');
     $query = "UPDATE entries SET title = ?, text = ?, image = ?, tags = ? {%WHERE%}";
     PDOSql::update($query, $params, $where);
     return M::cr(true, array(), 'Se han actualizado los datos correctamente');
 }
Example #5
0
 static function rubros()
 {
     PDOSql::$pdobj = pdoConnect();
     $rubs = Sql::fetch("SELECT rubro from rubros_generales ORDER BY id");
     $r = array();
     foreach ($rubs as $rub) {
         $r[] = array('rubro' => $rub['rubro']);
     }
     return $r;
 }