Skip to content

Commit 6620dc9

Browse files
committed
Update Helper And Config Files
1 parent be59914 commit 6620dc9

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

UrlShortner-English/config/config.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88
#----- Constants -----#
99

10-
const URL = 'http://HeroExpert.ir/UrlShortner-English/'; # File Location Url
10+
const URL = 'https://HeroExpert.ir/UrlShortner-English/'; # File Location Url
1111

1212
#----- DataBase -----#
1313

1414
$userName = 'root'; # DataBase Username
1515
$dbName = 'heroexpert_ir'; # DataBase Name
1616
$passWord = ''; # DataBase password
17-
$table = 'urls'; # DataBase Table Name
1817

1918
try {
2019
$connect = new PDO('mysql:host=localhost;dbname=' . $dbName, $userName, $passWord);

UrlShortner-English/controller/helper.php

+17-16
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,48 @@ function shortUrlCreate()
2121
# Save The Url Information In The DataBase
2222
function saveUrl($Url, $shortUrl)
2323
{
24-
global $table;
2524
global $connect;
26-
$sql = "INSERT INTO $table (url,shortUrl) VALUES (:url,:shortUrl);";
25+
$sql = "INSERT INTO urls (url,shortUrl) VALUES (:url,:shortUrl);";
2726
$stmt = $connect->prepare($sql);
28-
$stmt->execute([':url' => $Url, ':shortUrl' => $shortUrl,]);
27+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
28+
$stmt->bindParam(':shortUrl', $shortUrl,PDO::PARAM_STR);
29+
$stmt->execute();
2930
$result = $stmt->rowCount();
3031
return $result;
3132
}
3233

3334
# Get Information About The Existence Of A ShortUrl
3435
function receiveShortUrlCount($Url)
3536
{
36-
global $table;
3737
global $connect;
38-
$sql = "SELECT * FROM $table WHERE shortUrl = :shortUrl;";
38+
$sql = "SELECT * FROM urls WHERE shortUrl = :shortUrl;";
3939
$stmt = $connect->prepare($sql);
40-
$stmt->execute([':shortUrl' => $Url]);
40+
$stmt->bindParam(':shortUrl', $Url,PDO::PARAM_STR);
41+
$stmt->execute();
4142
$result = $stmt->rowCount();
4243
return $result;
4344
}
4445

4546
# Get Information About The Existence Of A Url
4647
function receiveUrlCount($Url)
4748
{
48-
global $table;
4949
global $connect;
50-
$sql = "SELECT * FROM $table WHERE url = :url;";
50+
$sql = "SELECT * FROM urls WHERE url = :url;";
5151
$stmt = $connect->prepare($sql);
52-
$stmt->execute([':url' => $Url]);
52+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
53+
$stmt->execute();
5354
$result = $stmt->rowCount();
5455
return $result;
5556
}
5657

5758
# Get Information About The Existence Of A ShortUrl
5859
function receiveShortUrl($ShortUrl)
5960
{
60-
global $table;
6161
global $connect;
62-
$sql = "SELECT * FROM $table WHERE shortUrl = :shortUrl;";
62+
$sql = "SELECT * FROM urls WHERE shortUrl = :shortUrl;";
6363
$stmt = $connect->prepare($sql);
64-
$stmt->execute([':shortUrl' => $ShortUrl]);
64+
$stmt->bindParam(':shortUrl', $ShortUrl,PDO::PARAM_STR);
65+
$stmt->execute();
6566
$result = $stmt->fetch(PDO::FETCH_ASSOC);
6667
$result = $result['url'];
6768
return $result;
@@ -70,11 +71,11 @@ function receiveShortUrl($ShortUrl)
7071
# Get Information About The Existence Of A Url
7172
function receiveUrl($Url)
7273
{
73-
global $table;
7474
global $connect;
75-
$sql = "SELECT * FROM $table WHERE url = :url;";
75+
$sql = "SELECT * FROM urls WHERE url = :url;";
7676
$stmt = $connect->prepare($sql);
77-
$stmt->execute([':url' => $Url]);
77+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
78+
$stmt->execute();
7879
$result = $stmt->fetch(PDO::FETCH_ASSOC);
7980
$result = $result['shortUrl'];
8081
return $result;
@@ -100,7 +101,7 @@ function alarm($mode, $message)
100101
title: '$message',
101102
icon: '$mode',
102103
toast: true,
103-
position: 'top-start',
104+
position: 'top-end',
104105
showConfirmButton: false,
105106
timer: 3500,
106107
timerProgressBar: true,

UrlShortner-Persian/config/config.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88
#----- Constants -----#
99

10-
const URL = 'http://HeroExpert.ir/UrlShortner-Persian/'; # File Location Url
10+
const URL = 'https://HeroExpert.ir/UrlShortner-Persian/'; # File Location Url
1111

1212
#----- DataBase -----#
1313

1414
$userName = 'root'; # DataBase Username
15-
$dbName = 'heroexpert_ir'; # DataBase Name
15+
$dbName = 'heroexpert'; # DataBase Name
1616
$passWord = ''; # DataBase password
17-
$table = 'urls'; # DataBase Table Name
1817

1918
try {
2019
$connect = new PDO('mysql:host=localhost;dbname=' . $dbName, $userName, $passWord);

UrlShortner-Persian/controller/helper.php

+16-15
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,48 @@ function shortUrlCreate()
2121
# Save The Url Information In The DataBase
2222
function saveUrl($Url, $shortUrl)
2323
{
24-
global $table;
2524
global $connect;
26-
$sql = "INSERT INTO $table (url,shortUrl) VALUES (:url,:shortUrl);";
25+
$sql = "INSERT INTO urls (url,shortUrl) VALUES (:url,:shortUrl);";
2726
$stmt = $connect->prepare($sql);
28-
$stmt->execute([':url' => $Url, ':shortUrl' => $shortUrl,]);
27+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
28+
$stmt->bindParam(':shortUrl', $shortUrl,PDO::PARAM_STR);
29+
$stmt->execute();
2930
$result = $stmt->rowCount();
3031
return $result;
3132
}
3233

3334
# Get Information About The Existence Of A ShortUrl
3435
function receiveShortUrlCount($Url)
3536
{
36-
global $table;
3737
global $connect;
38-
$sql = "SELECT * FROM $table WHERE shortUrl = :shortUrl;";
38+
$sql = "SELECT * FROM urls WHERE shortUrl = :shortUrl;";
3939
$stmt = $connect->prepare($sql);
40-
$stmt->execute([':shortUrl' => $Url]);
40+
$stmt->bindParam(':shortUrl', $Url,PDO::PARAM_STR);
41+
$stmt->execute();
4142
$result = $stmt->rowCount();
4243
return $result;
4344
}
4445

4546
# Get Information About The Existence Of A Url
4647
function receiveUrlCount($Url)
4748
{
48-
global $table;
4949
global $connect;
50-
$sql = "SELECT * FROM $table WHERE url = :url;";
50+
$sql = "SELECT * FROM urls WHERE url = :url;";
5151
$stmt = $connect->prepare($sql);
52-
$stmt->execute([':url' => $Url]);
52+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
53+
$stmt->execute();
5354
$result = $stmt->rowCount();
5455
return $result;
5556
}
5657

5758
# Get Information About The Existence Of A ShortUrl
5859
function receiveShortUrl($ShortUrl)
5960
{
60-
global $table;
6161
global $connect;
62-
$sql = "SELECT * FROM $table WHERE shortUrl = :shortUrl;";
62+
$sql = "SELECT * FROM urls WHERE shortUrl = :shortUrl;";
6363
$stmt = $connect->prepare($sql);
64-
$stmt->execute([':shortUrl' => $ShortUrl]);
64+
$stmt->bindParam(':shortUrl', $ShortUrl,PDO::PARAM_STR);
65+
$stmt->execute();
6566
$result = $stmt->fetch(PDO::FETCH_ASSOC);
6667
$result = $result['url'];
6768
return $result;
@@ -70,11 +71,11 @@ function receiveShortUrl($ShortUrl)
7071
# Get Information About The Existence Of A Url
7172
function receiveUrl($Url)
7273
{
73-
global $table;
7474
global $connect;
75-
$sql = "SELECT * FROM $table WHERE url = :url;";
75+
$sql = "SELECT * FROM urls WHERE url = :url;";
7676
$stmt = $connect->prepare($sql);
77-
$stmt->execute([':url' => $Url]);
77+
$stmt->bindParam(':url', $Url,PDO::PARAM_STR);
78+
$stmt->execute();
7879
$result = $stmt->fetch(PDO::FETCH_ASSOC);
7980
$result = $result['shortUrl'];
8081
return $result;

0 commit comments

Comments
 (0)