/    Sign up×
Community /Pin to ProfileBookmark

Nice exercise for experts in JavaScript – multiple tasks javascript

[B]The desired Javascript will have four uses:[/B]

  • Set and get cookies

  • Block one or more IP numbers

  • Redirect users

  • Select one of two CSS codes

  • Disable right click
  • [B]Usage:[/B]

    On load the site/blog will detect if javascript is off, if is off the user will get redirected to other page or site using :
    <noscript><meta content=’0;url=http://www.subdoman.domain.com‘ http-equiv=’refresh’/></noscript>
    (Unless there is other way to do that)

    [B]If java script is on:[/B]

    [B]– Set and get cookies –[/B] ( bad user cookie and nice user cookie )

    Check for a “bad” and “nice” user cookies

    If cookie is “bad” user cookie = redirect to subdomain.domain.com/x/x/bad.html
    If cookie is “nice” user cookie = next function of the javascript
    If there is no cookie = set “nice” user cookie

    [B]– Block one or more IP numbers – [/B]

    Check the IP’s, if all is ok do nothing

    If IP match = user get redirected to subdomain.domain.com/x/x/sorry.html
    If IP match = set cookie ( “bad user cookie” )


    ————————————————————-

    From the previous steps of the javascript
    If IP don’t match, check for banned user cookie

    If the banned user cookie is there redirect the user again
    ————————————————————-

    [B]– Select one of two CSS codes – [/B]

    If cookie is “bad” user cookie = site/blog uses <style type=’text/css’>Some code here for bad users</style>
    If cookie is “nice” user cookie = site/blog use <style type=’text/css’>Some code here for nice users</style>

    ~Optional : CSS style can be selected if IP’s match or not instead of cookies

    [B]– Disable right click –[/B]

    The disable right click will need to show an alert text message and one button.

    If a user use the right button the message open, once the user click on the button (like a ok or confirmation button to close the message box) the script set the “bad user cookie” and close the message box

    ~Optional : If the user use the right click more than once, the user get redirected to a new page like subdomain.domain.com

    ~~~~~~~~~~~~~~~~~~~

    [B]Note:[/B]

    1- The script need to work in sites/blogs like:
    domain.com
    subdomain.domain.com
    subdomain.domain.com/folder
    subdomain.domain.com/folder/page.html
    subdomain.domain.com/folder/folder2/you get the idea

    2- Please include and diferentiate funtions on the script for better understanding if posible

    3- Include your credits on the script ( website and or name ) / optional

    4- The script will be used by a lot of users and will be distribuited for free on different sites and blogs so please if you don’t like links back let me know.

    Sorry for my poor english

    to post a comment
    JavaScript

    6 Comments(s)

    Copy linkTweet thisAlerts:
    @KorOct 20.2010 — And? Which is the use of your post? Which is your problem (if you have one)? We may excuse you for your poor English, but we might not excuse your lack of substance.

    Which is your aim?
    Copy linkTweet thisAlerts:
    @GymsauthorOct 20.2010 — The use of the post is to get some help, as i don't know how to acomplish that with Javascript.

    The use of the javascript is a bit simple.

    The Javascript will be used mostly by bloggers, that need to:

    Block one or more IP numbers in order to protect part of the content of their blogs.

    I just take into consideration a few script that are available out there for free and see their potential, but all these scripts are made to accomplish one function or other, not all at the same time.

    I just trying to solve a few problems at once, without fill the whole blog of scripts, one for each function.

    ~Problems

    Block one or more IP numbers

    Disable the right click

    Hide part of the content of the blog to sertain unwanted users (using different CSS )

    Redirect (out) unwanted users

    Exampe of a problem

    Invalid clicks on Third Party Ads

    With a script like that i can bann the user, hide the ads with the CSS, and disable the right click so the user can't see the source code ( still some ways to view the source code, but at least will let out a few users without knowledge - like me ? )

    There is a lot of problems that can be solved with a script like this, personaly this is not my problem, but yes i have a problem in one of my blogs, where i know the IP used by this "bad" user and i will like to bann he.


    [B]Kor:[/B] i apologise, for mi lack of sustance and to don't explain the use of the script as well as what I'm trying to accomplish or what is my aim.

    I hope you like other users here in this forum can come up with ideas or suggestions or even a few lines of code that can help other users to implement a script that in my opinion will be really apriciated by a lot of bloggers, and at the same time will be very useful.



    ---
    After months of search on the web fo a simple script to redirect my users using cookies i decide to ask in this forum. At the moment i don't know if my problem was so esay to solve or here seems to be a lot of experienced people with javascript, anyway, the solution to my problem was posted 1:38 minutes later... that is awsome in my opinion. (http://www.webdeveloper.com/forum/showthread.php?p=1119057)

    So i decide to ask here for some solution to this problem

    As i don't know how to cal the problem i just decide to call the post "Nice exercise for experts in JavaScript - multiple tasks javascript"

    Because i think that for user experienced in Javascript this problem (i think) is just a small exercise (putting parts all toghether) to accomplish multiple tasks.


    Kor: my apologises again, and to all users of the furum.

    Sorry for my poor english, and i hope somebody can come up with something to help to solve the problem.

    Thanks
    Copy linkTweet thisAlerts:
    @KorOct 21.2010 — Definition: JavaScript is a client-side language

    1.[I] Block one or more IP numbers[/I] - this needs a server-side approach, not JavaScript

    3. [I]Hide part of the content of the blog to certain unwanted users[/I] - this needs also a server-side approach : a server-side language and a DataBase (like PHP/MySQL, for instance)

    4. [I]Redirect (out) unwanted users[/I] - same as above.

    2.[I] Disable the right click so the user can't see the source code[/I] - that is utopia. User might simple disable JavaScript on his computer. Or he might use View Source.

    still some ways to view the source code, but at least will let out a few users without knowledge
    [/quote]

    Lack of logic. A user without knowledge does not need your code. Or if he needs it and and he sees it, he will not understand it, nor will be able to use it, copying it, etc. He is [I]without knowledge[/I], remember? ?
    Copy linkTweet thisAlerts:
    @GymsauthorOct 22.2010 — Hi... kor, i don't meant to be rude but why you just don't say that before.

    ""And? Which is the use of your post? Which is your problem (if you have one)? We may excuse you for your poor English, but we might not excuse your lack of substance.

    Which is your aim?""

    Just a waste of time... if can't be done with javascript just say that instead of ask other things that will not really matter, as the problem can't be solved using javascript.

    Have a nice day
    Copy linkTweet thisAlerts:
    @KorOct 22.2010 — Neither do I want to be rude, but please, read, comparatively, your first 2 posts. In your first post you have simply exposed your whole project (detailed much to much, if you ask me), [I]without specifying where, precisely, you were expected us to help you[/I]. We saw nothing but an enunciation like: [I]"Boyz'n'girlz, I have a huge project to do"[/I]. It is obvious that the first reply would be something like:[I] "And what prevents you to do that?"[/I].

    Only in your second post you managed to isolate and organize your problems, thus I was able to give you on the dot answers.

    Look at your title: [B]Nice exercise for experts in JavaScript - multiple tasks javascript[/B] At a first glance I thought that my old teacher of Mathematics rose from the dead especially for bother me again with a new homework. :rolleyes: Choose carefully the titles of your threads in Forums. The title should be the brief exposure of: [I]what do you want, and which is the problem or the domain/sub-domain where your problem is placed[/I].
    Copy linkTweet thisAlerts:
    @GymsauthorOct 22.2010 — Ok... point taked...

    After see in perspective all that, i have nothng to say rather than I'm Sorry...

    As i find this site very useful, i will be more careful next time that i ask for help here...
    ×

    Success!

    Help @Gyms spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...