299 lines
12 KiB
PHP
299 lines
12 KiB
PHP
<?php
|
|
/*
|
|
profile.php
|
|
OpenLog Online Logbook
|
|
Copyright (C) 2026 Rod Wright
|
|
|
|
SPDX-License-Identifier: GPL-2.0
|
|
*/
|
|
|
|
include("functions.php");
|
|
|
|
if (!isset($_SESSION['login'])) {
|
|
header ("Location: login.php");
|
|
}
|
|
$techid=$_SESSION['login'] ?? NULL;
|
|
$print=$_REQUEST['print'] ?? NULL;
|
|
$table=$_REQUEST['table'] ?? NULL;
|
|
$updateinfo=$_REQUEST['updateinfo'] ?? NULL;
|
|
$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL;
|
|
$setcolor=$_REQUEST['setcolor'] ?? NULL;
|
|
$name=$_REQUEST['name'] ?? NULL;
|
|
$pass=$_REQUEST['pass'] ?? NULL;
|
|
$passconf=$_REQUEST['passconf'] ?? NULL;
|
|
$shift=$_REQUEST['shift'] ?? NULL;
|
|
$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL;
|
|
$display_showts=$_REQUEST['display_showts'] ?? NULL;
|
|
$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL;
|
|
$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL;
|
|
$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL;
|
|
$modcolor=$_REQUEST['modcolor'] ?? NULL;
|
|
$hexcolor=$_REQUEST['hexcolor'] ?? NULL;
|
|
$resetcustom=$_REQUEST["resetcustom"] ?? NULL;
|
|
|
|
$logname=LOG_NAME;
|
|
|
|
if ($print) {
|
|
$sbcolor=P_SIDEBAR_COLOR;
|
|
$mbgcolor=P_MENUBG_COLOR;
|
|
} else {
|
|
$sbcolor=SIDEBAR_COLOR;
|
|
$mbgcolor=MENUBG_COLOR;
|
|
}
|
|
|
|
|
|
framework("begin","$logname","My Profile",$print);
|
|
|
|
pagetable("begin");
|
|
if(!$print){
|
|
pageblock("left","begin");
|
|
|
|
// ******** begin database manipulation ********
|
|
if ($updateinfo) {
|
|
// name shift password settings
|
|
// do error checking
|
|
// test for name supplied
|
|
if (strlen(trim($name))) {
|
|
$namesuppld=1;
|
|
} else {
|
|
$namesuppld=0;
|
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
|
}
|
|
// test for name unique
|
|
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
|
|
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) {
|
|
$nameunique=0;
|
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
|
} else {
|
|
$nameunique=1;
|
|
}
|
|
} else {
|
|
$nameunique=1;
|
|
}
|
|
// test for matching passwords
|
|
if ($pass!="password_is_unchanged") {
|
|
if ($pass==$passconf) {
|
|
$passmatch=1;
|
|
$passhash=password_hash($pass,PASSWORD_DEFAULT);
|
|
$namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
|
|
} else {
|
|
$passmatch=0;
|
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
|
}
|
|
} else {
|
|
$passmatch=1;
|
|
$namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\"";
|
|
}
|
|
if ($namesuppld && $nameunique && $passmatch) {
|
|
mysqli_query($db,$namepassupdqry);
|
|
mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\"");
|
|
}
|
|
}
|
|
if ($updatedisplay) {
|
|
// display settings
|
|
if ($display_showts) $display_showts=1; else $display_showts=0;
|
|
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0;
|
|
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0;
|
|
// test for urlchunk supplied
|
|
if (strlen(trim($display_urlchunk))) {
|
|
$chunksuppld=1;
|
|
} else {
|
|
$chunksuppld=0;
|
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
|
}
|
|
if ($chunksuppld) {
|
|
putsetting('url_chunk_size',$display_urlchunk,$techid);
|
|
putsetting('show_ts',$display_showts,$techid);
|
|
putsetting('tech_alpha',$display_techalpha,$techid);
|
|
putsetting('subj_alpha',$display_subjalpha,$techid);
|
|
putsetting('log_style',$display_logstyle,$techid);
|
|
}
|
|
}
|
|
if ($setcolor) {
|
|
// color settings
|
|
$hexcolor="#".ltrim($hexcolor);
|
|
putsetting($modcolor,$hexcolor,$techid);
|
|
}
|
|
if ($resetcustom) mysqli_query($db,"delete from customs where customtech=\"$techid\"");
|
|
|
|
sidemenu();
|
|
pageblock("left","end");
|
|
}
|
|
pageblock("right","begin");
|
|
// pull my current data from tables
|
|
$curname=dblookup($db,"techs","techid","techname",$techid);
|
|
$curshift=dblookup($db,"techs","techid","shift",$techid);
|
|
$pass=$passconf="password_is_unchanged";
|
|
// other values from customs
|
|
$curlchunk=getsetting('url_chunk_size',$techid)["value"];
|
|
$curts=getsetting('show_ts',$techid)["value"];
|
|
$curtdo=getsetting('tech_alpha',$techid)["value"];
|
|
$cursdo=getsetting('subj_alpha',$techid)["value"];
|
|
$curbgc=getsetting('background_color',$techid)["value"];
|
|
$cursbc=getsetting('sidebar_color',$techid)["value"];
|
|
$curmbgc=getsetting('menubg_color',$techid)["value"];
|
|
$curtc=getsetting('text_color',$techid)["value"];
|
|
$curlc=getsetting('link_color',$techid)["value"];
|
|
$curvlc=getsetting('vlink_color',$techid)["value"];
|
|
$curhc=getsetting('heading_color',$techid)["value"];
|
|
$curlogstyle=getsetting('log_style',$techid)["value"];
|
|
|
|
// show the form
|
|
echo "
|
|
<form method=\"post\" action=\"profile.php\">
|
|
<b>My Information</b><br><br>
|
|
<table border=\"0\">
|
|
<tr><td>
|
|
Tech Name (first and last name): <input type=\"text\" name=\"name\" size=\"40\" value=\"$curname\"><br><br>
|
|
Password: <input type=\"password\" name=\"pass\" size=\"40\" value=\"$pass\"><br><br>
|
|
Repeat Password: <input type=\"password\" name=\"passconf\" size=\"40\" value=\"$passconf\"><br><br>
|
|
<font size=\"-1\">Need a random password? </font>
|
|
";
|
|
$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12);
|
|
echo "
|
|
$rpw<br><br>
|
|
<b>Shift: </b>
|
|
<select name=\"shift\">
|
|
";
|
|
$shiftrow=mysqli_query($db,"select * from shifts");
|
|
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
|
|
if ($shiftitem["status"] == 1) {
|
|
if ($shiftitem["shiftid"]==$curshift) {
|
|
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
|
} else {
|
|
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
|
}
|
|
}
|
|
}
|
|
echo "
|
|
</select>
|
|
</td></tr>
|
|
</table>
|
|
<br>
|
|
<input type=\"submit\" name=\"updateinfo\" value=\"Update My Information\">
|
|
<input type=\"submit\" name=\"reset\" value=\"Reset Form\"><br><br>
|
|
<hr>
|
|
<b>My Display Preferences</b><br><br>
|
|
Log style (the look of the log notes display): <select name=\"display_logstyle\">
|
|
";
|
|
$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\"");
|
|
while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) {
|
|
if ($logstylerow["styleid"]==$curlogstyle) {
|
|
printf("<option value=\"%s\" selected>%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
|
|
} else {
|
|
printf("<option value=\"%s\">%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
|
|
}
|
|
}
|
|
echo "
|
|
</select><br><br>
|
|
URL Chunk Size (long URLs will be linewrapped at this many characters):
|
|
<input type=\"text\" name=\"display_urlchunk\" size=\"3\" value=\"$curlchunk\"><br><br>
|
|
Show timestamps in log notes:
|
|
";
|
|
if ($curts) {
|
|
echo "<input type=\"checkbox\" name=\"display_showts\" checked>";
|
|
} else {
|
|
echo "<input type=\"checkbox\" name=\"display_showts\">";
|
|
}
|
|
echo "
|
|
<br><br>
|
|
Techs display order:
|
|
";
|
|
if ($curtdo) {
|
|
echo "
|
|
<input type=\"radio\" name=\"display_techalpha\" value=\"a\" checked>Alphabetical order
|
|
|
|
<input type=\"radio\" name=\"display_techalpha\" value=\"d\">Database order
|
|
";
|
|
} else {
|
|
echo "
|
|
<input type=\"radio\" name=\"display_techalpha\" value=\"a\">Alphabetical order
|
|
|
|
<input type=\"radio\" name=\"display_techalpha\" value=\"d\" checked>Database order
|
|
";
|
|
}
|
|
echo "
|
|
<br><br>
|
|
Subjects display order:
|
|
";
|
|
if ($cursdo) {
|
|
echo "
|
|
<input type=\"radio\" name=\"display_subjalpha\" value=\"a\" checked>Alphabetical order
|
|
|
|
<input type=\"radio\" name=\"display_subjalpha\" value=\"d\">Database order
|
|
";
|
|
} else {
|
|
echo "
|
|
<input type=\"radio\" name=\"display_subjalpha\" value=\"a\">Alphabetical order
|
|
|
|
<input type=\"radio\" name=\"display_subjalpha\" value=\"d\" checked>Database order
|
|
";
|
|
}
|
|
echo "
|
|
<br><br>
|
|
<input type=\"submit\" name=\"updatedisplay\" value=\"Update My Display Preferences\">
|
|
<input type=\"submit\" name=\"reset\" value=\"Reset Form\"><br><br>
|
|
<hr>
|
|
<b>My Color Preferences</b><br><br>
|
|
";
|
|
switch($modcolor) {
|
|
case "background_color":
|
|
echo "<table border=\"0\"><tr><td>Page background color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "sidebar_color":
|
|
echo "<table border=\"0\"><tr><td>Sidebar color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=sidebar_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "menubg_color":
|
|
echo "<table border=\"0\"><tr><td>Menu background color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=menubg_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "text_color":
|
|
echo "<table border=\"0\"><tr><td>Normal text color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=text_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "link_color":
|
|
echo "<table border=\"0\"><tr><td>Link color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=link_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "vlink_color":
|
|
echo "<table border=\"0\"><tr><td>Visited link color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=vlink_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
case "heading_color":
|
|
echo "<table border=\"0\"><tr><td>Heading color</td><td>";
|
|
colorpicker("profile.php?setcolor=1&modcolor=heading_color&hexcolor=");
|
|
echo "</td></tr></table><hr>";
|
|
break;
|
|
}
|
|
echo "
|
|
<b>Select the color you'd like to change</b><br><br>
|
|
<table border=\"1\" cellpadding=\"10\">
|
|
<tr><td><a href=\"profile.php?modcolor=background_color\">Page background color</a></td><td bgcolor=\"$curbgc\"><font color=\"$curtc\">$curbgc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=sidebar_color\">Sidebar color</a></td><td bgcolor=\"$cursbc\"><font color=\"$curtc\">$cursbc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=menubg_color\">Menu background color</a></td><td bgcolor=\"$curmbgc\"><font color=\"$curlc\">$curmbgc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=text_color\">Normal text color</a></td><td bgcolor=\"$curbgc\"><font color=\"$curtc\">$curtc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=link_color\">Link color</a></td><td bgcolor=\"$curbgc\"><font color=\"$curlc\">$curlc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=vlink_color\">Visited link color</a></td><td bgcolor=\"$curbgc\"><font color=\"$curvlc\">$curvlc</font></td></tr>
|
|
<tr><td><a href=\"profile.php?modcolor=heading_color\">Heading color</a></td><td bgcolor=\"$curbgc\"><font color=\"$curhc\">$curhc</font></td></tr>
|
|
</table>
|
|
<br><hr>
|
|
<br>
|
|
<center><input type=\"submit\" name=\"resetcustom\" value=\"Reset All To Defaults\"></center>
|
|
</form>
|
|
";
|
|
|
|
pageblock("right","end");
|
|
pagetable("end");
|
|
|
|
framework("end","","",$print);
|
|
|
|
?>
|