| Coding Forum Problems with your code? Let's hear about it. |
05-11-2006, 05:41 AM
|
#1 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
Javascript to PHP
I found this code on a web forum and I have been trying for the last couple of days to convert it to PHP and I haven't had any luck.
Is anyone able to help me, or even give me a few tips like, what does '>>>' mean, thats my main problem!
Code:
var GPR_HASH_SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
function GPR_awesomeHash(value) {
var gHash = 16909125;
for(var i = 0;i < value.length;i ++ ) {
gHash ^= GPR_HASH_SEED.charCodeAt(i % GPR_HASH_SEED.length) ^ value.charCodeAt(i);
gHash = gHash >>> 23 | gHash << 9}
return "8" + GPR_hexEncodeU32(gHash)
}
function GPR_hexEncodeU32(num) {
var result = GPR_toHex8(num >>> 24);
result += GPR_toHex8(num >>> 16 & 255);
result += GPR_toHex8(num >>> 8 & 255);
return result + GPR_toHex8(num & 255)
}
function GPR_toHex8 (num) {
return(num < 16? "0" : "") + num.toString(16)
}
function $(id) {
return document.getElementById(id)
}
function generate(f) {
$('r').innerHTML = GPR_awesomeHash( f.q.value )
}
function query(f) {
var x = f.fe.selectedIndex
var u =
'http://' + f.h.value
+ '/search?client=navclient-auto'
+ ( x == 0? '' : '&features=' + f.fe.options[x].value )
+ '&start=' + f.s.value
+ '&num=' + f.n.value
+ '&ch=' + GPR_awesomeHash( f.q.value )
+ '&q=' + ( f.i.checked || x > 0? 'info:' : '' ) + encodeURIComponent( f.q.value )
$('r').innerHTML = '<a target="blank" href="' + u +'">' + u + '</a>'
return u;
}
|
|
|
05-11-2006, 06:09 AM
|
#2 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 546
|
* Left Shift (<<)
* Sign-propagating Right Shift (>>)
* Zero-fill Right shift (>>>)
Left Shift (<<)
This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.
Sign-propagating Right Shift (>>)
This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left.
Zero-fill right shift (>>>)
This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left.
taken from: http://tinf2.vub.ac.be/~dvermeir/jav...ript/expr.html
|
|
|
05-11-2006, 07:51 AM
|
#3 (permalink)
|
|
Contributing Member
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
|
Lol.. just from reading the first line of code, are you trying to get through Google's PageRank system so it shows that you have something like a PR:9? Lol.. interesting idea, but Google will find that and delete your site from their SERPs
My 2 cents.. although I don't know if that's what you're trying to do or not.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
05-11-2006, 07:54 AM
|
#4 (permalink)
|
|
Inactive
Join Date: 03-20-06
Location: Germany
Posts: 523
|
I don't think this code is possible with php, it has to be Javascript because changes happen on Clientside.
|
|
|
05-11-2006, 07:56 AM
|
#5 (permalink)
|
|
Contributing Member
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
|
Well, if it is trying to change the Google PR in say the FireFox plugin or the Google Toolbar, no it is not possible with PHP since I don't think the toolbar sets in Session IDs or cookies to record the PR data, I think it just fetches the PR data directly from their server.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
05-11-2006, 07:58 AM
|
#6 (permalink)
|
|
Inactive
Join Date: 03-20-06
Location: Germany
Posts: 523
|
As you mentioned before, Izzmo, it's a bad idea anyway because easy tricks like that are easily tracked down 
|
|
|
05-11-2006, 08:01 AM
|
#7 (permalink)
|
|
Contributing Member
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
|
Yep, I know... because I've tried them lol. But if you think about it, only the real savvy Google Web users pay attention to the PR anyways, so why try and go through it, if the people like your site, they will go to it, PR really shouldn't be the basis on if you should go to a website or not.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
05-11-2006, 10:22 AM
|
#8 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 769
|
zero fill right shift
For instance, if the number shifting is 8, then this is zero fill right shift:
1111 < 8 in binary
0111 < push everything to the right 1 and fill with zero
Result is 7 binary
|
|
|
05-11-2006, 02:18 PM
|
#9 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
Quote:
|
Originally Posted by Mrblogs
* Left Shift (<<)
* Sign-propagating Right Shift (>>)
* Zero-fill Right shift (>>>)
Left Shift (<<)
This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.
Sign-propagating Right Shift (>>)
This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left.
Zero-fill right shift (>>>)
This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left.
taken from: http://tinf2.vub.ac.be/~dvermeir/jav...ript/expr.html
|
Thank you, that makes sence now. I should be able to convert it because that was my main problem 
|
|
|
05-11-2006, 02:19 PM
|
#10 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
Quote:
|
Originally Posted by Izzmo
Lol.. just from reading the first line of code, are you trying to get through Google's PageRank system so it shows that you have something like a PR:9? Lol.. interesting idea, but Google will find that and delete your site from their SERPs
My 2 cents.. although I don't know if that's what you're trying to do or not.
|
Yer thats what the code does, I didn't know that google would delete my site :s Isn't this how places like http://www.pagerank.net and iwebtools get their page rank data?
|
|
|
05-11-2006, 05:16 PM
|
#11 (permalink)
|
|
Contributing Member
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
|
Google would eventually find out, they watch their PR:8-10 sites VERY CLOSELY. So, yes, they would find out very quickly about your site.
But to answer your question, places like PageRank.net are doing it and showing the "actual" pagerank, not saying it's higher. But, I ask you then, are you trying to show your "actual" or put it up higher than it is?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
05-11-2006, 08:36 PM
|
#12 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
I want to show the same as what other sites do, so I guess the actual page rank.
I didn't know that the address I was requesting was different from the actual page rank.
|
|
|
05-11-2006, 09:25 PM
|
#13 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 769
|
Jeeze. I didn't actually read the code, just the part that needed interpretation.
I'm an accessory to a theoretical sin.
|
|
|
05-12-2006, 01:00 AM
|
#14 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 546
|
I think Sketch just wants to get the actual pagerank in PHP rather than in Javascript, so perhaps he can catalogue it or such?
|
|
|
05-13-2006, 08:45 AM
|
#15 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
Correct MrBogs, that is what I'm after, I have had a look at a few scripts and none of them work correctly for me, this is the only one that I have seen that works.
|
|
|
05-15-2006, 02:30 PM
|
#16 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
Latest Blog: None
|
Any ideas?
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|