Giter Site home page Giter Site logo

urls / url-shortener-php Goto Github PK

View Code? Open in Web Editor NEW
87.0 12.0 69.0 830 KB

Web application that will help you in shortening your url

Home Page: http://urls.github.io/url-shortener

License: MIT License

PHP 74.31% CSS 25.69%
url url-shortener shortner php-scripts php oops open-source-licensing

url-shortener-php's People

Contributors

alex9099 avatar aloklearning avatar amalmurali47 avatar amarlearning avatar danjohn008 avatar gyaaniguy avatar maartengdev avatar mrcarlosdev avatar prabhakar267 avatar yvisherve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

url-shortener-php's Issues

Shortening doesn‘t work

If I click shorten it shows the error message:

Warning: require_once(../UrlShortener.php): failed to open stream: No such file or directory in /storage/ssd1/551/13037551/public_html/functions/shorten.php on line 6

Fatal error: require_once(): Failed opening required '../UrlShortener.php' (include_path='.:/usr/share/pear:/usr/share/php') in /storage/ssd1/551/13037551/public_html/functions/shorten.php on line 6

Refactor for PDO & Modularity

PDO would allow this to be database-agnostic, and while it's refactored to support PDO, it should be implemented in a more modular way.

  • create a Connection class and store each database connection there. This will make url-shortener more portable, because other projects are more likely to have a modular approach to creating & managing database connections.

  • place the SQL statements in separate methods within the UrlShortener class. This, combined with the use of bindParam(), is a best-practice.

I've cloned the project and partially finished these changes. If you want, we could create a branch and I could push my current changes to it so we can work on it before pushing it to the master branch.

Security issue : Max lengths are not verified

Hi.

If someone host this tool as a public service it will be unsafe for him, given that the URL and the custom text lengths inputed by the user are not verified.

According to the table's structure :

  • URL's length should not exceed 1000

  • custom text's length should not exceed 20 characters.


if (($_POST['onoffswitch'] == 'on') && (isset($_POST['custom']))) {
    $customCode = $_POST['custom'];
    
    if (!$urlShortener->checkUrlExistInDatabase($customCode)) {
        $insertCustom = true;
    }
    
    else {
        $errors            = true;
        $_SESSION['error'] = 'The custom URL <a href="' . BASE_URL . $_POST['custom'] . '">' . BASE_URL . $_POST['custom'] . "</a> already exists";
    }
}
if (isset($_POST['url']) && !$errors) {
    $orignalURL = $_POST['url'];
    
    if (!$insertCustom) {
        if ($uniqueCode = $urlShortener->validateUrlAndReturnCode($orignalURL)) {
            $_SESSION['success'] = $urlShortener->generateLinkForShortURL($uniqueCode);
        }
        
        else {
            $_SESSION['error'] = "There was a problem. Invalid URL, perhaps?";
        }
    }
    
    else {
        if ($urlShortener->returnCustomCode($orignalURL, $customCode)) {
            $_SESSION['success'] = $urlShortener->generateLinkForShortURL($customCode);
        }
        
        else {
            header("Location: ../index.php?error=inurl");
            die();
        }
    }
}
CREATE TABLE IF NOT EXISTS `link` (
  `id` int(11) NOT NULL,
  `url` varchar(1000) DEFAULT NULL,
  `code` varchar(20) DEFAULT NULL,
  `created` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I am having problems redirecting to new link

The site loads, runs, shortens the url, i see it in mysql, but when i access the short link, it does not work

Not Found
The requested URL was not found on this server.
Apache/2.4.41 (Ubuntu) Server at XXXXXXXX.net Port 80

I dont think the redirect is working. Any any thoughts on that?

Thank you!
Alex

Redirecting to index.php

Hi,

I'm having trouble making the code to work, i changed the url and the mysql settings and it generated the codes, but when clicking on the shortned link it redirects me to index :(

hey im getting a problem

hey how do i fix this

Warning: require_once(../UrlShortener.php): failed to open stream: No such file or directory in C:\xampp\htdocs\functions\shorten.php on line 6

Fatal error: require_once(): Failed opening required '../UrlShortener.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\functions\shorten.php on line 6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.