Jump to content

[SOLVED] :'( Pass encoded stuff though a array with preg match


nuil

Recommended Posts

Hi

 

Im trying to pass encoded stuff though a array, that then goes to preg match(should had been decoded somewere on the way) to see if there is a match or not. I have simple examples below, im only a beginer and i hope you can understand what im trying to do

 

This code is fine, it is what i need to add the decoding to. With info what it does below

$lines= array();

// All this does is get word list that is encoded(pre encoded eg czo3OiJlbmNvZGVkIjs=, ready to be only decoded)
$lines=file('myfile.txt') or problem('<b>System error code 2.</b>');

foreach($lines as $word){ 
//grab the footer to be compaired with our encoded word list that should had been decoded by now or it will try and match encoded stuff that dont exist
$html = @file_get_contents('footer.php') or problem('<b>System error code 3.</b>');
$html = strtolower($html);
if (preg_match("/".trim($word)."/i", "$html") == 1) {  

//if all is well the header well go and load the page
require_once('images/header.php'); } 

//else if we get to here words were not matched and we are not going to display the page at all and go to error page
else { problem($settings['sys-variables']); } }

// START problem()
function problem($myproblem) {
//html or what ever here
echo($myproblem);
exit();
}

 

myfile.txt

czoyODoiaWYgeW91IHJlYWRpbmcgbWUgaW0gZGVjb2RlZCI7
czoxNToic29tZSBtb3JlIHdvcmRzIjs=
czoyMDoiYW5kIG1vcmUgd29yZHMgYWdhaW4iOw==

 

 

Simple decode

$str = 'czoyODoiaWYgeW91IHJlYWRpbmcgbWUgaW0gZGVjb2RlZCI7';

$decoded = unserialize(base64_decode($str));

echo $decoded;

 

I have tried so many way, it cannot be passed here like my example below to be decoded, pregmatch tries to match the encoded lines

 

 

$encodedarraydata=file('myfile.txt');

$lines = unserialize(base64_decode($encodedarraydata));

$lines = array();

 

I been though so many different ways without doing any good but i cant code complex stuff and hoping some one would be kind enough to help  :(

Link to comment
Share on other sites

<?php
$lines= array();

// All this does is get word list that is encoded(pre encoded eg czo3OiJlbmNvZGVkIjs=, ready to be only decoded)
$lines=file('myfile.txt') or problem('<b>System error code 2.</b>');

foreach($lines as $word){ 
// decode data
$word = unserialize(base64_decode($word));

//grab the footer to be compaired with our encoded word list that should had been decoded by now or it will try and match encoded stuff that dont exist
$html = @file_get_contents('footer.php') or problem('<b>System error code 3.</b>');
$html = strtolower($html);
if (preg_match("/".trim($word)."/i", "$html") == 1) {  

//if all is well the header well go and load the page
require_once('images/header.php'); } 

//else if we get to here words were not matched and we are not going to display the page at all and go to error page
else { problem($settings['sys-variables']); } }

// START problem()
function problem($myproblem) {
//html or what ever here
echo($myproblem);
exit();
}
?>

 

Have you tried just adding it in there like seen above?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.