Entries filed under English

Updating Owncloud News App with cron and Uberspace

Posted on 27. November 2013 Comments

Since it’s not possible to create a cronjob with the user the webserver is running under(as advised), I just created a cronjob with my user(crontab -e) and it works just fine.

[repat@uberspace]$ crontab -l
*/15 * * * * /package/host/localhost/php/bin/php -f /home/repat/html/owncloud/cron.php

The problem was the following: owncloud wouldn’t update my news and I didn’t think it was a cron problem, since I couldn’t update it manually(AJAX). Adding new feeds however did work. I still don’t get why manual updating doesn’t work , even with the Android app. Opening cron.php in the webbrowser didn’t work, although it did display {„status“:“success“}..turns out: it has to be called via CLI.

Unfortunately, I get an email every 15 minutes now… To disable that I added this above the cron entry:

MAILTO=""

Thanks to Raydiation and j-ed for helping me.

„Incomplete statements not supported yet, sorry, you’ll have to retype“ Error with Scala and Eclipse

Posted on 15. November 2013 Comments

I got this error defining the function

object test {
  val f:AnyVal => String = {
      case 10.0 => "10.0"
      case _: Double => "Double"
      case _: Int => "Int"
      case _: Byte => "Byte"
      case _ => "anything else"
}

 -> Incomplete statements not supported yet, sorry, you’ll have to retype.

However, in REPL it worked just fine.

repat@laptop:~$ scala
Welcome to Scala version 2.10.3 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.

scala>   val f:AnyVal => String = {
     |       case 10.0 => "10.0"
     |       case _: Double => "Double"
     |       case _: Int => "Int"
     |       case _: Byte => "Byte"
     |       case _ => "anything else"
     |   }
f: AnyVal => String = 

scala>

So aparrently the error is in Eclipse. I use the version 3.7.2. Have you tried turning it off and on again? 😉

Droid-Break – high quality alternatives to proprietary Android apps

Posted on 23. Oktober 2013 Comments

After the NSA scandal 2013 the website prism-break.org got a little famous for recommending software, that would help keeping snooping intelligence services out of your private conversations. There are a couple of proprietary solutions, because there are just no alternatives but it’s mostly free and open source software(FOSS). While the disclaimer says „this site will not guarantee that 100% of your communications will be shielded against surveillance states“ it’s probably the best you can do. So that got me thinking and I created droid-break.info.

Prism-break.org lists a couple of Android apps, but only to security related issues such as encryption. Droid-Break is about FOSS apps in general because – as it turned out – for most of the apps we use everyday there is a good alternative FOSS solution. Most of the apps are in the F-Droid app store so you don’t have to rely on Google doing no evil.

The list includes the following categories: Browser, Social Networks, Messenger, VoIP, Audio/Podcasts, Video, Email, Notes, News Reader, File Manager, Navigation, Keyboards, Cloud, and a category for misc app that didn’t fit anywhere else.

If you have any suggestions, write a comment, an e-mail, tweet @repat123 or @droidbreak or fork the project on github.

Btw, it’s kindly hosted by neocities.org 🙂

Owncloud News Reader Error after update to 5.0.11

Posted on 21. Oktober 2013 Comments

After updating to owncloud 5.0.11 I got the following error in my Owncloud News Reader:

Screenshot_2013-10-21-10-20-56

(For Google: A Toast saying „End of input at line 1 column 1“)

In my owncloud instance, I got an error in the administrator menu saying:

SQLSTATE[HY000]: General error: 1 no such column: feeds.articles_per_update at db.php#391

I updated the owncloud instance and app framework/news app but it still showed me that everything was uptodate, even when 5.0.12 was released. Via phpMyAdmin I could see that the feeds were still in the database but I couldn’t see them in the web app or Android app. So I just deleted the owncloud folder, downloaded the new .tar.bz2 from owncloud.org, removed the oc_news tables(do not delete e.g. the contacts or bookmarks!). Then I changed my username in oc_users, used my old username as my new username and reinstalled owncloud, this time version 5.0.12.  I could then delete the old (changed) username via the admin panel.

This is the third time I had to reinstall owncloud, because the update mechanism didn’t work properly… And yes, as advised, I did deactivate the news app and app framework for the update process 😉

I just had a look at the SQL-statements from my last backup and saw that articles_per_update is supposed to be a column in oc_news_feeds in the new version of the news app. Somehow, the owncloud update process didn’t update the news app or didn’t trigger a 3rd-party update process. Anyways, I guess this could also be solved by just adding this column manually:
`articles_per_update` bigint(20) NOT NULL DEFAULT '0'

MRBS: Check if user has booked 2 rooms at the same time

Posted on 17. Oktober 2013 Comments

This little function checks if the same user has booked $room1 and $room2 at the same time.

function checkForSameUser($room1,$room2,$user,$starttime,$endtime,$tbl_entry) {
$sql = "SELECT id, name, start_time, create_by, status
FROM $tbl_entry
WHERE start_time < $endtime
AND end_time > $starttime
AND (room_id=$room1 OR room_id=$room2)
AND create_by=\"$user\"";
$res = sql_query($sql);
if (empty($res))
{
// probably because the table hasn't been created properly
trigger_error(sql_error(), E_USER_WARNING);
fatal_error(TRUE, get_vocab("fatal_db_error"));
}
if (sql_count($res) != 0)
{
sql_free($res);
return "error";
}
}

 

You can use it e.g. in mrbs_sql.inc in the function mrbsCheckFree(..) to check if a user is allowed to book a certain room like this.

// 1 and 2 are the roomIDs
$result = checkForSameUser(1,2,$user,$starttime,$endtime,$tbl_entry);
if ($result == "error"){
$err[] = get_vocab("multiple_rooms");
return $err;
}
}

As you can see the first function returns the string „error“ in case an error occured. I translated the string for multiple_rooms in every language used on this MRBS system and edited the the lang.x file in the main folder, e.g. lang.de:

$vocab["multiple_rooms"] = "Mehrere Räume können nicht gleichzeitig vom selben User gebucht werden";

MRBS: Show email address instead of username

Posted on 17. Oktober 2013 Comments

Oftentimes people use MRBS with an LDAP directory and the users have identifiers that don’t fit their real names. MRBS uses these identifiers publicly to show who reserved a room.

I see 2 problems here: if the MRBS website is public, attackers get valid usernames(although this is more obscuring than actually making it more secure), and in case users want to discuss the usage of meeting rooms, they don’t know who to talk to. In my opinion, the email address would be much more helpful.

So I had a look at the sourcecode(v. 1.8.4) and edited the following lines:

file: functions_view.inc
line: 149 ..

// This was the original code
// $tbody .= create_details_row(get_vocab("createdby"), $data['create_by'], $as_html, $class);
// This is what I made out of it
$mail = authLdapGetEmail($data['create_by']);
$tbody .= create_details_row(get_vocab("createdby"), $mail, $as_html, $class); 

Update to the latest scala version with Ubuntu 12.04 Precise Pangolin

Posted on 7. Oktober 2013 Comments

Basically the wiki at summercode.com says it all, go to (or wget) the latest version at http://www.scala-lang.org/download and untar it. Then move the folder to /usr/share/scala. Then link the address of the new binaries to the old binaries in /usr/bin. The main problem here is that you have to delete them first so I just want to add this little piece of shellscript(including the instructions from the tutorial mentioned above):

$ wget http://www.scala-lang.org/files/archive/scala-2.10.3.tgz
$ tar zxf scala-2.10.3.tgz
$ sudo mv scala-2.10.3 /usr/share/scalasudo rm /usr/bin/scala
$ sudo rm /usr/bin/scalac
$ sudo rm /usr/bin/fsc
$ sudo rm /usr/bin/sbaz
$ sudo rm /usr/bin/sbaz-setup
$ sudo rm /usr/bin/scaladoc
$ sudo rm /usr/bin/scalap
$ sudo ln -s /usr/share/scala/bin/scala /usr/bin/scala
$ sudo ln -s /usr/share/scala/bin/scalac /usr/bin/scalac
$ sudo ln -s /usr/share/scala/bin/fsc /usr/bin/fsc
$ sudo ln -s /usr/share/scala/bin/sbaz /usr/bin/sbaz
$ sudo ln -s /usr/share/scala/bin/sbaz-setup /usr/bin/sbaz-setup
$ sudo ln -s /usr/share/scala/bin/scaladoc /usr/bin/scaladoc
$ sudo ln -s /usr/share/scala/bin/scalap /usr/bin/scalap

Or download the file here: update-scala.sh (github clone)

SQLDeveloper with Ubuntu 12.04, alien and the .rpm-file

Posted on 30. September 2013 Comments

There are a couple of tutorials[1] of how to install Oracles SQLDeveloper and they all say to install the sqldeveloper-XXX-no-jre.zip, in this case sqldeveloper-3.2.20.09.87-no-jre.zip. I didn’t read it because my first idea was the following and it also worked: It’s possible to download the .rpm-file and convert it with alien. You might have to install it with

sudo apt-get install alien

then

alien sqldeveloper-3.2.20.09.87-1.noarch.rpm
dpkg -i sqldeveloper_3.2.20.09.87-2_all.deb

You can then start the sqldeveloper. It will ask you for the Java Path which is usually /usr/lib/jvm/java-6-openjdk and give you some kind of error, which didn’t seem to have any impact.

repat@laptop:~$ sqldeveloper
Oracle SQL Developer
Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.sqldeveloper/jdk
/usr/lib/jvm/java-6-openjdk
/opt/sqldeveloper/sqldeveloper/bin/../../ide/bin/launcher.sh: Zeile 455: /home/repat/.sqldeveloper/jdk: Datei oder Verzeichnis nicht gefunden

[1] e.g. Oracle Forum, Linux Sagas, Software in a bottle

Simple MRBS Output from Database

Posted on 17. September 2013 Comments

I wrote a little PHP-script that extracts the most important and current data from MRBS’s MySQL database and just prints them in a simple HTML file. Its not pretty but good for bandwith and clarity. We use it to display information on an energy efficient e-ink screen in front of conference/computer rooms.

$date is set like this:

$date = date("Y-m-d");

The SELECT-statements go like this, where N is the ID of the room(in the database, not what you might call it)

SELECT name,description,from_unixtime(start_time),from_unixtime(end_time) FROM mrbs_entry WHERE from_unixtime(start_time) LIKE '%" . $date . "%' AND room_id = N;

I’m not gonna explain here how to establish a database connection in PHP, but you can have a  look at the whole sourcecode at github 😉

I then cut off the date with substr() because it’s always 10 characters in front of time->(YYYY-MM-DD) and printed it via echo. This is the simple version, there is a version with tables on github.

while($row=mysql_fetch_row($qry01)) {
echo "- <strong>Room</strong> 01 | <strong>Desc:</strong>" . $row[0]." - ".$row[1]." |  <strong>Time:</strong> ". substr($row[2],10) . " - " . substr($row[3],10) . " <br />";
}

update: I wrote another version that prints JSON objects which can be parsed on the other side. For easier parsing(e.g. if everything is in one String) I numbered them:

$jsonarray = array('begin' . $i => substr($row[2],11, 5), 'end' . $i => substr($row[3],11,5), 'name' . $i => $row['name'], 'description' . $i =>  $row['description']);

You’ll find the whole thing on github.