Example #1
14
function check_user($uid, $link)
{
    $query = "SELECT sid FROM " . USERS_TABLE . " WHERE uid='{$uid}';";
    $result = mysqli_query($link, $query) or die(mysqli_error());
    $row = mysqli_fetch_assoc($result);
    return $row["sid"] == SID ? true : false;
}
Example #2
0
function deleteInstitution($institutionId)
{
    //Delete all children of Institution
    $conn = connectToDatabase();
    mysqli_begin_transaction($conn, MYSQLI_TRANS_START_READ_WRITE);
    $sql = "SELECT CURP FROM BelongsToInstitution WHERE institutionId = '{$institutionId}';";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            deleteChildSameConnection($row["CURP"], $conn);
        }
    }
    //Delete all users from institution
    $sql = "SELECT userName FROM WorksInInstitution WHERE institutionId = '{$institutionId}';";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            deleteUserSameConnection($row["userName"], $conn);
        }
    }
    $sql = "DELETE FROM Institution WHERE institutionId = '{$institutionId}'";
    if (mysqli_query($conn, $sql)) {
        echo "1";
    } else {
        echo "0" . mysqli_error($conn);
    }
    mysqli_commit($conn);
    closeDb($conn);
}
Example #3
0
 public function view()
 {
     $sql = "SELECT * FROM herramientas WHERE idHerramienta = '{$this->idHerramienta}'";
     $datos = $this->con->consultaRetorno($sql);
     $row = mysqli_fetch_assoc($datos);
     return $row;
 }
function validateUser($user, $pass, $pass_confirm)
{
    $valueToRetun = 0;
    $validUsernameOrNot = validUsername($user);
    $validPasswordOrNot = validPassword($pass);
    //check to see if username exists
    $sqlQuery = "SELECT * FROM users WHERE username = '******'";
    $result = mysqli_query($connection, $sqlQuery);
    $row = mysqli_fetch_assoc($result);
    if ($row != "") {
        $valueToReturn = 1;
    } else {
        if ($validUsernameOrNot && $validPasswordOrNot) {
            $valueToReturn = 2;
            //Username and password is valid
        } else {
            if (!$validUsernameOrNot) {
                $valueToReturn = 3;
                //Username is not valid format
            } else {
                if (!$validPasswordOrNot) {
                    $valueToReturn = 4;
                    //Password is not valid format
                } else {
                    if (strcmp($pass, $pass_confirm) !== 0) {
                        $valueToReturn = 5;
                        //Password confirmation is incorrect
                    }
                }
            }
        }
    }
    mysql_free_result($result);
    return $valueToReturn;
}
Example #5
0
 public function view()
 {
     $sql = "SELECT t1.*, \n                        t2.nombre as nombre_seccion\n                    FROM estudiantes t1 \n                    INNER JOIN secciones t2 \n                        ON t1.id_seccion = t2.id\n                    WHERE t1.id = '{$this->id}'";
     $datos = $this->con->consultaRetorno($sql);
     $row = mysqli_fetch_assoc($datos);
     return $row;
 }
Example #6
0
function post_query($col)
{
    include 'conn.php';
    //  Get the number of row of a table
    $sql = "SELECT count(id) FROM blog";
    $query = mysqli_query($conn, $sql);
    $row = mysqli_fetch_row($query);
    //  Catch the session variable from another page
    $n = $_SESSION['var'];
    for ($i = 1; $i <= $row[0]; $i++) {
        $sql = "SELECT * FROM blog where id = {$n} order by time asc";
        //  For query
        $query = mysqli_query($conn, $sql);
        $row = mysqli_fetch_assoc($query);
        if ($col == 'post_detail') {
            str_cut($row['post_detail']);
            break;
        } elseif ($col == 'author') {
            echo $row['author'];
            break;
        } elseif ($col == 'time') {
            echo $row['time'];
            break;
        } elseif ($col == 'post_heading') {
            echo $row['post_heading'];
            break;
        } elseif ($col == 'image') {
            echo $row['image'];
            break;
        } elseif ($col == 'id') {
            echo $row['id'];
            break;
        }
    }
}
/**
* Função que valida um usuário e senha
*
* @param string $usuario - O usuário a ser validado
* @param string $senha - A senha a ser validada
*
* @return bool - Se o usuário foi validado ou não (true/false)
*/
function validaUsuario($usuario, $senha)
{
    global $_SG;
    $cS = $_SG['caseSensitive'] ? 'BINARY' : '';
    // Usa a função addslashes para escapar as aspas
    $nusuario = addslashes($usuario);
    $nsenha = addslashes($senha);
    // Monta uma consulta SQL (query) para procurar um usuário
    $sql = "SELECT `id`, `nome` FROM `" . $_SG['tabela'] . "` WHERE " . $cS . " `usuario` = '" . $nusuario . "' AND " . $cS . " `senha` = '" . $nsenha . "' LIMIT 1";
    $query = mysqli_query($sql);
    $resultado = mysqli_fetch_assoc($query);
    // Verifica se encontrou algum registro
    if (empty($resultado)) {
        // Nenhum registro foi encontrado => o usuário é inválido
        return false;
    } else {
        // Definimos dois valores na sessão com os dados do usuário
        $_SESSION['usuarioID'] = $resultado['id'];
        // Pega o valor da coluna 'id do registro encontrado no MySQL
        $_SESSION['usuarioNome'] = $resultado['nome'];
        // Pega o valor da coluna 'nome' do registro encontrado no MySQL
        // Verifica a opção se sempre validar o login
        if ($_SG['validaSempre'] == true) {
            // Definimos dois valores na sessão com os dados do login
            $_SESSION['usuarioLogin'] = $usuario;
            $_SESSION['usuarioSenha'] = $senha;
        }
        return true;
    }
}
Example #8
0
function createOpenInvoiceList()
{
    $currentDate = date('Ymd');
    $res = mysqli_query_check("select count(*) as cnt from {prefix}invoice i where i.deleted = 0 AND i.interval_type > 0 AND i.next_interval_date <= {$currentDate} AND i.archived = 0");
    $row = mysqli_fetch_assoc($res);
    if ($row['cnt'] > 0) {
        createList('open_invoices', 'invoice', 'resultlist_repeating_invoices', $GLOBALS['locLabelInvoicesWithIntervalDue'], "i.interval_type > 0 AND i.next_interval_date <= {$currentDate} AND i.archived = 0", true);
    }
    $open = '';
    $res = mysqli_query_check('SELECT id FROM {prefix}invoice_state WHERE invoice_open=1');
    while ($id = mysqli_fetch_value($res)) {
        if ($open) {
            $open .= ', ';
        }
        $open .= $id;
    }
    $unpaid = '';
    $res = mysqli_query_check('SELECT id FROM {prefix}invoice_state WHERE invoice_unpaid=1');
    while ($id = mysqli_fetch_value($res)) {
        if ($unpaid) {
            $unpaid .= ', ';
        }
        $unpaid .= $id;
    }
    if ($open) {
        createList('open_invoices', 'invoice', 'resultlist_open_invoices', $GLOBALS['locLabelOpenInvoices'], "i.state_id IN ({$open}) AND i.archived=0", true);
    }
    if ($unpaid) {
        createList('open_invoices', 'invoice', 'resultlist_unpaid_invoices', $GLOBALS['locLabelUnpaidInvoices'], "i.state_id IN ({$unpaid}) AND i.archived=0", true, true);
    }
}
Example #9
0
function verificar_login($userid, $pass, &$result)
{
    $servername = "localhost";
    $username = '******';
    $password = "";
    $dbname = "cmd";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = "SELECT * FROM `trabajador` WHERE `userid`=\"" . $userid . "\" and `password`=\"" . $pass . "\"";
    $result = mysqli_query($conn, $sql);
    $count = 0;
    if (!$result) {
        echo "no result";
    } else {
        if (mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $_SESSION['userid'] = $row["userid"];
                $_SESSION['rol'] = $row["rol"];
                $count++;
            }
        }
        if ($count == 1) {
            return 1;
        } else {
            return 0;
        }
    }
}
Example #10
0
function fetch_record($query)
{
    global $connection;
    $result = $connection->query($query);
    return mysqli_fetch_assoc($result);
    //return $result->fetch_assoc();
}
Example #11
0
 public static function queryToArray($sql)
 {
     global $my_user, $my_pass, $my_host, $my_db, $config_enable_cache;
     $link = Database::getLink();
     $db_selected = mysqli_select_db($link, $my_db);
     if (!$db_selected) {
         die('Can\'t use ' . $my_db . ' : ' . mysqli_error($link));
     }
     // Perform Query
     $result = mysqli_query($link, $sql);
     $id = mysqli_insert_id($link);
     if ($id > 0) {
         // we did an insert, just return the id
         return $id;
     }
     //echo ("\ndatabase qtoa before proc id is $id");
     if (!$result) {
         $message = 'Invalid query: ' . mysqli_error($link) . "\n";
         $message .= 'Whole query: ' . $sql;
         die($message);
     }
     if ($result === true) {
         // probably an insert..
         return false;
     }
     $rows = array();
     while ($row = mysqli_fetch_assoc($result)) {
         $rows[] = $row;
     }
     return $rows;
 }
function getRank($a, $b, $c)
{
    include 'config.php';
    $con = mysqli_connect($IP, $user, $pass, $db);
    //		echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
    //		echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
    //echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
    //    	$result=mysqli_query($con,"select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a") or die(mysqli_error($con));
    $result = mysqli_query($con, "select `idCategory` from Placed where `idBid`={$c} and `idAuction`={$a}") or die(mysqli_error($con));
    //		echo "select count(*)+1 as rank from Placed where `Price`>$b and `idAuction`=$a and `status` =  'A'";
    //		echo json_encode($result);
    //		echo mysqli_num_rows($result);
    $row = mysqli_fetch_assoc($result);
    $c = $row['idCategory'];
    //        echo $c.'sdf';
    if (empty($c)) {
        return 0;
    }
    //		echo "select count(*)+1 as rank from Placed where `Price`>$b and `idCategory`=$c and `idAuction`=$a and `status` =  'A'";
    //echo "select count(*)+1 as rank from Placed where `Price`>$b and `idCategory`=$c and `idAuction`=$a and `status` =  'A'";
    $result = mysqli_query($con, "select count(*)+1 as rank from Placed where `Price`>{$b} and `idCategory`={$c} and `idAuction`={$a} and `status` =  'A'") or die("Error" . mysqli_error($con));
    $output = [];
    while ($row = mysqli_fetch_assoc($result)) {
        return $row['rank'];
    }
}
Example #13
0
function query($SQL, $select = false)
{
    static $CONFIG = ['server' => 'localhost', 'username' => 'root', 'password' => 'root', 'database' => 'wt'];
    static $connection;
    if (!isset($connection)) {
        // Create connection
        $connection = mysqli_connect($CONFIG['server'], $CONFIG['username'], $CONFIG['password'], $CONFIG['database']);
        if (!$connection) {
            die('Could not connect to database!');
        }
    }
    if ($select) {
        // IS A SELECT QUERY, RETURN ARRAY
        $results = mysqli_query($connection, $SQL);
        $toReturn = [];
        if (mysqli_num_rows($results) > 0) {
            while ($result = mysqli_fetch_assoc($results)) {
                array_push($toReturn, $result);
            }
        }
        return $toReturn;
    } else {
        // RETURN BOOL
        if (mysqli_query($connection, $SQL)) {
            return true;
        } else {
            return false;
        }
    }
    // Execute SQL
}
 public function preffAction(Request $request)
 {
     $Applicant_id = $request->get('id');
     $result = get_all_schools();
     $schools = array();
     while ($row = mysqli_fetch_assoc($result)) {
         array_push($schools, $row);
     }
     $postData = $request->request->all();
     if (isset($postData['submit']) && isset($postData['school'])) {
         $count = 0;
         foreach ($postData['school'] as $school) {
             if (isset($school['sid']) && $school['id'] != "") {
                 $connection = connect();
                 $no = $school['id'];
                 $sch_id = $school['sid'];
                 $query = "insert into applicant_has_school (";
                 $query .= " Applicant_id, school_id, preferrence_no";
                 $query .= ") values( ";
                 $query .= " '{$Applicant_id}','{$sch_id}','{$no}'";
                 $query .= ")";
                 $result = mysqli_query($connection, $query);
                 colse_connection($connection);
             }
             $count++;
         }
         return $this->redirectToRoute('childrenofstaff_new', array('id' => $Applicant_id));
     }
     return $this->render('applicant/preferrence.html.twig', array('schools' => $schools, 'id' => $Applicant_id));
 }
Example #15
0
function Populate()
{
    //mysql connection
    $con = mysqli_connect("eu-cdbr-azure-west-a.cloudapp.net", "b8592f1b44ff9a", "fecb2128", "TeamProject");
    if (mysqli_connect_errno()) {
        $result = "f";
    } else {
        //query
        $query = "SELECT Name,Email FROM Subscriber";
        $result = mysqli_query($con, $query);
        //initialize arrays
        $i = 0;
        $subnames = array();
        $submails = array();
        //loop through the database populating
        while ($sub = mysqli_fetch_assoc($result)) {
            $subnames[$i] = $sub['Name'];
            $submails[$i] = $sub['Email'];
            $i++;
        }
        //close conection and return
        mysqli_close($con);
        return array($subnames, $submails);
    }
}
 public function searchPost($searchtext)
 {
     if (!empty($searchtext)) {
         $sql = "SELECT * FROM posts\n                    WHERE MATCH (title)\n                    AGAINST ('" . $searchtext . "' IN NATURAL LANGUAGE MODE)";
     } else {
         $sql = "SELECT * FROM posts ";
     }
     $query = mysqli_query($this->con, $sql);
     $postArray = array();
     // var_dump($query);
     // exit;
     if ($query) {
         while ($row = mysqli_fetch_assoc($query)) {
             $myPost = new BlogPostModel();
             $myPost->setId($row['id']);
             $myPost->setTitle($row['title']);
             $myPost->setSummary($row['body']);
             $myPost->setDateCreated($row['created']);
             array_push($postArray, $myPost);
         }
         return $postArray;
     } else {
         header('Location: ?action=search');
     }
 }
Example #17
0
/**
 *   https://github.com/Bigjoos/
 *   Licence Info: GPL
 *   Copyright (C) 2010 U-232 v.3
 *   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *   Project Leaders: Mindless, putyn.
 *
 */
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //=== delete from now viewing after 15 minutes
    sql_query('DELETE FROM now_viewing WHERE added < ' . (TIME_NOW - 900));
    //=== fix any messed up counts
    $forums = sql_query('SELECT f.id, count( DISTINCT t.id ) AS topics, count(p.id) AS posts
                          FROM forums f
                          LEFT JOIN topics t ON f.id = t.forum_id
                          LEFT JOIN posts p ON t.id = p.topic_id
                          GROUP BY f.id');
    while ($forum = mysqli_fetch_assoc($forums)) {
        $forum['posts'] = $forum['topics'] > 0 ? $forum['posts'] : 0;
        sql_query('update forums set post_count = ' . sqlesc($forum['posts']) . ', topic_count = ' . sqlesc($forum['topics']) . ' where id=' . sqlesc($forum['id']));
    }
    if ($queries > 0) {
        write_log("Forum clean-------------------- Forum cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
 public function view()
 {
     $sql = "SELECT * FROM secciones WHERE id = '{$this->id}'";
     $datos = $this->con->consultaRetorno($sql);
     $row = mysqli_fetch_assoc($datos);
     return $row;
 }
Example #19
0
function showDevices($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  gd.*, \n" . "  gowner.gps_owner_name as gps_owner_name \n" . "FROM \n" . "  gps_device gd \n" . "  left join gps_owner gowner on gd.gps_device_id = gowner.gps_owner_id \n" . "ORDER BY \n" . "  gd.gps_device_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>device id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    echo "<th>comment</th>\n";
    echo "<th>owner</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        $ownersSQL = "SELECT gps_owner_id, gps_owner_name from gps_owner \n" . "order by gps_owner_id";
        $ownersDropDown = buildDropDown($con, $ownersSQL, $row['gps_owner_id'], "owner", "gps_device", "gps_owner_id", "gps_owner_name", "gps_device_id", $row['gps_device_id'], true);
        echo "<td>" . $row['gps_device_id'] . "</td>\n";
        echo getTableRow($row, "gps_device_local_id", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_name", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_desc", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_comment", "gps_device", "gps_device_id", "", "");
        echo "<td>" . $ownersDropDown . "</td>\n";
        echo "<td><a onclick='updateDelete(\"gps_entries\", \"gps_device_id\", \"NULL\", \"gps_device\", \"gps_device_id=" . $row['gps_device_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Example #20
0
 public function fetch()
 {
     if ($this->queryResult) {
         return mysqli_fetch_assoc($this->queryResult);
     }
     return false;
 }
Example #21
0
function getLearnCheckPoint($userID, $class)
{
    global $template;
    global $dbc;
    $checkClass;
    if ($class == 1) {
        $getCPSql = "SELECT checkone FROM users WHERE user_id = '{$userID}'";
        $checkClass = "checkone";
    } else {
        if ($class == 2) {
            $getCPSql = "SELECT checktwo FROM users WHERE user_id = '{$userID}'";
            $checkClass = "checktwo";
        } else {
            if ($class == 3) {
                $getCPSql = "SELECT checkthree FROM users WHERE user_id = '{$userID}'";
                $checkClass = "checkthree";
            }
        }
    }
    if (!($res = mysqli_query($dbc, $getCPSql))) {
        $template->assign("DEFINITION", "DB error.");
        $template->parse("CONTENT", "main");
        return;
    } else {
        while ($row = mysqli_fetch_assoc($res)) {
            $checkpoint = $row[$checkClass];
        }
    }
    return $checkpoint;
}
Example #22
0
function showForm($connection)
{
    echo "<form action ='delect.php' method='POST'>";
    echo "<fieldset>";
    echo "<legend> Delect the Rugby Player</legend>";
    echo "<table>";
    echo "<tr><th>Delect</th><th>First Name</th><th>Last Name</th><th>Image</th><th>Position</th><th>Country Name</th></tr>";
    //Select statement.
    $queryString = "SELECT tblRugbyPlayer.ID, tblRugbyPlayer.FirstName, tblRugbyPlayer.LastName, tblRugbyPlayer.Image, tblRugbyPlayer.Position, tblCountry.CountryName FROM tblRugbyPlayer JOIN tblCountry WHERE tblRugbyPlayer.CountryCode = tblCountry.CountryCode";
    $result = mysqli_query($connection, $queryString);
    while ($row = mysqli_fetch_assoc($result)) {
        echo "<tr>";
        foreach ($row as $key => $value) {
            if ($key == "ID") {
                echo "<td><input type='checkbox' name='checkbox[]' value = {$value}></td>";
            } else {
                if ($key == "Image") {
                    echo "<td><img src = {$value} alt = {$value}></td>";
                } else {
                    echo "<td>{$value}</td>";
                }
            }
        }
        echo "</tr>";
    }
    echo "</table>";
    echo "<br><input type = 'submit' name = 'submit' value = 'DELETE'> ";
    echo "</fieldset>";
    echo "</form>";
}
Example #23
0
function getstockprice()
{
    global $con;
    $sql = "SELECT ROUND(current_stock_price, 1) as ct , ROUND(last_stock_price, 1) as lt from stocks";
    $query = mysqli_query($con, $sql);
    if (!$query && !mysqli_num_rows($query)) {
        throw new Exception('Error in SQL');
    }
    $i = 1;
    $ret = array();
    while ($row = mysqli_fetch_assoc($query)) {
        if ($row['ct'] > $row['lt']) {
            $direction = 'up';
            $color = 'green';
        } else {
            $direction = 'down';
            $color = 'red';
        }
        $arr[$i] = array($row['ct'], $direction, $color);
        array_push($ret, $arr[$i]);
        $i++;
    }
    mysqli_close($con);
    return $ret;
}
Example #24
0
function bjtable($res, $frame_caption)
{
    $htmlout = '';
    $htmlout .= begin_frame($frame_caption, true);
    $htmlout .= begin_table();
    $htmlout .= "<tr>\r\n\t<td class='colhead'>Rank</td>\r\n\t<td class='colhead' align='left'>User</td>\r\n\t<td class='colhead' align='right'>Wins</td>\r\n\t<td class='colhead' align='right'>Losses</td>\r\n\t<td class='colhead' align='right'>Games</td>\r\n\t<td class='colhead' align='right'>Percentage</td>\r\n\t<td class='colhead' align='right'>Win/Loss</td>\r\n\t</tr>";
    $num = 0;
    while ($a = mysqli_fetch_assoc($res)) {
        ++$num;
        //==Calculate Win %
        $win_perc = number_format($a['wins'] / $a['games'] * 100, 1);
        //==Add a user's +/- statistic
        $plus_minus = $a['wins'] - $a['losses'];
        if ($plus_minus >= 0) {
            $plus_minus = mksize(($a['wins'] - $a['losses']) * 100 * 1024 * 1024);
        } else {
            $plus_minus = "-";
            $plus_minus .= mksize(($a['losses'] - $a['wins']) * 100 * 1024 * 1024);
        }
        $htmlout .= "<tr><td>{$num}</td><td align='left'>" . "<b><a href='userdetails.php?id=" . $a['id'] . "'>" . $a['username'] . "</a></b></td>" . "<td align='right'>" . number_format($a['wins'], 0) . "</td>" . "<td align='right'>" . number_format($a['losses'], 0) . "</td>" . "<td align='right'>" . number_format($a['games'], 0) . "</td>" . "<td align='right'>{$win_perc}</td>" . "<td align='right'>{$plus_minus}</td>" . "</tr>\n";
    }
    $htmlout .= end_table();
    $htmlout .= end_frame();
    return $htmlout;
}
Example #25
0
function konprobatuSaioa($nora, $errorea)
{
    if (!isset($_SESSION)) {
        session_start();
    }
    if (!isset($_SESSION['posta'])) {
        $user_check = 0;
    } else {
        $user_check = $_SESSION['posta'];
    }
    $sql = "SELECT * FROM  erabiltzaileak where posta like '{$user_check}'";
    require_once __DIR__ . '/../datuBasea/konexioa.php';
    $result = mysqli_query($konexioa, $sql);
    $row = mysqli_fetch_assoc($result);
    $login_session = $row['izenabizen'];
    if (!isset($login_session) && !(isset($_SESSION['posta']) && $_SESSION['posta'] == true)) {
        if ($errorea) {
            echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"js/abixuak/dist/sweetalert2.css\"/>\n<script src=\"js/jquery.js\"></script>\n<script src=\"js/abixuak/dist/sweetalert2.min.js\"></script>\n<body bgcolor=\"#8A0829\">\n<script language=\"JavaScript\">";
            echo "\n        swal({\n                    title: \"GUNE PRIBATUA\",\n                    text: \"Logeatuta egon behar duzu, atal honetan sartzeko.\",\n                    type: \"error\"\n                },\n                function(){\n                    window.location.href = '{$nora}';\n                });\n                    window.onclick = function(){\n                        window.location.href = '{$nora}';\n                        }\n      ";
            echo "</script>\n</body>";
            return false;
        }
    } else {
        return true;
    }
}
Example #26
0
function write_staffs2()
{
    global $lang;
    //==ids
    $t = '$INSTALLER09';
    $iconfigfile = "<" . "?php\n/**\n{$lang['staffcfg_file_created']}" . date('M d Y H:i:s') . ".\n{$lang['staffcfg_mod_by']}\n**/\n";
    $ri = sql_query("SELECT id, username, class FROM users WHERE class BETWEEN " . UC_STAFF . " AND " . UC_MAX . " ORDER BY id ASC") or sqlerr(__FILE__, __LINE__);
    $iconfigfile .= "" . $t . "['allowed_staff']['id'] = array(";
    while ($ai = mysqli_fetch_assoc($ri)) {
        $ids[] = $ai['id'];
        $usernames[] = "'" . $ai["username"] . "' => 1";
    }
    $iconfigfile .= "" . join(",", $ids);
    $iconfigfile .= ");";
    $iconfigfile .= "\n?" . ">";
    $filenum = fopen('./cache/staff_settings.php', 'w');
    ftruncate($filenum, 0);
    fwrite($filenum, $iconfigfile);
    fclose($filenum);
    //==names
    $t = '$INSTALLER09';
    $nconfigfile = "<" . "?php\n/**\n{$lang['staffcfg_file_created']}" . date('M d Y H:i:s') . ".\n{$lang['staffcfg_mod_by']}\n**/\n";
    $nconfigfile .= "" . $t . "['staff']['allowed'] = array(";
    $nconfigfile .= "" . join(",", $usernames);
    $nconfigfile .= ");";
    $nconfigfile .= "\n?" . ">";
    $filenum1 = fopen('./cache/staff_settings2.php', 'w');
    ftruncate($filenum1, 0);
    fwrite($filenum1, $nconfigfile);
    fclose($filenum1);
    stderr($lang['staffcfg_success'], $lang['staffcfg_updated']);
}
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    //== delete torrents - ????
    $days = 30;
    $dt = TIME_NOW - $days * 86400;
    sql_query("UPDATE torrents SET flags='1' WHERE added < {$dt} AND seeders='0' AND leechers='0'") or sqlerr(__FILE__, __LINE__);
    $res = sql_query("SELECT id, name FROM torrents WHERE mtime < {$dt} AND seeders='0' AND leechers='0' AND flags='1'") or sqlerr(__FILE__, __LINE__);
    while ($arr = mysqli_fetch_assoc($res)) {
        sql_query("DELETE files.*, comments.*, thankyou.*, thanks.*, thumbsup.*, bookmarks.*, coins.*, rating.*, xbt_files_users.* FROM xbt_files_users\n                                 LEFT JOIN files ON files.torrent = xbt_files_users.fid\n                                 LEFT JOIN comments ON comments.torrent = xbt_files_users.fid\n                                 LEFT JOIN thankyou ON thankyou.torid = xbt_files_users.fid\n                                 LEFT JOIN thanks ON thanks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN bookmarks ON bookmarks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN coins ON coins.torrentid = xbt_files_users.fid\n                                 LEFT JOIN rating ON rating.torrent = xbt_files_users.fid\n                                 LEFT JOIN thumbsup ON thumbsup.torrentid = xbt_files_users.fid\n                                 WHERE xbt_files_users.fid =" . sqlesc($arr['id'])) or sqlerr(__FILE__, __LINE__);
        @unlink("{$INSTALLER09['torrent_dir']}/{$arr['id']}.torrent");
        write_log("Torrent " . (int) $arr['id'] . " (" . htmlsafechars($arr['name']) . ") was deleted by system (older than {$days} days and no seeders)");
    }
    if ($queries > 0) {
        write_log("Delete Old Torrents XBT Clean -------------------- Delete Old XBT Torrents cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
function sha_connect($offset, $host, $db, $port, $socket, $file)
{
    $link = mysqli_init();
    if (!$link->options(MYSQLI_SERVER_PUBLIC_KEY, $file)) {
        printf("[%03d + 001] mysqli_options failed, [%d] %s\n", $offset, $link->errno, $link->error);
        return false;
    }
    if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) {
        printf("[%03d + 002] [%d] %s\n", $offset, $link->connect_errno, $link->connect_error);
        return false;
    }
    if (!($res = $link->query("SELECT id FROM test WHERE id = 1"))) {
        printf("[%03d + 003] [%d] %s\n", $offset, $link->errno, $link->error);
    }
    return false;
    if (!($row = mysqli_fetch_assoc($res))) {
        printf("[%03d + 004] [%d] %s\n", $offset, $link->errno, $link->error);
        return false;
    }
    if ($row['id'] != 1) {
        printf("[%03d + 005] Expecting 1 got %s/'%s'", $offset, gettype($row['id']), $row['id']);
        return false;
    }
    $res->close();
    $link->close();
    return true;
}
Example #29
-1
 /**
  * This method will handle user login process
  * @param array $data
  * @return boolean true or false based on success or failure
  */
 public function login(array $data)
 {
     $_SESSION['logged_in'] = false;
     if (!empty($data)) {
         // Trim all the incoming data:
         $trimmed_data = array_map('trim', $data);
         // escape variables for security
         $email = mysqli_real_escape_string($this->_con, $trimmed_data['email']);
         $password = mysqli_real_escape_string($this->_con, $trimmed_data['password']);
         if (!$email || !$password) {
             throw new Exception(LOGIN_FIELDS_MISSING);
         }
         $password = md5($password);
         $query = "SELECT id, name, email, created FROM users where email = '{$email}' and password = '******' ";
         $result = mysqli_query($this->_con, $query);
         $data = mysqli_fetch_assoc($result);
         $count = mysqli_num_rows($result);
         mysqli_close($this->_con);
         if ($count == 1) {
             $_SESSION = $data;
             $_SESSION['logged_in'] = true;
             return true;
         } else {
             throw new Exception(LOGIN_FAIL);
         }
     } else {
         throw new Exception(LOGIN_FIELDS_MISSING);
     }
 }
Example #30
-1
function DbQuery()
{
    include 'databaseconn.php';
    if (isset($_POST["Areaid"]) && !empty($_POST["Areaid"])) {
        //Checks if action value exists
        $Idarea = $_POST["Areaid"];
    }
    if (isset($_POST["startdt"]) && !empty($_POST["startdt"])) {
        //Checks if action value exists
        $startdty = $_POST["startdt"];
    }
    if (isset($_POST["endt"]) && !empty($_POST["endt"])) {
        //Checks if action value exists
        $endty = $_POST["endt"];
    }
    //sql query start
    $returna = "";
    $sql1 = "SELECT tblAreaID,slrDate,slrTime,AvgSolRad,MinSolRad,MaxSolRad FROM tblftpfiledata where tblAreaID =" . $Idarea . " AND slrDate BETWEEN '" . $startdty . "' AND '" . $endty . "'";
    $no1 = 0;
    $result1 = mysqli_query($conn, $sql1);
    $encode = array();
    while ($row = mysqli_fetch_assoc($result1)) {
        $encode[] = $row;
    }
    $returna = json_encode($encode);
    echo json_encode($encode);
}