DropIn was developed using javascript technology too. Please enable javascript to get the website running properly.
Javascript not detected.
×
Hash Me!
Your *paches*
HTML
JS
PHP
SHELL
TCL-TK
XSLT
redirectWithStyle
[JS]
2024-10-12
21:13:18
#title: redirectWithStyle
#desc: redirect with a differnt day/night style
#tags: redirectWithStyle php function day night style
#cat:
JS
// Author: 5mode.com
// License: BSD
// Note: Please replace < and > accordingly
<?php if (SCRIPT_NAME === "home") { ?>
<script>
function isDay() {
retval = true;
const today = new Date();
if (today.getHours()<7 || today.getHours()>18) {
retval = false;
}
return retval;
}
function getTimestampInSec() {
var d = new Date();
timestamp = parseInt(d.getTime() / 1000);
return timestamp;
}
function redirectWithStyle() {
myhref = window.location.href;
userStyle = "<?php echo($userStyle);?>";
if ((myhref.indexOf("?")>0) && ((userStyle !== "startwithday"))) {
tspos = myhref.indexOf("&ts=");
// if a timestamp is passed on the url..
if (tspos) {
oldts = parseInt(myhref.substr(tspos+4));
curts = getTimestampInSec();
// if the current timestamp is already old, I refresh it..
if (curts > oldts) {
timeoutJS = getTimestampInSec() + <?php echo(SESSION_TIMEOUT - 90);?>;
myhref = myhref.substring(0, tspos) + "&ts="+timeoutJS;
window.open(myhref, "_self");
}
}
return;
}
if ((userStyle !== "") && (userStyle !== "startwithday")) {
hs=userStyle;
} else {
if (isDay()) {
hs="day";
} else {
hs="night";
}
}
timeoutJS = getTimestampInSec() + <?php echo(SESSION_TIMEOUT - 90);?>;
window.open("/" + "?hs=" +hs + "&ts=" + timeoutJS, '_self');
}
redirectWithStyle();
</script>
<?php } ?>
mytranslate
[JS]
2024-10-11
11:42:18
#title: mytranslate
#desc: client translation function in javascript
#tags: client translation js function
#cat:
JS
/**
* mytranslate
*
* Make the client translation of the current web page
*
* Context:
* - this function is for internal use in SqueeJS framework
*
* @returns {void}
*
* This function is part of SqueeJS.
*
* SqueeJS
* Author: 5mode.com
* License: MIT
*/
function mytranslate() {
this.getTranslitarates();
it=0;
for (ts of this.tranSource) {
nl = document.getElementsByTagName("H1");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("H2");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("H3");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("A");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("DIV");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("LABEL");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("SPAN");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
nl = document.getElementsByTagName("INPUT");
for (n of nl) {
n.value = n.value.replace(ts, this.tranDest[it]);
n.setAttribute("placeholder", n.getAttribute("placeholder").replace(ts, this.tranDest[it]));
}
nl = document.getElementsByTagName("TEXTAREA");
for (n of nl) {
n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
}
it++;
}
}
getBG
[PHP]
2024-10-11
11:15:19
#title: getBG
#desc: get a bg by a cookie with a random image
#tags: getbg php function bg cookie
#cat:
PHP
$cookie_cID = (string)Cookie::get("cid", PHP_STR);
function getBG(string $cookiecID): string
{
$bgVirtualPath = PHP_STR;
$bgFullPath = PHP_STR;
if ($cookiecID !== PHP_STR) {
$bgjpg = "./" . "bg" . PHP_SLASH . $cookiecID . ".jpg";
$bgpng = "./" . "bg" . PHP_SLASH . $cookiecID . ".png";
$bggif = "./" . "bg" . PHP_SLASH . $cookiecID . ".gif";
$bgjpgFullPath = (string)ImageUtil::getImageFullPath($bgjpg);
$bgpngFullPath = (string)ImageUtil::getImageFullPath($bgpng);
$bggifFullPath = (string)ImageUtil::getImageFullPath($bggif);
// if the small thumb jpg or png file exist..
if (file_exists($bgjpgFullPath)) {
$bgVirtualPath = $bgjpg;
$bgFullPath = $bgjpgFullPath;
} else if (file_exists($bgpngFullPath)) {
$bgVirtualPath = $bgpng;
$bgFullPath = $bgpngFullPath;
} else if (file_exists($bggifFullPath)) {
$bgVirtualPath = $bggif;
$bgFullPath = $bggifFullPath;
}
}
return $bgVirtualPath;
}
pcregrep
[SHELL]
2024-10-11
10:44:36
#title: pcregrep
#desc: regular expression facilitator (OpenBSD tested)
#tags: pcregrep shell script regexp
#cat:
SHELL
#!/bin/sh
# usage: regextr [exp]*
#
# eg:
# capt=(
# /capt=)
# etc.
#
# see your ~/.regextr for the complete syntax, or the code just below
#
# it can be used yet to compose expressions by piping.
#
# echo lol | pcregrep "`./regextr capt captname text /captname l repeated /capt`"
#
#
# Author: 5mode.com
# Source: https://github.com/par7133/tiny-tools/
# License: MIT
#
if [ "X$0" = "X" ]; then
echo "usage: regextr [exp]*"
exit
fi
if [ ! -e ~/.regextr ]; then
# creating default syntax file..
echo "exp=/" >>~/.regextr
echo "/exp=/" >>~/.regextr
echo "boundstart=^" >>~/.regextr
echo "boundend=$" >>~/.regextr
echo "capt=(" >>~/.regextr
echo "/capt=)" >>~/.regextr
echo "captor=|" >>~/.regextr
echo "captname=?" >>~/.regextr
echo "range=[" >>~/.regextr
echo "notrange=[^" >>~/.regextr
echo "/range=]" >>~/.regextr
echo "digit=\d" >>~/.regextr
echo "string=." >>~/.regextr
echo "word=\w" >>~/.regextr
echo "space=\s" >>~/.regextr
echo "notspace=\S" >>~/.regextr
echo "repeated=+" >>~/.regextr
echo "maybenot=?" >>~/.regextr
echo "quant={" >>~/.regextr
echo "quantsep=-" >>~/.regextr
echo "/quant=}" >>~/.regextr
fi
res=""
for exp in $@; do
test=`pcregrep ^$exp\= ~/.regextr | cut -d = -s -f 2`
if [ "X$test" = "X" ]; then
res=$res$exp
else
res=$res`pcregrep ^$exp\= ~/.regextr | cut -d = -s -f 2`
fi
done
echo $res
ren
[SHELL]
2024-10-10
23:43:30
#title: ren
#desc: shell script to rename portions of file system (OpenBSD tested)
#tags: file rename shell script
#cat:
SHELL
#!/bin/sh
# Software supplied AS-IS, use it at your own risk
# Author: 5mode.com
# Source: http://bsdload.com
mydir=`pwd`
read answer?"Current path = $mydir, do a recursive rename? [y/n] "
if [ ${answer} = 'n' ]; then
exit
fi
read spattern?"Search for: "
read dpattern?"Replace with: "
ii=0
for i in `find $mydir -name $spattern`; do
ii=`expr $ii + 1`
done
read answer?"Replace '$spattern'($ii) with '$dpattern' in '$mydir'? [y/n] "
if [ ${answer} = 'n' ]; then
exit
fi
for i in `find $mydir -name $spattern`; do
oripath=`dirname $i`
newpath="$oripath/$dpattern"
mv $i $newpath
echo "processed $newpath"
done
Button #1
×