Commit 8788ae8a authored by kernelpanic's avatar kernelpanic

/var/www komplett in git

parent 5ab65440
<?php
$BYPASSLOGIN=true;
function backButton()
{
print <<<EOF
<p>
<input type="button" name="back" id="button" class="myButton" value="zurück" onClick="document.location.href = '/'"/>
</p>
EOF;
}
function wrongPassword($res)
{
require_once "header.inc";
print <<<EOF
</head>
<body>
<div class="css_page" id="page">
Wrong Username or Password:
EOF;
print "<p>";
echo $res;
print "</p>";
backButton();
}
function ldapError()
{
require_once "header.inc";
print <<<EOF
</head>
<body>
<div class="css_page" id="page">
LDAP server error, cannot connect
EOF;
backButton();
}
function checkAllowed ($user)
{
global $BYPASSLOGIN;
if ($BYPASSLOGIN) return true; //!!!
$test_user=strtolower($user);
$allowed_file="/var/tmp/allowed.acl";
$f=fopen("$allowed_file","r");
$access=false;
while (($buffer = fgets($f, 4096)) !== false) {
$allowed_user=strtolower(trim ($buffer));
if ($allowed_user==$test_user) { $access=true; }
}
fclose ($f);
return $access;
}
session_start();
// username and password sent from form
$myusername=$_REQUEST['myusername'];
$mypassword=$_REQUEST['mypassword'];
if (!$BYPASSLOGIN) { //!!!
##$ldap_host="ldap://192.168.1.21";
$ldap_host="ldap://ldap.lan";
##$ldap_dn="cn=".$myusername.",cn=users,dc=cf,dc=cfvpn";
$ldap_dn="uid=".$myusername.",ou=users,dc=cccmz,dc=de";
$ldap=ldap_connect ($ldap_host);
if (!$ldap) {
header("location:ldap_error.php?code=1");
exit (0);
}
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
$login_success=ldap_bind ($ldap , $ldap_dn, $mypassword);
if (!$login_success) {
if (ldap_get_option($ldap, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
$res="Error Binding to LDAP: $extended_error";
} else {
$res="Error Binding to LDAP: No additional information is available.";
}
}
} else {
$login_success=true;
}
if($login_success && checkAllowed($myusername)){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['username']="$myusername";
$_SESSION['password']="$mypassword";
header("location:login_success.php");
} else {
wrongPassword($res);
}
ob_end_flush();
?>
<?php
exec("sudo /opt/cftools/lock-door");
?>
www/close.png

2.85 KB | W: | H:

www/close.png

2.18 KB | W: | H:

www/close.png
www/close.png
www/close.png
www/close.png
  • 2-up
  • Swipe
  • Onion skin
function submit()
{
document.login.submit();
}
This diff is collapsed.
<?php
$fields = array(
'cmd' => urlencode("status"),
'prm' => urlencode(""),
);
$fields_string="";
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
## wget -qO - --post-data=cmd=fullclose http://192.168.1.177/req
$status_file="/run/status.xml";
$xml=simplexml_load_file ("$status_file");
##$xml = new SimpleXMLElement($result) or die("Error: Cannot create object");
if (!$xml) { exit (0); }
if (intval($xml->dooropen)) { $dooropen="Tür steht offen"; } else { $dooropen="Tür ist geschlossen"; }
if (intval($xml->handle)) { $handle="Türklinke ist gedrückt"; } else { $handle="Türklinke ist nicht gedrückt"; }
if (intval($xml->unlocked)) { $unlocked="Aufgeschlossen"; } else { $unlocked="Nicht aufgeschlossen"; }
if (intval($xml->lock)) { $lock="Es ist abgeschlossen"; } else { $lock="Es ist nicht abgeschlossen"; }
if (intval($xml->hallsensor)) { $hallsensor="Motor läuft"; } else { $hallsensor="Motor steht"; }
if (!intval($xml->cable)) { $cable="Kabel ist ok"; } else { $cable="FATAL: Kabelbruch"; }
$msg=(string)$xml->msg;
$heartbeat=(string)$xml->heartbeat;
$disable_open=false;
$disable_close=false;
$disable_all=(intval($xml->dooropen)==1) || (intval($xml->handle)==1) || (intval($xml->cable)!=0);
if ($disable_all) {
$disable_open=true;
$disable_close=true;
} else {
if ((intval($xml->unlocked)==1) && (intval($xml->lock)==0)) { $disable_open=true; }
if ((intval($xml->unlocked)==0) && (intval($xml->lock)==1)) { $disable_close=true; }
}
/*
<handle>0</handle>
<unlocked>0</unlocked>
<hallsensor>0</hallsensor>
<cable>0</cable>
<lock>1</lock>
<dooropen>1</dooropen>
<msg>OK</msg>
<heartbeat>4568290</heartbeat>
*/
$arr = array(
'dooropen' => $dooropen,
'handle' => $handle,
'unlocked' => $unlocked,
'lock' => $lock,
'hallsensor' => $hallsensor,
'cable' => $cable,
'msg' => $msg,
'heartbeat' => $heartbeat,
'disable_open' => $disable_open,
'disable_close' => $disable_close,
);
echo json_encode($arr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="de" xml:lang="de">
<head>
<meta charset="UTF-8" />
<title>&#91;&#91;&#91;&nbsp;&#124;&#124;&#124;&#47;&nbsp;&#124;&#124;&#124;&#124;</title>
<link rel="shortcut icon" href="favicon.png" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<meta name="robots" content="index,follow" />
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no" />
<link rel="apple-touch-icon-precomposed" sizes="512x512" type="image/png" href="apple-touch-icon-512x512-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" type="image/png" href="apple-touch-icon-152x152-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" type="image/png" href="apple-touch-icon-120x120-precomposed.png" />
<script src="jquery.js" type="text/javascript" charset="UTF-8"></script>
<script src="exec.js" type="text/javascript" charset="UTF-8"></script>
var HeaderGuard;
if (!HeaderGuard)
{
HeaderGuard = window.onload = function ()
{
/* Does not open Links in the built-in Browser */
function changeLinkBehavior()
{
var a = document.getElementsByTagName("a");
for (var i = 0; i < a.length; i++)
{
a[i].onclick = function ()
{
window.location = this.getAttribute("href");
return false
}
}
}
/* Hides Address Bar when used in Browser */
function hideAddressBar()
{
window.scrollTo(0, 0.9)
}
HeaderGuard.init = function ()
{
changeLinkBehavior();
hideAddressBar()
};
HeaderGuard.init()
}
}
<?php
require_once "header.inc";
?>
</head>
<body>
<div class="css_page" id="page">
<div id="header">CCCMZ</div>
<form name="login" id="login" method="post" action="checklogin.php">
<fieldset>
<p>
<label for="username">Username:</label>
<input name="myusername" type="text" id="myusername">
</p>
<p>
<label for="password">Passwort:</label>
<input name="mypassword" type="password" id="mypassword">
</p>
<p>
<div class="myButton" onClick="submit();">
<div class="left" ></div>
<div class="middle" >
Login
</div>
<div class="right" ></div>
</div>
</p>
</fieldset>
</form>
</div>
<noscript>
<div class="noscript">Sorry, your browser does not allow
JavaScript. Please enable JavaScript and try again.</div>
</noscript>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
jquery-2.1.1.min.js
\ No newline at end of file
/*! JSON v3.2.5 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
;(function(){var o=!0,w=null;
(function(B){function v(a){if("bug-string-char-index"==a)return"a"!="a"[0];var f,c="json"==a;if(c||"json-stringify"==a||"json-parse"==a){if("json-stringify"==a||c){var d=k.stringify,b="function"==typeof d&&l;if(b){(f=function(){return 1}).toJSON=f;try{b="0"===d(0)&&"0"===d(new Number)&&'""'==d(new String)&&d(m)===r&&d(r)===r&&d()===r&&"1"===d(f)&&"[1]"==d([f])&&"[null]"==d([r])&&"null"==d(w)&&"[null,null,null]"==d([r,m,w])&&'{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'==d({a:[f,o,!1,w,"\x00\u0008\n\u000c\r\t"]})&&
"1"===d(w,f)&&"[\n 1,\n 2\n]"==d([1,2],w,1)&&'"-271821-04-20T00:00:00.000Z"'==d(new Date(-864E13))&&'"+275760-09-13T00:00:00.000Z"'==d(new Date(864E13))&&'"-000001-01-01T00:00:00.000Z"'==d(new Date(-621987552E5))&&'"1969-12-31T23:59:59.999Z"'==d(new Date(-1))}catch(n){b=!1}}if(!c)return b}if("json-parse"==a||c){a=k.parse;if("function"==typeof a)try{if(0===a("0")&&!a(!1)){f=a('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');var e=5==f.a.length&&1===f.a[0];if(e){try{e=!a('"\t"')}catch(g){}if(e)try{e=
1!==a("01")}catch(i){}}}}catch(O){e=!1}if(!c)return e}return b&&e}}var m={}.toString,p,C,r,D=typeof define==="function"&&define.amd,k="object"==typeof exports&&exports;k||D?"object"==typeof JSON&&JSON?k?(k.stringify=JSON.stringify,k.parse=JSON.parse):k=JSON:D&&(k=B.JSON={}):k=B.JSON||(B.JSON={});var l=new Date(-3509827334573292);try{l=-109252==l.getUTCFullYear()&&0===l.getUTCMonth()&&1===l.getUTCDate()&&10==l.getUTCHours()&&37==l.getUTCMinutes()&&6==l.getUTCSeconds()&&708==l.getUTCMilliseconds()}catch(P){}if(!v("json")){var s=
v("bug-string-char-index");if(!l)var t=Math.floor,J=[0,31,59,90,120,151,181,212,243,273,304,334],z=function(a,f){return J[f]+365*(a-1970)+t((a-1969+(f=+(f>1)))/4)-t((a-1901+f)/100)+t((a-1601+f)/400)};if(!(p={}.hasOwnProperty))p=function(a){var f={},c;if((f.__proto__=w,f.__proto__={toString:1},f).toString!=m)p=function(a){var f=this.__proto__,a=a in(this.__proto__=w,this);this.__proto__=f;return a};else{c=f.constructor;p=function(a){var f=(this.constructor||c).prototype;return a in this&&!(a in f&&
this[a]===f[a])}}f=w;return p.call(this,a)};var K={"boolean":1,number:1,string:1,undefined:1};C=function(a,f){var c=0,b,h,n;(b=function(){this.valueOf=0}).prototype.valueOf=0;h=new b;for(n in h)p.call(h,n)&&c++;b=h=w;if(c)c=c==2?function(a,f){var c={},b=m.call(a)=="[object Function]",d;for(d in a)!(b&&d=="prototype")&&!p.call(c,d)&&(c[d]=1)&&p.call(a,d)&&f(d)}:function(a,f){var c=m.call(a)=="[object Function]",b,d;for(b in a)!(c&&b=="prototype")&&p.call(a,b)&&!(d=b==="constructor")&&f(b);(d||p.call(a,
b="constructor"))&&f(b)};else{h=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];c=function(a,f){var c=m.call(a)=="[object Function]",b,d;if(d=!c)if(d=typeof a.constructor!="function"){d=typeof a.hasOwnProperty;d=d=="object"?!!a.hasOwnProperty:!K[d]}d=d?a.hasOwnProperty:p;for(b in a)!(c&&b=="prototype")&&d.call(a,b)&&f(b);for(c=h.length;b=h[--c];d.call(a,b)&&f(b));}}c(a,f)};if(!v("json-stringify")){var L={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",
10:"\\n",13:"\\r",9:"\\t"},u=function(a,f){return("000000"+(f||0)).slice(-a)},G=function(a){var f='"',b=0,d=a.length,h=d>10&&s,n;for(h&&(n=a.split(""));b<d;b++){var e=a.charCodeAt(b);switch(e){case 8:case 9:case 10:case 12:case 13:case 34:case 92:f=f+L[e];break;default:if(e<32){f=f+("\\u00"+u(2,e.toString(16)));break}f=f+(h?n[b]:s?a.charAt(b):a[b])}}return f+'"'},E=function(a,b,c,d,h,n,e){var g=b[a],i,j,k,l,q,s,v,x,y;try{g=b[a]}catch(A){}if(typeof g=="object"&&g){i=m.call(g);if(i=="[object Date]"&&
!p.call(g,"toJSON"))if(g>-1/0&&g<1/0){if(z){k=t(g/864E5);for(i=t(k/365.2425)+1970-1;z(i+1,0)<=k;i++);for(j=t((k-z(i,0))/30.42);z(i,j+1)<=k;j++);k=1+k-z(i,j);l=(g%864E5+864E5)%864E5;q=t(l/36E5)%24;s=t(l/6E4)%60;v=t(l/1E3)%60;l=l%1E3}else{i=g.getUTCFullYear();j=g.getUTCMonth();k=g.getUTCDate();q=g.getUTCHours();s=g.getUTCMinutes();v=g.getUTCSeconds();l=g.getUTCMilliseconds()}g=(i<=0||i>=1E4?(i<0?"-":"+")+u(6,i<0?-i:i):u(4,i))+"-"+u(2,j+1)+"-"+u(2,k)+"T"+u(2,q)+":"+u(2,s)+":"+u(2,v)+"."+u(3,l)+"Z"}else g=
w;else if(typeof g.toJSON=="function"&&(i!="[object Number]"&&i!="[object String]"&&i!="[object Array]"||p.call(g,"toJSON")))g=g.toJSON(a)}c&&(g=c.call(b,a,g));if(g===w)return"null";i=m.call(g);if(i=="[object Boolean]")return""+g;if(i=="[object Number]")return g>-1/0&&g<1/0?""+g:"null";if(i=="[object String]")return G(""+g);if(typeof g=="object"){for(a=e.length;a--;)if(e[a]===g)throw TypeError();e.push(g);x=[];b=n;n=n+h;if(i=="[object Array]"){j=0;for(a=g.length;j<a;y||(y=o),j++){i=E(j,g,c,d,h,n,
e);x.push(i===r?"null":i)}a=y?h?"[\n"+n+x.join(",\n"+n)+"\n"+b+"]":"["+x.join(",")+"]":"[]"}else{C(d||g,function(a){var b=E(a,g,c,d,h,n,e);b!==r&&x.push(G(a)+":"+(h?" ":"")+b);y||(y=o)});a=y?h?"{\n"+n+x.join(",\n"+n)+"\n"+b+"}":"{"+x.join(",")+"}":"{}"}e.pop();return a}};k.stringify=function(a,b,c){var d,h,j;if(typeof b=="function"||typeof b=="object"&&b)if(m.call(b)=="[object Function]")h=b;else if(m.call(b)=="[object Array]"){j={};for(var e=0,g=b.length,i;e<g;i=b[e++],(m.call(i)=="[object String]"||
m.call(i)=="[object Number]")&&(j[i]=1));}if(c)if(m.call(c)=="[object Number]"){if((c=c-c%1)>0){d="";for(c>10&&(c=10);d.length<c;d=d+" ");}}else m.call(c)=="[object String]"&&(d=c.length<=10?c:c.slice(0,10));return E("",(i={},i[""]=a,i),h,j,d,"",[])}}if(!v("json-parse")){var M=String.fromCharCode,N={92:"\\",34:'"',47:"/",98:"\u0008",116:"\t",110:"\n",102:"\u000c",114:"\r"},b,A,j=function(){b=A=w;throw SyntaxError();},q=function(){for(var a=A,f=a.length,c,d,h,k,e;b<f;){e=a.charCodeAt(b);switch(e){case 9:case 10:case 13:case 32:b++;
break;case 123:case 125:case 91:case 93:case 58:case 44:c=s?a.charAt(b):a[b];b++;return c;case 34:c="@";for(b++;b<f;){e=a.charCodeAt(b);if(e<32)j();else if(e==92){e=a.charCodeAt(++b);switch(e){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:c=c+N[e];b++;break;case 117:d=++b;for(h=b+4;b<h;b++){e=a.charCodeAt(b);e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70||j()}c=c+M("0x"+a.slice(d,b));break;default:j()}}else{if(e==34)break;e=a.charCodeAt(b);for(d=b;e>=32&&e!=92&&e!=34;)e=a.charCodeAt(++b);
c=c+a.slice(d,b)}}if(a.charCodeAt(b)==34){b++;return c}j();default:d=b;if(e==45){k=o;e=a.charCodeAt(++b)}if(e>=48&&e<=57){for(e==48&&(e=a.charCodeAt(b+1),e>=48&&e<=57)&&j();b<f&&(e=a.charCodeAt(b),e>=48&&e<=57);b++);if(a.charCodeAt(b)==46){for(h=++b;h<f&&(e=a.charCodeAt(h),e>=48&&e<=57);h++);h==b&&j();b=h}e=a.charCodeAt(b);if(e==101||e==69){e=a.charCodeAt(++b);(e==43||e==45)&&b++;for(h=b;h<f&&(e=a.charCodeAt(h),e>=48&&e<=57);h++);h==b&&j();b=h}return+a.slice(d,b)}k&&j();if(a.slice(b,b+4)=="true"){b=
b+4;return o}if(a.slice(b,b+5)=="false"){b=b+5;return false}if(a.slice(b,b+4)=="null"){b=b+4;return w}j()}}return"$"},F=function(a){var b,c;a=="$"&&j();if(typeof a=="string"){if((s?a.charAt(0):a[0])=="@")return a.slice(1);if(a=="["){for(b=[];;c||(c=o)){a=q();if(a=="]")break;if(c)if(a==","){a=q();a=="]"&&j()}else j();a==","&&j();b.push(F(a))}return b}if(a=="{"){for(b={};;c||(c=o)){a=q();if(a=="}")break;if(c)if(a==","){a=q();a=="}"&&j()}else j();(a==","||typeof a!="string"||(s?a.charAt(0):a[0])!="@"||
q()!=":")&&j();b[a.slice(1)]=F(q())}return b}j()}return a},I=function(a,b,c){c=H(a,b,c);c===r?delete a[b]:a[b]=c},H=function(a,b,c){var d=a[b],h;if(typeof d=="object"&&d)if(m.call(d)=="[object Array]")for(h=d.length;h--;)I(d,h,c);else C(d,function(a){I(d,a,c)});return c.call(a,b,d)};k.parse=function(a,f){var c,d;b=0;A=""+a;c=F(q());q()!="$"&&j();b=A=w;return f&&m.call(f)=="[object Function]"?H((d={},d[""]=c,d),"",f):c}}}D&&define(function(){return k})})(this);
}());
var timerid;
var dooropen_disabled;
var doorclose_disabled;
function doorOpen() {
if (!dooropen_disabled) window.location.replace("/login_success.php?dooropen");
}
function doorClose() {
if (!doorclose_disabled) window.location.replace("/login_success.php?doorclose");
}
function shutterOpen() {
//return false;
window.location.replace("/login_success.php?shutteropen");
}
function shutterClose() {
//return false;
window.location.replace("/login_success.php?shutterclose");
}
function ConvertFormToJSON(form){
var array = jQuery(form).serializeArray();
var json = {};
jQuery.each(array, function() {
json[this.name] = this.value || '';
});
return json;
}
function ajaxHandler(form) {
var json = ConvertFormToJSON(form);
var request=$.ajax({
type: "POST",
async: true,
cache: false,
url: "getstatus.php",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(json),
dataType: "json",
success: function (data) {
$('#dooropen').empty();
$('#dooropen').append(data.dooropen);
$('#dooropen').append("<br>");
$('#dooropen').append(data.handle);
$('#dooropen').append("<br>");
$('#dooropen').append(data.unlocked);
$('#dooropen').append("<br>");
$('#dooropen').append(data.lock);
$('#dooropen').append("<br>");
$('#dooropen').append(data.hallsensor);
$('#dooropen').append("<br>");
$('#dooropen').append(data.cable);
$('#dooropen').append("<br>");
$('#dooropen').append(data.msg);
$('#dooropen').append("<br>");
$('#dooropen').append(data.heartbeat);
if (data.disable_open==true) {
$('#open').removeClass("open");
$('#open').addClass("opendisabled");
dooropen_disabled=true;
} else {
$('#open').removeClass("opendisabled");
$('#open').addClass("open");
dooropen_disabled=false;
}
if (data.disable_close==true) {
$('#close').removeClass("close");
$('#close').addClass("closedisabled");
doorclose_disabled=true;
} else {
$('#close').removeClass("closedisabled");
$('#close').addClass("close");
doorclose_disabled=false;
}
}
});
}
var form=jQuery('form#login');
$(document).on('ready', function() {
$("#opendoor").click(function (event){
event.preventDefault();
doorOpen()
});
$("#closedoor").click(function (event){
event.preventDefault();
doorClose()
});
$("#openshutter").click(function (event){
event.preventDefault();
shutterOpen()
});
$("#closeshutter").click(function (event){
event.preventDefault();
shutterClose()
});
$('#popenshutter').addClass("shutteropen");
$('#pcloseshutter').addClass("shutterclose");
timerId=setInterval(function() {
ajaxHandler(form);
}, 800);
});
<?php
session_start();
if(!isset($_SESSION['username'])) {
header("location:index.php");
exit (0);
} else {
$name=$_SESSION['username'];
}
require_once "header.inc";
print <<<EOF
<script src="local.js" type="text/javascript" charset="UTF-8"></script>
<script src="json3.js" type="text/javascript" charset="UTF-8"></script>
</head>
EOF;
function sendToArduino($cmd)
{
$lockfile="/run/lock/dm.lock";
$l=fopen("$lockfile","w");
fclose($l);
$fields = array(
'cmd' => urlencode($cmd),
);
$fields_string="";
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$url="http://arduino/req";
$s = curl_init();
curl_setopt($s,CURLOPT_URL,$url);
curl_setopt($s,CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($s,CURLOPT_POST,true);
curl_setopt($s,CURLOPT_POST, count($fields));
curl_setopt($s,CURLOPT_POSTFIELDS, $fields_string);
curl_exec($s);
curl_close ($s);
unlink ("$lockfile");
}
function doorOpen()
{
sendToArduino("open");
}
function shutterOpen()
{
sendToArduino("shutteropen");
}
function doorHalfclose()
{
}
function doorFullclose()
{
sendToArduino("fullclose");
}
function shutterClose()
{
sendToArduino("shutterclose");
}
function hideMessage()
{
print <<<EOF
<script type="text/javascript">
$('#status').hide();
</script>
EOF;
}
echo "<body>\n";
if ( true ) {
hideMessage();
echo '<div class="css_page" id="page">'."\n";