0 Star 5 Fork 6

焦虑的羽毛 / p2_plan_team

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
admin.php 20.98 KB
一键复制 编辑 原始数据 按行查看 历史
programcj 提交于 2019-12-29 00:27 . V1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
<?php
require("./init.php");
$action = getArrayVal($_GET, "action");
$mode = getArrayVal($_GET, "mode");
$id = getArrayVal($_GET, "id");
$name = getArrayVal($_POST, "name");
$subtitle = getArrayVal($_POST, "subtitle");
$isadmin = getArrayVal($_POST, "isadmin");
$email = getArrayVal($_POST, "email");
$tel1 = getArrayVal($_POST, "tel1");
$tel2 = getArrayVal($_POST, "tel2");
$pass = getArrayVal($_POST, "pass");
$address1 = getArrayVal($_POST, "address1");
$address2 = getArrayVal($_POST, "address2");
$tags = getArrayVal($_POST, "tags");
$state = getArrayVal($_POST, "state");
$country = getArrayVal($_POST, "country");
$locale = getArrayVal($_POST, "locale");
$desc = getArrayVal($_POST, "desc");
$end = getArrayVal($_POST, "end");
$start = getArrayVal($_POST, "start");
$assign = getArrayVal($_POST, "assignme");
$assignto = getArrayVal($_POST, "assignto");
$language = getArrayVal($_POST, "language");
$timezone = getArrayVal($_POST, "timezone");
$dateformat = getArrayVal($_POST, "dateformat");
$templ = getArrayVal($_POST, "template");
$redir = getArrayVal($_GET, "redir");
$turl = getArrayVal($_POST, "web");
$gender = getArrayVal($_POST, "gender");
$zip = getArrayVal($_POST, "zip");
$newpass = getArrayVal($_POST, "newpass");
$repeatpass = getArrayVal($_POST, "repeatpass");
$rate = getArrayVal($_POST, "rate");
$budget = getArrayVal($_POST, "budget");
$role = getArrayVal($_POST, "role");
$rssuser = getArrayVal($_POST, "rssuser");
$rsspass = getArrayVal($_POST, "rsspass");
$accesskey = $_SESSION['genaccesskey'];//getArrayVal($_POST, "accesskey");
$company = getArrayVal($_POST, "company");
$client_id = getArrayVal($_POST, "client_id");
$client_name = getArrayVal($_POST, "client_name");
$template->assign("mode", $mode);
// get the available languages
$languages = getAvailableLanguages();
$template->assign("languages", $languages);
$user = new user();
$project = new project();
$theset = new settings();
$clientobj = new client();
$mainclasses = array("desktop" => "",
"profil" => "",
"admin" => "active"
);
$template->assign("mainclasses", $mainclasses);
// get admin client
$client_admin = $user->getProfileField($userid, "client_id");
if (!($userpermissions["admin"]["add"] || $action=="addpro" ||
(in_array($action, array("users")) && ($userpermissions["user"]["add"] || $userpermissions["user"]["edit"] || $userpermissions["user"]["del"])) ||
(in_array($action, array("adduser")) && $userpermissions["user"]["add"]) ||
(in_array($action, array("editform", "edituser")) && $userpermissions["user"]["edit"]) ||
(in_array($action, array("deleteuserform", "deleteuser")) && $userpermissions["user"]["del"])
)
){
$errtxt = $langfile["nopermission"];
$noperm = $langfile["accessdenied"];
$template->assign("errortext", "$errtxt<br>$noperm");
$template->display("error.tpl");
die();
}
if ($action == "index")
{
$classes = array("overview" => "overview_active",
"system" => "system",
"users" => "users"
);
$template->assign("classes", $classes);
$title = $langfile['admin'];
$template->display("admin.tpl");
} elseif ($action == "users")
{
$classes = array("overview" => "overview",
"system" => "system",
"users" => "active"
);
$template->assign("classes", $classes);
$users = $user->getAllUsers(14);
$projects = $project->getProjects(1, 10000);
$roleobj = (object) new roles();
$roles = $roleobj->getAllRoles();
$i2 = 0;
if (!empty($users))
{
foreach($users as $usr)
{
$i = 0;
if (!empty($projects))
{
foreach ($projects as $pro)
{
$chk = chkproject($usr["ID"], $pro["ID"]) ? 1 : 0;
$projects[$i]['assigned'] = $chk;
$i = $i + 1;
}
}
$users[$i2]['projects'] = $projects;
if (!empty($users[$i2]['lastlogin']))
{
$users[$i2]["lastlogin"] = date("d.m.y / H:i:s", $users[$i2]['lastlogin']);
}
$i2 = $i2 + 1;
}
}
$title = $langfile['useradministration'];
$template->assign("title", $title);
SmartyPaginate::assign($template);
$template->assign("users", $users);
$template->assign("projects", $projects);
$template->assign("roles", $roles);
if($userpermissions["admin"]["root"]) {
$template->assign("clients", $clientobj->getAllClients());
}
$template->assign("add_enabled", $clientobj->enabledAddUsers($userid));
$template->display("adminusers.tpl");
} elseif ($action == "adduser")
{
if(!$clientobj->enabledAddUsers($userid)) {
header("Location: admin.php?action=users");
exit;
}
$thetag = new tags();
$tags = $thetag->formatInputTags($tags);
$admin = $isadmin;
if (!isset($admin))
{
$admin = 1;
}
$sysloc = $settings["locale"];
$newid = $user->add($name, $email, $company, $pass, $sysloc, $tags, $rate);
if ($newid)
{
if (!empty($assignto))
{
foreach ($assignto as $proj)
{
$project->assign($newid, $proj);
}
}
$roleobj = (object) new roles();
if(!$userpermissions["admin"]["root"] && $role<2)
$role = 2;
if(!$userpermissions["admin"]["add"] && $role<3)
$role = 3;
$roleobj->assign($role, $newid);
if($userpermissions["admin"]["root"]){
if($client_name!="") {
$client_id = $clientobj->add($client_name);
}
} else{
$client_id = $client_admin;
}
$clientobj->assign($client_id, $newid);
if ($settings["mailnotify"])
{
if (!empty($email))
{
// send email
$themail = new emailer($settings);
$themail->send_mail($email, $langfile["profileaddedsubject"] , $langfile["profileaddedtext"] . "<br /><br />" . $langfile["profileusername"] . ":&nbsp;" . "$email<br />" . $langfile["profilepass"] . ":&nbsp;" . "$pass<br /><br />" . "<a href = \"$url\">$url</a>");
}
}
header("Location: admin.php?action=users&mode=added");
}
else
{
$goback = $langfile["goback"];
$endafterstart = $langfile["endafterstart"];
$template->assign("errortext", "The email address $email or the username $name already exists in the Userdatabase.<br>$goback");
$template->display("error.tpl");
}
} elseif ($action == "editform")
{
if(!$userpermissions["admin"]["root"] && $client_admin!=$user->getProfileField($id, "client_id")) {
header("Location: admin.php?action=users");
exit;
}
$languages_fin = array();
foreach($languages as $lang)
{
$lang2 = $langfile[$lang];
$fin = countLanguageStrings($lang);
if (!empty($lang2))
{
$lang2 .= " (" . $fin . "%)";
$fin = array("val" => $lang, "str" => $lang2);
}
else
{
$lang2 = $lang . " (" . $fin . "%)";
$fin = array("val" => $lang, "str" => $lang2);
}
array_push($languages_fin, $fin);
}
$template->assign("languages_fin", $languages_fin);
$roleobj = (object) new roles();
$user = $user->getProfile($id);
$title = $langfile['useradministration'];
$template->assign("title", $title);
$template->assign("user", $user);
$template->assign("roles", $roleobj->getAllRoles());
$template->assign("clients", $clientobj->getAllClients());
$template->display("edituseradminform.tpl");
} elseif ($action == "edituser")
{
if(!$userpermissions["admin"]["root"] && $client_admin!=$user->getProfileField($id, "client_id")) {
header("Location: admin.php?action=users");
exit;
}
$thetag = new tags();
$tags = $thetag->formatInputTags($tags);
$roleobj = new roles();
$roleobj->assign($role, $id);
if($userpermissions["admin"]["root"]){
$clientobj->assign($client_id, $id);
}
if ($id == $userid)
{
$_SESSION['userlocale'] = $locale;
$_SESSION['username'] = $name;
}
if (!isset($isadmin))
{
$isadmin = 1;
}
if (!empty($_FILES['userfile']['name']))
{
$fname = $_FILES['userfile']['name'];
$typ = $_FILES['userfile']['type'];
$size = $_FILES['userfile']['size'];
$tmp_name = $_FILES['userfile']['tmp_name'];
$error = $_FILES['userfile']['error'];
$root = "./";
$desc = $_POST['desc'];
$teilnamen = explode(".", $fname);
$teile = count($teilnamen);
$workteile = $teile - 1;
$erweiterung = $teilnamen[$workteile];
$subname = "";
if ($typ != "image/jpeg" and $typ != "image/png" and $typ != "image/gif")
{
$loc = $url . "manageuser.php?action=profile&id=$userid";
header("Location: $loc");
die();
}
for ($i = 0; $i < $workteile; $i++)
{
$subname .= $teilnamen[$i];
}
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$randval = rand(1, 999999);
$subname = preg_replace("/[^-_0-9a-zA-Z]/", "_", $subname);
$subname = preg_replace("/\W/", "", $subname);
if (strlen($subname) > 200)
{
$subname = substr($subname, 0, 200);
}
$fname = $subname . "_" . $randval . "." . $erweiterung;
$clientobj = new client();
$clientpath = $clientobj->getClientPath($userid);
if(!file_exists(CL_ROOT . "/files/" . CL_CONFIG . "$clientpath/avatar"))
mkdir(CL_ROOT . "/files/" . CL_CONFIG . "$clientpath/avatar");
$datei_final = CL_ROOT . "/files/" . CL_CONFIG . "$clientpath/avatar/" . $fname;
if (move_uploaded_file($tmp_name, $datei_final))
{
$avatar = $fname;
}
if ($user->edit($id, $name, "" , $email, $tel1, $tel2, $company, $zip, $gender, $turl, $address1, $address2, $state, $country, $tags, $locale, $avatar, $rate))
{
if (!empty($newpass) and !empty($repeatpass))
{
$user->admin_editpass($id, $newpass, $repeatpass);
}
header("Location: admin.php?action=users&mode=edited");
}
}
else
{
if ($user->edit($id, $name, "", $email, $tel1, $tel2, $company, $zip, $gender, $turl, $address1, $address2, $state, $country, $tags, $locale, "", $rate))
{
if (!empty($newpass) and !empty($repeatpass))
{
$user->admin_editpass($id, $newpass, $repeatpass);
}
header("Location: admin.php?action=users&mode=edited");
}
}
} elseif ($action == "deleteuserform")
{
if(!$userpermissions["admin"]["root"] && $client_admin!=$user->getProfileField($id, "client_id")) {
header("Location: admin.php?action=users");
exit;
}
$usr = $user->getProfile($id);
// Get user's projects
$proj = new project();
$projects = $proj->getMyProjects($id);
// Get members of each project
if (!empty($projects))
{
for ($i = 0; $i < count($projects); $i++)
{
$members = $proj->getProjectMembers($projects[$i]["ID"]);
$projects[$i]["members"] = $members;
}
$title = $langfile["deleteuser"];
$template->assign("title", $title);
$template->assign("user", $usr);
$template->assign("projects", $projects);
$template->display("admindeluserform.tpl");
}
else
{
if ($user->del($id))
{
header("Location: admin.php?action=users&mode=deleted");
}
}
} elseif ($action == "deleteuser")
{
if(!$userpermissions["admin"]["root"] && $client_admin!=$user->getProfileField($id, "client_id")) {
header("Location: admin.php?action=users");
exit;
}
$id = getArrayVal($_POST, "id");
$uprojects = getArrayVal($_POST, "uprojects");
$proarr = array();
foreach($uprojects as $upro)
{
$dat = explode("#", $upro);
$todo = array("project" => $dat[0], "user" => $dat[1]);
array_push($proarr, $todo);
}
if (!empty($proarr))
{
$task = new task();
foreach($proarr as $proj)
{
$tasks = $task->getAllMyProjectTasks($proj["project"], 100, $id);
if ($proj["project"] > 0 and $proj["user"] > 0)
{
if (!empty($tasks))
{
foreach($tasks as $mytask)
{
if ($task->deassign($mytask["ID"], $id))
{
$task->assign($mytask["ID"], $proj["user"]);
}
}
}
}
else
{
if (!empty($tasks))
{
foreach($tasks as $mytask)
{
$task->del($mytask["ID"]);
}
}
}
}
}
if ($user->del($id))
{
header("Location: admin.php?action=users&mode=deleted");
}
} elseif ($action == "assignform")
{
$projects = $project->getProjects(1, 10000);
$i = 0;
foreach ($projects as $project)
{
if (chkproject($id, $project[ID]))
{
$chk = 1;
}
else
{
$chk = 0;
}
$projects[$i]['assigned'] = $chk;
$i = $i + 1;
}
$template->assign("projects", $projects);
$user = $user->getProfile($id);
$template->assign("user", $user);
$template->display("assignform.tpl");
} elseif ($action == "massassign")
{
$projects = $_POST['projects'];
$user = $_POST['id'];
$allprojects = $project->getProjects(1, 10000);
$allpro = array();
foreach($allprojects as $pro)
{
array_push($allpro, $pro[ID]);
}
if (!empty($allpro) and !empty($projects))
{
$diff = array_diff($allpro, $projects);
} elseif (empty($projects))
{
$diff = $allpro;
}
if (!empty($projects))
{
foreach($projects as $pro)
{
if (!chkproject($user, $pro))
{
if ($settings["mailnotify"])
{
$usr = (object) new user();
$tuser = $usr->getProfile($user);
if (!empty($tuser["email"]))
{
// send email
$themail = new emailer($settings);
$themail->send_mail($tuser["email"], $langfile["projectassignedsubject"] , $langfile["hello"] . ",<br /><br/>" . $langfile["projectassignedtext"] . " <a href = \"" . $url . "manageproject.php?action=showproject&id=$pro\">" . $url . "manageproject.php?action=showproject&id=$pro</a>");
}
}
$project->assign($user, $pro);
}
}
}
if (!empty($diff))
{
foreach($diff as $mydiff)
{
$project->deassign($user, $mydiff);
}
}
header("Location: admin.php?action=users&mode=de-assigned");
}
elseif ($action == "projects")
{
$classes = array("overview" => "active",
"system" => "system",
"users" => "users"
);
$title = $langfile['projectadministration'];
$template->assign("title", $title);
$template->assign("classes", $classes);
$opros = $project->getProjects(1, 10000);
$clopros = $project->getProjects(0, 10000);
$i = 0;
$users = $user->getAllUsers(1000000);
if (!empty($opros))
{
foreach($opros as $opro)
{
$membs = $project->getProjectMembers($opro["ID"], 1000);
$opros[$i]['members'] = $membs;
$i = $i + 1;
}
$template->assign("opros", $opros);
}
$template->assign("users", $users);
$template->assign("clopros", $clopros);
$template->assign("add_enabled", $clientobj->enabledAddProjects($userid));
$template->display("adminprojects.tpl");
}
elseif ($action == "addpro")
{
if(!$clientobj->enabledAddProjects($userid)) {
header("Location: admin.php?action=projects");
exit;
}
if (!$userpermissions["projects"]["add"])
{
$errtxt = $langfile["nopermission"];
$noperm = $langfile["accessdenied"];
$template->assign("errortext", "$errtxt<br>$noperm");
$template->display("error.tpl");
die();
}
if (!$end)
{
$end = 0;
}
$add = $project->add($name, $desc, $end, $budget, 0, $start, $accesskey);
if ($add)
{
foreach ($assignto as $member)
{
$project->assign($member, $add);
}
if($userpermissions["admin"]["add"])
{
header("Location: admin.php?action=projects&mode=added");
}
else
{
header("Location: index.php?mode=projectadded");
}
}
} elseif ($action == "closepro")
{
if ($project->close($id))
{
echo "ok";
// header("Location: admin.php?action=projects&mode=closed");
}
} elseif ($action == "openpro")
{
if ($project->open($id))
{
header("Location: admin.php?action=projects&mode=opened");
}
} elseif ($action == "deletepro")
{
if ($project->del($id))
{
// header("Location: admin.php?action=projects&mode=deleted");
echo "ok";
}
} elseif ($action == "system")
{
$classes = array("overview" => "overview",
"system" => "active",
"users" => "users"
);
$languages_fin = array();
foreach($languages as $lang)
{
$lang2 = $langfile[$lang];
$fin = countLanguageStrings($lang);
if (!empty($lang2))
{
$lang2 .= " (" . $fin . "%)";
$fin = array("val" => $lang, "str" => $lang2);
}
else
{
$lang2 = $lang . " (" . $fin . "%)";
$fin = array("val" => $lang, "str" => $lang2);
}
array_push($languages_fin, $fin);
}
$msgcount = getArrayVal($_GET, "msg");
$peoplecount = getArrayVal($_GET, "peop");
$procount = getArrayVal($_GET, "pro");
$taskcount = getArrayVal($_GET, "tsk");
$template->assign("msgcount", $msgcount);
$template->assign("peoplecount", $peoplecount);
$template->assign("procount", $procount);
$template->assign("taskcount", $taskcount);
$template->assign("languages_fin", $languages_fin);
$title = $langfile["systemadministration"];
$template->assign("title", $title);
$template->assign("classes", $classes);
$sets = $theset->getSettings();
$templates = $theset->getTemplates();
$template->assign("settings", $sets);
$timezones = DateTimeZone::listIdentifiers();
$template->assign("timezones", $timezones);
$template->assign("templates", $templates);
$template->display("editsettings.tpl");
} elseif ($action == "editsets")
{
if ($theset->editSettings($name, $subtitle, $locale, $timezone, $dateformat, $templ, $rssuser, $rsspass))
{
$handle = opendir($template->compile_dir);
while (false !== ($file = readdir($handle)))
{
if ($file != "." and $file != "..")
{
unlink(CL_ROOT . "/" . $template->compile_dir . "/" . $file);
}
}
$_SESSION["userlocale"] = $locale;
$users = $user->getAllUsers(100000);
foreach($users as $theuser)
{
// set the new locale for all the users
$user->edit($theuser["ID"], $theuser["name"], $theuser["realname"], $theuser["email"], $theuser["tel1"], $theuser["tel2"], $theuser["company"], $theuser["zip"], $theuser["gender"], $theuser["url"], $theuser["adress"], $theuser["adress2"], $theuser["state"], $theuser["country"], $theuser["tags"], $locale, "", $theuser["rate"]);
}
header("Location: admin.php?action=system&mode=edited");
}
} elseif ($action == "editmailsets")
{
$status = getArrayVal($_POST, "mailstatus");
$mailfrom = getArrayVal($_POST, "mailfrommail");
$mailfromname = getArrayVal($_POST, "mailfromname");
$method = getArrayVal($_POST, "mailmethod");
$server = getArrayVal($_POST, "server");
$mailuser = getArrayVal($_POST, "mailuser");
$mailpass = getArrayVal($_POST, "mailpass");
if ($theset->editMailsettings($status, $mailfrom, $mailfromname, $method, $server, $mailuser, $mailpass))
{
header("Location: admin.php?action=system&mode=edited");
}
}
?>
PHP
1
https://gitee.com/programcj/p2_plan_team.git
git@gitee.com:programcj/p2_plan_team.git
programcj
p2_plan_team
p2_plan_team
1.4

搜索帮助