View Full Version : SHA1 for an ad server on a vBulletin forum

05-28-2011, 04:43 AM

I'm trying to set up an ad at my vBulletin website (PHP/MySQL) and the instructions for the SHA1 part of the code is throwing me. Their instructions say:

sig is calculated as follows: sha1(uid price vars description quantity weight your_password). The result will be base64 encoded. Variables that aren't used should be empty and do not have to be part of the calculation. The vars value used in the calculation should not be escaped/URLencoded.

I don't know what the syntax is for entering that many components. I only need vars and your_password. I tried, and it threw this error:

Security signature validation failed! Please notify the referring web site's administrator!
Signature should be: sha1('' . '' . 'zipcode=78759' . '' . '' . '' . '' . '' . '_YOUR_PASSWORD_')

So I changed the code to this:

sha1('' . '' . 'zipcode={vb: raw criteriaDisplay}' . '' . '' . '' . '' . '' . 'my-password')

And it continues to throw the same error. (The {vb: raw criteriaDisplay} is a vBulletin variable that is properly converted to the right number when seen in View Source. I also hard-coded the number and it still throws the same error.)

What is the proper syntax for writing the SHA1 hash with this many components?

05-28-2011, 06:56 AM
have you tried the comma , delimiter instead of the dot . ? and also put a ; after the close )

i dont know if this will work or not but try it.

$whatever = sha1('' , '' , 'zipcode={vb: raw criteriaDisplay}' , '' , '' , '' , '' , '' , 'my-password');

echo $whatever;

05-28-2011, 12:28 PM
This is also inside a hyperlink to their site for the ad setup page.

<a href="their_url/advertise/1366?vars=zipcode%3D{vb: raw criteriaDisplay}&sig=sha1('' , '' , 'zipcode={vb: raw criteriaDisplay}' , '' , '' , '' , '' , '' , 'my_password');">Create and place an ad in this forum.</a>

I tried that (was wondering about the closing ; ) and no go. I don't know where an echo command would go.

05-28-2011, 01:21 PM
i just put the echo for testing thats all, sorry about that. im thinking about this :)

inside your site put this (assuming your in a php file)

$whatever = sha1('' , '' , 'zipcode={vb: raw criteriaDisplay}' , '' , '' , '' , '' , '' , 'my-password');

echo $whatever; // this is just as a test to make sure that $whatever is loaded you can get rid of this

then in your link on the same php page

ok after sig=

try this

<?php echo $whatever;?>

05-28-2011, 05:37 PM
I'm embarrassed to say, I'm still too noobish and misunderstood how this all worked. :o

I've been trying to execute this in the vBulletin template and they don't do PHP. I have to get the SHA1 value in the PHP script, before the template is rendered, and then call it into the template.

I asked this same question over at DevShed, hope it's okay to link -

sha1-for-an-ad-server-on-a-vbulletin-forum (http://forums.devshed.com/php-development-5/sha1-for-an-ad-server-on-a-vbulletin-forum-819702.html#post2647319)