Skip to content

Commit 7770771

Browse files
committed
Initial build
1 parent 2aae03d commit 7770771

File tree

202 files changed

+26555
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+26555
-3
lines changed

AUTHORS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Authors
2+
3+
* Ben Curtis: <no-spam @ no-domain . com>
4+

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
owncloud-ownnote (0.0.1)
2+
* First release

COPYING

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ownnote
2-
=======
1+
# Own Note
2+
Place this app in **owncloud/apps/**
33

4-
Notes app for ownCloud

ajax/create.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
if (isset($_GET['id']) && $_GET['id'] != '' && $_GET['id'] != 'note title') {
9+
$TARGET=$FOLDER."/".$_GET['id'].".htm";
10+
11+
if (!\OC\Files\Filesystem::file_exists($TARGET)) {
12+
\OC\Files\Filesystem::touch($TARGET);
13+
}
14+
}
15+
16+
?>

ajax/delete.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
if (isset($_GET['id']) && $_GET['id'] != '') {
9+
$TARGET=$FOLDER."/".$_GET['id'];
10+
11+
if (\OC\Files\Filesystem::file_exists($TARGET)) {
12+
\OC\Files\Filesystem::unlink($TARGET);
13+
}
14+
}
15+
16+
?>

ajax/deletegroup.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
if ($listing = \OC\Files\Filesystem::opendir($FOLDER)) {
9+
if (!listing) {
10+
echo "ERROR: Error listing directory.";
11+
exit;
12+
}
13+
while (($file = readdir($listing)) !== false) {
14+
if (substr($file,0,1) == "[") {
15+
$group = "";
16+
$end = strpos($file, ']');
17+
$group = substr($file, 1, $end-1);
18+
if ($group == $_POST['group']) {
19+
$filename = substr($file, $end+1, strlen($file)-$end+1);
20+
$filename = trim($filename);
21+
if (\OC\Files\Filesystem::rename($FOLDER."/".$file, $FOLDER."/".$filename)) {
22+
echo "SUCCESS";
23+
} else {
24+
echo "FAIL";
25+
}
26+
}
27+
}
28+
29+
}
30+
}
31+
32+
?>

ajax/edit.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
if ($html = \OC\Files\Filesystem::file_get_contents($FOLDER."/".$_GET['id'])) {
9+
echo $html;
10+
}
11+
12+
?>

ajax/listing.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
// Create directory if it doesn't exist
9+
if (!\OC\Files\Filesystem::is_dir($FOLDER)) {
10+
if (!\OC\Files\Filesystem::mkdir($FOLDER)) {
11+
echo "ERROR: Could not create ownNote directory.";
12+
exit;
13+
}
14+
}
15+
16+
function endswith($string, $test) {
17+
$strlen = strlen($string);
18+
$testlen = strlen($test);
19+
if ($testlen > $strlen) return false;
20+
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
21+
}
22+
23+
24+
// Loop through and list files
25+
if ($listing = \OC\Files\Filesystem::opendir($FOLDER)) {
26+
if (!listing) {
27+
echo "ERROR: Error listing directory.";
28+
exit;
29+
}
30+
$now = new DateTime();
31+
$filetime = new DateTime();
32+
$delete = OCP\Util::imagePath('ownnote','delete.png');
33+
$farray = array();
34+
$count = 0;
35+
while (($file = readdir($listing)) !== false) {
36+
if ($file == "." || $file == "..") continue;
37+
if (!endswith($file, ".htm")) continue;
38+
if ($info = \OC\Files\Filesystem::getFileInfo($FOLDER."/".$file)) {
39+
$filetime->setTimestamp($info['mtime']);
40+
$difftime = $filetime->diff($now);
41+
$years = $difftime->y;
42+
$months = $difftime->m;
43+
$days = $difftime->d;
44+
$hours = $difftime->h;
45+
$minutes = $difftime->i;
46+
$seconds = $difftime->s;
47+
$timestring = "";
48+
if ($timestring == "" && $years == 1) $timestring = "$years year";
49+
if ($timestring == "" && $years > 0) $timestring = "$years years";
50+
if ($timestring == "" && $months == 1) $timestring = "$months month";
51+
if ($timestring == "" && $months > 0) $timestring = "$months months";
52+
if ($timestring == "" && $days == 1) $timestring = "$days day";
53+
if ($timestring == "" && $days > 0) $timestring = "$days days";
54+
if ($timestring == "" && $hours == 1) $timestring = "$hours hour";
55+
if ($timestring == "" && $hours > 0) $timestring = "$hours hours";
56+
if ($timestring == "" && $minutes == 1) $timestring = "$minutes minute";
57+
if ($timestring == "" && $minutes > 0) $timestring = "$minutes minutes";
58+
if ($timestring == "" && $seconds == 1) $timestring = "$seconds second";
59+
if ($timestring == "" && $seconds > 0) $timestring = "$seconds seconds";
60+
$filename = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file);
61+
$group = "";
62+
if (substr($filename,0,1) == "[") {
63+
$end = strpos($filename, ']');
64+
$group = substr($filename, 1, $end-1);
65+
$filename = substr($filename, $end+1, strlen($filename)-$end+1);
66+
$filename = trim($filename);
67+
}
68+
$f = array();
69+
$f['file'] = $file;
70+
$f['filename'] = $filename;
71+
$f['group'] = $group;
72+
$f['timestring'] = $timestring;
73+
$f['mtime'] = $info['mtime'];
74+
$f['timediff'] = $now->getTimestamp()-$info['mtime'];
75+
$farray[$count] = $f;
76+
$count++;
77+
} else {
78+
echo "ERROR: Error retrieving file information.";
79+
exit;
80+
}
81+
}
82+
echo json_encode($farray);
83+
}
84+
85+
?>

ajax/rename.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$FOLDER = "Notes";
4+
5+
\OCP\User::checkLoggedIn();
6+
\OCP\App::checkAppEnabled('ownnote');
7+
8+
if (\OC\Files\Filesystem::rename($FOLDER."/".$_POST['originalfilename'].".htm", $FOLDER."/".$_POST['editfilename'].".htm")) {
9+
echo "SUCCESS";
10+
} else {
11+
echo "FAIL";
12+
}
13+
14+
?>

0 commit comments

Comments
 (0)