sábado, 25 de julio de 2020

mysql insert


<?php
$link = mysqli_connect("localhost", "root", "2224psss", "dialer");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "INSERT INTO `audio` (`audio_id`, `audio_name`, `audio_desc`, `audio_path`, `audio_size`, `audio_date`)
VALUES (NULL, 'audio_name', 'Audio desc', 'path', '100MB', CURRENT_TIMESTAMP)";
if(mysqli_query($link, $query)) {
printf ("New Record has id %d.\n", mysqli_insert_id($link));
}
else {
printf("Error: %s\n", mysqli_error($link));
}
/* close connection */
mysqli_close($link);
?>

martes, 21 de julio de 2020

IP list from a file

<?php
$ip=file_get_contents("http://149.248.59.112/ip_address.txt");
$ip=explode("\n",$ip);

foreach($ip as $value){
if(!empty($value)){
if (in_array("$value", $ip)) {
    echo "Got $value<br>";
}

else {

echo " I\'m sorry";
}

}

}
?>


196.179.2.65
154.104.154.150
102.158.71.137
196.179.45.12
102.156.151.182
196.179.27.230
41.227.238.97

domingo, 12 de julio de 2020

How to Reset Joomla Admin Password?

In ordinary way you can reset Joomla admin password from the admin panel through the User Manager. To do this, you have to be logged in as a Super Administrator.

What if it is impossible to reset Joomla admin passwords in such a way? For example, your website have been hacked, the previous admin person is no longer available or you just have forgotten the password. What you have to do?

Joomla is not simple thing. Joomla has some possibilities to reset admin password in other way. We will show you two methods, follow our instructions and get knowledge in how to reset Joomla admin password:

lunes, 23 de marzo de 2020

PHP sendgrid API

 1007  echo "export SENDGRID_API_KEY='SG.8J2caHDtU'" > sendgrid.env


 1008  echo "sendgrid.env" >> .gitignore

 1009  source ./sendgrid.env

 1013  composer sendgrid/sendgrid

 1014  sudo curl -sS https://getcomposer.org/installer | php

 1015   mv composer.phar /usr/local/bin/composer

 1016  composer -V

 1023  composer require sendgrid/sendgrid
---------------------------------------------------------------------
PHP CODE

    <?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("admin@asterisk-voip.com", "Ambiorix Rodriguez");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("ambiorixg12@gmail.com", "Example User");
$email->addContent("text/plain", "and easy to do anywhere, even with PHP");
$email->addContent(
    "text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
try {
    $response = $sendgrid->send($email);
    print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n";
} catch (Exception $e) {
    echo 'Caught exception: '. $e->getMessage() ."\n";
}

?>

viernes, 6 de marzo de 2020

<?php
/* formats a 10 or 7 digit phone number (number only) by adding dashes at the appropriate locations */

function phoneFormat($number) {
if(ctype_digit($number) && strlen($number) == 10) {
  $number = substr($number, 0, 3) .'-'. substr($number, 3, 3) .'-'. substr($number, 6);
} else {
if(ctype_digit($number) && strlen($number) == 7) {
$number = substr($number, 0, 3) .'-'. substr($number, 3, 4);
}
}
return $number;
}

echo  phoneFormat(8297243489);

?>

829-724-3489

lunes, 10 de febrero de 2020

login script

<?php


  $dbhost='localhost';
        $dbuser='root';
        $dbpass=789456;
        $dbname='codigos';

        $db = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Couldn't connect to the database.");

        mysqli_select_db($db,$dbname) or die("Couldn't select the database");



    //--------------- AUTHENTICATION MODULE --------------------------

        function displayLogin() {
                header("WWW-Authenticate: Basic realm=\"Ambiorix\"");
                header("HTTP/1.0 401 Unauthorized");
                echo "<h2>Authentication Failure</h2>";
                echo "The username and password provided did not work. Please reload this page and try again.";
                exit;
        }



        if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
                // If username or password hasn't been set, display the login request.
                displayLogin();
        } else {
                // Escape both the password and username string to prevent users from inserting bogus data.
                $PHP_AUTH_USER = addslashes($_SERVER['PHP_AUTH_USER']);
                //$PHP_AUTH_PW = md5($PHP_AUTH_PW);
                $PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];

                // Check username and password against the database.
                   $query="SELECT count(user_id) as valid FROM codeusers WHERE password='$PHP_AUTH_PW' AND user='$PHP_AUTH_USER' ";    
                  $result = mysqli_query($db, $query);
                  while ($row = mysqli_fetch_assoc($result)) {
        if($row[valid]<1)  {
                displayLogin();

}


}
}
?>


CREATE TABLE `codeusers` (
  `user_id` int(10) NOT NULL,
  `user` char(10) NOT NULL,
  `password` char(10) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;