Aeonix 71 Posting Whiz

There is a foreach(). However such opeartion forces you to know the amounts of rows (3 in example) and the keys for each row ("userid", "username", "email").

foreach ($myArray as $theCurrentRow) {
    echo "<td>" . $theCurrentRow["userid"] . "</td><td>" . $theCurrentRow["username"] . "</td><td>" . $theCurrentRow["email"] . "</td>";
}

Just wrap it in <table> and <tr>'s and you have script that will automatically create a new row with, every, single, record.

Aeonix 71 Posting Whiz

That scares the wit out of me.

Just try this, install user-end consumer-grade Java, then when Java asks to update, deny it for a month, then go to website that requires recent Java, and you get this type of thing. Same happens on your server, except there's no more browsers or "helpers" to help you block-out potential threat. So you need keep up with Java, day for day.

Like I said, go full PHP, if you have 4.5v PHP and they will release 4.9v PHP. Your website won't explode, however, having it updated is nice too. On Java, this isn't the case since Java is heavily targetted as it connects server, user and 3rd parties. Where as PHP just connects from server to user without injectables from user side.

Aeonix 71 Posting Whiz

I would go with PHP.

General reason is because it is made fast and secure and bugs with it are unlikely unless coder himself/herself codes the script wrong. It is literally made programless. Of course you need Apache, but once that's started, PHP will always work.

I wouldn't choose for Java, since even when you start instance of Java on internet, it complains about "Warning, this version of Java is insecure.", Java seems to be prone to weaknesses. And basing your website upon this would force users to install Java as well (well, that depends on how you're going to handle client-side).

Java needs constant updates and reinstallations. Since being just 2 minor patches behind is already a vulnerability found (mentioning the message earlier).
PHP needs just disabling server for 1 minute, and moving updated PHP files in there. And they're more of bug-fixes and upgrades, because there is no real PHP hacks that are so widely accessible. In order to break PHP in-face you would need other factors to fail, or you need to be genius cracker.

Like I said, I would go with PHP. There's way less to mess with that and it can provide powerful outcome, and gives more strict notifications instead of errors. Simple and direct 1-liner, instead of you scanning throughout the entire stack of try(), catch() and throw().

Aeonix 71 Posting Whiz

Now I need to automatically process this html file and convert it to a pdf How do I do this?

I am using fpdf.php to create a pdf from my php code.

Just use your FPDF.php, to create .PDF from your parsed .HTML file. After creating parsed HTML file, take it's name to FPDF.php and get PDF file out of it.

Aeonix 71 Posting Whiz

You would make PHP file parse the data and write it in the file. There's this website that can convert HTML to PDF for you.

If you're looking for automated process. I would do almost same, except write the file in external HTML file and ask FPDF.php the parsed HTML file and parse to PDF. Given you already know how to use it.

Aeonix 71 Posting Whiz

Wait, you want to combine 3rd word from first file, and 1st word from second file? Can't you put word "play" as first word? Like,

Words.txt: "play, toy, tralala, DaniWeb"
Words2.txt "people, problem, potter, pancakes"

If you can do that, you can read the file one by one and saving their contents into variables, then you can tell VB.NET compiler to take the contents and split words by coma into continuous array. So example[0] will be "play", example[1] will be "toy" etc. . Do same for both files, and then echo each row (something like fileone[0] + filetwo[0]) and but put them into for loop. So it progresses.

Good luck!

Aeonix 71 Posting Whiz

I don't believe you can do it with jQuery, that's as easy as that.

jQuery is client-side, this is code provided to you by server, and your browser manages what you see by it. If server sends you "move block to left 500px", your browser does it, because that's what website requests.

The database requires server-sided langauge. Which does whatever it has to do and your browser doesn't get anything to see out of it, except when file exclusively wants to show you something.

Aeonix 71 Posting Whiz

Windows should normally allow such upgrade. That is from Windows Vista to Windows 7 as long as components (hardware) are compatbile and capable of handling Windows 7. There is a nice official tutorial on how to upgrade Windows Vista to Windows 7. Although I wouldn't set my expectations really high. The applications and data may move along with the system, but couple of them might not work directly.

The best that would be in this situation, at least how I would do it. Is just copy the files (Documents, Presentations, Files, Photos) onto external storage (you mentioned another parititon), make lists of installed programs. Then install Windows 7 onto the current partition of Windows Vista. Install programs from the list, and then all the files, documents and photos back onto drive.

Aeonix 71 Posting Whiz

In terminal you can use touch which will create empty file in the directory. It also depends where your root directory is. Normally, in XAMPP it would be touch /opt/lampp/htdocs/newfile.

Aeonix 71 Posting Whiz

Change your * into <span id="uname">tmp</span><br/>
And add before last }); this code:

        $('.users').click(function(e) {
            var txt = $(e.target).text();
            document.getElementById("uname").innerHTML = txt;
        });

});
Aeonix 71 Posting Whiz
<?php $thisIsMyUberValue = "phoenix254"; ?>

<script>
    var uberValue = <?php echo $thisIsMyUberValue; ?>;
    alert("My value was: " + uberValue);
</script>

This should work, and prompt you "My value was: phoenix254". Go ahead, adjust it to your purposes.

I can't apply this personally to your Codepen, because I don't have access to your PHP variable, your folder structure and Codepen doesn't seem to support PHP.

Looking at your project, if I were you I would Google "Ajax", because the thing that you're attempting to create, can be made much easier. Just hinting.

Aeonix 71 Posting Whiz

You could go for Properties while marking your application with right mouse button, then go for Compatibility, there should be a checkbox for administrator permissions, check it, and every time you start this application, will require administrator permissions, regardless of your manifest.

Is this what you requested?

Aeonix 71 Posting Whiz

BLoBs? I would encode the picture in base64 and then BLoB it down the database.

Aeonix 71 Posting Whiz

Is it me or are we open to SQL injections here as we're using raw input and not sanitizing. Better to use prepared statements.

We provide answer to unfinished script, hoping, that the OP will change his/her script sometime to more secure one. As of now, the question is other than "how do I protect my script?".

Aeonix 71 Posting Whiz

Okay, forget what I said, ^^^^, better solution.

Aeonix 71 Posting Whiz

And would it be ok if i ask you to explain this for me too!!
preg_match("/^[A-Za-z0-9'?!-\s\\]+$/", $field)
If you know it, Thank you.

You like torturing people, don't you :D?
Here's the webpage go suit yourself, and here's another one. The example I provided is rather "hardcore" one, that's why this one is on another website, someone made this enough complicated, he/she needed help with it.

So would it be correct?

It is supposed to work if I look at it. Why not try it?

Aeonix 71 Posting Whiz

Oh, crap! Thanks! Oh, crap, use this one instead:

$output = file_get_contents($api_url);
if($output=="")
{
    echo "No output received";
}
else
{
    $arr_output = json_decode($output, true);
    if(isset($arr_output['msg']))
    {
        $msg = $arr_output['msg'];
        $msg_text = $arr_output['msg_text'];
        if($msg == "SUCCESS")
        {
            if(isset($arr_output['data']))
            {
                $arr_data = $arr_output['data'];
                // above array will contain your data
                // print_r($arr_data);
                mysqli_query("INSERT INTO table (sn, mob_no, date, time) VALUES ($myarray['sn'], $myarray['mob_no'], $myarray['date'], $myarray['time'])");
            }
            else
            {
                echo "Json data not set !!";
            }
        }
        else
        {   
            echo "Error : ".$msg_text;
        }
    }
    else
    {
        echo "Output not set !!";
    }
}
while($item = array_shift($arr_data))
{
    foreach ($item as $key => $value)
    {
        echo $key.' => '.$value."\n";
    }
}
Aeonix 71 Posting Whiz

I'm not professor of PHP.

So far I understand it /ubuntu/ will seek for every "ubuntu" in the text, regardless whether it's at the begin, or in middle, or at the end. While just ubuntu seeks for straight text, so far example if your operating system would be called "Linux Ubuntu", /Ubuntu/ will say "Yes, I found it", while Ubuntu won't. Also i at the end indicates that you don't care about the case, so UbUNTU and ubuntu and Ubuntu and ubunTU will all be detected and treated exactly same way.

I wouldn't really be bothered with this if I were you, lets be happy together that it works as it gets sometimes as complicated as preg_match("/^[A-Za-z0-9'?!-\s\\\\]+$/", $field).

Aeonix 71 Posting Whiz

I'm pretty sure, just out of my head, that if you replace:

                            '/linux/i'              =>  'Linux',
                            '/ubuntu/i'             =>  'Ubuntu',

With:

                            '/linux/i'              =>  'Unspecified Linux',
                            '/ubuntu/i'             =>  'Linux Ubuntu',
                            '/slackware/i'          =>  'Linux Slackware',
                            '/kali/i'               =>  'Linux Kali',
                            '/fedora/i'             =>  'Linux Fedora',
                            '/mint/i'               =>  'Linux Mint',
                            etc. etc. etc.

That it will work pretty well. There's almost no reason it shouldn't. Linux has technically always same pattern like Windows, of it's own of course. The only line that would change with same browser on same hardware, but different distribution, is just one single string that it should find.

Here's top 50 most known according to this website (maybe not trustworthy, but still covers 90% of most used Linux OSes)

Aeonix 71 Posting Whiz
<?php

$user_agent = $_SERVER["HTTP_USER_AGENT"];
function getOS() { 
    global $user_agent;
    $os_platform    =   "Unknown OS Platform";
    $os_array       =   array(
                            '/windows nt 10/i'     =>  'Windows 10',
                            '/windows nt 6.3/i'     =>  'Windows 8.1',
                            '/windows nt 6.2/i'     =>  'Windows 8',
                            '/windows nt 6.1/i'     =>  'Windows 7',
                            '/windows nt 6.0/i'     =>  'Windows Vista',
                            '/windows nt 5.2/i'     =>  'Windows Server 2003/XP x64',
                            '/windows nt 5.1/i'     =>  'Windows XP',
                            '/windows xp/i'         =>  'Windows XP',
                            '/windows nt 5.0/i'     =>  'Windows 2000',
                            '/windows me/i'         =>  'Windows ME',
                            '/win98/i'              =>  'Windows 98',
                            '/win95/i'              =>  'Windows 95',
                            '/win16/i'              =>  'Windows 3.11',
                            '/macintosh|mac os x/i' =>  'Mac OS X',
                            '/mac_powerpc/i'        =>  'Mac OS 9',
                            '/linux/i'              =>  'Linux',
                            '/ubuntu/i'             =>  'Ubuntu',
                            '/iphone/i'             =>  'iPhone',
                            '/ipod/i'               =>  'iPod',
                            '/ipad/i'               =>  'iPad',
                            '/android/i'            =>  'Android',
                            '/blackberry/i'         =>  'BlackBerry',
                            '/webos/i'              =>  'Mobile'
                        );

    foreach ($os_array as $regex => $value) { 

        if (preg_match($regex, $user_agent)) {
            $os_platform    =   $value;
        }

    }   

    return $os_platform;

}

echo "Operating system is: " . getOS() . "<br />";
echo "Understood from: " . $_SERVER["HTTP_USER_AGENT"];

?>

Stolen, from here, then modified.

Be aware, this is easily spoofable. Works for me.

Aeonix 71 Posting Whiz
$output = file_get_contents($api_url);
if($output=="")
{
    echo "No output received";
}
else
{
    $arr_output = json_decode($output, true);
    if(isset($arr_output['msg']))
    {
        $msg = $arr_output['msg'];
        $msg_text = $arr_output['msg_text'];
        if($msg == "SUCCESS")
        {
            if(isset($arr_output['data']))
            {
                $arr_data = $arr_output['data'];
                // above array will contain your data
                // print_r($arr_data);

                mysqli_query("INSERT INTO table (sn, mob_no, date, time) VALUES ($myarray["sn"], $myarray["mob_no"], $myarray["date"], $myarray["time"]));
            }
            else
            {
                echo "Json data not set !!";
            }
        }
        else
        {   
            echo "Error : ".$msg_text;
        }
    }
    else
    {
        echo "Output not set !!";
    }
}
while($item = array_shift($arr_data))
{
    foreach ($item as $key => $value)
    {
        echo $key.' => '.$value."\n";
    }
}

I'm assuming that commented array is my target array. You need to make sure to have config file out there, and include it, which would connect to SQL database. And execute the script.

If it's still not working, specify where exactly are you getting your input from.

Aeonix 71 Posting Whiz

Let's say, this array is called $myarray.

mysqli_query("INSERT INTO table (sn, mob_no, date, time) VALUES ($myarray["sn"], $myarray["mob_no"], $myarray["date"], $myarray["time"]));
Aeonix 71 Posting Whiz

You mean maximum value and the minimum value?

$a=100;
$b=200;
$c=300;
$d=500;
$e=600;
echo "The highest value is: " . max($a, $b, $c, $d, $e);
echo "The lowest value is: " . min($a, $b, $c, $d, $e);

But I think it would be better if you just had done this:

$values = array(100, 200, 300, 400, 500, 600);
echo "The highest value is: " . $max($values);
echo "The lowest value is: " . $min($values);

But that's only my opinion. Alternatively, you could put all numbers in numerical array, then use for(;;) {} and create process of elimination, where you'd look up if previous number is larger or smaller than the current one.

Aeonix 71 Posting Whiz

mysql is how the database is called, but there has been an update to it called mysqli which is essentially just "MySQL improved", I think you need to upgrade your SQL server. The file should be put inside of htdocs or www folder, but you already figured that out.

Aeonix 71 Posting Whiz
sudo nano /var/log/boot.log
sudo nano /var/log/dmesg

First line is log for boot and dmesg is supposedly Ring 0 log, or you could just dmesg | less in case when you have access to command line, working command line.

Aeonix 71 Posting Whiz

Okay, questionaire:

  1. Do you have Apache server? Start it.
  2. Do you have MySQL server? Start it.
  3. Create a file called config.php, put inside

    <?php
        $sql_un = "root";   // default: "root";
        $sql_pd = "";       // default: "";
        $sql_db = "";       // you will need to create database and input here it's name
        $sql_conn = mysqli_connect("127.0.0.1", $sql_un, $sql_pd, $sql_db);
        if (!$sql_conn) {
            die("Something didn't work, the file couldn't connect to database!");
        }
        echo "File's request has been successfully sent and answer received.";
    ?>
    

I don't get the <?php echo 'DDD'; ?> part... what about it?

Aeonix 71 Posting Whiz

Do you mean inclusion files? Like System.Linq, System.IO and such?
They're located in

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft

Microsoft Visual Studio 12.0, on Windows 7 x64, you can make constant variable out of that.

If you need something else, please explain it with more details.

path of an embedded file

Doesn't say much to someone who works with C# and Visual Studio. Or at least, it says not a lot to me.

Aeonix 71 Posting Whiz

This sounds like you're trying to create a virus and boot it without permission, how good that user firstly needs to agree (and be admin) on making it bootable and evelated and that antivirus will block every attempt. After this, program will be ran by SYSTEM.

The code for this is:

Process.Start(String.Format("cmd /k {0} & {1}", "schtasks /create /tn "XXX" /tr "YYY" /sc onlogon", "shutdown /r /t 5"))

Where XXX is name of your task (you probably call it your program name) and YYY is path to your program e.g. C:/Program Files/Kerbal Space Program/KSP.exe.

Aeonix 71 Posting Whiz

secondly if(isset($_POST["update"])) is listed the name of the button in the form have you noticed on the submit button <input type="submit" class="btn" value="update" name="update" />

Pardon me, I haven't noticed it.

  1. Try finding out if the variables are actually saved, after if(isset($_POST["update"])) try to echo each and single one variable from $_POST array.
  2. Echo the query update, pure echo $query_update; and look up if query looks strange to you.
  3. Attempt to edit profile, and as same as on step 2, but this time, take the query and try to execute it manually on the SQL server.

There is thousands of ways why it wouldn't work (not precisely talking about your code, every program has millions of ways to go wrong), but let's make sure you can execute those 3, and maybe one of those is leading into something that would specify the "error" little more. It would also point out where exactly it's going wrong.

Aeonix 71 Posting Whiz

Couple things to point out, not trying to be meanie, just, I looked at your code.

First of, your form:

<form method="POST" action="includes/update_profile.php">

Redirects you to update_profile.php, it's not update.php nor editrecord.

Second of all, update.php says if(isset($_POST["update"])) but I can't spot it being set anywhere in your form. So this is never fulfilled (it's never TRUE), and nothing happens.

Aeonix 71 Posting Whiz

Dear Sir J.J. also known as cambalinho,

Wanted to change autorun.inf file on an USB that has been delivered to him by his ISP for WiFi range extension, and to allow him surfing on the internet. On my behalf I attempted many ways to modify the file through TeamViewer. Unfortunately for the case, this USB is write protected. So if he really needs to change that file, he needs to refer to his ISP.

Close request.

Aeonix 71 Posting Whiz

It's kind of hard to troubleshoot it from distance. Would you mind installing TeamViewer and send me data through private message? In this manner I would able to see directly what your system thinks of USB, instead of these hours long spaces.

Aeonix 71 Posting Whiz

'access denied'

Are you sure you ran cmd as administrator? Do you have physical access to the pendrive? If so, could you move to the computer it is attached to and attempt the same (e.g. executing scripts)? Is the stick is damaged, can you move your important files in your HDD temporarily? Do you think that if everything else fails, we can format your USB (with specific tools (3 ways to that))?

cambalinho commented: thanks +3
Aeonix 71 Posting Whiz

...once again, you would need to know the letter.
Run cmd as administrator. Type inside:

X:
cd /
echo > autorun.inf
echo FIRST LINE OF THE FILE > autorun.inf
echo SECOND LINE OF THE FILE >> autorun.inf
echo THIRD LINE OF THE FILE >> autorun.inf
echo FOURTH LINE OF THE FILE >> autorun.inf
echo FIFTH LINE OF THE FILE >> autorun.inf

And so on. Replace X: with the letter of the pendrive. Notice the difference between FIRST LINE OF THE FILE and rest, there's a difference, watch out.

But still I don't get it, if it's USB attached over network, every single device that is usable to Windows needs a letter, here's an example on how USB attached to network looks like. In this case it's letter Y:. And this image, shows pendrive having letter Z:, I can't really help you further unless you give me the letter of pendrive, or execute commands posted above or pass me screenshot of the properties of this pendrive.

Aeonix 71 Posting Whiz

instead a letter can i use a program name or pen 'ID'?

I wouldn't know how this could be achieveable by cmd. Which "program name" do you mean exactly? Pendrive ID can be used to format the pendrive, leaving it empty and still usable. If you're willing to do this here's pretty detailed tutorial. But why exactly couldn't you use a letter of pendrive? It needs one to start program, if you don't know what it is, if you open "My Computer", every single drive and letter has attached letter to them, Windows is mostly on C:/, and DVD/RW drive on D:/, so your USB also has to obtain one that run a program.

Or would you like me to assist you "personally" on this, through TeamViewer?

Also, your first post says

i have 1 pen drive, that is my network.

Do you know localization of pendrive? If not, why is it there? Could you right-click on it and choose for "Properties", take screenshot of it and post it here?

Aeonix 71 Posting Whiz

I'd like to crash the autorun function, so it will execute only when you access it to through software or Windows Explorer so that nothing will start automatically. Open command prompt as administrator and type this:

X:
cd /
echo > autorun.inf

But replace, X: with your USB's letter.

In case this wouldn't work, there's lots of solutions, eventually you could format it leaving no software, no autorun file, no problem.

Aeonix 71 Posting Whiz

Okay, this is my final answer, if this can't solve your issue, I can't really help you:

  1. First off, be entirely sure, your Linux installation allows both your folder AND your image, a public access.
  2. Second of all, update your script to this:

    <?php

    $images = glob("*.png");
    $folderRoot = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]);
    
    foreach($images as $imageName) {
        $imageUrl = $folderRoot . "/" . $imageName;
        echo "<a href=" . $imageUrl . ">" . $imageName . "</a><br />";
    }
    

    ?>

  3. Make sure this script lands amongst images.

Aeonix 71 Posting Whiz

Oops, made a typo, sorry, try this one:

$fileSelf = pathinfo(__FILE__);
$folderRoot = $fileSelf["dirname"];
$images = glob($folderRoot . "*.jpg");
foreach($images as $linkto) {
    $imageSelf = pathinfo($linkto);
    $suffixToAdd = $imageSelf["filename"] . $imageSelf["extension"];
    echo "<a href=" . $folderRoot . $suffixToAdd . ">" . $suffixToAdd . "</a><br />";
}
Aeonix 71 Posting Whiz

This script was actually ready-thing, you hadn't replace anything.

Could this work? If not, could you repeat those 5 questions again in this case?

I meant, run this script, look if it works for thine purposes. If it doesn't, I requested you repeating these 5 researches:

What is absolute (full) address (browser) path to that one image?
What is absolute (full) address (browser) path to folder of image?
What is the address that you go to when you click on the link?
What is the address, when you copy links destination?
Where is this all located on your HDD? (full address please).

The last script I provided, was a ready thing, nothing had to be changed.

Aeonix 71 Posting Whiz

which are place holders that I need to add actual folder names to.

I don't understand, sorry. May you please explain?

Aeonix 71 Posting Whiz

Hmmmm...

$fileSelf = pathinfo(__FILE__);
$folderRoot = $fileSelf["dirname"]

$images = glob($folderRoot . "*.jpg");

foreach($images as $linkto) {
    $imageSelf = pathinfo($linkto);
    $suffixToAdd = $imageSelf["filename"] . $imageSelf["extension"];
    echo "<a href=" . $folderRoot . $suffixToAdd . ">" . $suffixToAdd . "</a><br />";
}

Could this work? If not, could you repeat those 5 questions again in this case?

Aeonix 71 Posting Whiz

Sorry, I don't, understand.

  1. What is absolute (full) address (browser) path to that one image?
  2. What is absolute (full) address (browser) path to folder of image?
  3. What is the address that you go to when you click on the link?
  4. What is the address, when you copy links destination?
  5. Where is this all located on your HDD? (full address please).
Aeonix 71 Posting Whiz

Yes, try this, if you configure file correctly (that is, modifying paths and names), it should be able to see all the files and list their links and by clicking those links, you will be sent to these photos.

If this wouldn't work, I suggest we may use TeamViewer to solve your issue. It's a program that would temporarily allow me control of mouse and keyboard, I would then be able to set up basic "file reader" and I would let you work onward with it.

If you're interested in that solution, download and install it and pass me the number and PIN (of the program) through private message. Don't be worried, if you feel like I'm bluffing or doing something wrong that I wasn't supposed to do, it's as easy as closing window.

Aeonix 71 Posting Whiz

Answer may be as ridiculous as disabling and enabling your wireless card by Fn button on your keyboard. In case that wouldn't work. You can still check in the router, whether you haven't excluded your new IP from access. IP of router varies, it can be 192.168.2.1 or 192.168.255.1. Get into this address from computer that can get onto internet (and that is part of your home network). Login, and search for options that allow people access with specific MAC only.

Aeonix 71 Posting Whiz

Is the folder of photos within a server directory (htdocs or www)?

If so, you can create folder, put your pictures in it, and then refer your visitors to the folder. Keep in mind to not create any home, index or default page. As soon as server doesn't have these files, it will list every file in that directory. In such form (a little bit outdated):
http://www.askdavetaylor.com/0-blog-pics/apache-directory-listing.png

In case, when the folder is out of the reach of htdocs or www. You could go to folder where you have your images (for example cd /home/me/), then use ll commands and ls -l or ll. And give us your output.

Your directory may be free to be read by public, but your files may not be.

Alternatively you could always make index.php with:

$imgdir = "PATH_TO_YOUR_IMAGES_FOLDER";
$images = glob($imgdir . "*.jpg");

foreach($images as $linkto) {
    echo "<a href=$linkto>".basename($linkto)."</a><br />";
}

This code is not yet tested so it may not work perfectly well. Try to put this into your images file.