|
Lakshmanan Duraisamy wrote: sh: wmic: command not found
You are running Linux on the server which does not know the Windows wmic command.
There are several methods to get disk serial numbers with Linux like using hdparm and udevadm. But all these require to specifiy the device (e.g. /dev/sda) and filter the output for the serial number (e.g. using grep). Just search the web for something like "linux get hard disk serial" for examples.
|
|
|
|
|
Remember, your code is running on the server.
If your intention is to get the serial number of the server's disk, that's fine.
But if you were wanting to get the serial number of the user's disk, your code won't work. And you won't be able to do it from Javascript either, because that doesn't have access to the user's hardware.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Goodmorning everyone.. please i need help with how to connect a php application to a vb.net application to obtain data from it
|
|
|
|
|
|
I'm trying to create a secure login script, but my code doesn't seem optimal. It seems to work but I'd like to know if there is a way I could optimize things and make it more secure.
<pre lang="PHP">
<pre><?php
include 'dbconnect.php';
//Database information
if (isset($_POST['submit'])){ //Was the form submitted?
$error = array();//Declare An Array to store any error message
if (filter_var($_POST['Email'], FILTER_VALIDATE_EMAIL)) { //Check to see if email is valid.
$validatedemail = $_POST['Email'];
//Now we know that the email is valid. Let's run some Queries
$sql = "SELECT * FROM users WHERE email = '$validatedemail'";
$result = mysql_query($sql);
$num_result = mysql_numrows($result);
$row = mysql_fetch_row($result);
if ($num_result== 1) {
if ($row[2] == sha1($_POST['Password'])) {
echo "MEGA SUCCESS";
}
else {$error[] = "Passwords do not match";}
}
else {$error[] = "No user found";}
}
else {$error[] = "Not a valid Email";}
}
echo
"<div class=\"errormsgbox\"> <ol>";
foreach ($error as $key => $values) {
echo "<li>".$values."</li>";
}
echo "<form class=\"login\" action=\"login.php\" method=\"post\">
<p class=\"title\">Log in</p>
<input type=\"text\" name=\"Email\" placeholder=\"Email\" autofocus/>
"fa">
<input type=\"Password\" name=\"Password\" placeholder=\"Password\" />
<button>
^__i class=\"spinner\">
<input type=\"submit\" name=\"submit\" value=\"Login!\">
</button>
</form>";
?>
Thanks guys
|
|
|
|
|
Actually, the best way to optimize your Secure login is by slowing it down.
The login page is exposed to all the world wide web, including automated scripts. If you add a "Do Nothing" line that waste an increasing number of seconds for every attempt right before querying your DB, it will slow down scripts from finding a way in. It will also helps in guaranteeing DB bandwidth to your real users, in case someone is requesting 10000 logins per second.
Claudio
|
|
|
|
|
I have a pretty simple multidimensional array.
Array (
[183] => Array (
[info] => Array (
[name] => Ben
[points] => 4800
)
)
[380] => Array (
[info] => Array (
[name] => Ruben
[points] => 14500
)
)
[450] => Array (
[info] => Array (
[name] => Alex
[points] => 4800
)
)
)
I also have some PHP code. It sorts the array.
The first criteria is points which will be sorted descending. The second criteria is name which will be sorted ascending.
uasort($array, function($a, $b)
{
if ($a['info']['points'] == $b['info']['points'])
{
return strcmp($a['info']['name'], $b['info']['name']);
}
return $b['info']['points'] - $a['info']['points'];
});
After my code does its job, the array looks like this:
Array (
[380] => Array (
[info] => Array (
[name] => Ruben
[points] => 14500
)
)
[450] => Array (
[info] => Array (
[name] => Alex
[points] => 4800
)
)
[183] => Array (
[info] => Array (
[name] => Ben
[points] => 4800
)
)
)
Sorting goes just fine, but I also would like to add position numbers while sorting the array.
In other words, if the points are better, the position is better. If the points are equal, the position must be equal.
The final array should look like this:
Array (
[380] => Array (
[info] => Array (
[name] => Ruben
[points] => 14500
[position] => 1
)
)
[450] => Array (
[info] => Array (
[name] => Alex
[points] => 4800
[position] => 2 /* because Alex has less points than Ruben */
)
)
[183] => Array (
[info] => Array (
[name] => Ben
[points] => 4800
[position] => 2 /* because Ben has same points with Alex */
)
)
)
So, how could I add those position numbers? The faster way, the better way.
http://btsoft.vn/thiet-ke-web-hcm
|
|
|
|
|
Hello everyone i need to hashed my password when i put it in my login application android and then i need to compare it with my password in my table fos_user of symfony and the password in fos_user is encoders:bcrypt
This is my code:
<?php
include 'config.inc.php';
if(isset($_POST['username']) && isset($_POST['password']))
{
$result='';
$username = $_POST['username'];
$password = $_POST['password'];
$hash = password_hash($password, PASSWORD_BCRYPT);
$sql = "SELECT password FROM fos_user WHERE username = '$username' AND password = '$hash'";
$test = mysql_query($sql) or die( mysql_error() );
$row = mysql_fetch_assoc($test);
if ($hash == $row['password'])
{
$result="true";
}
else
{
$result="false";
}
echo $result;
}
?>
My file config.inc.php is this code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "projet_grh";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
die("OOPs something went wrong");
}
?>
|
|
|
|
|
There is no need to compare the password hash because that is already done by the SQL query.
Omit calling mysql_fetch_assoc and use PHP: mysql_num_rows - Manual[^] instead to check if a matching recordset has been found (optionally after checking for errors by testing if $test is false).
|
|
|
|
|
I test this code but the same problem
<?php
if(isset($_POST['username']) && isset($_POST['password']))
{
$link = mysql_connect("localhost", "root", "");
mysql_select_db("projet_grh", $link);
$result='';
$username = $_POST['username'];
$password = $_POST['password'];
$hash = password_hash($password, PASSWORD_BCRYPT);
$sql = mysql_query("SELECT password FROM fos_user WHERE username = '$username' AND password = '$hash'", $link);
$num_rows = mysql_num_rows($sql);
if (($num_rows == 0))
{
$result="false";
}
else
{
$result="true";
}
echo $result;
}
?>
|
|
|
|
|
What kind of problem?
You never specified any.
Are all mysql calls successful (you did not check for errors)?
Is the hash wrong?
|
|
|
|
|
i do this code in my application android
if(result.equalsIgnoreCase("true"))
{
Intent intent2 = new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent2);
MainActivity.this.finish();
}else if (result.equalsIgnoreCase("false")){
Toast.makeText(MainActivity.this, "nom utilisateurs ou mot de passe incorrect", Toast.LENGTH_LONG).show();
all the time php return the result false and show me the message "nom utilisateurs ou mot de passe incorrect"
|
|
|
|
|
Check the status of all mysql calls and return an error message if a call failed. Then show that error message within your application.
Only then you will know what is happening.
|
|
|
|
|
Programming buddies,
I'm back online after nearly 2wks of offline. Gonna be harassing you guys again and more this time. Eeek!
Anyway, right now, I'm trying to build a script that adds multi entries into same single cell or mysql row.
The script tries monitoring what you are browsing via the:
<pre><input type="text" name="browse_url" size="120">
and then record your viewed urls into the same row (position: 0), column: browsings like so:
1.com,2.com and so on.
So, at first, the mysql array or cell is blank. When you view a url (eg.) 1.com then the array would show like this:
1.com
And then afterwards, if you view facebook.com then the cell should get updated by first grabbing the previously viewed urls and then adding the latest url onto the same cell/array like so (each url separated by comma):
1.com,facebook.com
Throw your precious eyes on line 79 onwards on both sample scripts. I reckon the 1st script is no good but the 2nd should work. Gave you both scripts to show the variety of ways I attempted.
Sample 1:
[php]
<?php
session_start();
require "conn.php";
require "site_details.php";
if(!isset($_SESSION["user"]))
{
header("location:login.php");
}
else
{
$user = $_SESSION["user"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<p>
<p>
<?php
?>
<iframe src='<?php echo $db_latest_view;?>'></iframe>
<p>
<p>
<p>
<form method="post" action="">
<table border="1" width="50%">
<tr>
<td width="10">Url: </td>
<td><input type="text" name="browse_url" size="120"></td>
</tr>
<tr>
<td width="10">Browse: </td>
<td>
<select name="browsing_type">
<OPTION>Anonymous Browsing</OPTION>
<OPTION>Group Browsing</OPTION>
</SELECT>
</td>
</tr>
<td></td>
<td><input type="submit" name="browse" size="50" value="Browse"><input type="submit" name="search_keywords" size="50" value="Search Keywords"></td>
<tr>
<td width="10">Message: </td><td><textarea name="message" cols="120" rows="10"></textarea></td>
</tr>
<tr>
<td></td>
<td width="50"><input type="submit" name="submit_message" size="50" value="Send Message!"></td>
</tr>
<p>
<p>
</table>
</form>
<?php
if(isset($_REQUEST['browse']))
{
$browse_url = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browse_url"]))));
$browsing_type = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browsing_type"]))));
$sql = "SELECT * FROM users WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
$numrows = mysqli_num_rows($result);
if($numrows)
{
while($row = mysqli_fetch_assoc($result))
{
$db_user_browsings = $row["browsings"];
}
$sql = "INSERT INTO users(browsings) VALUES('".$browse_url."''".$db_user_browsings."')";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
$sql = "UPDATE users SET browsings_latest = '".$browse_url."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
}
}
}
?>
[/php]
Sample 2
[php]
<?php
session_start();
require "conn.php";
require "site_details.php";
if(!isset($_SESSION["user"]))
{
header("location:login.php");
}
else
{
$user = $_SESSION["user"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<p>
<p>
<?php
?>
<iframe src='<?php echo $db_latest_view;?>'></iframe>
<p>
<p>
<p>
<form method="post" action="">
<table border="1" width="50%">
<tr>
<td width="10">Url: </td>
<td><input type="text" name="browse_url" size="120"></td>
</tr>
<tr>
<td width="10">Browse: </td>
<td>
<select name="browsing_type">
<OPTION>Anonymous Browsing</OPTION>
<OPTION>Group Browsing</OPTION>
</SELECT>
</td>
</tr>
<td></td>
<td><input type="submit" name="browse" size="50" value="Browse"><input type="submit" name="search_keywords" size="50" value="Search Keywords"></td>
<tr>
<td width="10">Message: </td><td><textarea name="message" cols="120" rows="10"></textarea></td>
</tr>
<tr>
<td></td>
<td width="50"><input type="submit" name="submit_message" size="50" value="Send Message!"></td>
</tr>
<p>
<p>
</table>
</form>
<?php
if(isset($_REQUEST['browse']))
{
$browse_url = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browse_url"]))));
$browsing_type = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browsing_type"]))));
$sql = "SELECT * FROM users WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
$numrows = mysqli_num_rows($result);
if($numrows)
{
while($row = mysqli_fetch_assoc($result))
{
$db_user_browsings = $row["browsings"];
}
$sql = "UPDATE users SET browsings = '".$browse_url."''".$db_user_browsings."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
$sql = "UPDATE users SET browsings_latest = '".$browse_url."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
}
}
}
?>
[/php]
|
|
|
|
|
You appear to be spamming because you are posting "weird" statements without asking questions. Shape up or get shipped out.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Please allow me to trouble you one more time.
I got my html working great - thanks in large part to Richard Deeming.
I successfully converted it to php.
I created a template in wordpress called Contact and uploaded it to my wordpress theme.
The name of the theme is Responsive.
The issue now is that I cannot upload the php with the libraries in it. These libraries and their accompanying CSS, as I understand, will need to uploaded to separate directories and then invoked somewhere.
I am not getting clear instructions on how to tie these to my template.
These libraries and inline css are:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.min.js"></script>
<style type="text/css">
.bs-example{
margin-left: 250px;
margin-top: 30px;
}
</style>
Can someone please give me directions as to where to put these?
As I understand it, they can either go to header.php or functions.php.
But how do I use these libraries?
Sorry I realized I didn't give all the useful information.
I have three libraries, the AngularJS handlebags, bootstrap and jquery libraries.
I uploaded those to the theme's js directory.
Then on header.php, I added the following just below the header hook
<?php responsive_in_header(); ?>
//get the js and jquery frameworks
<?php if( is_page(Contact) ){ ?>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.min.js.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/handlebars.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/addrows.js"></script>
<?php }?>
When I tested the page, it is not doing what it is doing my local PC.
modified 17-Feb-17 14:37pm.
|
|
|
|
|
I have users and categories tables and pivot table categorie_users in database. In controller I make that every user can create your own categories and I make check if some category exist and if logged user have that category, he can't create new category with same name and that works fine. So next what I want is 'else' - if category exist and logged user don't have that category but he want to create it - in that case I want to connect that category which already exist and that user. Other words - I want to, let's say, category 'Music' to be just one category with that name for all future users. This is so complicated so any suggestions will appreciate. Thanks.
This is my CategoriesController.php
public function store(Request $request)
{
$user = Sentinel::getUser();
$category = Categories::where('name', $request->name)->get();
foreach ($category as $cat){
$user = CategorieUser::where('categorie_id',$cat->id)->where('user_id', $user->id);
}
if($category->count() > 0){
if($user->count() > 0){
return redirect()->route('categories.index');
}
else{
/*THIS IS THAT 'else' FROM ABOVE QUESTION*/
}
}
else{
$categories = new Categories();
$categories->name = $request->name;
$categories->sections_id = $request->sections_id;
$categories->save();
$categories->users()->sync([$user->id]);
}
session()->flash('success', "New category '{$categories->name}' has been created.");
return redirect()->route('categories.index');
}
And this is my model Categories.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Categories extends Model
{
protected $table = 'categories';
public function sections()
{
return $this->belongsTo('App\Models\Sections');
}
public function users()
{
return $this->belongsToMany('App\Models\Users', 'categorie_user','categorie_id','user_id');
}
}
This is model Users.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Users extends Model
{
protected $table = 'users';
public function categories()
{
return $this->belongsToMany('App\Models\Categories', 'categorie_user','user_id','categorie_id');
}
}
And this is pivot model CategorieUser.php (which I must create that I can go through foreach loop)
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CategorieUser extends Model
{
protected $table = 'categorie_user';
public function categories(){
return $this->belongsTo('App\Models\Categories', 'categorie_id');
}
}
|
|
|
|
|
Yes, we understand that you need to setup the relationships between the user and categories. But what is the problem? Did you try anything that does this?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi,
I'm a newbie in OOP. Can you please help me how to fix this code below because it gives me an infinite output. I want to output or echo my fetched data to my main program. Thanks.
===========================================
class DB {
private $_hostdb = 'localhost';
private $_namedb = 'imsdb';
private $_userdb = 'root';
private $_passdb = '';
private $_conn;
private static $_instance;
private $_rowResult;
private function __construct(){
try{
$this->_conn=new PDO("mysql:host=$this->_hostdb;dbname=$this->_namedb",$this->_userdb,$this->_passdb);
$this->_conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
if($this->_conn){
echo "Connected Successfully! ";
}
} catch (Exception $ex) {
echo ("Connection Failed!")." ".$ex->getMessage();
}
}
public static function getInstance(){
if(!isset(self::$_instance))
{
return self::$_instance=new DB();
}
}
public function processQuery($sql){
try{
$q=$this->_conn->prepare($sql);
$q->execute();
$q->setFetchMode(PDO::FETCH_ASSOC);
return $this->_rowResult=$q->fetch(); //Is this correct??
} catch (Exception $ex) {
echo ("Failed!")." ".$ex->getMessage();
}
}
}
//MAIN PROGRAM -> OUTPUT gives me an infinite data which is wrong
$dbUser=DB::getInstance()->processQuery("SELECT * FROM users");
while($dbUser){
echo $dbUser['username'];
}
|
|
|
|
|
while($dbUser){
echo $dbUser['username'];
}
The while statement will repeat as long as the value in $dbUser is not null. So in your case it will continue until the end of time.
|
|
|
|
|
Hi sorry I am just a baby in PHP. I want to get the value of $_SESSION['username'] but it gives me this error : Notice: Undefined offset: 0. Please see my code below. Your help will be greatly appreciated. Thanks.
";
echo $_SESSION[0]; //I want an output "andrew" but it fails.
|
|
|
|
|
$_SESSION (see PHP: $_SESSION - Manual[^] ) is an associative array containing key value pairs (see PHP: Arrays - Manual[^]).
These are not accessed by an index but by their keys which might be integers or strings. Because you have not assigned a value with the key '0' you will get the error.
Just use the key instead:
echo $_SESSION['username'];
|
|
|
|
|
|
Hi all,
I got a problem
I used CentOS 7.1,
used command: yum -y install httpd to install apahce
used command: yum -y install php to install php
noting to change the configure file /etc/httpd/conf/httpd.conf
and then I have done this two things in /var/www/html/:
1. ln -s /home/ninja/workspace/storage .
2. create a test file test.php
[root@localhost html]# pwd
/var/www/html
[root@localhost html]# ls
storage test.php
[root@localhost html]# ll
total 4
lrwxrwxrwx 1 root root 29 Dec 28 20:05 storage -> /home/ninja/workspace/storage
-rwxr-xr-x 1 root root 122 Dec 28 20:04 test.php
[root@localhost html]# cat test.php
<?php
echo "====================\n";
$data = file_get_contents("./storage/8010252");
echo "get data";
echo $data;
?>
the file 8010252 does really there, but php can not access.
the apache error log shows:
[Wed Dec 28 20:06:46.858835 2016] [:error] [pid 8605] [client 192.168.3.57:26918] PHP Warning: file_get_contents(./storage/8010252): failed to open stream: No such file or directory in /var/www/html/test.php on line 4
If I don't use Symbolink, it works, it seems like apache can not access the Symbolink folder.
Anyone can help, Thanks a lot.
Solution:
To solve this problem, I just run the command:
chmod -R +x /home/ninja
and then it works!
modified 28-Dec-16 21:15pm.
|
|
|
|
|
I got the following error trying to install a package error while loading shared libraries libio_misc.so
I am not familiar with Linux would anyone know what this means
|
|
|
|