Skip to content

Commit

Permalink
[24] Added admin-panel. Big update :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantet committed Jul 7, 2010
1 parent 307e82b commit 1ee8f45
Show file tree
Hide file tree
Showing 25 changed files with 423 additions and 57 deletions.
123 changes: 123 additions & 0 deletions addtype.php
@@ -0,0 +1,123 @@
<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" && isset($_POST['type']) && isset($_POST['input1']))
{
$type = intval($_POST['type']);
$input1 = $_POST['input1'];
$change = false;
$delete = false;

if(isset($_POST['input2']))
$input2 = $_POST['input2'];

if(isset($_POST['change']))
$change = $_POST['change'];

if(isset($_POST['delete']))
$delete = true;

require_once("config.php");
require_once("lib/classes.php");
$sql = new sql;
$main = new main;

if(!$change && !$delete)
{
switch($type)
{
case 1:
$query = "INSERT INTO `bt_priority` (`name`,`color`) VALUES ('".$input1."','".$input2."')";
break;
case 2:
$query = "INSERT INTO `bt_section` (`name`) VALUES ('".$input1."')";
break;
case 3:
$query = "INSERT INTO `bt_subtype` (`name`) VALUES ('".$input1."')";
break;
case 4:
$query = "INSERT INTO `bt_status` (`name`) VALUES ('".$input1."')";
break;
default:
$query = false;
}
}
else if(!$delete)
{
switch($type)
{
case 1:
$query = "UPDATE `bt_priority` SET `name` = '".$input1."', `color` = '".$input2."' WHERE `id` = '".$change."'";
break;
case 2:
$query = "UPDATE `bt_section` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
case 3:
$query = "UPDATE `bt_subtype` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
case 4:
$query = "UPDATE `bt_status` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
default:
$query = false;
}
}
else if($delete)
{
switch($type)
{
case 1:
$query = "DELETE FROM `bt_priority` WHERE `id` = '".$change."' LIMIT 1";
break;
case 2:
$query = "DELETE FROM `bt_section` WHERE `id` = '".$change."' LIMIT 1";
break;
case 3:
$query = "DELETE FROM `bt_subtype` WHERE `id` = '".$change."' LIMIT 1";
break;
case 4:
$query = "DELETE FROM `bt_status` WHERE `id` = '".$change."' LIMIT 1";
break;
default:
$query = false;
}
}
if($query)
{
if($delete)
{
$id = $main->GetPreviousElement($type,$change);
switch($type)
{
case 1:
$upd = "UPDATE `bt_message` SET `priority` = '".$id."' WHERE `priority` = '".$change."'";
break;
case 2:
$upd = "UPDATE `bt_options` SET `type` = '".$id."' WHERE `type` = '".$change."'";
break;
case 3:
$upd = "UPDATE `bt_options` SET `subtype` = '".$id."' WHERE `subtype` = '".$change."'";
break;
case 4:
$upd = "UPDATE `bt_message` SET `status` = '".$id."' WHERE `status` = '".$change."'";
break;
default:
$upd = false;
}
if($upd)
{
if(!$sql->exe($cfg->get("realmd"),$upd))
echo 'Ошибка переноса! MySQL код некорректен!';
}
else
echo 'Ошибка! Тип '.$type.' не опознан!';
}
if($sql->exe($cfg->get("realmd"),$query))
echo 1;
else
echo 'Ошибка! MySQL код некорректен!';
}
else
echo 'Ошибка! Тип '.$type.' не опознан!';
}
else
echo 'Параметры не переданы!';
?>
2 changes: 1 addition & 1 deletion config.php
Expand Up @@ -50,7 +50,7 @@ function get($id)
## installquery: Count of query for install. Do not change!
##################################################################################################*/
"CheckVersion" => false,
"version" => 23,
"version" => 24,
"checkdiff" => 2,
"installquery" => 212
);
Expand Down
Binary file added img/Thumbs.db
Binary file not shown.
Binary file added img/cancel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/check_mark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/noadd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/nocancel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/nocheck_mark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/nolens.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/noscissors.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/notrash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/onadd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/oncancel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/oncheck_mark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/onlens.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/onscissors.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/ontrash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/scissors.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 27 additions & 26 deletions lib/classes.php
Expand Up @@ -9,34 +9,34 @@ function num_rows($query);

interface create
{
public function SelectMessage($id);
public function SelectOptions($id);
public function GetNewId();
public function GetNameByGUID($guid);
public function GetAccountNameById($id);
public function GetSections();
public function GetPercent($id,$one=false);
public function GetPriority($id,$one=false);
public function GetStatus($id,$one=false);
public function GetDate($format);
function SelectMessage($id);
function SelectOptions($id);
function GetNewId();
function GetNameByGUID($guid);
function GetAccountNameById($id);
function GetSections();
function GetPercent($id,$one=false);
function GetPriority($id,$one=false);
function GetStatus($id,$one=false);
function GetDate($format);
function GetPreviousElement($type,$change);
function SetStatus($statusid=-1,$id=-1);

public function SetStatus($statusid=-1,$id=-1);
function LoadZones();
function LoadChar($acc);
function LoadStatus($id="0");
function LoadSection();
function LoadMap();
function LoadList($status="all");
function LoadPriority($id = "0");
function LoadView($id);
function LoadSubType();

public function LoadZones();
public function LoadChar($acc);
public function LoadStatus($id="0");
public function LoadSection();
public function LoadMap();
public function LoadList($status="all");
public function LoadPriority($id = "0");
public function LoadView($id);
public function LoadSubType();

public function login($login,$pass);
public function cookies($login,$pass);
public function AccountRepass($acc,$code);
public function isValidSection($id);
public function PercentList($id=0);
function login($login,$pass);
function cookies($login,$pass);
function AccountRepass($acc,$code);
function isValidSection($id);
function PercentList($id=0);
}

interface html
Expand All @@ -57,6 +57,7 @@ function login();
function success();
function inc($content);
function admin();
function adminconfig();
function CheckVersion();
function adminpanel();
function authorization($login,$pass);
Expand Down
64 changes: 46 additions & 18 deletions lib/create.php
Expand Up @@ -95,7 +95,29 @@ public function GetDate($format)
return date($format);
}
}


public function GetPreviousElement($type,$change)
{
$cfg = new config;
$sql = new sql;
switch($type)
{
case 1: $table='bt_priority';break;
case 2: $table='bt_section';break;
case 3: $table='bt_subtype';break;
case 4: $table='bt_status';break;
default: return;
}
$id = $sql->res($cfg->get("realmd"),"SELECT `id` FROM `".$table."` WHERE `id` < '".$change."' ORDER BY `id` DESC LIMIT 1");
if($id != -1)
return $id;
else
$id = $sql->res($cfg->get("realmd"),"SELECT `id` FROM `".$table."` WHERE `id` > '".$change."' ORDER BY `id` ASC LIMIT 1");
if($id != -1)
return $id;
return false;
}

public function SetStatus($statusid=-1,$id=-1)
{
$cfg = new config;
Expand Down Expand Up @@ -155,11 +177,10 @@ public function LoadStatus($id="0",$all="0")
$text = "";
while($row=$sql->fetch($query))
{
if($id > 0)
$attr = "";
if($id > "0")
if($row['id'] == $this->GetStatus($all,true))
$attr = "SELECTED";
else
$attr = "";
$text.= '<option '.$attr.' value="'.$row['id'].'">'.$row['name'].'</option>';
}
return $text;
Expand All @@ -170,10 +191,12 @@ public function LoadSection()
$cfg = new config;
$sql = new sql;
$query = $sql->exe($cfg->get("realmd"),"SELECT `id`,`name` FROM `bt_section` ORDER BY `id` ASC");
$text = '';
while($row=mysql_fetch_array($query))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
$text.= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
return $text;
}

public function LoadMap()
Expand Down Expand Up @@ -239,30 +262,35 @@ public function LoadList($status="all",$sort='')
return $sql->exe($cfg->get("realmd"),$query);
}

public function LoadPriority($id="0",$all="0")
public function LoadPriority($id="0",$all="0",$color="0")
{
$cfg = new config;
$sql = new sql;
$query = $sql->exe($cfg->get("realmd"),"SELECT `id`,`name` FROM `bt_priority` ORDER BY `id` ASC");
$query = $sql->exe($cfg->get("realmd"),"SELECT `id`,`name`,`color` FROM `bt_priority` ORDER BY `id` ASC");
$txt="";
while($row=mysql_fetch_array($query))

if($color == "color")
$clr = '<div id="PriorityColor" style="display:none;">';

while($row=$sql->fetch($query))
{
if($color == "color")
$clr.= $row['color'].'^';

$attr = "";
if($id > "0")
{
if($row['id'] == $this->GetPriority($all,true))
{
$attr = "SELECTED";
}
else
{
$attr = "";
}
}
$txt.= '<option '.$attr.' value="'.$row['id'].'">'.$row['name'].'</option>';
}
if($id > "0")
return $txt;
echo $txt;
if($color == "color")
{
$clr.= '</div>';
echo $clr;
}
return $txt;
}

public function LoadSubType()
Expand All @@ -275,7 +303,7 @@ public function LoadSubType()
{
$txt.= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
echo $txt;
return $txt;
}

public function LoadView($opt)
Expand Down

0 comments on commit 1ee8f45

Please sign in to comment.