View Single Post
Old 11-09-2012, 06:08 AM   PM User | #2
Blinkin_Blippy
New to the CF scene

 
Join Date: Nov 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Blinkin_Blippy is an unknown quantity at this point
I'm not sure where my topic content went, or if I'm doing something wrong, but here it is again. I'm not able to see it anymore for some reason.

@Mods, my apologies for the double posting of this topic, and please remove the other one that is identical.

I'm new to the forum, and hopefully I did a good job with the title.

I'm trying to create a script that will block people from viewing certain pages of a site if they have not uploaded a photo. I don't have server side scripting access, so I'm limited to what can be done, and need to use Javascript.

Essentially I want to block all urls except for a handful. When a person reaches a blocked page, I want to redirect them to the photo upload page.

The way that I find out if they have uploaded a photo is by this: $member_profile_image. That is a snippet the the platform gives that will display the url in text on the webpage. It doesn't require anything other than what I've given to do that, so the <?php reference to it in the script isn't needed, nor will it work because I don't have access to php.

What I've been trying to do thus far is finding out the indexOf a particular word in the default photo's address on the server. Default meaning, if you haven't uploaded a photo, you have the default one that everyone does when they first join. The address for the photo contains the word "Default", and it indexes out at 22.

So, if the index value shows up at 22, and they are on a blocked page, redirect them to the photo upload page and alert("you have to upload a photo"). If the index value shows up at 22 and they are not on a blocked page, do nothing at all. What seems the easiest since I want pretty much all urls to blocked aside from a handful, would be to just say, if these urls and index of 22, do nothing, else redirect and alert.

What I'm working with is below, but it's total fail and I don't know why:

[CODE]
image = "$member_profile_image"; // Displays the url as text, no <?php.
upload = image.indexOf("Default") === 22; // Default indexes at 22 in the url
myurls = [
'http://www.myurl1.com',
'http://www.myurl1.com/wiki.htm',
'http://www.myurl1.com/?page=login&cmd=confirm,
'http://www.myurl1.com/blog.htm'
];
if(myurls.indexOf(window.location) > -1 && upload)
{
//This is where I need the code to do nothing at all.
}
else{
alert("you have to upload an image to access this page");
window.location.replace("http://www.myurl1/member/?page=settings");
}
[CODE]

I've tried it this way and I can't get much of anything to happen at all. Anyone have any advice or tip on what could be going wrong?
Blinkin_Blippy is offline   Reply With Quote