Unique URLs in a databse

I am using PHP / MySQL. I want to make a database of
websites, where the website URLs are unique. Let's say '
http://www.adobe.com' exists in
the database...
If someone tries to insert a record with the URL '
http://adobe.com', then script should
find '
http://www.adobe.com' (with the
www in front) in the database and detect that it is the same site,
and prohibit the insertion of the record.
Also, if someone tries to insert '
http://www.adobe.com/' (with that
added / at the end), it should just simply remove the end slash
before inserting it or looking for any records with a similar URL.
Lastly, the '
http://' should be added to the beginning of a
URL automatically if it isn't already provided.
How do I do these three things? Also, is there anything else
I should design the script to look for to make sure the URLs are
unique and duplicates are not being inserted?
Edit:
One other thing, '
http://www.adobe.com/some_page.html'
should be seen as the same thing as '
http://www.adobe.com', and would
prohibited from insertion. I'd actually like it if specific pages
could just be knocked off automatically, leaving just the domain.
Although, URL entries like '
http://some_host.com/user123'
and '
http://user123.some_host.com'
should still work.

AngryCloud wrote:
> I am using PHP / MySQL. I want to make a database of
websites, where the
> website URLs are unique.
How you design your script depends a great deal on who will
be inputting
the material. If this is going to be on an open site, with
anyone free
to input material, you will need to do a lot of checking and
sanitizing
of the user input before submitting it to your database. If
it's going
to be in a protected area where only trusted users are given
permission
to insert new entries, you can be less paranoid.
PHP has a useful function called parse_url() that extracts
the various
elements of a URL:
http://www.php.net/manual/en/function.parse-url.php
You could use it like this:
// check that input field isn't blank
if (isset($_POST['url']) && !empty($_POST['url])) {
// remove magic quotes
$url = get_magic_quotes_gpc() ? stripslashes($_POST['url]) :
$_POST['url];
// parse the URL
$parts = parse_url($url);
// if it looks OK, go ahead
if (isset($parts['scheme']) && $parts['scheme'] ==
'http' &&
isset($parts['host']) {
$host = $parts['host'];
// get the domain name with and without www.
if (strpos($host, 'www.') === 0) {
$www_host = $host;
$no_www = substr($host, 4);
else {
$www_host = 'www.'.$host;
$no_www = $host;
// query the database to see if URL already registered
$sql = "SELECT url FROM myTable
WHERE url = '
http://{$www_host}'
OR url = '
http://{$no_www}'";
$result = mysql_query($sql);
if (mysql_num_rows($result)) {
$error = 'That URL is already registered';
else {
$error = 'URL must begin with
http://';
// if no errors detected, insert into database
if (!$error) {
$site = '
http://'.mysql_real_escape_string($host);
$sql = "INSERT INTO myTable SET url = '$site'";
mysql_query($sql);
This isn't the only way of doing it, and you should probably
add more
checks, but the inline comments should show you how the
script works.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Unique URLs

    I am indexing a Lotus Domino 4.5 Database and I have Ultrasearch
    keying off of the URL of a Notes Search Page. However, when I
    do a search I end up with the same page multiple times because
    of links to 'previous' and 'next' on the notes page. Any
    suggestions on how to have Ultrasearch show only unique URL's in
    the result set it returns.

    As a clarification point. What I would really like to know is how to modify the queries used to return search results from the ultrasearch sample JSPs. I want to retrieve unique URLs from wk$url table. Any suggestions?

  • Unique ID's in ColdFusion 8?

    What tools are available to create UNIQUE ID's for an application?
    I know in ColdFusion we can use CreateUUID() but this generates a string that is very long.
    What I want to be able to do is create a string of say no more than 6 characters long that can be considered unique for a number of records that could reach the millions.
    For example, the website TinyURL seems to do this quite well with a link like the following:
    http://tinyurl.com/dlz23k
    How do you think they ensure it's uniqu everytime??
    Cheers,
    Mikey

    I've done quite a bit of research on URL shortening due to a customer's desire. After review of 8th grade math (permutations and combinations), there are two solutions to URL shortening. These schemes assume that the URL cannot be recycled and put back into circulation.
    Base 36 - a 6 character URL key consisting of letters a-z and 0-9 for a total of 36 characters, and hence base 36. (26 characters (a-z) and 10 digits). This scheme provides  2,238,976,116 unique URL keys ((36^7-36)/35). Notice, this is case-insensitive. For example, http://foo.com/?ItsMagic and http://foo.com/?itsmagic resolve to the same real URL. If over 2 billion URLs is sufficient, this scheme is for you.
    Base 62 - a 6 character URL key consisting of letters a-z, A-Z, and 0-9 for a total of 62 characters (26 +26 + 10 = 62). This scheme provides 57,731,386,986 ((62^7-62)/61) unique URLs. For example, http://foo.com/?ItsMagic and http://foo.com/?itsmagic resolve to DIFFERENT real URLs. If over 5 billion URLs is sufficient, this scheme is for you. (ref: http://www.bennadel.com/blog/1540-Converting-Numbers-To-A-Character-Set-Based-Radix-Using- ColdFusion.htm)
    Scheme 1 code:
            <!--- number of times to try getting a unique suffix before quiting --->
            <cfset var tries = 10>
            <!--- current number of trys --->
            <cfset var trycnt = 1>
            <!--- flag that suffix is unique --->
            <cfset var isunique = false>
            <!--- try to generate a random url suffix --->
            <cfloop condition="(not isunique and trycnt lte tries)">
                <!--- number of epoch seconds --->
                <cfset epochs = DateDiff("s", "January 1 1970 00:00", Now())>
                <!--- the suffix is a base 36 number --->
                <cfset suffix = FormatBaseN((RandRange(1,100000000) + epochs),36)>
                <!--- make sure this URL key is unique among those already created --->
                <cfset isunique = URLDAO.isURLUnique(this,suffix);
                <cfset trycnt = trycnt + 1>
            </cfloop>
    Scheme 2 code:
    See http://www.bennadel.com/blog/1540-Converting-Numbers-To-A-Character-Set-Based-Radix-Using- ColdFusion.htm)

  • How to use one PSE with multiple URLs?

    I need to hit my DMZ SAP Web Dispatcher with multiple unique URLs.  I am starting off using webdisp1.abc.com and webdisp2.vde.com.  DNS will resolve both the Web Dispatcher Host.  Following Tobias Winterhalter's Blog: Name-based virtual hosts and one SAP Web Dispatcher to access multiple SAP systems.
    My question is how do I go about generating the pse so I can store both webdisp1.abc.com and webdisp2.vde.com?  Do I just import the first request and initiate another certificate request using the same pse?
    Example
    sapgenpse gen_pse -s 2048 -p D:\<file path>\SAPSSLS.pse -r D:\<file path>\webdisp1.req CN=webdisp1.abc.com, OU=IT, O=XYZ Inc., C=US
    Cheers,
    Dan Mead

    Hi Daniel,
    what you are looking for are so called SAN certificates. As Martin said, with sapgenpse you are pretty out of luck. However you can create the certificates using openssl and then use sapgenpse to import them into a pse. There are a number of guides on how to create SAN certificates on the web, like the one mentioned by Martin from CAcert (which is one of the best imho) or this one. And there are also guides on the internet on how to convert OpenSSL keys to PSE.
    You should however keep in mind, that SAN certificates are more expensive than standard certificates. Therefor they only pay if the hostnames in there are stable for the lifetime of the certificate. If the hostnames need to change once a year, you already will be better off (from a cost perspective) by creating one pse per hostname an let the webdispatcher listen to different addresses, as each hostname requires a new certificate signed by the CA.
    Please also make sure, the systems and browsers connecting to your webservers are able to understand SAN certificates. For SAP systems this requires at least pl24 of the sapcryptolib.
    Kind regards,
    Patrick

  • Multiple URLs for different sites created on iWeb?

    When I created a second site and went to publish it, the site was given the same URL (web address) as the first site I created. Does iWeb not identify new sites with unique URLs? Essentially my question is does each MobileMe account only support a single website?

    Welcome to the Apple Discussions. When publishing multiple sites to to a MobileMe account the last published site will be accessible via the simple URL: http://web.me.com/youraccountname/
    However each site has it's own URL which would be:
    http://web.me.com/youraccount_name/sitename
    So you need to tack on the site name at the end of the simple URL.
    For what it's worth I use iWebSites to manage over 40 individual sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your original Domain.sites files before starting the splitting process and move it to another location on your HD until you're satisfied the separation process is completed and what you want.
    This lets me edit several sites and only republish the one I want. It's something you might want to take a look at.

  • Picking files based on the requested URL

    Hi Experts
    I have a requirement where I need to pick image files from SAP DMS server based on the URL requested.
    The scenario :
    Third-party sends a URL  corresponding to a particular image in DMS as request and PI needs to Pick the image
    file and send it as response.
    Due we need BPM? How to set up sender file adapter source directory as  the file name/directory   to be picked is dynamic in nature and there is no specifc pattern .We need to pick the exact file base on the Unique URL.
    Can we do this requirement in a synchronous interface by using HTTP or SOAP attachments for image? What about
    the performance impact as we have img files here.
    Regards,
    Srinivas
    Edited by: Srinivas on Sep 27, 2010 11:36 AM

    Third-party sends a URL corresponding to a particular image in DMS as request and PI needs to Pick the image
    file and send it as response.
    BPM would be required....We had a similar requirement wherein a URL was given at runtime to PI....then PI had to call the location and get back the details and we used SOAP for this (SYNC Call to the URL using SOAP channel from the BPM).
    Can we do this requirement in a synchronous interface by using HTTP or SOAP attachments for image?
    Not sure how the attachment will function inside a BPM....in my case I got the details as part of the message...even it was an image but it was stored as a base64 encoded message.
    Regards,
    Abhishek.

  • Routing of messages to different interfaces via HTTP using one single URL.

    Hi all,
    I'm working on an inbound scenario. Messages are coming to SAP via HTTP adapter and i'm using a unique URL of every interface. But what is required is one single URL for all interfaces without any dropbox in PI, i.e. all messages will be pushed to one URL and i have to route them to their respective interfaces, there is no storage involved in PI box.

    Shamit2903 wrote:
    Hi all,
    >
    > I'm working on an inbound scenario. Messages are coming to SAP via HTTP adapter and i'm using a unique URL of every interface. But what is required is one single URL for all interfaces without any dropbox in PI, i.e. all messages will be pushed to one URL and i have to route them to their respective interfaces, there is no storage involved in PI box.
    logically this is not a possibility.
    But in case you are looking at a generic interface then you will have to handle this using;
    1.  a generic Data type to accommodate all required structures
    2. use conditional routing in configuration to execute further transformations.
    I wouldnt recommend this though.

  • Is it possible to access a group of (sequentia​l) registers with a single URL?

    I'm testing out datasockets to an A-B RSLinx OPC server. At the moment, it appears as though each register in the PLC has to be accessed with an individual URL. Is it possible to access a group of (sequential) registers with a single URL? I suspect i may have to cluster a bunch of individuals together

    goog,
    For each data member, you will need a unique URL. There is not a way to bundle them into one URL.
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • Setting Default Url At User Level? Help !!

    Hi-
    After a user logs on .. I would like to point that user to a specific default url .. if I specify the default url at the domain level:
    manage domains
    select domain
    select user tab
    show advanced settings
    delete default url: /DesktopServlet
    add new url
    It works fine when the default url is set at this level .. problem is it then points EVERY user who is a member of that domain to the specified url ..
    Logically.. one would think that the correct approach would be to specify the defaul url for a particular user at the user level:
    manage domains
    select domain
    select role
    select users
    click username
    click user tab
    show advanced settings
    delete default url: /DesktopServlet
    add new url
    However, when this approach is used .. the user is sent to:
    /DesktopServlet
    in spite of the fact that the users default url had been set to a specific url other than:
    /DesktopServlet
    Question:
    Is it possible to set a users default url to a specified url and have it only affect that user?
    If so .. how?
    Does anyone have any recommendations as to how to make this work?
    Essentially .. I would like to create a domain with multiple users and have each user within that domain sent to a distinct and unique url .. how can I accomplish this objective?
    And if it simpy can't be done .. please let me know .. it would be much appreciated .. Happy Holidays .. to all ..
    Sincerely .. jesus ..

    Thanks for your response .. as it is .. I was able to accomplish the stated objective by using the Url Scraper to point each user to a page containing a meta-refresh tag which causes the desktop to appear for a fraction of a second before the user is advanced to the desired url .. sans the desktop and with the secure lock in the right hand corner .. thanks again for your response .. much appreciated .. jesus ..

  • One Portal - multiple URl's, orgs, groups

    Hi Forum
    I am in the process of doing a proof of concept for using Web Space Server to manage a large spectrum of diverse communities, hosted within a single portal. One could describe this as a large virtual organisation.
    The basic requirements are roughly the following:
    1. The portal will serve multiple small organisations and interest groups, with each org or interest group having its own landing page.
    2. Each landing page will have its own unique URL i.e. myspot1.com, myspot2.com etc. and the web server need to redirect each URL to its appropriate landing page.
    3. The look and feel of each landing page will likely be unique in terms layout etc. thus need to be customised for each instance.
    4. Web Space will be used in conjunction with Glassfishv2.1 and MySQL. The server will also run the amp stack with Apache on port 80 for other purposes.
    5. This portal will serve as a core foundation shared amongst various organisations, groups etc to enable collaboration across organisational and community boundaries with least effort form a user perspective to engage wherever need to.
    From playing around with both Liferay and Sun Webspace Server, it seems that these platforms can serve as a core to manage access rights, permissions, organisations, groups, etc.
    My immediate needs are to better understand the following:
    1. What is the best practice to route URL's to its unique landing page prior to client login?
    2. From a webserver perspective, what are the options to route URL requests to the appropriate Web Space "entry points" i.e. would one set this up in Apache, Glassfish, or Web Space and how?
    3. What are the options to customise each landing page to have its own unique look and feel?
    Any comments or pointers to documentation will be greatly appreciated.

    1. What is the best practice to route URL's to its unique landing page prior to client login?What you need is virtual hosting.
    See http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/High%20Availability%20Guide#section-High+Availability+Guide-TheBigPicture for details.
    2. From a webserver perspective, what are the options to route URL requests to the appropriate Web Space "entry points" i.e. would one set this up in Apache, Glassfish, or Web Space and how?See my first comment. It can be handled in the web server(tomcat)
    3. What are the options to customise each landing page to have its own unique look and feel?Each community can have its own look and feel.
    See http://docs.sun.com/app/docs/doc/820-7054/ghycy?a=view to know how to do this.

  • Iweb URL is the same for every page

    I have a small website built on iweb with a personal domain name, www.westonbennett.com and if you click on any of my pages the url doesn't change and is still www.westonbennett.com and I would like it to be a unique url for every page. Can anyone help me out?

    Hi,
    welcome to the Apple iWeb Discussion Forums!
    What you did is webforward with cloaking/masking whose result is giving the same url for all pages.
    What you should do to get yourdomain.com/sitename/pagename.html instead is change the CNAME
    Have a look at the following page to know how to achieve that
    http://alyeska.altervista.org/en/iWeb_Domains.html
    Regards,
    Cédric

  • Iweb url question

    Hello everyone,
    I am wondering if it's possible to create my own unique url name for my iweb site. I'm thinking of using godaddy.com or yahoo.com's domain hosting services to host my site for 2.99 a year, so that I could create my own domain name. Is this possible?
    Thanks,
    Steve

    Well, lessee, this all depends on how you want to do this.
    Are you already hosting your iWeb site on you .Mac account? If you are hosting your site of your .mac account the URL will probably look something like:
    "http://web.mac.com/<your.macnamehere>/iWeb/"
    All then you would need to do is to go to Godaddy.com and register a domain name (www.yourdomainname.com) and have godaddy.com forward that domain name to your .mac site.
    Once all this is set up, anyone visiting your site could go about it in 2 ways. First, they could just open a web browser and enter "http://web.mac.com/<your.macnamehere>/iWeb/" and get to your site.
    OR, they could enter the site name you registered (www.yourdomainname.com) and it would immediately forward the browser to "http://web.mac.com/<your.macnamehere>/iWeb/". For the rest of the time that person is browsing your site, all the URLs would look like your .mac url. This sounds to me like what you're asking for.
    Now, if you want to have your site fully hosted on "www.yourdomainname.com" without the URL changing to "http://web.mac.com/<your.macnamehere>/iWeb/" once you start browsing the site, then that's a whole different set of instructions, cause then you'd need to buy hosting space and manually upload your site to that server instead of just using iWeb's built in "publish to .mac" function.

  • Using URL Parameters  to Control Data Regions - HTML Data set.

    Hello folks,
    I creating a website for company and I am using HTML data set for siderbar navigation and content. It works beautifully and content updates as it have to without page refreshing. But I need to have an unique url for each sidebar element, so I i found  this nice sample http://labs.adobe.com/technologies/spry/samples/data_region/DataWithURLParams.html?row=20.  I did analogy with that sample on my website and indeed all sidebar elements now have unique url - but here comes new problem. Now  when I click on the each sidebar element - page starts to refresh . Here is my website http://www.varpa.eu . What have i done wrong ? How can I get  it to load new content without refreshing the page and to have each sidebar element unique url ? Please mention that I am talking only about the sidebar , not the topbar. Please help me .
    Sorry for my bad english , it aint my native language.
    Thank you,
    Richard.

    Thank you for your response Ben.
    That code which you provided is the top bar code. The top bar buttons should refresh the page, because I haven't done a spry magic with them yet.
    I was talking about the sidebar where Company , History etc.  elements are standing. Sidebar code is:
    <div id="sidebarbuttonwrapper" spry:region="about_us" >
    <div spry:repeatchildren="about_us" spry:choose="choose" >
    <div  id="sidebarbutton"
    onclick="location.href='about.html?row={ds_RowID}';"
    spry:when="{ds_CurrentRowID} == {ds_RowID}" spry:setrow="about_us"  spry:selected="sidebarbuttonselected" spry:select="sidebarbuttonselected" spry:hover="sidebarbuttonhover">{button_name}</div>
    <div  id="sidebarbutton"
    onclick="location.href='about.html?row={ds_RowID}';" spry:default="spry:default"  spry:setrow="about_us" spry:hover="sidebarbuttonhover" spry:select="sidebarbuttonselected">
    {button_name}
    </div>
    </div> 
    </div>
    As you can see here http://www.varpa.eu/test/about.html?row=0 when I click on the sidebar elements page doesn't refresh , but the each sidebar element doesn't have unique URL.
    When I included the URL params as in that sample above, now in this case http://www.varpa.eu/about.html?row=0 each element have unique URL, but this URL change makes page to refresh.
    Any suggestion how to achieve that each sidebar element would have unique URL, and clicking on it would not cause page to refresh ?
    Richard.

  • External OWA URL

    Hi,
    I've Exchange 2010 SP3 system with 3 CASHUB, 4 MBX servers.
    I also have 2 OwaVirtualDirectory, for example: https://abc.com/owa (for both Internal and External) and
    https://xyz.com/owa (for both Internal ang External)
    When I use Autodiscover to configure Outlook, it automatically detects https://xyz.com/owa as default InternalURL and ExternalURL.
    How can I change this setting to choose https://abc.com/owa as my default URL instead of the other one?
    Thanks,

    Hi Andy,
    But the URL appears in Outlook is not the one we want. In outlook 2010 it's in the "Access this account on the web ... "
    So as you mentioned there is no way to change the default URL in autodiscover?
    Thanks for your reply.
    If you have 2 unique URLs that autodiscover can return to clients, its pretty random what is returned. 
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • How Sap SDN do it? -  navigation change Portal URL

    Hi:
    If you check SDN home page you´ll see that almost every link changes the url site but the content is display in content area ( do not change the page completly). I was wondering how that could be done as my EP has always the same URL.
    I checked:
    URL Generator Service
    http://help.sap.com/saphelp_nw04/helpdata/en/7d/236cfa17034a37a439dc392ec59eb0/frameset.htm
    Portal URL Aliases
    Portal navigation
    and ECPM stuff
    I´m not quite sure if there´s a configuration at Visual admin/Portal that enables this behavior.
    Thanks a lot for your time on this thread.
    Rocío.

    We can also create a unique url for every page or iview.
    There is a property called Quick Link  which exists for every page/iview
    Let us say open a page  as object and set the Quick Link property as 'abc'
    Then you can access that page directly from the url  // http://<yourhostname>:<portno>/irj/portal/abc
    hope it helps you to some extent.
    Raghu

Maybe you are looking for