Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:01:00+00:00 2026-06-18T11:01:00+00:00

I could not find this problem anywhere and nothing really related that I can

  • 0

I could not find this problem anywhere and nothing really related that I can see. I have a URL Shortening script that I purchased, this script works great on my first server, installed the database, FTP’d the files and was all set and shortening URLs.

But since then I moved it to a VPS server, I setup the server exactly same, with Centos 5.6. Installed the script, everything is fine. But the only thing that I find that does not work is the shortening process. I have no idea why it won’t work. I have little knowledge of Ajax and JavaScript which I think the problem is with.

Here is ajax.php

 <?php
require_once '../config.php';

function url_exist($url)
{
    $c=curl_init();
    curl_setopt($c,CURLOPT_URL,$url);
    curl_setopt($c,CURLOPT_HEADER,1);
    curl_setopt($c,CURLOPT_NOBODY,1);
    curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
    if(!curl_exec($c)){
        return false;
    }else{
        return true;
    }
}

function shorteURLFromID ($integer)
{
    $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $length = strlen($base);
    $out = '';

    while($integer > $length - 1)
    {
        $out = $base[fmod($integer, $length)] . $out;
        $integer = floor( $integer / $length );
    }
    return $base[$integer] . $out;
}

if(isset($_POST['url']))
{
    $l_type = (string) $db->escape(trim(strip_tags($_POST['type'])));

    $url = trim(strip_tags($_POST['url']));
    $url = str_replace(array("http://"), array(''), $url);

    if(strlen($url) < 3) {
        print '<style>.alert-300{width:325px;margin-left:182px;}</style>';
        die("<div class='alert alert-error alert-300'>".translate('empty_url_error')."</div>");
    }

    if(stristr($url, $_SERVER['SERVER_NAME'])) {
        print '<style>.alert-300{width:325px;margin-left:182px;}</style>';
        die("<div class='alert alert-error alert-300'>".translate('same_site_error')."</div>");
    }

    if(url_exist($url))
    {
        //check if exists for this user
        $rs = $db->get_row("SELECT string FROM links WHERE uID = '".$usersObject->ID()."' AND 
                            destination = '".mysql_real_escape_string($url)."' LIMIT 1");
        if(count($rs)) {
            $string = $rs->string;
            print "http://".$_SERVER['SERVER_NAME']."/".$string;
        }else{
            $rs = $db->query("INSERT INTO links (destination, added, ip, uID, type) VALUES 
                            ('".$db->escape($url)."', '".time()."', '".ip2long($_SERVER['REMOTE_ADDR'])."', 
                            '".$usersObject->ID()."', '".$l_type."')");
            if($rs) {
                $string = shorteURLFromID($db->insert_id);
                $rs = $db->query("UPDATE links SET string = '$string' WHERE linkID = '".mysql_insert_id()."'");
                print "http://".$_SERVER['SERVER_NAME']."/".$string;
            }else{
                print '<style>.alert-300{width:325px;margin-left:182px;}</style>';
                print "<div class='alert alert-error alert-300'>Could not create shortened link ".mysql_error()."</div>";
            }
        }

    }else{
        print '<style>.alert-300{width:325px;margin-left:182px;}</style>';
        print "<div class='alert alert-error alert-300'>".translate('invalid_url_error')."</div>";
    }
}else{
    print '<style>.alert-300{width:325px;margin-left:182px;}</style>';
    print '<div class="alert alert-error alert-300">'.translate('invalid_url_error').'</div>';
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:01:02+00:00Added an answer on June 18, 2026 at 11:01 am

    Try adding in this option:

    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);

    It looks like the default was changed with cURL 7.10 to true, so it is possible PHP 5.2.17 was using a version prior to 7.10.

    Levi

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem which I could not find a solution for anywhere.
I feel really silly to not be able to find this answer anywhere. Could
I have the following problem and I could not find a solution anywhere. I
Yes, I've googled and I could not find the answer to this problem. First
I have searched but could not find the reason for this behavior. I have
I have been looking everywhere but could not find a tutorial for this. I
I have been looking for an answer to this and could not find it
This feels like a really simple question, but I can't find the answer anywhere.
I have tried to find a solution to this naming problem, but I could
I could not find a clear answer to this question elsewhere, so I'll try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.