Jump to content

Recommended Posts

hey im busy working on some proxy code for a php driven proxy as i have not yet been happy with anything i have found online but am faced with a problem with java script i am using function below to run the html stuff and i can use the same general setup to do javascripts as well if some one would be so kind as helping me modify it or point me in the direction of a site where i can get the info i need?

 

html part as follows:

 

function parse_html ($string) {
		$parse = array(
			'a' => array('href'),
			'img' => array('src', 'longdesc'),
			'image' => array('src', 'longdesc'),
			'body' => array('background'),
			'frame' => array('src', 'longdesc'),
			'iframe' => array('src', 'longdesc'),
			'head' => array('profile'),
			'layer' => array('src'),
			'input' => array('src', 'usemap', 'onclick'),
			'form' => array('action'),
			'area' => array('href'),
			'link' => array('href', 'src', 'urn'),
			'meta' => array('content'),
			'param' => array('value'),
			'applet' => array('codebase', 'code', 'object', 'archive'),
			'object' => array('usermap', 'codebase', 'classid', 'archive', 'data'),
			'script' => array('src'),
			'select' => array('src'),
			'hr' => array('src'),
			'table' => array('background'),
			'tr' => array('background'),
			'th' => array('background'),
			'td' => array('background'),
			'bgsound' => array('src'),
			'blockquote' => array('cite'),
			'del' => array('cite'),
			'embed' =>  array('src'),
			'fig' => array('src', 'imagemap'),
			'ilayer' => array('src'),
			'ins' => array('cite'),
			'note' => array('src'),
			'overlay' => array('src', 'imagemap'),
			'q' => array('cite'),
			'ul' => array('src')
		);
		$tags = $this->get_tags($string);
		$to_replace = array();
		foreach ($tags as $tag) {
			$tag_name = $this->get_tag_name($tag);
			$attributes = $this->get_attributes($tag);
			if ($tag_name == 'base' && $attributes['href']) {
				$this->url = parse_url($attributes['href']);
				$this->url['full'] = $attributes['href'];
				$to_replace[] = array(
					'string' => $tag,
					'value' => ''
				);
			}
			if ($attributes['style']) {
				$attributes['style'] = $this->parse_css($attributes['style']);
			}
			if ($parse[$tag_name]) {
				$extra_html = '';
				$relink = true;
				$new_tag = "<$tag_name";
				//switch ($tag_name) {
					//case 'form':
					if ($tag_name == 'form'){
						if (strtolower($attributes['method']) == 'get' || !$attributes['method']) {
							$url = $attributes['action'] ? $this->encode_url($attributes['action'], false, true) : $this->encode_url($this->url['full'], false, true);
							$extra_html = "<input type=\"hidden\" name=\"__new_url\" value=\"$url\" /><input type=\"hidden\" name=\"__proxy_action\" value=\"redirect_get\" />";
							$attributes['action'] = './';
							$attributes['method'] = 'post';
							$relink = false;
						}
					//break;
				}
				if ($attributes) {
					foreach ($attributes as $attribute_name => $attribute_value) {
						if (in_array($attribute_name, $parse[$tag_name])) {
							switch ($tag_name) {
								default:
									if ($relink) {
										$attribute_value = $this->encode_url($attribute_value) . $extra;
									}
								break;
								case 'meta':
									if (eregi('refresh', $attributes['http-equiv']) && $tag_name == 'meta' && $attribute_name == 'content' && preg_match('#^(\s*[0-9]*\s*;\s*url=)(.*)#i', $attribute_value, $content)) {
										$attribute_value =  $content[1] . $this->encode_url($content[2]);
									}
								break;
							}
						}
						$new_tag .= " $attribute_name=\"$attribute_value\"";
					}
				}
				$new_tag .= ">$extra_html";
				$to_replace[] = array(
					'string' => $tag,
					'value' => $new_tag
				);
			}
		}
		$string = $this->mass_replace($to_replace, $string);
		return $string;
	}

 

thanks to anyone that can lend a hand

Link to comment
https://forums.phpfreaks.com/topic/70889-solved-proxying-java/
Share on other sites

So... you want a proxy driven by PHP? And you haven't found anything useful yet?

If t3h Internets have failed you, you might have to roll your own. What exactly is this proxy supposed to do?

Once you figure that out, formalize that requirement and break each part down. Then, design a solution.

Easier said than, done, I know, but it might be your only option.

 

Also, what is the attached code supposed to do? It's completely uncommented, and we aren't given any context. Help us help you, man.

-Bob

Link to comment
https://forums.phpfreaks.com/topic/70889-solved-proxying-java/#findComment-356398
Share on other sites

Yah sorry about that bob it was like midnight here when I posted that so it dose not make as much sense as I would like it to basically rolling my own is exactly what I am doing

 

and the code I attached is a chunk of it basically it parse the html so to save posting all my code will give a little more detail

 

for simple coding everything is wrapped inside a class for 2 reasons A it keeps it easy to work with and B I can return the entire page in a variable in the event I wish to cache it (but I haven’t really given that any thought to that at this exact point but I wanted to give my self room to improve with our completely rewriting it latter)

 

I am using curl to get the data the site in to the script and I currently have 2 major functions doing to work parse_css, and parse_html parse_html html is he code sample I gave above

 

Now I would like to add a another function called parse_javascript which I was planning to base around the same system

 

this leads me to the attached code above it is a copy of the parse html function my problem is where I know PHP rather well I have limited knowledge of JavaScript as you might see from the code the array keeps all the fields I need the parse and what attributes in it I need to work with and then it dose its thing

 

What I would like to do is the same with the JavaScript and I’m hoping some one can point me in the right direction with what tags and attributes I should be looking for in order to do that

 

And sorry for my lack of commends in the code I have been commending all the code in another file to allow me to write the code as clean as possible and then commend it all latter

 

Link to comment
https://forums.phpfreaks.com/topic/70889-solved-proxying-java/#findComment-356760
Share on other sites

So you've already made a proxy, however now your removing all content (what about css level defined html tags?) and you need the full language specification for javascript? How secure is your proxy when it comes to logging and routing, because what will you be enabling other nefarious people to do in your name? Here's a link to some spec's on web languages, http://www.w3schools.com/default.asp, if Aussie owt like here in the UK, then things are about to get a bit tighter and you need to ask yourself, "if i'm asking for this basic help on a forum, am I good enough to know what i'm doing when it comes to setting up an open proxy?". Especially when you title it java and it's about javascript! However, good luck, or should I say have a good look!

Link to comment
https://forums.phpfreaks.com/topic/70889-solved-proxying-java/#findComment-357071
Share on other sites

I am logging all users through into a database and tracking on IP as country location (through geoIPlite) and a list of sites visited through this I am using "block list" to block users by IP address I am blocking sites based on whether or not they are legal

 

I do understand the difference between java and java script so ill call that a naming error, I also have quite a good understanding of PHP and almost ZERO knowledge of java or java scripting

 

so I do take some what offence to be called a kiddies scripter as I have been writing PHP code for well over 5 years and I don’t see how a lack of knowledge of java script has anything to do with my problem at hand given it is completely written in PHP with no java needed AT ALL

 

I’m also not removing all content I am redirecting content and links via my script to allow for open access give that some one using a proxy is probably accessing a blocked site in there network it would be foolish to only load a given page and not let them browse through it

 

I also stated I have a parse_css function to parse the CSS level defined tags just didn’t both posting the function

 

i am sorry if i have now offended you but i really think your wording could have been selected just a little better so it dose not come across as offensively because i'm shore if you re read it you will understand

 

Link to comment
https://forums.phpfreaks.com/topic/70889-solved-proxying-java/#findComment-357103
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.