DEV Community

Alistair Shepherd
Alistair Shepherd

Posted on • Updated on • Originally published at alistairshepherd.uk

Fixes for Koken problems in 2020

Koken was a self-hosted Content Management System built for photographers, offering off-the-shelf features like Adobe Lightroom integration, EXIF handling, album categorisation and much more.

5 years ago, if you were looking for a free photo management website you could host yourself, Koken was a great option. I started with Koken for a photography client in 2014, and decided upon it based on the great documentation and very easy theme development.

Note: I would highly suggest against anyone setting up a new Koken site now. I'm not even sure if it's possible! This is for people maintaining their existing sites.

Alt Text

History of Koken

Koken's public beta was released in Early 2013, and got fairly popular pretty quick. It's creator Todd Dominey nailed what photographers wanted and needed from a self-hosted CMS. Although it became stable and fairly well-supported, it never made it to 1.0.

Fast forward a couple years and in 2015 Koken is bought by NetObjects, a software company which in the 90s had success with a desktop site-builder.

NetObjects continued to update Koken for around 2 years (although focusing on premium functionality), with the last release of v0.22.24 in August 2017. As far as I am aware, there has been no further development of Koken since then. The help centre and social media was active for about another year before they also had no further updates.

As of 2020 Koken still functions, but has some major issues. The store and documentation went offline sometime around the end of 2019 which obviously makes development harder and prevents the easy installation of themes, plugins, and even causes issues with logins on some older versions.

There was a Community Koken Forum called Koken Community, but as Koken died it went not long after, understandably given the lack of any official support.

My relationship with Koken

Every few weeks I get a message on twitter or an email from someone asking for help with their Koken site. This is because I have the 'honour' of being the last tweet on Koken's twitter account @koken. In 2017 I developed a theme for Koken for the previously mentioned client called Monolith. Over the end of 2017 and early 2018 I refined this and released it onto GitHub open-sourced under a GPL-v3.0 license. At this point I was unaware of the problems going on with Koken and perhaps had I known that client would be on a different platform.

Since 2017 I have been maintaining a couple of Koken sites, and have encountered a few problems that I am consistently asked about. These are my fixes for them, I hope they help!

Note these are all made on v0.22.24 and may differ for previous versions.

"Cannot connect to the API" on login, PHP 7+

When using Koken with PHP 7+ (confirmed on PHP 7.3 and 7.4) and visiting /admin/, you may get a red error box appear with "Cannot connect to the API" without any further error message. Usually this appears with a database error etc, but this is code related. To fix it:

In your installation, find /app/database/DB_Driver.php and take a look at line 1018 and you should see something like this:

        else
        {
            $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
            if (is_null($args))
            {
                return call_user_func($function);
            }
            else
            {
                return call_user_func_array($function, $args);
            }
        }
Enter fullscreen mode Exit fullscreen mode

Now, replace line 1028 (the $args declaration) with the following two lines:

$func_args = func_get_args();
$args = (func_num_args() > 1) ? array_splice($func_args, 1) : null;
Enter fullscreen mode Exit fullscreen mode

The code should now look like:

        else
        {
            $func_args = func_get_args();
            $args = (func_num_args() > 1) ? array_splice($func_args, 1) : null;
            if (is_null($args))
            {
                return call_user_func($function);
            }
            else
            {
                return call_user_func_array($function, $args);
            }
        }
Enter fullscreen mode Exit fullscreen mode

Images not loading, PHP 7+

You may not notice this immediately if you have images cached, but if you cleared the cache or uploaded a new image you may find it is not rendered. This can also occur in PHP 7+ (confirmed with 7.3 and 7.4) and is another easy fix.

Find /i.php in the root of your installation. On lines 13 and 14 there is the following:

require $root . '/app/koken/Shutter/Shutter.php';
require $root . '/app/koken/Utils/KokenAPI.php';
Enter fullscreen mode Exit fullscreen mode

Replace those lines with:

require_once $root . '/app/koken/Shutter/Shutter.php';
require_once $root . '/app/koken/Utils/KokenAPI.php';
Enter fullscreen mode Exit fullscreen mode

You also need to open /app/koken/Shutter/Shutter.php and on line 274 replace the following:

include dirname(__DIR__) . '/Utils/KokenAPI.php';
Enter fullscreen mode Exit fullscreen mode

with:

include_once dirname(__DIR__) . '/Utils/KokenAPI.php';
Enter fullscreen mode Exit fullscreen mode

Forgotten Password

First try to enter a wrong password and click the "Forgot Password" link that appears in the bottom right. This is the easiest way on more recent version of Koken

Unfortunately however it seems that previous versions relied upon store.koken.me in order to offer forgotten password functionality. We can still reset the password, but it's a bit more manual.

You need access to your koken database for this, whether than be through phpmyadmin, another database management tool, or mysql on the command line. I won't bore with the exact commands/clicks required for each, just the general process.

  1. Gain access to the database. If you don't know the login details, you can find them in /storage/configuration/database.php;
  2. Go to the koken_users table. This should have only one entry, your user with associated email etc;
  3. Copy the internal_id for the user;
  4. Then go to "http://yourwebsite.com/api.php?/users/reset_password/" with the id at the end of the URL;
  5. Visiting that link should send the email attached to your account a new password

Conclusion

If you haven't gathered from the rest of this post, unfortunately Koken is dead. I will continue to maintain a Koken site as my client cannot afford the cost of a rebuild and relies upon the Lightroom integration, something I haven't seen anywhere else. I would however say you shouldn't be setting up any new Koken websites, and if you still have one you should be seriously looking at alternatives.

There is a change.org petition calling on NetObjects to open-source Koken but I am not hopeful. They are a commercial software company, and most software companies will cling to thier code to the end.

A couple of people have asked me about alternatives now, so I've included a list below. Unfortunately there's nothing quite like it Koken but hopefully one might fill your needs

If you have any further issues with Koken then feel free to leave a comment and I'd be happy to help.

Koken Alternatives

Custom-built website

As a freelance developer I am more or less obligated to suggest that if you have the money, the best solution you will get will be through a web developer or development agency. This can be the design you want and function exactly as you need. If you're interested in my services as a developer or want some throughts on what you need, feel free to get in touch.

Hosted Photography Solutions

There are hosted photography portfolio services out there including:

I haven't used any of these platforms but I have heard they are reliable and easy-to-use and not too expensive.

Hosted Websites

For a bit more work you could use a hosted website builder like Squarespace, Wix, or WordPress.com. This will give you a bit more flexibility than a platform designed to fill a niche.

WordPress

As much as WordPress can have a bad reputation, if you consider themes and plugins carefully then you can get a great looking and performing WordPress site for photography.

It's worth looking for themes that are designed for photography so functionality like EXIF data, lightboxes, and copy protection is included. I don't have any examples but there are several free ones on the official theme directory and many options in commercial theme directories like ThemeForest.

For more Technical...

If you're fairly technically minded, there are also some great programs designed to generate a static website from your content and once you get used to them are really quick and simple.

One I've come across is called "Prosopopee" (github.com/Psycojoker/prosopopee/) and is designed for photography websites and features everything you'd need. It's a bit more involved to publish content as it's done with text files rather than a GUI or Lightroom integration, and you'll probably initially need a developer to make it look how you'd like but that wouldn't be too hard to come across.

Not focused on Photography, but again for the more technical 11ty (11ty.dev) is a static site generator that could absolutely work as a brilliant image gallery. You'd also probably need a developer to get the initial site going and perhaps integrate it with a headless CMS, but with a bit of extra work you can get a system that's a lot more flexible and resilient.

If I were to set up a new site for a photographer, this is probably the direction I'd go down. I've been burned by Koken dying in only a few years, a static site and static site generator will be around a lot longer than that.

Top comments (35)

Collapse
 
michaelkirste1 profile image
Michael Kirste

Hey folks,
some time ago, I released a self-hosted alternative to Koken called PortfolioSiteLab. Over the time the product has matured and got much more features.
You can find the project at io200.com. There is a completely free version up to a certain number of photos/articles/pages and migration from Koken can be done automatically. Unlimited usage can be purchased for a one-time payment (no subscription). If you are interested, check it out ;-).
BR, Michael
Image description

Collapse
 
michaelkirste1 profile image
Michael Kirste

Thanks for this great article. I'm also running multiple koken installations and could fix all problems with php 7.4.
However, I decided to completely reprogram the frontend and backend version of Koken. If you are interested, take a look at my article: michaelkirste.de/artikel/koken-cms...
Alt CMS Backend

Collapse
 
accudio profile image
Alistair Shepherd • Edited

That looks really interesting! I know a few people have been looking to do that but haven't found the appetite to do so.
Is any of the Koken codebase left in your code or have you built an entirely new solution from scratch?
If you make it public at any point I'd be interested to take a look!

Collapse
 
michaelkirste1 profile image
Michael Kirste

Hi Alistair, thanks for your reply. I did a complete rewrite of the system. This approachs offers the best performance and the new systems does not depend on so many other libraries.

Thread Thread
 
accudio profile image
Alistair Shepherd

Don't sell yourself short then, market it as a new system!
Koken was great but has a lot of baggage and although dead, someone still has the trademarks so probably worth distancing yourself a bit.

Regardless, good luck with it and if you do make it public I'll definitely check it out.

Thread Thread
 
michaelkirste1 profile image
Michael Kirste

Hey guys,
I finally finished the new CMS system for managing photo portfolio websites called PortfolioSiteLab. There is even an automated script that migrates your Koken data.

If you are interested, check out: portfoliositelab.com

BR regards and have a great weekend

Thread Thread
 
michaelkirste1 profile image
Michael Kirste

Hey folks, over the last year I further worked on PortfolioSiteLab. Nearly all former Koken functionalities have been implemented and many more added. Furthermore, setting up the new system is much easier using an automatic install script which also migrates an existing Koken installation.

Collapse
 
clack69 profile image
Thomas Rauers

Thanks a lot, this was really helpful - encountered the login problem after upgrading from PHP 7.2 to 7.4. What I really got in the Chrome console was

Uncaught TypeError: Cannot read property 'store' of null
    at Object.finished (koken-core.js:1937)
    at koken-core.js:1251
Enter fullscreen mode Exit fullscreen mode

but your fix for /app/database/DB_Driver.php solved the login issue. Well, two more years of Koken until support for 7.4 runs out... ;-)

Collapse
 
accudio profile image
Alistair Shepherd

Glad to hear it!

It's worth looking for a replacement as soon as you can regardless of PHP, it's never a good idea to run a dead CMS without security updates!

Collapse
 
erniebee profile image
erniebee

Thank you for your help with Koken PHP issues. However, I am a bit of a beginner, so I have the following problem when trying to correct for the fact that my hosting service has just upgraded to PHP 7.4. I was able to downgrade to 7.2 so that everything works again, but 7.2 will no longer be available to me after November 30. So here is my problem:
When trying to implement your suggested fix i do the following

name_of_my_website.com/app/databas...

and i receive a 404 error.

Any ideas? Am I going about this in a wrong way?

Collapse
 
accudio profile image
Alistair Shepherd

Yes, you'll need to edit the actual files rather than visiting the pages.

Your hosting company will offer a file manager/FTP login and then in a folder probably called public_html or www you'll be able to find the files I refer to.

Be careful when editing these, any slight mistake might break your website but if you make the changes exactly how I say you'll be fine! :)

Collapse
 
erniebee profile image
erniebee

Hi Alistair,
Thanks for taking time to guide me in the right direction. Much appreciated, and it worked beautifully! I did, however, make a couple of observations in the process to implement this fix:
1) Contrary to your statement I found that PHP 7.3 actually worked fine without the fix, while 7.4 really needs it.
2) While my hosting provider also offers a beta version of PHP 8, I tried this both with and without the fix. Neither worked (I got the red Koken admin login window), so it seems this is going to be an ongoing problem as the PHP versions progress over time.
Thanks again,
Ernie

Thread Thread
 
accudio profile image
Alistair Shepherd

That's good to know, I migrated from PHP 7.2 to 7.4 and had assumed that 7.3 would also be an issue. Thanks, I'll update the article.

As for PHP 8, given there's a fair few breaking changes it will need more fixes as you say. Honestly I think given the timescale it will be before PHP 7.4 stops being available, it would be wise to have migrated away from Koken by then.
If it's easy for me to do so however I might see if I can come up with the fixes required in future.

Thread Thread
 
erniebee profile image
erniebee

OK, and as you say it's probably time to start looking for alternatives to Koken. However, finding something that does the job as well as Koken does for photographers, with Lightroom plug-in as well as being totally free, is going to be hard, I think.

Collapse
 
pirsch profile image
Pirsch

Hello Alistair,
thanks again for the fix. We run two installations of koken. One - the older one - is working again after the adjustments. The other one - however - which is a newer version of koken, does not work. While the site itself is serving files, the admin page says "Connection error. Cannot connect to the API." Might there be other adjustments to make?
Unfortunately, I don't know how to find out which built of koken it is.
Thank you
-Stephan

Collapse
 
accudio profile image
Alistair Shepherd

Hi Stephan,

This should be all that is required to make the newest version of Koken work with PHP 7.3/7.4. Keep in mind that more changes would be required for PHP 8 compatibility. I am undecided about diagnosing and releasing these though as it would be encouraging using Koken well beyond its lifespanβ€”perhaps irresponsible security-wise.

It may be you have an older version that does require additional work, or there are plugins/modifications that would also need changes to work.

Regardless, for that second installation you are probably going to have to diagnose it yourself or have a developer do so for you. Koken is not a complex system and is not too hard to diagnose, but the lack of documentation does make it tricky.

Thanks,
Alistair

Collapse
 
pirsch profile image
Pirsch

Hi Alistair,
thanks for getting back. Yeah, it's really strange. Both installations run on PHP 7.3. I am asking myself if it is some kind of cache issue. Unfortunately, I can't access the server logfiles at this time, since I only have an ftp-account. You are certainly right in saying that one should rather not stick to Koken, but often - as in my case - there are customers that are reluctant to spending any more money on a website that just keeps serving static content and does not have to be touched anymore.
Thanks and all the best
Stephan

Collapse
 
cmahoney_photo profile image
π™²πš‘πš›πš’πšœ π™ΌπšŠπš‘πš˜πš—πšŽπš’

First off, thanks for your hard work on this and for taking the time to post this. The only issue I have is that I would like to update jQuery due to the outdated version. I have tried some find/replace on all files, but ultimately it errors out when trying to load any images. Have you had any luck in doing this?

Collapse
 
accudio profile image
Alistair Shepherd • Edited

Hi, I'm afraid not - although it should be fairly straightforward I think.

Honestly though, I think trying to update jQuery is a waste of your time. Koken is dead, and it is very risky to continue using it.
I wrote this post to buy people more time to migrate.

Collapse
 
maxican profile image
rawimage

Thank you very much for this helpful article. Don't know if this is relevant, but I also had to clear the system cache in koken after updating i.php and shutter.php to fix the images-not-loading issue.

Collapse
 
accudio profile image
Alistair Shepherd

Thanks for mentioning! That's good to know - it wasn't required for me but I don't know Koken's image conversion system well so I perhaps got lucky.

Collapse
 
akhena profile image
AndrΓ©

Thank you a lot for this post Alistair!

I have been using Koken for more than 6 years and I have been failing miserably these last months in moving the koken install to a new server.

Thanks to the fix in DB_Driver.php mentionned in your post, I was finally able to have the admin console working on my new server (with php 7).

Big up for you Alistair!

Collapse
 
mohamedowsam profile image
Mohamed osam

Hello,
Thanks for sharing this knowledge, It's really helpful.
but I'm a bit confused as I have zero knowledge with coding should I write the new lines in the line no 1028 or should I replace it in 1018

Collapse
 
accudio profile image
Alistair Shepherd

Hi Mohamed,
Replace this line:

$args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
Enter fullscreen mode Exit fullscreen mode

with this:

$func_args = func_get_args();
$args = (func_num_args() > 1) ? array_splice($func_args, 1) : null;
Enter fullscreen mode Exit fullscreen mode

Hope that helps!

Collapse
 
accudio profile image
Alistair Shepherd

I'm afraid I haven't heard of a php file you can use to reset but I assume it would be doing the exact process that I have listed just on the server rather than manually.

Are you making sure to include the internal_id in the URL of the api? You should visit a URL like "yourwebsite.com/api.php?/users/res...".

If you've got the internal_id and the url correct then you will have to diagnose the problem. As it's a 500 error it will appear in your hosting error log, which might help work out what the problem is.

I don't know if perhaps the reset password procedure has changed at some point, do you know if you are running the latest version of Koken? If it has changed I'm afraid I don't know the procedure you should be using.

Collapse
 
daedric7 profile image
daedric7

Thank you, with your fixes and some more tinkering i managed to get koken back running.

Yet, i'm facing a weird issue. Aparently some photos although being taken in portrait orientation, are stored in landscape proportions and with a exif tag (i think) to correct the orientation which most apps and websites respect, yet koken ignores.

No problem, i'll rotate the images. And in the admin the images are rotated and displayed correctly. But on the public website, they are distorced to the original proportions.

Am i alone in this experience ?

Collapse
 
accudio profile image
Alistair Shepherd

I'm afraid I haven't experienced that at all but I don't actually use Koken day-to-day, I have only developed for it.
I assume that Koken performs some manipulation then for either the website or admin that ignores EXIF orientation. You could maybe try a service that removes EXIF data and see if that succeeds?
Best of luck!

Collapse
 
pirsch profile image
Pirsch

Hey Alistair, thanks for your help and for keeping Koken alive!

Collapse
 
accudio profile image
Alistair Shepherd

Hi Pirsch, you're welcome.
Make no mistake though, Koken is very much dead. The intention of this post is not to help you keep your Koken site going longer - this is to help buy you a bit more time to migrate to a better solution.

Collapse
 
jonathanr79 profile image
Jonathan R • Edited

A big thanks! That did help me for the admin page but my site is still returning an error 500 :-(

Do you believe there is an easy way to upgrade jquery on Koken? It's quite old and may contain some security issues.

Regarding replacing a koken website. Did you look at Hugo, Gatsby and Next ?

Collapse
 
accudio profile image
Alistair Shepherd

There may be some further Koken issues other than I'm aware of. Unfortunately it's a bit tricky to diagnose, your best bet will be to take a look at the error log of your hosting and it should point you in the right direction.

Personally I don't think it's worth upgrading jQuery, although it will likely have security bugs - as it's a frontend-only dependency and Koken has limited interactivity I don't think that the risk is significant compared to using a CMS without security updates.

As for the SSGs you mention, good question! The alternatives I listed are mostly focused at Photographers rather than developers so are designed to be fairly easy to set up.
Personally as a developer I would be using an HTML-only Static Site Generator like 11ty, or Hugo (although I don't know Go so it's less accessible for me). I don't really like Gatsby as a technology or company (that's something I won't get into now) but if your website has lots of dynamic functionality and is more app-like than website-like then Next.js (w/ Preact), Nuxt or Sapper would do a great job.
Of course then it's a lot harder to manage content so I'd also probably pair it with a headless CMS like Sanity, Forestry, or my favourite - WordPress!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.