From f90bb6ea756a032244a95a37e275d9055f05d21a Mon Sep 17 00:00:00 2001 From: Nico Prananta Date: Sat, 30 Jul 2016 22:59:25 +0200 Subject: [PATCH] add installlation script and update some PHP files for Ubuntu 16.04 Xenial with PHP7.0 --- .../guides/InstallationUbuntuXenialApache.sh | 144 ++++++++++++++++++ src/libraries/adapters/DatabaseMySql.php | 8 +- src/libraries/external/epi/EpiRoute.php | 2 +- src/libraries/models/Tag.php | 1 + 4 files changed, 150 insertions(+), 5 deletions(-) create mode 100755 documentation/guides/InstallationUbuntuXenialApache.sh diff --git a/documentation/guides/InstallationUbuntuXenialApache.sh b/documentation/guides/InstallationUbuntuXenialApache.sh new file mode 100755 index 000000000..9c0189645 --- /dev/null +++ b/documentation/guides/InstallationUbuntuXenialApache.sh @@ -0,0 +1,144 @@ +#!/bin/bash +####################################### +# OpenPhoto Install +# Run with sudo for best results +####################################### +SECONDS=0 +if [[ "$(/usr/bin/whoami)" != "root" ]]; then + echo "This script must be run as root or using sudo.Script aborted." + exit 1 +fi + +echo "" +echo "" +echo "====================================================" +echo "Updating Ubuntu and apt-get" +echo "====================================================" +echo "" +echo "" + +apt update +apt upgrade + +echo "" +echo "" +echo "====================================================" +echo "Installing needed packages and modules" +echo "====================================================" +echo "" +echo "" + +apt install -y apache2 curl vim git-core build-essential exiftran mysql-server mysql-client php7.0 libapache2-mod-php7.0 php7.0-curl curl php7.0-gd php7.0-mcrypt php7.0-mysql php-pear php-apcu libpcre3-dev php7.0-dev php-imagick +a2enmod rewrite +a2enmod deflate +a2enmod expires +a2enmod headers + +echo "" +echo "" +echo "====================================================" +echo "Installing oauth from pecl" +echo "====================================================" +echo "" +echo "" + +pecl install oauth +echo "extension=oauth.so" >> /etc/php/7.0/apache2/conf.d/oauth.ini + +echo "" +echo "" +echo "====================================================" +echo "Downloading OpenPhoto and unpacking" +echo "====================================================" +echo "" +echo "" + +wget https://github.com/photo/frontend/tarball/master -O openphoto.tar.gz +tar -zxvf openphoto.tar.gz > /dev/null 2>&1 +mv photo-frontend-* /var/www/openphoto +sudo rm openphoto.tar.gz + +echo "" +echo "" +echo "====================================================" +echo "Setting permissions for Dev server" +echo "====================================================" +echo "" +echo "" + +mkdir /var/www/openphoto/src/userdata +chown www-data:www-data /var/www/openphoto/src/userdata + +mkdir /var/www/openphoto/src/html/assets/cache +chown www-data:www-data /var/www/openphoto/src/html/assets/cache + +mkdir /var/www/openphoto/src/html/photos +chown www-data:www-data /var/www/openphoto/src/html/photos + +echo "" +echo "" +echo "====================================================" +echo "Setting up Apache" +echo "====================================================" +echo "" +echo "" + +cp /var/www/openphoto/src/configs/openphoto-vhost.conf /etc/apache2/sites-available/openphoto.conf +sed 's/\/path\/to\/openphoto\/html\/directory/\/var\/www\/openphoto\/src\/html/g' /var/www/openphoto/src/configs/openphoto-vhost.conf > /etc/apache2/sites-available/openphoto.conf +a2dissite 000-default +a2ensite openphoto + +echo "" +echo "" +echo "====================================================" +echo "Adjusting PHP settings" +echo "====================================================" +echo "" +echo "" + +sed -e 's/file_uploads.*/file_uploads = On/g' -e 's/upload_max_filesize.*/upload_max_filesize = 16M/g' -e 's/post_max_size.*/post_max_size = 16M/g' /etc/php/7.0/apache2/php.ini > /etc/php/7.0/apache2/php.ini.tmp +mv /etc/php/7.0/apache2/php.ini.tmp /etc/php/7.0/apache2/php.ini + +echo "" +echo "" +echo "====================================================" +echo "Launching Your OpenPhoto site" +echo "====================================================" +echo "" +echo "" + +service apache2 restart + +# finding IP address and compensating for possible EC2 installation +EC2=`curl --silent --connect-timeout 1 http://169.254.169.254/latest/meta-data/public-hostname` +if [[ $EC2 != "" ]]; +then + IP=`echo $EC2 | sed -rn 's/ec2-(.*?)\.compute.*/\1/p' | sed 's/-/./g'` +else + IP=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` +fi + +echo "" +echo "" +echo "" +echo "****************************************************" +echo "====================================================" +echo "CONGRATULATIONS!!!" +echo "" +echo "The photographic heavens are applauding your" +echo "brand new installation of OpenPhoto." +echo "" +echo "" +echo "Took $SECONDS seconds to install." +echo "" +echo "" +echo "Now you can test your installation by directing your" +echo "browser to $IP" +echo "====================================================" +echo "****************************************************" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" diff --git a/src/libraries/adapters/DatabaseMySql.php b/src/libraries/adapters/DatabaseMySql.php index 434f407b8..59f44fe0e 100644 --- a/src/libraries/adapters/DatabaseMySql.php +++ b/src/libraries/adapters/DatabaseMySql.php @@ -1091,8 +1091,8 @@ public function postAlbumAdd($albumId, $type, $elementIds) $res = true; foreach($elementIds as $elementId) { - $tmpRes = $this->db->execute("REPLACE INTO `{$this->mySqlTablePrefix}elementAlbum`(`owner`,`type`,`element`,`album`) VALUES(:owner,:type,:elementId,:albumId)", - array(':owner' => $this->owner, ':type' => $type, ':elementId' => $elementId, ':albumId' => $albumId)); + $tmpRes = $this->db->execute("REPLACE INTO `{$this->mySqlTablePrefix}elementAlbum`(`owner`,`type`,`element`,`album`, `actor`) VALUES(:owner,:type,:elementId,:albumId,:actor)", + array(':owner' => $this->owner, ':type' => $type, ':elementId' => $elementId, ':albumId' => $albumId, ':actor' => $this->getActor())); $res = $res && $tmpRes !== 0; } return $res !== false; @@ -2494,8 +2494,8 @@ private function postVersions($id, $versions) { // TODO this is gonna fail if we already have the version -- hfiguiere // Possibly use REPLACE INTO? -- jmathai - $result = $this->db->execute("REPLACE INTO {$this->mySqlTablePrefix}photoVersion (`id`, `owner`, `key`, `path`) VALUES(:id, :owner, :key, :value)", - array(':id' => $id, ':owner' => $this->owner, ':key' => $key, ':value' => $value)); + $result = $this->db->execute("REPLACE INTO {$this->mySqlTablePrefix}photoVersion (`id`, `owner`, `key`, `path`, `actor`) VALUES(:id, :owner, :key, :value, :actor)", + array(':id' => $id, ':owner' => $this->owner, ':key' => $key, ':value' => $value, ':actor' => $this->getActor())); } // TODO, what type of return value should we have here -- jmathai return ($result != 1); diff --git a/src/libraries/external/epi/EpiRoute.php b/src/libraries/external/epi/EpiRoute.php index 0618efd12..5e0ce0a46 100644 --- a/src/libraries/external/epi/EpiRoute.php +++ b/src/libraries/external/epi/EpiRoute.php @@ -87,7 +87,7 @@ public function load($file) if(!file_exists($file)) { EpiException::raise(new EpiException("Config file ({$file}) does not exist")); - break; // need to simulate same behavior if exceptions are turned off + return; // need to simulate same behavior if exceptions are turned off } $parsed_array = parse_ini_file($file, true); diff --git a/src/libraries/models/Tag.php b/src/libraries/models/Tag.php index 03f3fdd3f..5135aa9b8 100644 --- a/src/libraries/models/Tag.php +++ b/src/libraries/models/Tag.php @@ -145,6 +145,7 @@ public function update($id, $params) { $params['owner'] = $this->owner; $params['actor'] = $this->getActor(); + $params['extra'] = ''; return $this->db->postTag($id, $params); }