Skip to content

Commit 6786ffb

Browse files
committed
Fully functional version!
1 parent 31947ed commit 6786ffb

File tree

6 files changed

+110
-180
lines changed

6 files changed

+110
-180
lines changed

_include.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
<script type="text/javascript">
1818
<?php $cond = (isset($_GET['error']) && $_GET['error'] == 1) || (isset($_GET['login_required']) && $_GET['login_required'] == 1);?>
19-
var cont = 1, <?php echo "error = ".($cond?"true":"false").";";
20-
if (current_user()) {
21-
if (current_user())
22-
echo "var cur = '".current_user()."';";
23-
}
19+
var cont = 1, <?php echo "error = ".($cond?"true":"false").", cur = '".current_user()."';";
2420
?>
2521

2622
$(document).ready(function(){
@@ -46,7 +42,7 @@
4642
$('#mainheader>span').click(function(){
4743
window.location='index.php';
4844
});
49-
$('#accordion').accordion({ autoHeight:false, active:0});
45+
$('#accordion').accordion({ header: "h3", navigation: true});
5046
$('#tabs').tabs();
5147
$('.button').button();
5248
$('#loginform input').keydown(function(e){

admin/_adminclude.php

+27-41
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5-
<title>Inloggad - <?php echo $_SESSION['user']; ?></title>
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7-
<link rel="stylesheet" type="text/css" href="../style.css" />
8-
<link type="text/css" href="../css/custom-theme/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
9-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
10-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
11-
<style type="text/css" media="screen">
12-
#error {
13-
border: 3px groove #F33;
14-
padding: 5px;
15-
margin:10px 0 10px 0;
16-
color: #F33;
17-
}
18-
</style>
19-
<script type="text/javascript" src="../js/json.js"></script>
20-
<link href='http://fonts.googleapis.com/css?family=Architects+Daughter|Permanent+Marker|Aclonica|Muli&v2' rel='stylesheet' type='text/css' />
21-
<?php
22-
echo "<script type='text/javascript'>
23-
var data=".json_encode(simplexml_load_file('../rum/'.$currentRum.'/data.xml')).";
24-
if(!data)data={};
25-
if(!data.nyheter){data.nyheter={nyhet:[]};}
26-
if(!data.nyheter.nyhet)data.nyheter.nyhet=[];
27-
if(!data.kontakter){data.kontakter={kontakt:[]};}
28-
if(!data.kontakter.kontakt)data.kontakter.kontakt=[];
29-
if(!data.kalender){data.kalender={date:[]};}
30-
if(!data.kalender.date)data.kalender.date=[];";
31-
32-
echo "data.rum=[];";
33-
echo "data.rum.delete=[];\n";
34-
echo "!(data.kontakter.kontakt instanceof Array)&&(data.kontakter.kontakt=[data.kontakter.kontakt]);";
35-
echo "var tab_counter = ".count($SimpleTab).";";
36-
echo "</script>";
37-
?>
4+
<meta charset="utf-8">
5+
<title>Inloggad - <?php echo $_SESSION['user']; ?></title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7+
<link rel="stylesheet" type="text/css" href="../css/style.css" />
8+
<link type="text/css" href="../css/custom-theme/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
9+
<link href='http://fonts.googleapis.com/css?family=Architects+Daughter|Permanent+Marker|Aclonica|Muli' rel='stylesheet' type='text/css' />
10+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
11+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
12+
<script type="text/javascript" src="../js/json.js"></script>
13+
<script type="text/javascript">
14+
var data = <?php echo json_encode(simplexml_load_file('../rum/'.$currentRum.'data.xml'));?>;
15+
if(!data) data = {};
16+
if(!data.nyheter) data.nyheter = {nyhet: []};
17+
if(!data.nyheter.nyhet) data.nyheter.nyhet = [];
18+
if(!data.kontakter)data.kontakter = {kontakt: []};
19+
if(!data.kontakter.kontakt)data.kontakter.kontakt = [];
20+
if(!data.kalender) data.kalender = {date:[]};
21+
if(!data.kalender.date) data.kalender.date = [];
22+
data.rum=[];
23+
data.rum.delete=[];
24+
!(data.kontakter.kontakt instanceof Array)&&(data.kontakter.kontakt=[data.kontakter.kontakt]);
25+
var tab_counter = <?php echo count($SimpleTab); ?>;
26+
</script>
3827
<script type="text/javascript">
3928
function kontakterClick(t,undefined){
4029
var k=undefined;
41-
if(t!=undefined){
30+
if(t!=k){
4231
var i=$('#kont .ui-button').index($(t));
4332
k=data.kontakter.kontakt[i];
4433
$('#namn').val(typeof k.namn == 'object'?"":k.namn);
@@ -90,14 +79,11 @@ function kontakterClick(t,undefined){
9079
$(function(){
9180
$('#tools').find('button').button();
9281
$('#mainheader').find('button').button().click(function(){
93-
window.location="logout.php?rum=<?php echo $_GET['rum']; ?>";
82+
window.location="logout.php?rum=<?php echo isset($_GET['rum'])?$_GET['rum']:''; ?>";
9483
});
9584
$('#kont .ui-button').click(function(){
9685
kontakterClick(this);
9786
});
98-
/*$('#mainheader>span').click(function(){
99-
window.location='../index.php';
100-
});*/
10187
$('#accordion').accordion({ header: "h3", autoHeight:false, navigation: true});
10288

10389
/** ------------------------------------------------------------------------**/
@@ -201,7 +187,7 @@ function(event){
201187
});
202188
var rum={};
203189
rum.add=function(pa){
204-
var li = $('<li style="padding:10px 0 10px 0;border-bottom:2px groove #ccc;" />');
190+
var li = $('<li>');
205191
li.html('<input type="text" name="'+(pa=="nyheter"?"nyhet":"date")+'[]" /><span style="float:right;" onclick="this.parentNode.outerHTML=\'\';rum.update();" class="del ui-icon ui-icon-trash"></span>');
206192
if(pa=="nyheter")
207193
$('#accordion .nyheter').append(li);
@@ -384,4 +370,4 @@ function change(type){
384370
lists.data("load",true);
385371
}
386372
}
387-
</script>
373+
</script>

admin/index.php

+16-112
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
<?php
22
session_start();
3-
function translate($string) {
4-
$search = array( "\\t", "\\n", "\\r", " ");
5-
$replace = array( "&#09;", "<br/>", "<br/>", "&#32;");
6-
return str_replace($search, $replace, $string);
7-
}
8-
3+
94
include "upload.php";
105
require_once "auth.php";
116
require_login();
127

138
function rrmdir($path){
149
return is_file($path)?@unlink($path):array_map('rrmdir',glob($path.'/*'))==@rmdir($path);
1510
}
11+
$currentRum = "";
1612
if($_SESSION["user"]!="admin"){
1713
include_once("_adminclude.php");
1814
exit("<div style='
@@ -23,15 +19,15 @@ function rrmdir($path){
2319
' >Du har inte tillräcklig behörighet för att redigera denna sidan!<br/>
2420
<a href=\"rum.php?rum=". str_replace(" ","_",$_SESSION["user"])."\">Gå tillbaka till din sida.</a><img src='../img/premission-denied.png' style='float:right;width:200px;' /></div>");
2521
}
26-
if($_POST["text_content_sida"]){ //Redigera hemsidan
22+
if(isset($_POST["text_content_sida"])){ //Redigera hemsidan
2723
$sim = simplexml_load_file("../rum/data.xml");
2824
$sim->tab->desk = "<![CDATA[".$_POST["text_content_sida"]."]]>";
2925
$ifle=fopen("../rum/data.xml","w") or die("error!");
3026
fwrite($ifle,$sim->asXML());
3127
fclose($ifle);
3228
}
3329

34-
if($_POST["nyheter"]=="nyhet"){
30+
if(isset($_POST["nyheter"]) && $_POST["nyheter"]=="nyhet"){
3531
$path="../rum/data.xml";
3632
$sim=simplexml_load_file($path);
3733
unset($sim->nyheter);
@@ -41,7 +37,7 @@ function rrmdir($path){
4137
}
4238
fwrite(fopen($path,"w"),$sim->asXML());
4339
}
44-
if($_POST["kalender"]=="date"){
40+
if(isset($_POST["kalender"]) && $_POST["kalender"] == "date"){
4541
$path="../rum/data.xml";
4642
$sim=simplexml_load_file($path);
4743
for($i=0;$i < count($_POST["date"]) || $i < count($sim->kalender->date) ;$i++){
@@ -77,13 +73,13 @@ function rrmdir($path){
7773
fwrite(fopen($path,"w"),$sim->asXML());
7874
}
7975

80-
if($_POST["del_rum"]=="true"){ //delete rum
76+
if(isset($_POST["del_rum"]) && $_POST["del_rum"]=="true"){ //delete rum
8177
if($_POST["cur_rum"]&&$_POST["cur_rum"]!=""&&is_dir("../rum/".str_replace(" ","_",$_POST["cur_rum"]))){
8278
rrmdir("../rum/".str_replace(" ","_",$_POST["cur_rum"]));
8379
deletePass($_POST["cur_rum"]);
8480
}
8581
}
86-
else if($_POST["rum"]){ //redigera rum eller lägg till
82+
else if(isset($_POST["rum"])){ //redigera rum eller lägg till
8783
$path="../rum/".$_POST["cur_rum"];
8884
$newPath=str_replace(" ","_","../rum/".$_POST["rum"]);
8985
if($_POST["cur_rum"]==""){ //Lägga till nytt rum
@@ -170,7 +166,7 @@ function addPass($room,$pass){
170166
}
171167
?>
172168
<script type="text/javascript" charset="utf-8">
173-
var ar = <?php echo json_encode($roomusers); ?>;
169+
var ar = <?php echo json_encode(isset($roomusers)?$roomusers:'[]'); ?>;
174170
$(document).ready(function(){
175171
$('#edit-room').dialog({
176172
width:"auto" ,
@@ -274,106 +270,14 @@ function addPass($room,$pass){
274270

275271
$(".inneboende:not(.add)").mouseover(function(){
276272
$(this).css("background-position","0px 220px");
277-
$(this).parent().find(".desc").css("visibility","visible");
273+
$(".desc",this).show();
278274
});
279275
$(".inneboende:not(.add)").mouseout(function(){
280276
$(this).css("background-position","0px 0px");
281-
$(this).parent().find(".desc").css("visibility","hidden");
277+
$(".desc",this).hide();
282278
});
283279
});
284280
</script>
285-
<style type="text/css" media="screen">
286-
#beskrivning, #list-rum {color:#000;}
287-
#beskrivning {height:150px;overflow-y:auto;}
288-
#list-rum {width:475px;margin-left:5px;padding-left:15px;}
289-
#list-rum a {width:475px;margin-bottom: 5px;text-decoration:none;}
290-
/* Alltså alla olika rummen om någon inte fattar*/
291-
.inneboende{
292-
width:220px;
293-
height:220px;
294-
background:url("../img/door_icon.png");
295-
float:left;
296-
margin:15px 5px 15px 5px;
297-
border-radius:2px;
298-
text-align:center;
299-
position:relative;
300-
color: #333;
301-
font-weight: bold;
302-
overflow: hidden;
303-
}
304-
.inneboende.add{
305-
width:120px;
306-
height:160px;
307-
background:rgba(50,50,50,0.7);
308-
float:left;
309-
margin:20px;
310-
border-radius:2px;
311-
text-align:center;
312-
padding-top:20px;
313-
}
314-
.inneboende img{
315-
width:200px;
316-
box-shadow:0 0 2px #000;
317-
padding:10px;
318-
}
319-
.inneboende.add img{
320-
width:100px;
321-
box-shadow:0 0 0px #000;
322-
padding:10px;
323-
}
324-
#list-rum a div.desc {
325-
text-decoration:none;
326-
width: 220px;
327-
height: 190px;
328-
padding-top:30px;
329-
position:absolute;
330-
visibility: hidden;
331-
}
332-
#list-rum a div div.namn {
333-
text-decoration:underline;
334-
text-transform:capitalize;
335-
}
336-
#list-rum a div div.besk {
337-
margin-top:10px;
338-
text-decoration:none;
339-
}
340-
#list-rum .add {
341-
width:auto;
342-
padding:30px;
343-
height:auto;
344-
background:rgba(200,200,200,0.2);
345-
}
346-
#list-rum .add:hover {
347-
width:auto;
348-
padding:30px;
349-
height:auto;
350-
background:rgba(200,200,200,0.4);
351-
}
352-
.left_edit , .right_edit{
353-
float: left;
354-
margin-left: -20px;
355-
position:relative;
356-
z-index: 2;
357-
/*background-color: #fed22f;*/
358-
background-color: #ccc;
359-
border:1px solid #000;
360-
border-radius:2px;
361-
}
362-
.left_edit{
363-
left:10px;
364-
top:15px;
365-
}
366-
.right_edit{
367-
top:265px;
368-
left:-450px;
369-
}
370-
#beskr{
371-
padding: 0;
372-
}
373-
#accordion input{
374-
width:100px;
375-
}
376-
</style>
377281
</head>
378282
<body>
379283
<div id="media0" style="display:none;">
@@ -507,7 +411,7 @@ function addPass($room,$pass){
507411
echo '<span class="left_edit">
508412
<span class="button ui-icon ui-icon-tag" style="float:left;" title="Redigera" onclick="$(\'#cur_rum\').val(\'null\');$(\'#edit-room\').dialog(\'open\');"></span>
509413
</span>';
510-
echo '<a href="rum.php?rum='.$file.'"><div class="inneboende"><div class="desc"><div class="namn" >'.str_replace('_',' ',$file).'</div><div class="besk">'.$beskriv.'</div><input type="hidden" value="'.$access.'" /></div></div></a>';
414+
echo '<a href="rum.php?rum='.$file.'"><div class="inneboende"><div class="desc"><div class="namn" >'.str_replace('_',' ',$file).'</div><div class="besk">'.$beskriv.'</div><input type="hidden" /></div></div></a>';
511415
if(($index % 2) == 0)
512416
echo '<span class="left_edit">
513417
<span class="button ui-icon ui-icon-tag" style="float:left;" title="Redigera" onclick="$(\'#cur_rum\').val(\'null\');$(\'#edit-room\').dialog(\'open\');"></span>
@@ -537,13 +441,13 @@ function addPass($room,$pass){
537441
if(count($SimpleNyh) > 0){
538442
if(isset($_POST["data"])){
539443
for($i=0;$i<count($SimpleNyh);$i++){
540-
echo '<li style="padding:10px 0 10px 0;border-bottom:2px groove #ccc;" >'.$SimpleNyh["nyhet"].' <span>X</span></li>';
444+
echo '<li>'.$SimpleNyh["nyhet"].' <span>X</span></li>';
541445
}
542446
}
543447
else{
544448
$i=0;
545449
foreach ($SimpleNyh as $nyhet){
546-
echo '<li style="padding:10px 0 10px 0;border-bottom:2px groove #ccc;" >'.$nyhet.'</li>';
450+
echo '<li>'.$nyhet.'</li>';
547451
$i++;
548452
}
549453
}
@@ -565,12 +469,12 @@ function addPass($room,$pass){
565469
if(count($SimpleCal) >0){
566470
if(isset($_POST["data"])){
567471
for($i=0;$i<count($SimpleCal);$i++){
568-
echo '<li style="padding:10px 0 10px 0;border-bottom:2px groove #ccc;" >'.$SimpleCal["date"].'</li>';
472+
echo '<li>'.$SimpleCal["date"].'</li>';
569473
}
570474
}
571475
else{
572476
foreach ($SimpleCal as $date){
573-
echo '<li style="padding:10px 0 10px 0;border-bottom:2px groove #ccc;" >'.$date.'</li>';
477+
echo '<li>'.$date.'</li>';
574478
}
575479
}
576480
}
@@ -602,7 +506,7 @@ function addPass($room,$pass){
602506
foreach($SimpleCont->children() as $kontakt){
603507
echo "<table class='ui-button ui-corner-all' style='width:100%;border:0px solid #000;padding:2px;text-align:left;' onmouseover='this.className=\"ui-button ui-corner-all ui-state-hover\";' onmouseout='this.className=\"ui-button ui-corner-all\";' ><tr>";
604508
if ($kontakt->img&&$kontakt->img!='#')
605-
echo '<td><img width="30" align="left" onerror="this.src=\'../img/top_bottom.png\';console.warn(\'Försök att läsa kontakt bild misslyckades!\');return false;" style="margin-right:3px;" src="'.$kontakt->img.'" /></td>';
509+
echo '<td><img width="30" align="left" style="margin-right:3px;" src="'.$kontakt->img.'" /></td>';
606510
else
607511
echo '<td><img width="30" align="left" style="margin-right:3px;display:inline;" src="../img/top_bottom.png" /></td>';
608512
echo "<td>";

0 commit comments

Comments
 (0)