Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php
$database = "starter_mag";
$password = "XXXXXXX";
$username = "XXXXXXX";
$hostname = "127.0.0.1";
$link = mysqli_connect($hostname, $username, $password, $database);
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT distinct TABLE_NAME FROM Information_schema.columns where TABLE_SCHEMA = '$database' ORDER BY table_name  ASC";
$offset = 10000;
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_array($result)){
            $tableName = $row['TABLE_NAME'];
            $count = 0;
            echo '------------------- INIT '.$tableName.' TABLE ---------------'.PHP_EOL;
            do{
                $tableQuery = "SELECT * FROM ".$tableName." limit ".$count*$offset.", $offset";
                if($resultTableQuery = mysqli_query($link, $tableQuery)) {
                    if (mysqli_num_rows($resultTableQuery) > 0) {
                        while ($tableRow = mysqli_fetch_array($resultTableQuery)) {
                            echo ('('.$count.') '.$tableName.': ');
                            echo implode(',',$tableRow);
                            echo PHP_EOL;
                        }
                    }
                }
                $count++;
            }while(mysqli_num_rows($resultTableQuery));
            echo '------------------- END  '.$tableName.'  TABLE ---------------'.PHP_EOL;
        }
        mysqli_free_result($result);
    }
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);


What I have tried:

I'm a beginner in PHP I need to know what the function and output of this code is.
thanks
Posted
Updated 17-Sep-22 14:34pm
v2
Comments
[no name] 17-Sep-22 16:02pm    
Looks like a database tables' data dumper; using sampling. Like someone looking for something.
Dan Neely 19-Sep-22 9:53am    
Create an sql injection vulnerability?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900