Jump to content

Recommended Posts

@flyhoney

No output at all, i've also tried several variations of what you gave me to see if it was just a param problem. Nothing will output except the -v data it seems.

 

@DarkWater

I/we concluded that the file_get_contents will not work for parsing the PHP files since it does not interpret it.

What I mean to say is it will ignore any variable declarations (and other stuff) in the output, so you can't get the variables from the php files using any method except eval which still declares the classes. fread/curl will also have the same problem. The only way it would work is if I used copy() to copy the version.php and made an alternate one, then somehow edited out the class name in the new one. Then did this every time the script was ran. I'm not really sure it would be possible to edit a class name in a .php file through .php.

@flyhoney

How is that possible though, everything I tried ignores most of the php? Your idea is probably the best out of everything because it's the most efficient and doesn't require creating new files and the like, but I just can't get the execute to work... I'll probably have to investigate into a it a little bit myself but I can't really find any information on Google about executing other .php files and getting args/params.

 

@Mchl

Running the script on each of the sites would probably be another step I would not like to take; granted they could be cron'ed or something I guess. If possible, this could use my copy() idea so the script would output all the data dynamically every time the script is run so we wouldn't have to run the script on EVERY site. Again though, I don't think there's a way to replace a specific portion of the .php or .xml or whatever.

 

You could

 

1. Load the file with class into a string using file_get_contents

2. Rename class using str_replace or other string functions into something like class123

3. Save this file in your directory with temporary name

4. include this temporary file to run it

 

Sorry, about that. Everybody is probably really annoyed at me now, haha.

 

Mchl, what I was saying in the posts above is there is no way to get the full class or even the class name using file_get_contents, fread, or curl. Unless there is some option/argument that will get everything rather than selective output - everything that I tried just strips more php.

file_get_contents loads whole text in a file into a string variable. You can then do with it anything you can do with a string.

 

<?php
class classname {

public $variable1 = "foo";

}

$f = file_get_contents("test.php");
echo $f;

$f = str_replace("classname","classfoo",$f);
echo $f;

$h = fopen("test1.php","w");
fwrite($h,$f);
fclose($h);
?>

 

Check this out. Save this as test.php and run (you will have to display source in the browser to see actual output).

Sorry, this was my own fault... something weird was happening and your direction to "view source" made me realize that it's going to echo the php directly, but in my view it was only showing some as plain text (comments broke some into html), the rest was in the source code. I forgot all about commands like strip_tags and htmlspecialchars - for whatever reason I just assumed echo would show me the output.

 

Now that, that is solved, I can just parse it now instead of creating another file. DarkWater, since you asked for some example stuff, here would be an example of the content to parse:

 

<?php

class configclass {

var $variable1 = '0';

var $variable2 = 'jce';

var $variable3 = '20';

} ?>

 

Obviously I would like to get all the variables in the class to extend the usability of the application, but if it's easier I can just search for specific variables.

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.