Updated various files where the version number exists.

Continued work on templates.php.
This commit is contained in:
2026-02-10 22:18:42 -05:00
parent 85f6fc6f4a
commit c11ef1ad8c
28 changed files with 983 additions and 306 deletions

View File

@@ -2,7 +2,7 @@
/*
functions.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -181,17 +181,28 @@ function framework($option,$htmltitle,$pagetitle,$print) {
}
}).datepicker(\"setDate\", defdate);
function insertUrlAtCaret(outputAreaId, inputAreaId) {
var rawlinktext=document.getElementById(inputAreaId).value;
var url='<a href=\"' + rawlinktext.replace(/ /g,'\%20') + '\">' + rawlinktext + '</a>';
function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) {
var linktext=document.getElementById(inputTextAreaId).value;
var rawurltext=document.getElementById(inputUrlAreaId).value;
if (rawurltext=='') return;
var lastslashindex=rawurltext.lastIndexOf('/');
if (lastslashindex==rawurltext.length-1) {
rawurltext=rawurltext.slice(0, -1);
}
if (linktext=='' && rawurltext!= '') {
lastslashindex=rawurltext.lastIndexOf('/');
var lastpartofurl=rawurltext.substring(lastslashindex+1);
linktext=lastpartofurl;
}
var link='<a href=\"' + rawurltext.replace(/ /g,'\%20') + '\" target=\"_blank\">' + linktext + '</a>';
var txtarea = document.getElementById(outputAreaId);
var scrollPos = txtarea.scrollTop;
var caretPos = txtarea.selectionStart;
var front = (txtarea.value).substring(0, caretPos);
var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
txtarea.value = front + url + back;
caretPos = caretPos + url.length;
txtarea.value = front + link + back;
caretPos = caretPos + link.length;
txtarea.selectionStart = caretPos;
txtarea.selectionEnd = caretPos;
txtarea.focus();
@@ -311,6 +322,7 @@ function sidemenu($noprint=false) {
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
<tr><td align=\"center\"><a href=\"admin.php\" title=\"Control global settings. Must be an administrator.\"><b>Administration</b></a></td></tr>
<tr><td align=\"center\"><a href=\"profile.php\">My Profile</a></td></tr>
<tr><td align=\"center\"><a href=\"templates.php\">Manage Templates</a></td></tr>
</table>
";
if (!isset($_SESSION['login'])) {
@@ -375,8 +387,13 @@ function banner($print) {
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
// look up a single field in a database given a value for a single field
$out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""));
return($out_data[0]);
$dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"");
if (mysqli_num_rows($dbqry)) {
$out_data=mysqli_fetch_row($dbqry)[0];
} else {
$out_data=NULL;
}
return($out_data);
}
function calendar($year,$month,$day,$link_url) {
@@ -625,63 +642,53 @@ function islink($il_note) {
// determines if the argument is a link in a reference chain
// returns 1 if note is a link, 0 if not
global $db;
$il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\""));
if ($il_pq[0]=="") {
$il_hasprev=0;
} else {
$il_hasprev=1;
}
$il_sq=mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where refs like \"%$il_note%\""));
if ($il_sq) {
$il_hassubs=1;
} else {
$il_hassubs=0;
}
if($il_hassubs || $il_hasprev) {
$refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
if (mysqli_num_rows($refqry)) {
return 1;
} else {
return 0;
}
}
function generate_chain($chainlink) {
// generate a reference chain
// takes a single parameter, a noteid
// finds all notes that are members of a chain containing the supplied noteid
// returns a sorted array of all notes in chain
// returns a sorted array (chainarray) of all notes in chain
global $db;
$refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\"");
$nanote=array();
$narefs=array();
while ($allrefs=mysqli_fetch_row($refsqry)) {
$spltrefs=explode(",",$allrefs[1]);
$iptr=0;
while ($iptr<count($spltrefs)) {
array_push($nanote,$allrefs[0]);
array_push($narefs,$spltrefs[$iptr]);
$iptr=$iptr+1;
}
// create notes and refs arrays from the reflinks table
$notes=[];
$targets=[];
$linkqry=mysqli_query($db,"select noteid,target from reflinks where noteid is not null");
while ($link=mysqli_fetch_assoc($linkqry)) {
$notes[]=$link['noteid'];
$targets[]=$link['target'];
}
$chainarray=array($chainlink);
$results=array();
$mptr=0;
while($mptr<count($chainarray)) {
$nptr=0;
while($nptr<count($nanote)) {
if(($nanote[$nptr]==$chainarray[$mptr]) && ( ! in_array($narefs[$nptr],$chainarray))) {
array_push($chainarray,$narefs[$nptr]);
$chainarray=array(); // create the chainarray
$chainarray[]=$chainlink; // add the incoming noteid for which the chain should be generated
$captr=0; // chainarray pointer
while($captr<count($chainarray)) { // as long as the chainarray is growing
$nptr=0; // note pointer
// run through the notes array, adding all targets for this note to the chainarray
while($nptr<count($notes)) {
if(($notes[$nptr]==$chainarray[$captr]) && ( ! in_array($targets[$nptr],$chainarray))) {
$chainarray[]=$targets[$nptr];
}
$nptr=$nptr+1;
}
$rptr=0;
while($rptr<count($narefs)) {
if(($narefs[$rptr]==$chainarray[$mptr]) && ( ! in_array($nanote[$rptr],$chainarray))) {
array_push($chainarray,$nanote[$rptr]);
// run through the targets array, adding all notes for this target to the chainarray
$tptr=0; //target pointer
while($tptr<count($targets)) {
if(($targets[$tptr]==$chainarray[$captr]) && ( ! in_array($notes[$tptr],$chainarray))) {
$chainarray[]=$notes[$tptr];
}
$rptr=$rptr+1;
$tptr=$tptr+1;
}
$mptr=$mptr+1;
$captr=$captr+1;
}
// sort and return the output array
sort($chainarray);
return($chainarray);
}