示例#1
26
function check_login($user_id, $password)
{
    session_destroy();
    session_start();
    $moodle_host = "127.0.0.1";
    $moodle_port = "3306";
    $moodle_user = "******";
    $moodle_db = "moodle";
    $moodle_pass = "";
    $moodle_conn = mysql_connect($moodle_host . ":" . $moodle_port, $moodle_user, $moodle_pass);
    $moodle_salt = '-Y9-h0;),c@<i)D~*i/j7.pD6lh/,B';
    $password = md5($password . $moodle_salt);
    $ret = false;
    $moodle_pre = "mdl_";
    $sql = "select password from " . $moodle_pre . "user where username='******'";
    if ($moodle_conn) {
        mysql_select_db($moodle_db, $moodle_conn);
        $result = mysqli_query($mysqli, $sql, $moodle_conn);
        $row = mysqli_fetch_row($result);
        if ($row && $password == $row[0]) {
            $ret = $user_id;
        }
    }
    return $ret;
}
 function signup()
 {
     global $id1, $emailid1, $pass1;
     $con = mysqli_connect('localhost', 'root', '');
     $db = mysqli_select_db($con, 'accommodation');
     $query = "SELECT * FROM property_manager WHERE email_id = '{$emailid1}'";
     $result = mysqli_query($con, $query);
     $num = mysqli_num_rows($result);
     if ($num != 0) {
         echo "EmailID already exists";
     } else {
         $query = "INSERT INTO property_manager (`email_id`, `pass`) VALUES ('{$emailid1}','{$pass1}')";
         if (!$con->query($query)) {
             echo "INSERT failed";
         } else {
             $q2 = "SELECT id FROM property_manager WHERE email_id='{$emailid1}'";
             $result = mysqli_query($con, $q2);
             $row = mysqli_fetch_row($result);
             $id1 = $row[0];
             session_start();
             $_SESSION["id_1"] = $id1;
             header('location: pm_home.php');
         }
     }
 }
示例#3
12
function check_id($conn, $uid)
{
    $sql = "select count(*) from users where uid = {$uid}";
    $result = mysqli_query($conn, $sql);
    $row = mysqli_fetch_row($result);
    return !$row[0];
}
示例#4
1
文件: sourcecode.php 项目: CDFLS/CWOJ
function sc_check_priv($prob_id, $opened, $user)
{
    if (!function_exists('check_priv')) {
        require __DIR__ . '/privilege.php';
    }
    if (isset($_SESSION['user'])) {
        if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
            return TRUE;
        }
    }
    require __DIR__ . '/../conf/database.php';
    if (!defined('PROB_HAS_TEX')) {
        require __DIR__ . '/../lib/problem_flags.php';
    }
    if ($opened) {
        $row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
        if (!$row) {
            return _('There\'s no such problem');
        }
        $prob_flag = $row[0];
        if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
            return _('Looks like you can\'t access this page');
        }
        if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
            return _('This solution is not open-source');
        } else {
            if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
                if (isset($_SESSION['user'])) {
                    $query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
                    $user_status = mysqli_query($con, $query);
                    $row = mysqli_fetch_row($user_status);
                    if ($row && $row[0] == 0) {
                        return TRUE;
                    }
                }
                return _('You can\'t see me before solving it');
            } else {
                if (isset($_SESSION['user'])) {
                    $res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n                                       RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n                                       LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n                                       LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n                                       where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
                    $num = mysqli_num_rows($res);
                    if ($num > 0) {
                        $accessible = false;
                        while ($row = mysqli_fetch_row($res)) {
                            if (!is_null($row[1])) {
                                $accessible = true;
                            }
                        }
                        if ($accessible) {
                            return TRUE;
                        } else {
                            return _('You can\'t see me before the contest ends');
                        }
                    }
                    return TRUE;
                }
            }
        }
    }
    return _('Looks like you can\'t access this page');
}
function getInfo($element, $sharer_id, $conx)
{
    $sql = "SELECT {$element} FROM table_userinfo WHERE id='{$sharer_id}' AND activated='1' LIMIT 1";
    $query = mysqli_query($conx, $sql);
    $info = mysqli_fetch_row($query);
    return "{$info['0']}";
}
示例#6
0
 public function LoadGraph($id)
 {
     $tableid = $id;
     if ($id > 12) {
         $id = $id % 12;
     }
     $query = "select date, OilLevel{$id}, OilAlarmLevel{$id}, GasLevel{$id}, GasAlarmLevel{$id} from detector{$tableid}";
     if ($result = mysqli_query($this->link, $query)) {
         $fp = fopen("datafiles/detector{$tableid}.csv", "w");
         /* fetch associative array */
         while ($row = mysqli_fetch_row($result)) {
             if ($row[1] > 100) {
                 $row[1] = 100;
             }
             if ($row[2] > 100) {
                 $row[2] = 100;
             }
             if ($row[3] > 100) {
                 $row[3] = 100;
             }
             if ($row[4] > 100) {
                 $row[4] = 100;
             }
             fwrite($fp, implode(',', $row) . "\n");
         }
         /* free result set */
         mysqli_free_result($result);
         //	echo json_encode(array("demo"=>$returnArray));
     }
 }
示例#7
0
function sqllogin($host, $dbuser, $dbpass, $dbname)
{
    // connectivity
    //mysql connections for stacked query examples.
    $con1 = mysqli_connect($host, $dbuser, $dbpass, $dbname);
    $username = mysqli_real_escape_string($con1, $_POST["login_user"]);
    $password = $_POST["login_password"];
    // Check connection
    if (mysqli_connect_errno($con1)) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    } else {
        @mysqli_select_db($con1, $dbname) or die("Unable to connect to the database ######: ");
    }
    /* execute multi query */
    $sql = "SELECT * FROM users WHERE username='******' and password='******'";
    if (@mysqli_multi_query($con1, $sql)) {
        /* store first result set */
        if ($result = @mysqli_store_result($con1)) {
            if ($row = @mysqli_fetch_row($result)) {
                if ($row[1]) {
                    return $row[1];
                } else {
                    return 0;
                }
            }
        }
    }
}
 function login()
 {
     global $emailid1, $pass1;
     $con = mysqli_connect('localhost', 'root', '');
     $db = mysqli_select_db($con, 'accommodation');
     $query = "SELECT email_id, pass FROM property_manager WHERE email_id='{$emailid1}'";
     $result = mysqli_query($con, $query);
     $num = mysqli_num_rows($result);
     $row = mysqli_fetch_array($result);
     if ($num == 0) {
         echo "Property Manager Doesn't Exist";
     } else {
         if ($pass1 == $row['pass']) {
             $q2 = "SELECT id FROM property_manager WHERE email_id='{$emailid1}'";
             $result = mysqli_query($con, $q2);
             $row = mysqli_fetch_row($result);
             $id1 = $row[0];
             session_start();
             $_SESSION["id_1"] = $id1;
             header('location: pm_home.php');
         } else {
             echo "Incorrect Password";
         }
     }
 }
function search_results1($name1)
{
    $link = mysqli_connect("localhost", "root", "", "db1");
    $returned_result = array();
    $where = "";
    $name1 = preg_split('/[\\s]/', $name1);
    $total = count($name1);
    foreach ($name1 as $key => $keywords) {
        $where .= "`desc` LIKE '%{$keywords}%'";
        if ($key != $total - 1) {
            $where .= " AND ";
        }
    }
    $result = "select * from `collect` where {$where}";
    $res1 = mysqli_query($link, $result);
    $b = ".jpg";
    if (mysqli_num_rows($res1) === 0) {
        echo "<h3   color='#1cff33'>Nothing Found!!!</h3><br><br><br><br><br><br><br><br><br><br><br>";
    } else {
        while ($res = mysqli_fetch_row($res1)) {
            $d = "{$res['4']}" . "{$b}";
            echo "<table class=\"one\" cellspacing=\"1px\">\n  <tr>\n  <td align=\"center\">\n   <img class=\"one\" src='./product/electronics/{$d}' />\n  </td>\n  </tr>\n  <tr>\n  <p>\n  <td align=\"center\">\n  ";
            echo "<p><a href=\"#\" class=\"five\">\n<font color=\"#a20099\" size=\"6\"><br>{$res['2']}\n<br>\n</a>\n</font>\n<br />\n<font color=\"cc1100\" size=\"6\">\n<b>Rs.{$res['3']}</b>\n<hr />\n</font>\n</td>\n</tr>\n</table>";
        }
    }
    echo "</div>";
}
示例#10
0
function DisplayTableInHTML($table_name)
{
    global $db;
    // refer to the global variable 'db'
    $query = "SELECT * FROM " . $table_name;
    $res = $db->query($query);
    // yes, just like this
    if (!$res) {
        exit("There is a MySQL error, exiting this script");
    }
    echo "<p style=\"text-align:center; background-color:#FAEBD7; margin-top: 10px\">Table " . $table_name . "<br></p>";
    // dynamic HTML table
    echo "<table border=\"1px\" class=\"admin_table table table-striped table-hover\" style=\"border-collapse: collapse\">";
    echo "<thead>";
    echo "<tr><th>Graph ID</th>";
    echo "<th>User ID</th>";
    echo "<th>Best Score</th>";
    echo "</tr>";
    echo "</thead>";
    while ($r = mysqli_fetch_row($res)) {
        // important command
        echo "<tr><td>" . $r[0] . "</td>";
        // echo first column
        for ($i = 1; $i < count($r); $i++) {
            echo "<td>" . $r[$i] . "</td>";
        }
        echo "</tr>";
    }
    echo "</table>";
}
示例#11
0
 public function Select()
 {
     $a = null;
     $sql = "select * from publishednews";
     if ($this->PublisherId > 0) {
         $sql .= " where PublisherId = " . $this->PublisherId;
     }
     $r = mysqli_query($this->cn, $sql);
     while ($s = mysqli_fetch_row($r)) {
         $item = new publishednews();
         $item->NewsId = $s[0];
         $item->PublisherId = $s[1];
         $item->Date = $s[2];
         include_once 'Model/news.php';
         $item->News = new News();
         $item->News->Id = $item->NewsId;
         $item->News->SelectById();
         include_once 'Model/user.php';
         $item->Publisher = new User();
         $item->Publisher->Id = $item->PublisherId;
         $item->Publisher->SelectById();
         $a[] = $item;
     }
     return $a;
 }
示例#12
0
文件: API.php 项目: bennyty/suggestr
function get_array_similar($conn)
{
    $sql = "SELECT * FROM Session";
    $result = $conn->query($sql);
    $user_id = $_COOKIE['user'];
    $sql2 = "SELECT * FROM `Session` WHERE `id` = " . $user_id;
    $user_query = mysqli_query($conn, $sql2);
    $user_row = mysqli_fetch_row($user_query);
    $major = $user_row[1];
    $year = $user_row[2];
    echo "Users who are: " . $major . $year . " Chose to take these classes:";
    //$sql3 = "SELECT * FROM `Action` WHERE `major` = '".$major."' AND `year` = '".$year."' AND `choice` = '0' ORDER by course_id DESC";
    $sql3 = "SELECT course_id,count(*) FROM `Action` WHERE `major` = '" . $major . "' AND `year` = '" . $year . "' AND `choice` = '0' GROUP by course_id ORDER BY count(*) DESC";
    echo $sql3;
    $selected_courses = mysqli_query($conn, $sql3);
    //Choose the classes "chosen" by previous people who were of your major.
    //$priorityQueue = new PQtest();
    //$priorityQueue->insert($potential_course[3],$times);
    /*echo "<ul>";
    	while($potential_course = mysqli_fetch_row($selected_courses)){
    		echo "<li>".$potential_course[1]." : ".request_course_name($conn,$potential_course[0])."</li>";
    	}
    	echo "</ul>";
    	*/
    return $selected_courses;
}
示例#13
0
function listDbData()
{
    $link = mysqli_connect('localhost', 'root', '') or die(mysql_error());
    $db_list = mysql_list_dbs($link);
    print "<table width=100% bgcolor='BLACK' cellspacing=1 cellpadding=0>";
    print "<tr bgcolor=#BBBBBB><td align='center'>";
    print "<b>Database list</b>";
    print "</td></tr>";
    while ($row = mysqli_fetch_object($link, $db_list)) {
        print "<tr bgcolor='WHITE'><td align='center'>";
        print $row->Database;
        //echo $row->Database . "<br>";
        print "</td></tr>";
    }
    print "<tr bgcolor=#BBBBBB><td align='center'>";
    print "<b>Tables</b>";
    print "</td></tr>";
    $db_selected = mysqli_select_db('maxinedb', $link);
    $sql = "SHOW TABLES";
    $result = mysqli_query($link, $sql);
    if (!$result) {
        throw new man_exception('MySQL Error: ' . mysql_error());
    }
    while ($row = mysqli_fetch_row($link, $result)) {
        print "<tr bgcolor='WHITE'><td align='center'>";
        print $row[0] . "";
        print "</td></tr>";
    }
    print "</table>";
}
示例#14
0
 public function getAttribute($attribute, &$source = null, $func = 'PDO::getAttribute', &$last_error = null)
 {
     if ($source == null) {
         $source =& $this->driver_options;
     }
     switch ($attribute) {
         case PDO::ATTR_AUTOCOMMIT:
             $result = mysqli_query($this->link, 'SELECT @@AUTOCOMMIT', MYSQLI_USE_RESULT);
             if (!$result) {
                 $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, $func);
             }
             $row = mysqli_fetch_row($result);
             mysqli_free_result($result);
             return intval($row[0]);
             break;
         case PDO::ATTR_CLIENT_VERSION:
             return mysqli_get_client_info();
             break;
         case PDO::ATTR_CONNECTION_STATUS:
             return mysqli_get_host_info($this->link);
             break;
         case PDO::ATTR_SERVER_INFO:
             return mysqli_stat($this->link);
             break;
         case PDO::ATTR_SERVER_VERSION:
             return mysqli_get_server_info($this->link);
             break;
         default:
             return parent::getAttribute($attribute, $source, $func, $last_error);
             break;
     }
 }
function display_view()
{
    $con = mysqli_connect('localhost', 'root', '');
    $db = mysqli_select_db($con, 'stats');
    $query = "SELECT team_name,(no_of_wins + no_of_losses+no_of_draws) as Total_Matches, no_of_wins,no_of_losses,no_of_draws FROM team order by Total_Matches desc";
    $result = mysqli_query($con, $query);
    if ($result) {
        $row = mysqli_fetch_row($result);
        echo '<table border="1" style= "text-align: center; color: #092f44; margin: 0 auto;" >';
        echo '<tr> <th>Team </th>
				  <th>Matches Played</th>
                  <th>WON</th>
                  <th>LOST</th>
                  <th>DRAW</th>                  
				</tr>';
        while ($row) {
            $col = count($row);
            echo "<tr>";
            for ($c = 0; $c < $col; $c++) {
                echo "<td>" . $row[$c] . "</td>";
            }
            echo "</tr>";
            $row = mysqli_fetch_row($result);
        }
        echo "</table>";
    } else {
        echo "err";
    }
}
示例#16
0
 function createDatabase()
 {
     dprint("here\n");
     $rdb = $this->lx_mysql_connect('localhost', $this->main->__var_dbadmin, $this->main->__var_dbpassword);
     mysqli_query($rdb, "use mysql");
     $res = mysqli_query($rdb, "select * from user where User = '******'");
     $ret = null;
     if ($res) {
         $ret = mysqli_fetch_row($res);
     }
     if ($ret) {
         throw new lxException("database_user_already_exists__{$this->main->username}", 'username', '');
     }
     mysqli_query($rdb, "create database {$this->main->dbname};");
     $this->log_error_messages($rdb);
     mysqli_query($rdb, "grant all on {$this->main->dbname}.* to '{$this->main->username}'@'%' identified by '{$this->main->dbpassword}';");
     mysqli_query($rdb, "grant all on {$this->main->dbname}.* to '{$this->main->username}'@'localhost' identified by '{$this->main->dbpassword}';");
     if ($this->main->__var_primary_user) {
         $parentname = $this->main->__var_primary_user;
         mysqli_query($rdb, "grant all on {$this->main->dbname}.* to '{$parentname}'@'localhost';");
         mysqli_query($rdb, "grant all on {$this->main->dbname}.* to '{$parentname}'@'%';");
     }
     $this->log_error_messages($rdb, false);
     mysqli_query($rdb, "flush privileges;");
 }
示例#17
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;
        }
    }
}
示例#18
0
 public function showByAddress($pageWiseData)
 {
     $sqlAddress = "SELECT latitude,longitude FROM userDetails WHERE email='" . $pageWiseData->getEmail() . "' ";
     $latlong = mysqli_query($this->con, $sqlAddress);
     $latLongValue = mysqli_fetch_row($latlong);
     $latitude = $latLongValue[0];
     $longitude = $latLongValue[1];
     $sql = "SELECT clinic_id,clinic_name,clinic_address,doctor_name,contact,notes,email,clinic_image,city,area,latitude,longitude,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( latitude ) ) ) ) * 1.609344 AS distance\n\t\t\t\t\tFROM petclinic\n\t\t\t\t\tHAVING distance < 5 ORDER BY distance";
     try {
         $result = mysqli_query($this->con, $sql);
         $count = mysqli_num_rows($result);
         $numOfRows = $count;
         $rowsPerPage = 10;
         $totalPages = ceil($numOfRows / $rowsPerPage);
         $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
         if (is_numeric($pageWiseData->getCurrentPage())) {
             $currentPage = (int) $pageWiseData->getCurrentPage();
         }
         if ($currentPage >= 1 && $currentPage <= $totalPages) {
             $offset = ($currentPage - 1) * $rowsPerPage;
             $sql = "SELECT clinic_id,clinic_name,clinic_address,doctor_name,contact,notes,email,clinic_image,city,area,latitude,longitude,(3959 * acos( cos( radians('{$latitude}') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( latitude ) ) ) ) * 1.609344 AS distance\n\t\t\t\t\t\t\tFROM petclinic\n\t\t\t\t\t\t\tHAVING distance < 5 ORDER BY distance LIMIT {$offset}, {$rowsPerPage}";
             $result = mysqli_query($this->con, $sql);
             $this->data = array();
             while ($rowdata = mysqli_fetch_assoc($result)) {
                 $this->data[] = $rowdata;
             }
             return $this->data;
         }
     } catch (Exception $e) {
         echo 'SQL Exception: ' . $e->getMessage();
     }
     return $this->data = array();
 }
示例#19
0
function showForm($connection)
{
    //Select the username from the database.
    $selectString = "SELECT DISTINCT(username) from User ORDER BY username";
    $result = mysqli_query($connection, $selectString);
    echo "<form action ='AddData.php' method='POST'>";
    echo "<fieldset>";
    echo "<legend><h3>Add Data</h3></legend>";
    echo "<p>Select The User: "******"<select name='username'>";
    echo "<option value = 'SelectTheUser'></option></p>";
    while ($row = mysqli_fetch_row($result)) {
        echo "<option value = \"{$row['0']}\">{$row['0']}</option>";
    }
    echo "</select>";
    echo "<br>";
    echo "<p>Select The Date: ";
    echo "<input type='text' name='Date' id='data' class='datepicker'></p>";
    echo "<p>Enter Total of Your Steps:";
    echo "<input type = 'text' name = 'total_Steps'></p>";
    echo "<p>Enter Total of Your Floor:";
    echo "<input type = 'text' name = 'total_Floors'></p>";
    echo "<p>Enter Total of Your Calories Burns:";
    echo "<input type = 'text' name = 'total_Calories'></p>";
    echo "<p>Enter Total of Your Distance:";
    echo "<input type = 'text' name = 'total_Distance'></p>";
    echo "</fieldset>";
    echo "<br><input type = 'submit' name = 'submitdata' value = 'Submit'>";
    echo "<br>";
    echo "</form>";
}
示例#20
0
function validarLogin($login, $pass)
{
    $con = mysqli_connect("*********", "**********", "**********", "************");
    #Se comprueba la conexion
    if (mysqli_connect_errno()) {
        echo 'Error de conexion: ' . mysqli_connect_error();
        exit;
    }
    #Se quitan posibles caracteres especiales [NUL (ASCII 0), \n, \r, \, ', ", y Control-Z] (sql injection)
    $login = mysqli_real_escape_string($con, $login);
    $pass = mysqli_real_escape_string($con, $pass);
    #Se comprueban login y pass hasheada
    $usuario = mysqli_query($con, "SELECT login, pwd FROM Usuario WHERE login = '******'");
    #Se comprueba que se han devuelto resultados
    if (!$usuario) {
        echo 'Error en la consulta: ' . mysqli_error($con);
        exit;
    }
    #Se coge el resultado
    $result = mysqli_fetch_row($usuario);
    #Si coincide, se devuelve la lista de bichos de ese usuario
    if ($result[0] == $login && $result[1] == $pass) {
        return true;
    } else {
        return false;
    }
}
示例#21
0
 public function fetch_row($result)
 {
     if (!is_resource($result)) {
         debug_print_backtrace();
     }
     return mysqli_fetch_row($result);
 }
示例#22
0
function getDatosAnteriores($nombreUsuario)
{
    $datos = array();
    if ($connect = mysqli_connect("localhost", "root", "", "prueba1")) {
        $sql_select = sprintf("select Nombre,Apellidos,Fecha_Nacimiento,DNI,Localidad,Provincia,CP,Telefono from datos_usuarios\r\n\t\t\t\t\t\t\tinner join credenciales on datos_usuarios.ID_Credenciales=credenciales.idCredenciales\r\n\t\t\t\t\t\t\twhere credenciales.Usuario= '%s';", $nombreUsuario);
        //echo $sql_select."</br>";
        $resultado_queryDatos = mysqli_query($connect, $sql_select);
        if ($resultado_queryDatos == FALSE) {
            echo "Error al ejecutar la consulta:</br>";
            echo mysqli_error($resultado_queryDatos) . "</br>";
        } else {
            if (mysqli_num_rows($resultado_queryDatos) == 1) {
                $i = 0;
                $registro = mysqli_fetch_row($resultado_queryDatos);
                while ($i <= 7) {
                    //echo $i." ".$registro[$i]."</br>";
                    $datos[$i] = $registro[$i];
                    $i++;
                }
                return $datos;
            } else {
                echo "El resultado es diferente uno";
                return false;
            }
        }
    } else {
        echo "Error al conectar con BBDD </br>";
        return false;
    }
}
 function addApplicant(Applicant $applicant)
 {
     $connectionObject = Connection::getInstance();
     $connection = $connectionObject->get_connection();
     $name_in_full = $applicant->getNameInFull();
     $name_with_initials = $applicant->getNameWithInitials();
     $nic = $applicant->getNic();
     $is_sri_lankan = $applicant->getIsSriLankan();
     $religion = $applicant->getReligion();
     $address = $applicant->getAddress();
     $telephone = $applicant->getTelephone();
     $district = $applicant->getDistrict();
     $divisional_sec_area = $applicant->getDivisionalSecArea();
     $grama_niladari_divi = $applicant->getGramaNiladariDivi();
     $sql = "SELECT \tapplicant_id FROM applicant WHERE nic = '" . $nic . "'";
     $resultset = mysqli_query($connection, $sql);
     $numberOfRows = mysqli_num_rows($resultset);
     if ($numberOfRows > 0) {
         $row = mysqli_fetch_row($resultset);
         $applicant_id = $row[0];
     } else {
         $stmt = $connection->prepare("INSERT INTO applicant (name_in_full, name_with_initials, nic, religion, address, is_sri_lankan, district, divisional_sec_area, grama_niladari_divi,telephone) VALUES (?,?,?,?,?,?,?,?,?,?)");
         $stmt->bind_param("ssssssssss", $name_in_full, $name_with_initials, $nic, $religion, $address, $is_sri_lankan, $district, $divisional_sec_area, $grama_niladari_divi, $telephone);
         $result = $stmt->execute();
         $stmt->close();
         $applicant_id = mysqli_insert_id($connection);
     }
     return $applicant_id;
 }
示例#24
0
 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     $this->dataPack = $dataPack;
     $field = $this->dataPack[0];
     $term = $this->dataPack[1];
     $this->sql = "SELECT * FROM {$this->tableMaster} WHERE {$field}='{$term}'";
     //Conditional statement in MySQL query for data output
     $ret = $this->hookup->query($this->sql);
     if ($result = $this->hookup->query($this->sql)) {
         echo "<link rel='stylesheet' href='main.css'>";
         echo "<table>";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr>";
             foreach ($row as $cell) {
                 echo "<td>{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
     return $ret;
 }
function comment_like_unlike()
{
    global $CURUSER, $type, $tb_fields, $the_id, $banned_users, $disabled_time;
    $userip = $_SERVER['REMOTE_ADDR'];
    $res = sql_query("SELECT user_likes,disabled_time FROM " . $tb_fields[$type[0]] . " LEFT OUTER JOIN manage_likes ON manage_likes.user_id = " . sqlesc($CURUSER['id']) . " WHERE " . $tb_fields[$type[0]] . ".id = " . sqlesc($the_id) . "") or sqlerr(__FILE__, __LINE__);
    $data = mysqli_fetch_row($res);
    if ($data[1] + $disabled_time > time()) {
        die($lang['ajlike_you_been_disabled']);
    } elseif (in_array($CURUSER['id'], $banned_users)) {
        die($lang['ajlike_you_been_banned']);
    }
    $exp = explode(',', $data[0]);
    if ($res && $type[1] == 'like' && array_key_exists($type[0], $tb_fields)) {
        if (!in_array($CURUSER['id'], $exp)) {
            $res2 = sql_query("UPDATE " . $tb_fields[$type[0]] . " SET user_likes = IF(LENGTH(user_likes),CONCAT(user_likes,','," . sqlesc((string) $CURUSER['id']) . ")," . sqlesc((string) $CURUSER['id']) . ") WHERE id = " . sqlesc($the_id) . "") or sqlerr(__FILE__, __LINE__);
        } else {
            die($lang['ajlike_you_already_liked']);
        }
    } elseif ($res && $type[1] == 'unlike' && array_key_exists($type[0], $tb_fields)) {
        if (in_array($CURUSER['id'], $exp)) {
            $key = array_search($CURUSER['id'], $exp);
            unset($exp[$key]);
            $exp = implode(",", $exp);
            $res2 = sql_query("UPDATE " . $tb_fields[$type[0]] . " SET user_likes = " . sqlesc($exp) . "WHERE id = " . sqlesc($the_id) . "") or sqlerr(__FILE__, __LINE__);
        } else {
            die($lang['ajlike_you_already_unliked']);
        }
    } else {
        die($lang['ajlike_get_lost']);
    }
}
示例#26
0
function check_bans($ip, &$reason = '')
{
    global $INSTALLER09, $mc1;
    $key = 'bans:::' . $ip;
    if (($ban = $mc1->get_value($key)) === false) {
        $nip = ip2long($ip);
        $ban_sql = sql_query('SELECT comment FROM bans WHERE (first <= ' . $nip . ' AND last >= ' . $nip . ') LIMIT 1');
        if (mysqli_num_rows($ban_sql)) {
            $comment = mysqli_fetch_row($ban_sql);
            $reason = 'Manual Ban (' . $comment[0] . ')';
            $mc1->cache_value($key, $reason, 86400);
            // 86400 // banned
            return true;
        }
        mysqli_free_result($ban_sql) || is_object($ban_sql) && get_class($ban_sql) == "mysqli_result" ? true : false;
        $mc1->cache_value($key, 0, 86400);
        // 86400 // not banned
        return false;
    } elseif (!$ban) {
        return false;
    } else {
        $reason = $ban;
        return true;
    }
}
示例#27
0
 /**
  * @param string $query
  * @param int $singleResult
  * @return array
  */
 function query($query, $singleResult = 0)
 {
     $this->_result = mysqli_query($this->_dbHandle, $query);
     if (preg_match("/select/i", $query)) {
         $result = array();
         $table = array();
         $field = array();
         $tempResults = array();
         $numOfFields = mysqli_num_fields($this->_result);
         while ($fdata = mysqli_fetch__field($this->_result)) {
             array_push($table, $fdata->table);
             array_push($field, $fdata->name);
         }
         while ($row = mysqli_fetch_row($this->_result)) {
             for ($i = 0; $i < $numOfFields; ++$i) {
                 $table[$i] = trim(ucfirst($table[$i]), 's');
                 $tempResults[$table[$i]][$field[$i]] = $row[$i];
             }
             if ($singleResult == 1) {
                 mysqli_free_result($this->_result);
                 return $tempResults;
             }
             array_push($result, $tempResults);
         }
         mysqli_free_result($this->_result);
         return $result;
     }
 }
示例#28
0
function getLevel()
{
    $q = "SELECT * FROM `current_buildings` WHERE `user` = '{$_SESSION['user_id']}' AND `building` = 1";
    $result = mysqli_query(getConnection(), $q);
    $level = mysqli_fetch_row($result)[3];
    return $level;
}
function display_view()
{
    $con = mysqli_connect('localhost', 'root', '');
    $db = mysqli_select_db($con, 'accommodation');
    $query = "SELECT house_no,addr,zip_code,no_room,rent,dist,furnished,prop_manager,email_id,prop_address,contact_no FROM prop_acco";
    $result = mysqli_query($con, $query);
    if ($result) {
        $row = mysqli_fetch_row($result);
        echo '<table border="1" style= "text-align: center; color: #000099; margin: 0 auto;" >';
        echo '<tr> <th>House Number</th>
				  <th>Address</th>
				  <th>Zip Code</th>
				  <th>Number of Rooms</th>
				  <th>Rent per month</th>
				  <th>Distance from the university(miles)</th>
				  <th>Furnished </th>
				  <th>Property Manager </th>
				<th>Email ID </th>
				<th>Property Manager Address </th>
				  <th>Contact </th>
				</tr>';
        while ($row) {
            $col = count($row);
            echo "<tr>";
            for ($c = 0; $c < $col; $c++) {
                echo "<td>" . $row[$c] . "</td>";
            }
            echo "</tr>";
            $row = mysqli_fetch_row($result);
        }
        echo "</table>";
    } else {
        echo "err";
    }
}
function display_view()
{
    $con = mysqli_connect('localhost', 'root', '');
    $db = mysqli_select_db($con, 'stats');
    $query = "SELECT s.Year, t.team_name FROM season s, team t where s.winner_team_id = t.team_id";
    $result = mysqli_query($con, $query);
    if ($result) {
        $row = mysqli_fetch_row($result);
        echo '<table border="1" style= "text-align: center; color: #092f44; margin: 0 auto;" >';
        echo '<tr> <th>Season Year</th>
				  <th>Winner Team</th>
				</tr>';
        while ($row) {
            $col = count($row);
            echo "<tr>";
            for ($c = 0; $c < $col; $c++) {
                echo "<td>" . $row[$c] . "</td>";
            }
            echo "</tr>";
            $row = mysqli_fetch_row($result);
        }
        echo "</table>";
    } else {
        echo "err";
    }
}