urls / url-shortener-php Goto Github PK
View Code? Open in Web Editor NEWWeb application that will help you in shortening your url
Home Page: http://urls.github.io/url-shortener
License: MIT License
Web application that will help you in shortening your url
Home Page: http://urls.github.io/url-shortener
License: MIT License
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
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.
I just put your code in my website and configuration but the shortlink redirect to index.php
http://link.troke.id/gila
Maybe problem at .htaccess or what?
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 made all but still cant it always keep saying "Error in connecting to database!"
i am looking forward for this
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
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 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.