aboutsummaryrefslogtreecommitdiff
path: root/php/admin
diff options
context:
space:
mode:
Diffstat (limited to 'php/admin')
-rw-r--r--php/admin/index.php13
-rw-r--r--php/admin/locations.php10
-rw-r--r--php/admin/login.php4
-rw-r--r--php/admin/logout.php4
-rw-r--r--php/admin/mirror-list.php25
-rw-r--r--php/admin/mstats.php3
-rw-r--r--php/admin/os.php10
-rw-r--r--php/admin/products.php10
-rw-r--r--php/admin/pstats.php3
-rw-r--r--php/admin/regions.php11
-rw-r--r--php/admin/users.php10
11 files changed, 48 insertions, 55 deletions
diff --git a/php/admin/index.php b/php/admin/index.php
index 8c3db5c..e8feaec 100644
--- a/php/admin/index.php
+++ b/php/admin/index.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add mirror
if (!empty($_POST['add-submit'])) {
- if (mirror_insert_mirror($_POST['mirror_name'],$_POST['region_id'],$_POST['mirror_baseurl'],$_POST['mirror_rating'])) {
+ if (Mirror::insert_mirror($_POST['mirror_name'],$_POST['region_id'],$_POST['mirror_baseurl'],$_POST['mirror_rating'])) {
set_msg('Mirror added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_mirror($_POST['mirror_id'],$_POST['mirror_name'],$_POST['region_id'],$_POST['mirror_baseurl'],$_POST['mirror_rating'])) {
+ if (Mirror::update_mirror($_POST['mirror_id'],$_POST['mirror_name'],$_POST['region_id'],$_POST['mirror_baseurl'],$_POST['mirror_rating'])) {
set_msg('Mirror updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit Mirror</h2>';
- $posts = mirror_get_one_mirror($_POST['mirror_id']);
+ $posts = Mirror::get_one_mirror($_POST['mirror_id']);
form_start();
include_once(INC.'/forms/mirror.php');
form_hidden('doit','1');
@@ -49,14 +49,14 @@ if (!empty($_POST['submit'])) {
}
break;
case 'delete':
- if (mirror_delete_mirror($_POST['mirror_id'])) {
+ if (Mirror::delete_mirror($_POST['mirror_id'])) {
set_msg('Mirror deleted successfully.');
} else {
set_error('Mirror could not be deleted.');
}
break;
case 'toggle':
- if (mirror_toggle($_POST['mirror_id'])) {
+ if (Mirror::toggle($_POST['mirror_id'])) {
set_msg('Mirror enabled/disabled.');
} else {
set_error('Mirror could not be enabled/disabled.');
@@ -75,7 +75,7 @@ echo '<h2>Mirrors</h2>';
show_error();
show_msg();
-$mirrors = mirror_get_mirrors();
+$mirrors = Mirror::get_mirrors();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'mirror_active';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'ASC';
@@ -108,4 +108,3 @@ form_submit('add-submit','','button1','Add Mirror');
form_end();
require_once(FOOTER);
-?>
diff --git a/php/admin/locations.php b/php/admin/locations.php
index f1bb456..e868d1a 100644
--- a/php/admin/locations.php
+++ b/php/admin/locations.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add mirror
if (!empty($_POST['add-submit'])&&!empty($_POST['location_path'])) {
- if (mirror_insert_location($_POST['product_id'],$_POST['os_id'],$_POST['location_path'])) {
+ if (Mirror::insert_location($_POST['product_id'],$_POST['os_id'],$_POST['location_path'])) {
set_msg('Location added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/locations.php');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_location($_POST['location_id'],$_POST['product_id'],$_POST['os_id'],$_POST['location_path'])) {
+ if (Mirror::update_location($_POST['location_id'],$_POST['product_id'],$_POST['os_id'],$_POST['location_path'])) {
set_msg('Location updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/locations.php');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit Location</h2>';
- $posts = mirror_get_one_location($_POST['location_id']);
+ $posts = Mirror::get_one_location($_POST['location_id']);
form_start();
include_once(INC.'/forms/location.php');
form_hidden('doit','1');
@@ -49,7 +49,7 @@ if (!empty($_POST['submit'])) {
}
break;
case 'delete':
- if (mirror_delete_location($_POST['location_id'])) {
+ if (Mirror::delete_location($_POST['location_id'])) {
set_msg('Location deleted successfully.');
} else {
set_error('Location could not be deleted.');
@@ -68,7 +68,7 @@ echo '<h2>Locations</h2>';
show_error();
show_msg();
-$locations = mirror_get_locations();
+$locations = Mirror::get_locations();
$_GET['sort'] = (!empty($_GET['sort']))?$_GET['sort']:'product_name';
$_GET['order'] = (!empty($_GET['order']))?$_GET['order']:'ASC';
diff --git a/php/admin/login.php b/php/admin/login.php
index 5e9d4c3..455c556 100644
--- a/php/admin/login.php
+++ b/php/admin/login.php
@@ -9,8 +9,8 @@ require_once(LIB.'/auth.php');
// authenticate
if (!empty($_POST['submit'])) {
- if ($auth = auth_mysql($_POST['username'],$_POST['password'])) {
- auth_create_session($auth);
+ if ($auth = Auth::query($_POST['username'],$_POST['password'])) {
+ Auth::create_session($auth);
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/');
exit;
} else {
diff --git a/php/admin/logout.php b/php/admin/logout.php
index d980d9d..f876efe 100644
--- a/php/admin/logout.php
+++ b/php/admin/logout.php
@@ -6,7 +6,5 @@
*/
require_once('../cfg/init.php');
require_once(LIB.'/auth.php');
-auth_logout();
+Auth::logout();
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/login.php');
-exit;
-?>
diff --git a/php/admin/mirror-list.php b/php/admin/mirror-list.php
index c161efd..e0876d4 100644
--- a/php/admin/mirror-list.php
+++ b/php/admin/mirror-list.php
@@ -9,20 +9,20 @@ require_once('../cfg/init.php');
if (!empty($_GET['os'])&&!empty($_GET['product'])) {
// clean in os and product strings
- $os_name = mysql_real_escape_string(trim(strtolower($_GET['os'])));
- $product_name = mysql_real_escape_string(trim(strtolower($_GET['product'])));
+ $os_name = trim(strtolower(filter_input(INPUT_GET,'os')));
+ $product_name = trim(strtolower(filter_input(INPUT_GET,'product')));
// get os and product IDs
- $os_id = db_name_to_id('mirror_os','os_id','os_name',$os_name);
- $product_id = db_name_to_id('mirror_products','product_id','product_name',$product_name);
+ $os_id = DB::name_to_id('mirror_os','os_id','os_name',$os_name);
+ $product_id = DB::name_to_id('mirror_products','product_id','product_name',$product_name);
}
if (!empty($_GET['os_id'])&&!empty($_GET['product_id'])) {
- $os_id = intval($_GET['os_id']);
- $product_id = intval($_GET['product_id']);
+ $os_id = intval(filter_input(INPUT_GET,'os_id',FILTER_SANITIZE_NUMBER_INT));
+ $product_id = intval(filter_input(INPUT_GET,'product_id',FILTER_SANITIZE_NUMBER_INT));
- $mirrors = db_get("
+ $mirrors = DB::get("
SELECT DISTINCT
mirror_baseurl
FROM
@@ -36,11 +36,11 @@ if (!empty($_GET['os_id'])&&!empty($_GET['product_id'])) {
ON
mirror_location_mirror_map.location_id = mirror_locations.location_id
WHERE
- mirror_locations.os_id = {$os_id} AND
- mirror_locations.product_id = {$product_id} AND
+ mirror_locations.os_id = ? AND
+ mirror_locations.product_id = ? AND
mirror_location_mirror_map.location_active = '1' AND
mirror_mirrors.mirror_active = '1'
- ");
+ ", PDO::FETCH_ASSOC, [$os_id, $product_id]);
header("Content-type: text/plain;");
foreach ($mirrors as $mirror) {
@@ -58,17 +58,16 @@ if (!empty($_GET['os_id'])&&!empty($_GET['product_id'])) {
form_start('list','list','get','./mirror-list.php');
echo '<div>';
form_label('Product', 'product','label-small');
- form_select('product_id','product','',mirror_get_products_select(),$posts['product_id']);
+ form_select('product_id','product','',Mirror::get_products_select(),$posts['product_id']);
echo ' [<a href="./products.php">edit products</a>]';
echo '</div><br />';
echo '<div>';
form_label('OS', 'os','label-small');
- form_select('os_id','os','',mirror_get_oss_select(),$posts['os_id']);
+ form_select('os_id','os','',Mirror::get_oss_select(),$posts['os_id']);
echo ' [<a href="./os.php">edit operating systems</a>]';
echo '</div><br />';
form_submit('submit','','button1','Update');
form_end();
require_once(FOOTER);
}
-?>
diff --git a/php/admin/mstats.php b/php/admin/mstats.php
index 5778d16..284dcf4 100644
--- a/php/admin/mstats.php
+++ b/php/admin/mstats.php
@@ -12,7 +12,7 @@ $nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Mirror Statistics</h2>';
-$stats = mirror_get_mirror_stats();
+$stats = Mirror::get_mirror_stats();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'count';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'DESC';
@@ -29,4 +29,3 @@ $headers = array(
show_list($stats,$headers,'simple');
require_once(FOOTER);
-?>
diff --git a/php/admin/os.php b/php/admin/os.php
index b150245..72bb383 100644
--- a/php/admin/os.php
+++ b/php/admin/os.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add os
if (!empty($_POST['add-submit'])&&!empty($_POST['os_name'])) {
- if (mirror_insert_os($_POST['os_name'],$_POST['os_priority'])) {
+ if (Mirror::insert_os($_POST['os_name'],$_POST['os_priority'])) {
set_msg('OS added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/os.php');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_os($_POST['os_id'],$_POST['os_name'],$_POST['os_priority'])) {
+ if (Mirror::update_os($_POST['os_id'],$_POST['os_name'],$_POST['os_priority'])) {
set_msg('OS updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/os.php');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit OS</h2>';
- $posts = mirror_get_one_os($_POST['os_id']);
+ $posts = Mirror::get_one_os($_POST['os_id']);
form_start();
include_once(INC.'/forms/os.php');
form_hidden('doit','1');
@@ -49,7 +49,7 @@ if (!empty($_POST['submit'])) {
}
break;
case 'delete':
- if (!record_exists('mirror_locations','os_id',$_POST['os_id'])&&mirror_delete_os($_POST['os_id'])) {
+ if (!record_exists('mirror_locations','os_id',$_POST['os_id'])&&Mirror::delete_os($_POST['os_id'])) {
set_msg('OS deleted successfully.');
} else {
set_error('OS cannot be deleted because it is being used by a file location.');
@@ -69,7 +69,7 @@ echo '<h2>Operating Systems</h1>';
show_error();
show_msg();
-$oss = mirror_get_oss();
+$oss = Mirror::get_oss();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'os_name';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'ASC';
diff --git a/php/admin/products.php b/php/admin/products.php
index e93686f..a0d5187 100644
--- a/php/admin/products.php
+++ b/php/admin/products.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add product
if (!empty($_POST['add-submit'])&&!empty($_POST['product_name'])) {
- if (mirror_insert_product($_POST['product_name'],$_POST['product_priority'])) {
+ if (Mirror::insert_product($_POST['product_name'],$_POST['product_priority'])) {
set_msg('Product added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/products.php');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_product($_POST['product_id'],$_POST['product_name'],$_POST['product_priority'])) {
+ if (Mirror::update_product($_POST['product_id'],$_POST['product_name'],$_POST['product_priority'])) {
set_msg('Product updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/products.php');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit Product</h2>';
- $posts = mirror_get_one_product($_POST['product_id']);
+ $posts = Mirror::get_one_product($_POST['product_id']);
form_start();
include_once(INC.'/forms/product.php');
form_hidden('doit','1');
@@ -49,7 +49,7 @@ if (!empty($_POST['submit'])) {
}
break;
case 'delete':
- if (!record_exists('mirror_locations','product_id',$_POST['product_id'])&&mirror_delete_product($_POST['product_id'])) {
+ if (!record_exists('mirror_locations','product_id',$_POST['product_id'])&&Mirror::delete_product($_POST['product_id'])) {
set_msg('Product deleted successfully.');
} else {
set_error('Product cannot be deleted because it is being used by a file location.');
@@ -69,7 +69,7 @@ echo '<h2>Products</h1>';
show_error();
show_msg();
-$products = mirror_get_products();
+$products = Mirror::get_products();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'product_name';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'ASC';
diff --git a/php/admin/pstats.php b/php/admin/pstats.php
index e0b4aff..ef887bd 100644
--- a/php/admin/pstats.php
+++ b/php/admin/pstats.php
@@ -12,7 +12,7 @@ $nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Product Statistics</h2>';
-$stats = mirror_get_product_stats();
+$stats = Mirror::get_product_stats();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'count';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'DESC';
@@ -26,4 +26,3 @@ $headers = array(
show_list($stats,$headers,'simple');
require_once(FOOTER);
-?>
diff --git a/php/admin/regions.php b/php/admin/regions.php
index f42c0da..0709e43 100644
--- a/php/admin/regions.php
+++ b/php/admin/regions.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add region
if (!empty($_POST['add-submit'])&&!empty($_POST['region_name'])) {
- if (mirror_insert_region($_POST['region_name'],$_POST['region_priority'])) {
+ if (Mirror::insert_region($_POST['region_name'],$_POST['region_priority'])) {
set_msg('Region added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/regions.php');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_region($_POST['region_id'],$_POST['region_name'],$_POST['region_priority'])) {
+ if (Mirror::update_region($_POST['region_id'],$_POST['region_name'],$_POST['region_priority'])) {
set_msg('Region updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/regions.php');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit Region</h2>';
- $posts = mirror_get_one_region($_POST['region_id']);
+ $posts = Mirror::get_one_region($_POST['region_id']);
form_start();
include_once(INC.'/forms/region.php');
form_hidden('doit','1');
@@ -49,7 +49,7 @@ if (!empty($_POST['submit'])) {
}
break;
case 'delete':
- if (!record_exists('mirror_mirror_region_map','region_id',$_POST['region_id'])&&mirror_delete_region($_POST['region_id'])) {
+ if (!record_exists('mirror_mirror_region_map','region_id',$_POST['region_id'])&&Mirror::delete_region($_POST['region_id'])) {
set_msg('Region deleted successfully.');
} else {
set_error('Region cannot be deleted because it is linked to a mirror.');
@@ -69,7 +69,7 @@ echo '<h2>Regions</h2>';
show_error();
show_msg();
-$regions = mirror_get_regions();
+$regions = Mirror::get_regions();
$_GET['sort']=(!empty($_GET['sort']))?$_GET['sort']:'region_name';
$_GET['order']=(!empty($_GET['order']))?$_GET['order']:'ASC';
@@ -98,4 +98,3 @@ form_submit('add-submit','','button1','Add Region');
form_end();
require_once(FOOTER);
-?>
diff --git a/php/admin/users.php b/php/admin/users.php
index 3017c49..4926117 100644
--- a/php/admin/users.php
+++ b/php/admin/users.php
@@ -9,7 +9,7 @@ require_once('../cfg/init.php');
// add user
if (!empty($_POST['add-submit'])&&!empty($_POST['username'])&&!empty($_POST['password'])&&!empty($_POST['rpassword'])) {
- if (mirror_insert_user($_POST['username'],$_POST['password'],$_POST['rpassword'],$_POST['user_firstname'],$_POST['user_lastname'],$_POST['user_email'])) {
+ if (Mirror::insert_user($_POST['username'],$_POST['password'],$_POST['rpassword'],$_POST['user_firstname'],$_POST['user_lastname'],$_POST['user_email'])) {
set_msg('User added successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/users.php');
exit;
@@ -24,7 +24,7 @@ if (!empty($_POST['submit'])) {
switch($_POST['action']) {
case 'edit':
if (!empty($_POST['doit'])) {
- if (mirror_update_user($_POST['user_id'],$_POST['username'],$_POST['password'],$_POST['rpassword'],$_POST['user_firstname'],$_POST['user_lastname'],$_POST['user_email'])) {
+ if (Mirror::update_user($_POST['user_id'],$_POST['username'],$_POST['password'],$_POST['rpassword'],$_POST['user_firstname'],$_POST['user_lastname'],$_POST['user_email'])) {
set_msg('User updated successfully.');
header('Location: http://'.$_SERVER['HTTP_HOST'].WEBPATH.'/admin/users.php');
exit;
@@ -36,7 +36,7 @@ if (!empty($_POST['submit'])) {
$nav = INC.'/admin_nav.php';
require_once(HEADER);
echo '<h2>Edit User</h2>';
- $posts = mirror_get_one_user($_POST['user_id']);
+ $posts = Mirror::get_one_user($_POST['user_id']);
form_start();
include_once(INC.'/forms/user.php');
form_hidden('doit','1');
@@ -51,7 +51,7 @@ if (!empty($_POST['submit'])) {
case 'delete':
if ($_POST['user_id']==$_SESSION['user']['user_id']) {
set_error('You cannot delete yourself.');
- } elseif (mirror_delete_user($_POST['user_id'])) {
+ } elseif (Mirror::delete_user($_POST['user_id'])) {
set_msg('User deleted successfully.');
} else {
set_error('User could not be deleted because of an error.');
@@ -71,7 +71,7 @@ echo '<h2>Users</h2>';
show_error();
show_msg();
-$users = mirror_get_users();
+$users = Mirror::get_users();
$_GET['sort'] = (!empty($_GET['sort']))?$_GET['sort']:'user_lastname';
$_GET['order'] = (!empty($_GET['order']))?$_GET['order']:'ASC';