Skip to content

Commit

Permalink
add '+' in the end of the uri to get base url
Browse files Browse the repository at this point in the history
  • Loading branch information
YehudaEi committed Apr 4, 2020
1 parent 5f051e2 commit f27bfd3
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 21 deletions.
30 changes: 30 additions & 0 deletions getData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php if(isset($getData) && $getData){ include 'include/header.php'; ?>

<body>
<div style="top:0;right:0;position:fixed;"><span dir="rtl">בס"ד</span></div>

<section class="success-screen">
<div class="container verticle-center">
<div class="main-content">
<div class="close noselect">
<a href="<?php echo siteURL ?>/"><i class="material-icons">close</i></a>
</div>
<section class="head">
<h2>Base URL:</h2>
</section>
<section class="link-section">
<input type="text" class="short-url" disabled style="text-transform:none;" value="<?php echo urldecode($link); ?>">
<button class="short-url-button noselect" data-clipboard-text='short link: "<?php echo siteURL.'/'.$uri ?>" | base url: <?php echo urldecode($link); ?>'>Copy</button>
</section>
</div>
</section>

<script>
var clipboard = new Clipboard('.short-url-button');
</script>

<?php include 'include/footer.php'; ?>
</body>
<!-- Remove rimon scripts </body> -->
</html>
<?php } else{ http_response_code(404); include 'apache-errors/404.html'; } ?>
43 changes: 28 additions & 15 deletions include/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,59 @@
// GENERAL

// Site URL (no trailing slash)
define('siteURL', 'https://y-link.ml');
if(!defined('siteURL'))
define('siteURL', 'https://y-link.ml');

// Page title for your site
define('title', 'Yehuda Link | קיצור קישורים');
if(!defined('title'))
define('title', 'Yehuda Link | קיצור קישורים');

// The short title of your site, used in the footer and in some sub pages
define('shortTitle', '<a href="https://yehudae.ga">Yehuda Eisenberg</a>');
if(!defined('shortTitle'))
define('shortTitle', '<a href="https://yehudae.net">Yehuda Eisenberg</a>');

// A description of your site, meta tag.
define('description', 'y-link.ml - האתר הרשמי לקיצור קישורים מאת יהודה אייזנברג');
if(!defined('description'))
define('description', 'y-link.ml - האתר הרשמי לקיצור קישורים מאת יהודה אייזנברג');

// A description of your site, shown on the homepage.
define('HelloText', 'Welcome! <br>new design!');
if(!defined('HelloText'))
define('HelloText', 'Welcome! <br>new design!');

// The favicon for your site
define('favicon', '/include/assets/img/logo.png');
if(!defined('favicon'))
define('favicon', '/include/assets/img/logo.png');

// Logo for your site, displayed on home page
define('logo', '/include/assets/img/logo.png');
if(!defined('logo'))
define('logo', '/include/assets/img/logo.png');

// Enables the custom URL field
// true or false
define('enableCustomURL', true);
if(!defined('enableCustomURL'))
define('enableCustomURL', true);

define('DataBase', array(
if(!defined('DataBase'))
define('DataBase', array(
"ServerName" => "localhost",
"Username" => "root",
"Password" => "",
"DBName" => "link"
));
define('USE_TOKEN', false);
define('LINK_REGEX', '/^[a-zA-Z0-9\x{0590}-\x{05fe}_.\s\-]+$/u');
if(!defined('USE_TOKEN'))
define('USE_TOKEN', false);
if(!defined('LINK_REGEX'))
define('LINK_REGEX', '/^[a-zA-Z0-9\x{0590}-\x{05fe}_.\s\-]+$/u');

define('SITE_DOMAIN', preg_replace("(^https?://)", "", siteURL));
if(!defined('SITE_DOMAIN'))
define('SITE_DOMAIN', preg_replace("(^https?://)", "", siteURL));

// Optional
// Set a primary colour to be used. Default: #007bff
// Here are some other colours you could try:
// Set a primary color to be used. Default: #007bff
// Here are some other colors you could try:
// #f44336: red, #9c27b0: purple, #00bcd4: teal, #ff5722: orange
define('colour', '#007bff');
if(!defined('color'))
define('color', '#007bff');

// Optional
// Set a background image to be used.
Expand Down
21 changes: 15 additions & 6 deletions link.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
header("Cache-Control: no-cache");
header("Cache-Control: no-store");

$uri = urldecode(substr($_SERVER['REQUEST_URI'], 1));

if(isset($uri) && preg_match(LINK_REGEX, $uri)){
$uri = urldecode(substr($_SERVER['REDIRECT_URL'], 1));

if(substr($_SERVER['REDIRECT_URL'], -1) == "+"){
$getData = true;
$uri = substr($uri, 0, -1);
}

if(isset($uri) && preg_match(LINK_REGEX, $uri)){
$conn = new mysqli(DataBase['ServerName'], DataBase['Username'], DataBase['Password'], DataBase['DBName']);
mysqli_set_charset($conn, "utf8mb4");
if ($conn->connect_error) {
http_response_code(500);
include 'apache-errors/500.html';
die();
}
}
$sql = "SELECT `counter`,`link`,`id` FROM `Link` WHERE `id` = \"".$uri."\" AND `Link`.`deleted` = FALSE";
$res = $conn->query($sql);
if (!empty($res) && $res->num_rows > 0) {
Expand All @@ -30,8 +34,13 @@
}
}
if(isset($link) && !empty($link)){
header("Location: ".urldecode($link));
echo "error in moving you to <a href=\"".urldecode($link)."\" rel=\"noreferrer nofollow\">this link</a>. You can click <a href=\"".urldecode($link)."\" rel=\"noreferrer nofollow\">here</a>";
if(isset($getData) && $getData){
include 'getData.php';
}
else{
header("Location: ".urldecode($link));
echo "error in moving you to <a href=\"".urldecode($link)."\" rel=\"noreferrer nofollow\">this link</a>. You can click <a href=\"".urldecode($link)."\" rel=\"noreferrer nofollow\">here</a>";
}

$sql = "UPDATE `Link` SET `counter` = ".($count + 1)." WHERE `Link`.`id` = '".$uri."'";
$conn->query($sql);
Expand Down

0 comments on commit f27bfd3

Please sign in to comment.