From e77ffc6849a0099823b830d1e20f114ffa77fef7 Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 1 Apr 2016 23:44:31 +0200 Subject: [PATCH] big commit --- .gitignore | 1 - composer.json | 8 + composer.lock | 1604 +++++++++++++++++ libraries/BBcodeDefinitions/User.php | 3 +- libraries/Comment.php | 2 +- libraries/Controllers/AuthController.php | 99 +- .../Settings/AdvancedController.php | 12 +- libraries/Controllers/Settings/Controller.php | 5 + .../Settings/FriendsController.php | 6 +- .../Settings/GeneralController.php | 175 +- .../Settings/NotificationsController.php | 4 +- libraries/Controllers/UserController.php | 10 +- libraries/Session.php | 2 +- libraries/Urls.php | 314 +--- libraries/User.php | 16 +- libraries/Users.php | 169 -- libraries/Utils.php | 349 ---- public/content/data/yuuno/css/yuuno.css | 13 +- public/settings.php | 221 +-- routes.php | 9 +- sakura.php | 32 +- templates/misaki/main/profile.twig | 2 +- templates/yuuno/elements/comment.twig | 2 +- templates/yuuno/forum/thread.twig | 2 +- templates/yuuno/global/master.twig | 1 - .../yuuno/old-settings/friends.listing.twig | 37 - .../yuuno/old-settings/friends.requests.twig | 38 - .../yuuno/old-settings/general.home.twig | 20 - .../yuuno/old-settings/general.options.twig | 31 - .../yuuno/old-settings/general.profile.twig | 59 - .../yuuno/old-settings/messages.compose.twig | 0 .../yuuno/old-settings/messages.inbox.twig | 23 - .../yuuno/old-settings/messages.read.twig | 0 .../yuuno/old-settings/messages.sent.twig | 0 .../old-settings/notifications.history.twig | 49 - templates/yuuno/settings/advanced/master.twig | 3 + .../yuuno/settings/advanced/sessions.twig | 51 + templates/yuuno/settings/friends/listing.twig | 39 + templates/yuuno/settings/friends/master.twig | 11 + .../yuuno/settings/friends/requests.twig | 40 + templates/yuuno/settings/general/options.twig | 33 + templates/yuuno/settings/general/profile.twig | 76 + .../yuuno/settings/notifications/history.twig | 59 + .../yuuno/settings/notifications/master.twig | 3 + templates/yuuno/user/profile.twig | 2 +- templates/yuuno/user/report.twig | 5 + utility.php | 278 +++ 47 files changed, 2544 insertions(+), 1374 deletions(-) create mode 100644 composer.lock delete mode 100644 libraries/Users.php delete mode 100644 libraries/Utils.php delete mode 100644 templates/yuuno/old-settings/friends.listing.twig delete mode 100644 templates/yuuno/old-settings/friends.requests.twig delete mode 100644 templates/yuuno/old-settings/general.home.twig delete mode 100644 templates/yuuno/old-settings/general.options.twig delete mode 100644 templates/yuuno/old-settings/general.profile.twig delete mode 100644 templates/yuuno/old-settings/messages.compose.twig delete mode 100644 templates/yuuno/old-settings/messages.inbox.twig delete mode 100644 templates/yuuno/old-settings/messages.read.twig delete mode 100644 templates/yuuno/old-settings/messages.sent.twig delete mode 100644 templates/yuuno/old-settings/notifications.history.twig create mode 100644 templates/yuuno/settings/advanced/master.twig create mode 100644 templates/yuuno/settings/advanced/sessions.twig create mode 100644 templates/yuuno/settings/friends/listing.twig create mode 100644 templates/yuuno/settings/friends/master.twig create mode 100644 templates/yuuno/settings/friends/requests.twig create mode 100644 templates/yuuno/settings/general/options.twig create mode 100644 templates/yuuno/settings/general/profile.twig create mode 100644 templates/yuuno/settings/notifications/history.twig create mode 100644 templates/yuuno/settings/notifications/master.twig create mode 100644 templates/yuuno/user/report.twig create mode 100644 utility.php diff --git a/.gitignore b/.gitignore index 2fb4319..46befc7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ google*.html [Tt]humbs.db Desktop.ini $RECYCLE.BIN/ -composer.lock diff --git a/composer.json b/composer.json index 45853f2..0afdce1 100644 --- a/composer.json +++ b/composer.json @@ -19,5 +19,13 @@ "phroute/phroute": "^2.1", "illuminate/database": "5.2.*", "doctrine/dbal": "~2.4" + }, + "autoload": { + "psr-4": { + "Sakura\\": "libraries/" + }, + "files": [ + "utility.php" + ] } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..cada582 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1604 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "74d0e0231a20998b63636505d174d1d2", + "content-hash": "1af681873ad63e53d42dfd445d67b388", + "packages": [ + { + "name": "corneltek/class-template", + "version": "2.1.2", + "source": { + "type": "git", + "url": "https://github.com/c9s/ClassTemplate.git", + "reference": "4bdb46a6b1a5245118e7bf08b4cdacdfdaadb77b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/c9s/ClassTemplate/zipball/4bdb46a6b1a5245118e7bf08b4cdacdfdaadb77b", + "reference": "4bdb46a6b1a5245118e7bf08b4cdacdfdaadb77b", + "shasum": "" + }, + "require": { + "corneltek/codegen": "^2", + "php": ">=5.3.0", + "twig/twig": "^1" + }, + "require-dev": { + "corneltek/phpunit-testmore": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "ClassTemplate\\": "src/ClassTemplate/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Yo-An Lin", + "email": "yoanlin93@gmail.com", + "homepage": "http://c9s.me" + } + ], + "description": "Class template Utilities", + "homepage": "http://github.com/c9s/ClassTemplate", + "time": "2015-09-06 05:04:14" + }, + { + "name": "corneltek/cliframework", + "version": "2.8.1", + "source": { + "type": "git", + "url": "https://github.com/c9s/CLIFramework.git", + "reference": "7ca1239bb032f5cd1d746974954adde0233900ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/c9s/CLIFramework/zipball/7ca1239bb032f5cd1d746974954adde0233900ce", + "reference": "7ca1239bb032f5cd1d746974954adde0233900ce", + "shasum": "" + }, + "require": { + "corneltek/class-template": "^2", + "corneltek/codegen": "^2", + "corneltek/getoptionkit": "^2", + "corneltek/universal": ">= 1.4", + "php": ">=5.3.0", + "pimple/pimple": "*", + "symfony/class-loader": "^2.7", + "symfony/finder": "^2.7" + }, + "require-dev": { + "corneltek/phpunit-testmore": "dev-master", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "CLIFramework\\": "src/CLIFramework/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Yo-An Lin", + "email": "cornelius.howl@gmail.com", + "homepage": "http://c9s.me" + } + ], + "description": "Command-line framework for PHP", + "homepage": "http://github.com/c9s/CLIFramework", + "keywords": [ + "command", + "command-line", + "completion", + "framework", + "getopt", + "zsh" + ], + "time": "2015-11-07 11:01:47" + }, + { + "name": "corneltek/codegen", + "version": "2.7.1", + "source": { + "type": "git", + "url": "https://github.com/c9s/CodeGen.git", + "reference": "b2a1835b4a0c63cb5f1c1c0a44176adbbfd46dcd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/c9s/CodeGen/zipball/b2a1835b4a0c63cb5f1c1c0a44176adbbfd46dcd", + "reference": "b2a1835b4a0c63cb5f1c1c0a44176adbbfd46dcd", + "shasum": "" + }, + "require": { + "doctrine/inflector": "*", + "php": ">=5.3.0", + "twig/twig": "^1 >=1.21" + }, + "require-dev": { + "corneltek/phpunit-testmore": "dev-master" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "CodeGen\\": "src/CodeGen/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Yo-An Lin", + "email": "yoanlin93@gmail.com", + "homepage": "http://c9s.me" + } + ], + "description": "PHP Code Generation Library", + "homepage": "http://github.com/c9s/CodeGen", + "time": "2016-03-26 07:10:40" + }, + { + "name": "corneltek/getoptionkit", + "version": "2.2.5", + "source": { + "type": "git", + "url": "https://github.com/c9s/GetOptionKit.git", + "reference": "977b11bf1f44a02398ecfc96cf2fc913cb9f017b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/c9s/GetOptionKit/zipball/977b11bf1f44a02398ecfc96cf2fc913cb9f017b", + "reference": "977b11bf1f44a02398ecfc96cf2fc913cb9f017b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "corneltek/phpunit-testmore": "dev-master", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "GetOptionKit\\": "src/GetOptionKit/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Yo-An Lin", + "email": "cornelius.howl@gmail.com", + "homepage": "http://c9s.me" + } + ], + "description": "Powerful command-line option toolkit", + "homepage": "http://github.com/c9s/GetOptionKit", + "time": "2016-02-16 10:41:32" + }, + { + "name": "corneltek/universal", + "version": "1.7.2", + "source": { + "type": "git", + "url": "https://github.com/c9s/Universal.git", + "reference": "7815546cc524f6eac84d8f7620510e9277252d78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/c9s/Universal/zipball/7815546cc524f6eac84d8f7620510e9277252d78", + "reference": "7815546cc524f6eac84d8f7620510e9277252d78", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "corneltek/phpunit-testmore": "dev-master", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "Universal\\": "src/Universal/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Yo-An Lin", + "email": "cornelius.howl@gmail.com", + "homepage": "http://c9s.me" + } + ], + "description": "Universal library for PHP", + "homepage": "http://github.com/c9s/Universal", + "time": "2015-11-07 10:32:02" + }, + { + "name": "doctrine/annotations", + "version": "v1.2.7", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2015-08-31 12:32:49" + }, + { + "name": "doctrine/cache", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "shasum": "" + }, + "require": { + "php": "~5.5|~7.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2015-12-31 16:37:02" + }, + { + "name": "doctrine/collections", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2015-04-14 22:21:58" + }, + { + "name": "doctrine/common", + "version": "v2.6.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~5.5|~7.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2015-12-25 13:18:31" + }, + { + "name": "doctrine/dbal", + "version": "v2.5.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/abbdfd1cff43a7b99d027af3be709bc8fc7d4769", + "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.7-dev", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/console": "2.*" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2016-01-05 22:11:12" + }, + { + "name": "doctrine/inflector", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2015-11-06 14:35:42" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09 13:34:57" + }, + { + "name": "illuminate/container", + "version": "v5.2.28", + "source": { + "type": "git", + "url": "https://github.com/illuminate/container.git", + "reference": "1e156f8017490f5583ab161030bf839c77c95e54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/container/zipball/1e156f8017490f5583ab161030bf839c77c95e54", + "reference": "1e156f8017490f5583ab161030bf839c77c95e54", + "shasum": "" + }, + "require": { + "illuminate/contracts": "5.2.*", + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Container\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "description": "The Illuminate Container package.", + "homepage": "http://laravel.com", + "time": "2016-03-16 17:19:17" + }, + { + "name": "illuminate/contracts", + "version": "v5.2.28", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "411b851962c211078ade7664a6976e77a78cd2a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/411b851962c211078ade7664a6976e77a78cd2a5", + "reference": "411b851962c211078ade7664a6976e77a78cd2a5", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "http://laravel.com", + "time": "2016-03-07 20:37:17" + }, + { + "name": "illuminate/database", + "version": "v5.2.28", + "source": { + "type": "git", + "url": "https://github.com/illuminate/database.git", + "reference": "1ea9f36cef011a80b1623ea3566d57017e7913bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/database/zipball/1ea9f36cef011a80b1623ea3566d57017e7913bc", + "reference": "1ea9f36cef011a80b1623ea3566d57017e7913bc", + "shasum": "" + }, + "require": { + "illuminate/container": "5.2.*", + "illuminate/contracts": "5.2.*", + "illuminate/support": "5.2.*", + "nesbot/carbon": "~1.20", + "php": ">=5.5.9" + }, + "suggest": { + "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).", + "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", + "illuminate/console": "Required to use the database commands (5.2.*).", + "illuminate/events": "Required to use the observers with Eloquent (5.2.*).", + "illuminate/filesystem": "Required to use the migrations (5.2.*).", + "illuminate/pagination": "Required to paginate the result set (5.2.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Database\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "description": "The Illuminate Database package.", + "homepage": "http://laravel.com", + "keywords": [ + "database", + "laravel", + "orm", + "sql" + ], + "time": "2016-04-01 18:17:22" + }, + { + "name": "illuminate/support", + "version": "v5.2.28", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "e4aa03c5f26db752e838354a7d71b85e6138f4ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/e4aa03c5f26db752e838354a7d71b85e6138f4ec", + "reference": "e4aa03c5f26db752e838354a7d71b85e6138f4ec", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.0", + "ext-mbstring": "*", + "illuminate/contracts": "5.2.*", + "paragonie/random_compat": "~1.4", + "php": ">=5.5.9" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (5.2.*).", + "jeremeamia/superclosure": "Required to be able to serialize closures (~2.2).", + "symfony/polyfill-php56": "Required to use the hash_equals function on PHP 5.5 (~1.0).", + "symfony/process": "Required to use the composer class (2.8.*|3.0.*).", + "symfony/var-dumper": "Improves the dd function (2.8.*|3.0.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + }, + "files": [ + "helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "http://laravel.com", + "time": "2016-03-30 18:18:45" + }, + { + "name": "jbbcode/jbbcode", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/jbowens/jBBCode.git", + "reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jbowens/jBBCode/zipball/645b6a1c0afa92b7d029d3417ebd8b60a5c578b3", + "reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "JBBCode": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jackson Owens", + "email": "jackson_owens@alumni.brown.edu", + "homepage": "http://jbowens.org/", + "role": "Developer" + } + ], + "description": "A lightweight but extensible BBCode parser written in PHP 5.3.", + "homepage": "http://jbbcode.com/", + "keywords": [ + "BB", + "bbcode" + ], + "time": "2014-07-06 05:48:20" + }, + { + "name": "nesbot/carbon", + "version": "1.21.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7b08ec6f75791e130012f206e3f7b0e76e18e3d7", + "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/translation": "~2.6|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2015-11-04 20:07:17" + }, + { + "name": "paragonie/random_compat", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "c7e26a21ba357863de030f0b9e701c7d04593774" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774", + "reference": "c7e26a21ba357863de030f0b9e701c7d04593774", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "pseudorandom", + "random" + ], + "time": "2016-03-18 20:34:03" + }, + { + "name": "paypal/rest-api-sdk-php", + "version": "v1.6.4", + "source": { + "type": "git", + "url": "https://github.com/paypal/PayPal-PHP-SDK.git", + "reference": "06837d290c4906578cfd92786412dff330a1429c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/06837d290c4906578cfd92786412dff330a1429c", + "reference": "06837d290c4906578cfd92786412dff330a1429c", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "PayPal": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "PayPal", + "homepage": "https://github.com/paypal/rest-api-sdk-php/contributors" + } + ], + "description": "PayPal's PHP SDK for REST APIs", + "homepage": "http://paypal.github.io/PayPal-PHP-SDK/", + "keywords": [ + "payments", + "paypal", + "rest", + "sdk" + ], + "time": "2016-01-20 17:45:52" + }, + { + "name": "phpmailer/phpmailer", + "version": "v5.2.14", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "e774bc9152de85547336e22b8926189e582ece95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/e774bc9152de85547336e22b8926189e582ece95", + "reference": "e774bc9152de85547336e22b8926189e582ece95", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "*", + "phpunit/phpunit": "4.7.*" + }, + "suggest": { + "league/oauth2-client": "Needed for XOAUTH2 authentication", + "league/oauth2-google": "Needed for Gmail XOAUTH2" + }, + "type": "library", + "autoload": { + "classmap": [ + "class.phpmailer.php", + "class.phpmaileroauth.php", + "class.phpmaileroauthgoogle.php", + "class.smtp.php", + "class.pop3.php", + "extras/EasyPeasyICS.php", + "extras/ntlm_sasl_client.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "time": "2015-11-01 10:15:28" + }, + { + "name": "phroute/phroute", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/mrjgreen/phroute.git", + "reference": "dbe2b986f9ee1dd33dc956fcc35d1fa22e8e196c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mrjgreen/phroute/zipball/dbe2b986f9ee1dd33dc956fcc35d1fa22e8e196c", + "reference": "dbe2b986f9ee1dd33dc956fcc35d1fa22e8e196c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "*", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "Phroute\\Phroute\\": "src/Phroute" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Joe Green", + "email": "joe.green.0991@gmail.com" + } + ], + "description": "Fast, fully featured restful request router for PHP", + "keywords": [ + "router", + "routing" + ], + "time": "2015-07-22 20:46:43" + }, + { + "name": "pimple/pimple", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a", + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2015-09-11 15:10:35" + }, + { + "name": "symfony/class-loader", + "version": "v2.8.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/class-loader.git", + "reference": "7d362c22710980730d46a5d039e788946a2938cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/class-loader/zipball/7d362c22710980730d46a5d039e788946a2938cb", + "reference": "7d362c22710980730d46a5d039e788946a2938cb", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/polyfill-apcu": "~1.1" + }, + "require-dev": { + "symfony/finder": "~2.0,>=2.0.5|~3.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\ClassLoader\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony ClassLoader Component", + "homepage": "https://symfony.com", + "time": "2016-03-10 19:33:53" + }, + { + "name": "symfony/finder", + "version": "v2.8.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/ca24cf2cd4e3826f571e0067e535758e73807aa1", + "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2016-03-10 10:53:53" + }, + { + "name": "symfony/polyfill-apcu", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-apcu.git", + "reference": "0c901e4e65a2f7ece68f0fd249b56d6ad3adc214" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/0c901e4e65a2f7ece68f0fd249b56d6ad3adc214", + "reference": "0c901e4e65a2f7ece68f0fd249b56d6ad3adc214", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting apcu_* functions to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "apcu", + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2016-03-03 16:49:40" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "1289d16209491b584839022f29257ad859b8532d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", + "reference": "1289d16209491b584839022f29257ad859b8532d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2016-01-20 09:13:37" + }, + { + "name": "symfony/translation", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "f7a07af51ea067745a521dab1e3152044a2fb1f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/f7a07af51ea067745a521dab1e3152044a2fb1f2", + "reference": "f7a07af51ea067745a521dab1e3152044a2fb1f2", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<2.8" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/intl": "~2.8|~3.0", + "symfony/yaml": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2016-03-25 01:41:20" + }, + { + "name": "twig/twig", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "3e5aa30ebfbafd5951fb1b01e338e1800ce7e0e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/3e5aa30ebfbafd5951fb1b01e338e1800ce7e0e8", + "reference": "3e5aa30ebfbafd5951fb1b01e338e1800ce7e0e8", + "shasum": "" + }, + "require": { + "php": ">=5.2.7" + }, + "require-dev": { + "symfony/debug": "~2.7", + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.24-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "http://twig.sensiolabs.org/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2016-01-25 21:22:18" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.0.0", + "ext-curl": "*", + "ext-json": "*" + }, + "platform-dev": [] +} diff --git a/libraries/BBcodeDefinitions/User.php b/libraries/BBcodeDefinitions/User.php index d731b4f..6b5aa02 100644 --- a/libraries/BBcodeDefinitions/User.php +++ b/libraries/BBcodeDefinitions/User.php @@ -11,7 +11,6 @@ use JBBCode\CodeDefinition; use JBBCode\ElementNode; use Sakura\Router; use Sakura\User as SakuraUser; -use Sakura\Utils; /** * Username BBcode for JBBCode. @@ -44,7 +43,7 @@ class User extends CodeDefinition $content = ""; foreach ($el->getChildren() as $child) { - $content .= Utils::cleanString($child->getAsText(), true); + $content .= clean_string($child->getAsText(), true); } $user = SakuraUser::construct($content); diff --git a/libraries/Comment.php b/libraries/Comment.php index ba78797..a3a1463 100644 --- a/libraries/Comment.php +++ b/libraries/Comment.php @@ -104,7 +104,7 @@ class Comment public function parsed() { if (!$this->parsedCache) { - $this->parsedCache = BBcode::parseEmoticons(Utils::cleanString($this->text)); + $this->parsedCache = BBcode::parseEmoticons(clean_string($this->text)); } return $this->parsedCache; diff --git a/libraries/Controllers/AuthController.php b/libraries/Controllers/AuthController.php index c8f0531..b3ff19d 100644 --- a/libraries/Controllers/AuthController.php +++ b/libraries/Controllers/AuthController.php @@ -18,8 +18,6 @@ use Sakura\Router; use Sakura\Session; use Sakura\Template; use Sakura\User; -use Sakura\Users; -use Sakura\Utils; /** * Authentication controllers. @@ -125,7 +123,7 @@ class AuthController extends Controller } // Get account data - $user = User::construct(Utils::cleanString($username, true, true)); + $user = User::construct(clean_string($username, true, true)); // Check if the user that's trying to log in actually exists if ($user->id === 0) { @@ -304,11 +302,12 @@ class AuthController extends Controller } // Attempt to get account data - $user = User::construct(Utils::cleanString($username, true, true)); + $user = User::construct(clean_string($username, true, true)); // Check if the username already exists if ($user && $user->id !== 0) { - $message = "{$user->username} is already a member here! If this is you please use the password reset form instead of making a new account."; + $message = "{$user->username} is already a member here!" + . " If this is you please use the password reset form instead of making a new account."; Template::vars(['page' => compact('success', 'redirect', 'message')]); @@ -343,7 +342,7 @@ class AuthController extends Controller } // Check the MX record of the email - if (!Utils::checkMXRecord($email)) { + if (!check_mx_record($email)) { $message = 'No valid MX-Record found on the e-mail address you supplied.'; Template::vars(['page' => compact('success', 'redirect', 'message')]); @@ -364,7 +363,7 @@ class AuthController extends Controller } // Check password entropy - if (Utils::pwdEntropy($password) < Config::get('min_entropy')) { + if (password_entropy($password) < Config::get('min_entropy')) { $message = 'Your password is too weak, try adding some special characters.'; Template::vars(['page' => compact('success', 'redirect', 'message')]); @@ -382,7 +381,7 @@ class AuthController extends Controller // Check if we require e-mail activation if ($requireActive) { // Send activation e-mail to user - Users::sendActivationMail($user->id); + $this->sendActivationMail($user); } // Return true with a specific message if needed @@ -502,8 +501,8 @@ class AuthController extends Controller } // Grab forms - $username = isset($_POST['username']) ? Utils::cleanString($_POST['username'], true) : null; - $email = isset($_POST['email']) ? Utils::cleanString($_POST['email'], true) : null; + $username = isset($_POST['username']) ? clean_string($_POST['username'], true) : null; + $email = isset($_POST['email']) ? clean_string($_POST['email'], true) : null; // Do database request $getUser = DB::table('users') @@ -533,7 +532,7 @@ class AuthController extends Controller } // Send activation e-mail to user - Users::sendActivationMail($user->id); + $this->sendActivationMail($user); $success = 1; $redirect = Router::route('auth.login'); @@ -587,8 +586,8 @@ class AuthController extends Controller $userId = isset($_POST['user']) ? $_POST['user'] : 0; $key = isset($_POST['key']) ? $_POST['key'] : ""; $password = isset($_POST['password']) ? $_POST['password'] : ""; - $userName = isset($_POST['username']) ? Utils::cleanString($_POST['username'], true) : ""; - $email = isset($_POST['email']) ? Utils::cleanString($_POST['email'], true) : null; + $userName = isset($_POST['username']) ? clean_string($_POST['username'], true) : ""; + $email = isset($_POST['email']) ? clean_string($_POST['email'], true) : null; // Create user object $user = User::construct($userId ? $userId : $userName); @@ -613,7 +612,7 @@ class AuthController extends Controller if ($key && $password) { // Check password entropy - if (Utils::pwdEntropy($password) < Config::get('min_entropy')) { + if (password_entropy($password) < Config::get('min_entropy')) { $message = "Your password doesn't meet the strength requirements!"; Template::vars(['page' => compact('success', 'redirect', 'message')]); @@ -650,8 +649,8 @@ class AuthController extends Controller $message = "Changed your password! You may now log in."; $redirect = Router::route('auth.login'); } else { - // Send e-mail - Users::sendPasswordForgot($user->id, $user->email); + // Send the e-mail + $this->sendPasswordMail($user); $success = 1; $message = "Sent the e-mail, keep an eye on your spam folder as well!"; @@ -662,4 +661,72 @@ class AuthController extends Controller return Template::render('global/information'); } + + /** + * Send the activation e-mail + * + * @param User $user + */ + private function sendActivationMail($user) + { + // Generate activation key + $activate = ActionCode::generate('ACTIVATE', $user->id); + + $siteName = Config::get('sitename'); + $baseUrl = "http://" . Config::get('url_main'); + $activateLink = Router::route('auth.activate') . "?u={$user->id}&k={$activate}"; + $profileLink = Router::route('user.profile', $user->id); + $signature = Config::get('mail_signature'); + + // Build the e-mail + $message = "Welcome to {$siteName}!\r\n\r\n" + . "Please keep this e-mail for your records. Your account intormation is as follows:\r\n\r\n" + . "----------------------------\r\n\r\n" + . "Username: {$user->username}\r\n\r\n" + . "Your profile: {$baseUrl}{$profileLink}\r\n\r\n" + . "----------------------------\r\n\r\n" + . "Please visit the following link in order to activate your account:\r\n\r\n" + . "{$baseUrl}{$activateLink}\r\n\r\n" + . "Your password has been securely stored in our database and cannot be retrieved. " + . "In the event that it is forgotten," + . " you will be able to reset it using the email address associated with your account.\r\n\r\n" + . "Thank you for registering.\r\n\r\n" + . "--\r\n\r\nThanks\r\n\r\n{$signature}"; + + // Send the message + send_mail([$user->email => $user->username], "{$siteName} activation mail", $message); + } + + /** + * Send the activation e-mail + * + * @param User $user + */ + private function sendPasswordMail($user) + { + // Generate the verification key + $verk = ActionCode::generate('LOST_PASS', $user->id); + + $siteName = Config::get('sitename'); + $baseUrl = "http://" . Config::get('url_main'); + $reactivateLink = Router::route('auth.resetpassword') . "?u={$user->id}&k={$verk}"; + $signature = Config::get('mail_signature'); + + // Build the e-mail + $message = "Hello {$user->username},\r\n\r\n" + . "You are receiving this notification because you have (or someone pretending to be you has)" + . " requested a password reset link to be sent for your account on \"{$siteName}\"." + . " If you did not request this notification then please ignore it," + . " if you keep receiving it please contact the site administrator.\r\n\r\n" + . "To use this password reset key you need to go to a special page." + . " To do this click the link provided below.\r\n\r\n" + . "{$baseUrl}{$reactivateLink}\r\n\r\n" + . "If successful you should be able to change your password here.\r\n\r\n" + . "You can of course change this password yourself via the settings page." + . " If you have any difficulties please contact the site administrator.\r\n\r\n" + . "--\r\n\r\nThanks\r\n\r\n{$signature}"; + + // Send the message + send_mail([$user->email => $user->username], "{$siteName} password restoration", $message); + } } diff --git a/libraries/Controllers/Settings/AdvancedController.php b/libraries/Controllers/Settings/AdvancedController.php index e0d0dff..09b65ae 100644 --- a/libraries/Controllers/Settings/AdvancedController.php +++ b/libraries/Controllers/Settings/AdvancedController.php @@ -7,6 +7,10 @@ namespace Sakura\Controllers\Settings; +use Sakura\ActiveUser; +use Sakura\DB; +use Sakura\Template; + /** * Advanced settings. * @@ -17,7 +21,13 @@ class AdvancedController extends Controller { public function sessions() { - return $this->go('advanced.sessions'); + $sessions = DB::table('sessions') + ->where('user_id', ActiveUser::$user->id) + ->get(); + + Template::vars(compact('sessions')); + + return Template::render('settings/advanced/sessions'); } public function deactivate() diff --git a/libraries/Controllers/Settings/Controller.php b/libraries/Controllers/Settings/Controller.php index 6a854c5..92e9e82 100644 --- a/libraries/Controllers/Settings/Controller.php +++ b/libraries/Controllers/Settings/Controller.php @@ -11,6 +11,7 @@ use Sakura\ActiveUser; use Sakura\Controllers\Controller as BaseController; use Sakura\Perms\Site; use Sakura\Router; +use Sakura\Template; use Sakura\Urls; /** @@ -26,6 +27,10 @@ class Controller extends BaseController public function __construct() { $this->urls = new Urls(); + + $navigation = $this->navigation(); + + Template::vars(compact('navigation')); } public function go($location) diff --git a/libraries/Controllers/Settings/FriendsController.php b/libraries/Controllers/Settings/FriendsController.php index 11d4343..5e09b1e 100644 --- a/libraries/Controllers/Settings/FriendsController.php +++ b/libraries/Controllers/Settings/FriendsController.php @@ -7,6 +7,8 @@ namespace Sakura\Controllers\Settings; +use Sakura\Template; + /** * Friends settings. * @@ -17,11 +19,11 @@ class FriendsController extends Controller { public function listing() { - return $this->go('friends.listing'); + return Template::render('settings/friends/listing'); } public function requests() { - return $this->go('friends.requests'); + return Template::render('settings/friends/requests'); } } diff --git a/libraries/Controllers/Settings/GeneralController.php b/libraries/Controllers/Settings/GeneralController.php index 6bd2715..069c337 100644 --- a/libraries/Controllers/Settings/GeneralController.php +++ b/libraries/Controllers/Settings/GeneralController.php @@ -8,8 +8,11 @@ namespace Sakura\Controllers\Settings; use Sakura\ActiveUser; +use Sakura\DB; use Sakura\Perms\Site; +use Sakura\Router; use Sakura\Template; +use stdClass; /** * General settings. @@ -21,23 +24,177 @@ class GeneralController extends Controller { public function home() { - ActiveUser::class; - Site::class; - - $navigation = $this->navigation(); - - Template::vars(compact('navigation')); - return Template::render('settings/general/home'); } public function profile() { - return $this->go('general.profile'); + // Check permission + if (!ActiveUser::$user->permission(Site::ALTER_PROFILE)) { + $message = "You aren't allowed to edit your profile!"; + $redirect = Router::route('settings.general.home'); + + Template::vars(compact('message', 'redirect')); + + return Template::render('global/information'); + } + + // Get profile fields + $rawFields = DB::table('profilefields') + ->get(); + + // Create output array + $fields = []; + + // Iterate over the fields and clean them up + foreach ($rawFields as $fieldData) { + $field = new stdClass; + $field->id = clean_string($fieldData->field_name, true, true); + $field->name = $fieldData->field_name; + $field->type = $fieldData->field_type; + $field->link = $fieldData->field_link; + $field->format = $fieldData->field_linkformat; + $field->description = $fieldData->field_description; + $field->additional = json_decode($fieldData->field_additional, true); + $fields[$fieldData->field_id] = $field; + } + + // Attempt to get the session value + $session = $_POST['session'] ?? null; + + if ($session) { + $redirect = Router::route('settings.general.profile'); + + // Go over each field + foreach ($fields as $field) { + // Add to the store table + if (isset($_POST["profile_{$field->id}"])) { + DB::table('user_profilefields') + ->insert([ + 'user_id' => ActiveUser::$user->id, + 'field_name' => $field->id, + 'field_value' => $_POST["profile_{$field->id}"], + ]); + } + + // Check if there's additional values we should keep in mind + if (!empty($field->additional)) { + // Go over each additional value + foreach ($field->additional as $addKey => $addVal) { + // Add to the array + $store = (isset($_POST["profile_additional_{$addKey}"])) + ? $_POST["profile_additional_{$addKey}"] + : false; + + DB::table('user_profilefields') + ->insert([ + 'user_id' => ActiveUser::$user->id, + 'field_name' => $addKey, + 'field_value' => $store, + ]); + } + } + } + + // Birthdays + if (isset($_POST['birthday_day']) + && isset($_POST['birthday_month']) + && isset($_POST['birthday_year'])) { + $day = intval($_POST['birthday_day']); + $month = intval($_POST['birthday_month']); + $year = intval($_POST['birthday_year']); + + // Check the values + if (!checkdate($month, $day, $year ? $year : 1) + || $year > date("Y") + || ($year != 0 && $year < (date("Y") - 100))) { + $message = "Your birthdate was considered invalid, everything else was saved though."; + + Template::vars(compact('message', 'redirect')); + + return Template::render('global/information'); + } + + // Combine it into a YYYY-MM-DD format + $birthdate = implode( + '-', + [$_POST['birthday_year'], $_POST['birthday_month'], $_POST['birthday_day']] + ); + + DB::table('users') + ->where('user_id', ActiveUser::$user->id) + ->update([ + 'user_birthday' => $birthdate, + ]); + } + + $message = "Updated your profile!"; + + Template::vars(compact('message', 'redirect')); + + return Template::render('global/information'); + } + + Template::vars(compact('fields')); + + return Template::render('settings/general/profile'); } public function options() { - return $this->go('general.options'); + // Get profile fields + $rawFields = DB::table('optionfields') + ->get(); + + // Create output array + $fields = []; + + // Iterate over the fields and clean them up + foreach ($rawFields as $fieldData) { + if (!ActiveUser::$user->permission(constant("Sakura\Perms\Site::{$fieldData->option_permission}"))) { + continue; + } + + $field = new stdClass; + $field->id = $fieldData->option_id; + $field->name = $fieldData->option_name; + $field->description = $fieldData->option_description; + $field->type = $fieldData->option_type; + $field->permission = $fieldData->option_permission; + $fields[$fieldData->option_id] = $field; + } + + // Attempt to get the session value + $session = $_POST['session'] ?? null; + + if ($session) { + // Delete all option fields for this user + DB::table('user_optionfields') + ->where('user_id', ActiveUser::$user->id) + ->delete(); + + // Go over each field + foreach ($fields as $field) { + if (isset($_POST["option_{$field->id}"])) { + DB::table('user_optionfields') + ->insert([ + 'user_id' => ActiveUser::$user->id, + 'field_name' => $field->id, + 'field_value' => $_POST["option_{$field->id}"], + ]); + } + } + + $message = "Updated your options!"; + $redirect = Router::route('settings.general.options'); + + Template::vars(compact('message', 'redirect')); + + return Template::render('global/information'); + } + + Template::vars(compact('fields')); + + return Template::render('settings/general/options'); } } diff --git a/libraries/Controllers/Settings/NotificationsController.php b/libraries/Controllers/Settings/NotificationsController.php index 2e677a9..257e883 100644 --- a/libraries/Controllers/Settings/NotificationsController.php +++ b/libraries/Controllers/Settings/NotificationsController.php @@ -7,6 +7,8 @@ namespace Sakura\Controllers\Settings; +use Sakura\Template; + /** * Notification settings. * @@ -17,6 +19,6 @@ class NotificationsController extends Controller { public function history() { - return $this->go('notifications.history'); + return Template::render('settings/notifications/history'); } } diff --git a/libraries/Controllers/UserController.php b/libraries/Controllers/UserController.php index 80440f6..1bf194c 100644 --- a/libraries/Controllers/UserController.php +++ b/libraries/Controllers/UserController.php @@ -15,7 +15,6 @@ use Sakura\Rank; use Sakura\Router; use Sakura\Template; use Sakura\User; -use Sakura\Utils; /** * Everything that is just for serving user data. @@ -41,7 +40,7 @@ class UserController extends Controller if ($profile->id == 0) { // Fetch from username_history $check = DB::table('username_history') - ->where('username_old_clean', Utils::cleanString($id, true, true)) + ->where('username_old_clean', clean_string($id, true, true)) ->orderBy('change_id', 'desc') ->get(); @@ -94,7 +93,7 @@ class UserController extends Controller } // Get the active rank - $rank = array_key_exists($rank, $ranks) ? $rank : ($rank ? 0 : 2); + $rank = array_key_exists($rank, $ranks) ? $rank : ($rank ? 0 : intval(Config::get('default_rank_id'))); // Get members per page $membersPerPage = Config::get('members_per_page'); @@ -105,4 +104,9 @@ class UserController extends Controller // Render the template return Template::render('user/members'); } + + public function report($id = 0) + { + return Template::render('user/report'); + } } diff --git a/libraries/Session.php b/libraries/Session.php index b0d581d..e7a9fbc 100644 --- a/libraries/Session.php +++ b/libraries/Session.php @@ -98,7 +98,7 @@ class Session ->insert([ 'user_id' => $this->userId, 'user_ip' => Net::pton(Net::ip()), - 'user_agent' => Utils::cleanString(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'No user agent header.'), + 'user_agent' => clean_string(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'No user agent header.'), 'session_key' => $session, 'session_start' => time(), 'session_expire' => time() + 604800, diff --git a/libraries/Urls.php b/libraries/Urls.php index 994fe7f..51ea3b6 100644 --- a/libraries/Urls.php +++ b/libraries/Urls.php @@ -8,325 +8,33 @@ namespace Sakura; /** - * Rewrite URL generator. + * URL generator. * * @package Sakura * @author Julian van de Groep */ class Urls { - /** - * Unformatted links - * 0 - Plain - * 1 - mod_rewrite - * - * @var array - */ - protected $urls = [ - - // General site sections - 'SITE_HOME' => [ - '/index.php', - '/', - ], - 'SITE_NEWS' => [ - '/news.php', - '/news', - ], - 'SITE_NEWS_POST' => [ - '/news.php?id=%u', - '/news/%u', - ], - 'SITE_NEWS_CAT' => [ - '/news.php?cat=$s', - '/news/%s', - ], - 'SITE_NEWS_CAT_POST' => [ - '/news.php?cat=%s&id=%u', - '/news/%s/%u', - ], - 'SITE_SEARCH' => [ - '/search.php', - '/search', - ], - 'SITE_PREMIUM' => [ - '/support.php', - '/support', - ], - 'SITE_DONATE_TRACK' => [ - '/support.php?tracker=true', - '/support/tracker', - ], - 'SITE_FAQ' => [ - '/faq.php', - '/faq', - ], - 'SITE_LOGIN' => [ - '/authenticate.php?ref=login', - '/login', - ], - 'SITE_LOGOUT' => [ - '/authenticate.php?ref=logout', - '/logout', - ], - 'SITE_REGISTER' => [ - '/authenticate.php?ref=register', - '/register', - ], - 'SITE_FORGOT_PASSWORD' => [ - '/authenticate.php?ref=forgotpassword', - '/forgotpassword', - ], - 'SITE_ACTIVATE' => [ - '/authenticate.php?ref=activate', - '/activate', - ], - 'INFO_PAGE' => [ - '/index.php?p=%s', - '/p/%s', - ], - 'AUTH_ACTION' => [ - '/authenticate.php', - '/authenticate', - ], - - // Memberlist - 'MEMBERLIST_INDEX' => [ - '/members.php', - '/members', - ], - 'MEMBERLIST_SORT' => [ - '/members.php?sort=%s', - '/members/%s', - ], - 'MEMBERLIST_RANK' => [ - '/members.php?rank=%u', - '/members/%u', - ], - 'MEMBERLIST_PAGE' => [ - '/members.php?page=%u', - '/members?page=%u', - ], - 'MEMBERLIST_ALL' => [ - '/members.php?sort=%s&rank=%u', - '/members/%s/%u', - ], - - // Forums - 'FORUM_INDEX' => [ - '/index.php?forum=true', - '/forum', - ], - 'FORUM_SUB' => [ - '/viewforum.php?f=%u', - '/forum/%u', - ], - 'FORUM_MARK_READ' => [ - '/viewforum.php?f=%u&read=true&session=%s', - '/forum/%u?read=true&session=%s', - ], - 'FORUM_THREAD' => [ - '/viewtopic.php?t=%u', - '/forum/thread/%u', - ], - 'FORUM_POST' => [ - '/viewtopic.php?p=%u', - '/forum/post/%u', - ], - 'FORUM_REPLY' => [ - '/posting.php?t=%u', - '/forum/thread/%u/reply', - ], - 'FORUM_NEW_THREAD' => [ - '/posting.php?f=%u', - '/forum/%u/new', - ], - 'FORUM_EDIT_POST' => [ - '/posting.php?p=%1$u&edit=%1$u', - '/forum/post/%u/edit', - ], - 'FORUM_DELETE_POST' => [ - '/posting.php?p=%1$u&delete=%1$u', - '/forum/post/%u/delete', - ], - 'FORUM_QUOTE_POST' => [ - '/posting.php?p=%1$u"e=%1$u', - '/forum/post/%u/quote', - ], - 'FORUM_LOCK' => [ - '/viewtopic.php?t=%u&lock=%s', - '/forum/thread/%u?lock=%s', - ], - 'FORUM_STICKY' => [ - '/viewtopic.php?t=%u&sticky=%s', - '/forum/thread/%u?sticky=%s', - ], - 'FORUM_ANNOUNCE' => [ - '/viewtopic.php?t=%u&announce=%s', - '/forum/thread/%u?announce=%s', - ], - 'FORUM_RESTORE' => [ - '/viewtopic.php?t=%u&restore=%s', - '/forum/thread/%u?restore=%s', - ], - 'FORUM_TRASH' => [ - '/viewtopic.php?t=%u&trash=%s', - '/forum/thread/%u?trash=%s', - ], - 'FORUM_PRUNE' => [ - '/viewtopic.php?t=%u&prune=%s', - '/forum/thread/%u?prune=%s', - ], - - // Image serve references - 'IMAGE_AVATAR' => [ - '/imageserve.php?m=avatar&u=%u', - '/a/%u', - ], - 'IMAGE_BACKGROUND' => [ - '/imageserve.php?m=background&u=%u', - '/bg/%u', - ], - 'IMAGE_HEADER' => [ - '/imageserve.php?m=header&u=%u', - '/u/%u/header', - ], - - // User actions - 'USER_LOGOUT' => [ - '/authenticate.php?mode=logout&time=%u&session=%s&redirect=%s', - '/logout?mode=logout&time=%u&session=%s&redirect=%s', - ], - 'USER_REPORT' => [ - '/report.php?mode=user&u=%u', - '/u/%u/report', - ], - 'USER_PROFILE' => [ - '/profile.php?u=%s', - '/u/%s', - ], - 'USER_COMMENTS' => [ - '/profile.php?u=%u&view=comments', - '/u/%u/comments', - ], - 'USER_FRIENDS' => [ - '/profile.php?u=%u&view=friends', - '/u/%u/friends', - ], - 'USER_GROUPS' => [ - '/profile.php?u=%u&view=groups', - '/u/%u/groups', - ], - 'USER_THREADS' => [ - '/profile.php?u=%u&view=threads', - '/u/%u/threads', - ], - 'USER_POSTS' => [ - '/profile.php?u=%u&view=posts', - '/u/%u/posts', - ], - 'USER_GROUP' => [ - '/group.php?g=%u', - '/g/%u', - ], - - // Settings urls - 'SETTINGS_INDEX' => [ - '/settings.php', - '/settings', - ], - 'SETTING_CAT' => [ - '/settings.php?cat=%s', - '/settings/%s', - ], - 'SETTING_MODE' => [ - '/settings.php?cat=%s&mode=%s', - '/settings/%s/%s', - ], - 'REQUEST_NOTIFICATIONS' => [ - '/settings.php?request-notifications=true', - '/notifications', - ], - - // Friend Actions - 'FRIEND_ACTION' => [ - '/settings.php?friend-action=true', - '/friends', - ], - 'FRIEND_ADD' => [ - '/settings.php?friend-action=true&add=%u&session=%s&time=%u&redirect=%s', - '/friends?add=%u&session=%s&time=%u&redirect=%s', - ], - 'FRIEND_REMOVE' => [ - '/settings.php?friend-action=true&remove=%u&session=%s&time=%u&redirect=%s', - '/friends?remove=%u&session=%s&time=%u&redirect=%s', - ], - - // Manage urls - 'MANAGE_INDEX' => [ - '/manage.php', - '/manage', - ], - 'MANAGE_CAT' => [ - '/manage.php?cat=%s', - '/manage/%s', - ], - 'MANAGE_MODE' => [ - '/manage.php?cat=%s&mode=%s', - '/manage/%s/%s', - ], - - // Comments urls - 'COMMENT_POST' => [ - '/settings.php?comment-action=true', - '/comments', - ], - 'COMMENT_VOTE' => [ - '/settings.php?comment-action=true&id=%u&mode=vote&state=%u&category=%s&session=%s', - '/comments?id=%u&mode=vote&state=%u&category=%s&session=%s', - ], - 'COMMENT_DELETE' => [ - '/settings.php?comment-action=true&id=%u&category=%s&mode=delete&session=%s', - '/comments?id=%u&mode=delete&category=%s&session=%s', - ], - - ]; - /** * Format a URL. * - * @param string $lid The ID of a URL. - * @param array $args Additional arguments. - * @param bool $rewrite Toggle mod_rewrite. + * @param string $lid doesn't do anything + * @param array $args [category, mode] + * @param bool $rewrite doesn't do anything either + * @param bool $b hackjob for the settings panel * - * @return null|string The formatted URL. + * @return null|string url */ public function format($lid, $args = [], $rewrite = null, $b = true) { - - // Check if the requested url exists - if (!array_key_exists($lid, $this->urls)) { - return null; - } - - if ($b && ($lid === 'SETTING_CAT' || $lid === 'SETTING_MODE')) { - if (in_array('messages', $args)) { - return null; - } - - if ($lid === 'SETTING_CAT') { - return Router::route("settings.{$args[0]}"); - } - - if ($lid === 'SETTING_MODE') { - $a = implode('.', $args); - $a = str_replace("usertitle", "title", $a); - return Router::route("settings.{$a}"); - } + if ($b) { + $a = implode('.', $args); + $a = str_replace("usertitle", "title", $a); + return Router::route("settings.{$a}"); } // Format urls - $formatted = vsprintf($this->urls[$lid][0], $args); + $formatted = vsprintf('/settings.php?cat=%s&mode=%s', $args); // Return the formatted url return $formatted; diff --git a/libraries/User.php b/libraries/User.php index c6f164c..79ea784 100644 --- a/libraries/User.php +++ b/libraries/User.php @@ -254,8 +254,8 @@ class User public static function create($username, $password, $email, $ranks = [2]) { // Set a few variables - $usernameClean = Utils::cleanString($username, true); - $emailClean = Utils::cleanString($email, true); + $usernameClean = clean_string($username, true); + $emailClean = clean_string($email, true); $password = Hashing::createHash($password); // Insert the user into the database and get the id @@ -273,7 +273,7 @@ class User 'last_ip' => Net::pton(Net::ip()), 'user_registered' => time(), 'user_last_online' => 0, - 'user_country' => Utils::getCountryCode(), + 'user_country' => get_country_code(), ]); // Create a user object @@ -299,7 +299,7 @@ class User // Get the user database row $userRow = DB::table('users') ->where('user_id', $userId) - ->orWhere('username_clean', Utils::cleanString($userId, true, true)) + ->orWhere('username_clean', clean_string($userId, true, true)) ->get(); // Populate the variables @@ -401,7 +401,7 @@ class User */ public function country($long = false) { - return $long ? Utils::getCountryName($this->country) : $this->country; + return $long ? get_country_name($this->country) : $this->country; } /** @@ -793,7 +793,7 @@ class User // Check if profile fields aren't fake foreach ($profileFields as $field) { // Completely strip all special characters from the field name - $fieldName = Utils::cleanString($field->field_name, true, true); + $fieldName = clean_string($field->field_name, true, true); // Check if the user has the current field set otherwise continue if (!array_key_exists($fieldName, $profileValues)) { @@ -1087,7 +1087,7 @@ class User public function setUsername($username) { // Create a cleaned version - $username_clean = Utils::cleanString($username, true); + $username_clean = clean_string($username, true); // Check if the username is too short if (strlen($username_clean) < Config::get('username_min_length')) { @@ -1210,7 +1210,7 @@ class User } // Check password entropy - if (Utils::pwdEntropy($new) < Config::get('min_entropy')) { + if (password_entropy($new) < Config::get('min_entropy')) { return [0, 'PASS_TOO_SHIT']; } diff --git a/libraries/Users.php b/libraries/Users.php deleted file mode 100644 index 975d714..0000000 --- a/libraries/Users.php +++ /dev/null @@ -1,169 +0,0 @@ - - */ -class Users -{ - /** - * Send password forgot e-mail - * - * @param string $userId The user id. - * @param string $email The e-mail. - */ - public static function sendPasswordForgot($userId, $email) - { - $user = User::construct($userId); - - if (!$user->id || $user->permission(Site::DEACTIVATED)) { - return; - } - - // Generate the verification key - $verk = ActionCode::generate('LOST_PASS', $user->id); - - $siteName = Config::get('sitename'); - $baseUrl = "http://" . Config::get('url_main'); - $reactivateLink = Router::route('auth.resetpassword') . "?u={$user->id}&k={$verk}"; - $signature = Config::get('mail_signature'); - - // Build the e-mail - $message = "Hello {$user->username},\r\n\r\n" - . "You are receiving this notification because you have (or someone pretending to be you has)" - . " requested a password reset link to be sent for your account on \"{$siteName}\"." - . " If you did not request this notification then please ignore it," - . " if you keep receiving it please contact the site administrator.\r\n\r\n" - . "To use this password reset key you need to go to a special page." - . " To do this click the link provided below.\r\n\r\n" - . "{$baseUrl}{$reactivateLink}\r\n\r\n" - . "If successful you should be able to change your password here.\r\n\r\n" - . "You can of course change this password yourself via the settings page." - . " If you have any difficulties please contact the site administrator.\r\n\r\n" - . "--\r\n\r\nThanks\r\n\r\n{$signature}"; - - // Send the message - Utils::sendMail([$user->email => $user->username], "{$siteName} password restoration", $message); - } - - /** - * Send activation e-mail. - * - * @param mixed $userId User ID. - * @param mixed $customKey Key. - */ - public static function sendActivationMail($userId, $customKey = null) - { - - // Get the user data - $user = User::construct($userId); - - // User is already activated or doesn't even exist - if (!$user->id || !$user->permission(Site::DEACTIVATED)) { - return; - } - - // Generate activation key - $activate = ActionCode::generate('ACTIVATE', $user->id); - - $siteName = Config::get('sitename'); - $baseUrl = "http://" . Config::get('url_main'); - $activateLink = Router::route('auth.activate') . "?u={$user->id}&k={$activate}"; - $profileLink = Router::route('user.profile', $user->id); - $signature = Config::get('mail_signature'); - - // Build the e-mail - $message = "Welcome to {$siteName}!\r\n\r\n" - . "Please keep this e-mail for your records. Your account intormation is as follows:\r\n\r\n" - . "----------------------------\r\n\r\n" - . "Username: {$user->username}\r\n\r\n" - . "Your profile: {$baseUrl}{$profileLink}\r\n\r\n" - . "----------------------------\r\n\r\n" - . "Please visit the following link in order to activate your account:\r\n\r\n" - . "{$baseUrl}{$activateLink}\r\n\r\n" - . "Your password has been securely stored in our database and cannot be retrieved. " - . "In the event that it is forgotten," - . " you will be able to reset it using the email address associated with your account.\r\n\r\n" - . "Thank you for registering.\r\n\r\n" - . "--\r\n\r\nThanks\r\n\r\n{$signature}"; - - // Send the message - Utils::sendMail([$user->email => $user->username], "{$siteName} activation mail", $message); - } - - /** - * Get all available profile fields. - * - * @return array|null The fields. - */ - public static function getProfileFields() - { - // Get profile fields - $profileFields = DB::table('profilefields') - ->get(); - - // If there's nothing just return null - if (!count($profileFields)) { - return null; - } - - // Create output array - $fields = []; - - // Iterate over the fields and clean them up - foreach ($profileFields as $field) { - $field = get_object_vars($field); - $fields[$field['field_id']] = $field; - $fields[$field['field_id']]['field_identity'] = Utils::cleanString($field['field_name'], true, true); - $fields[$field['field_id']]['field_additional'] = json_decode($field['field_additional'], true); - } - - // Return the yeahs - return $fields; - } - - /** - * Get all available option fields. - * - * @return array|null The fields. - */ - public static function getOptionFields() - { - // Get option fields - $optionFields = DB::table('optionfields') - ->get(); - - // If there's nothing just return null - if (!count($optionFields)) { - return null; - } - - // Create output array - $fields = []; - - // Iterate over the fields and clean them up - foreach ($optionFields as $field) { - $field = get_object_vars($field); - - if (!ActiveUser::$user->permission(constant('Sakura\Perms\Site::' . $field['option_permission']))) { - continue; - } - - $fields[$field['option_id']] = $field; - } - - // Return the yeahs - return $fields; - } -} diff --git a/libraries/Utils.php b/libraries/Utils.php deleted file mode 100644 index 3a01dd2..0000000 --- a/libraries/Utils.php +++ /dev/null @@ -1,349 +0,0 @@ - - */ -class Utils -{ - /** - * The error handler. - * - * @param int $errno The error ID. - * @param string $errstr Quick description of the event. - * @param string $errfile File the error occurred in. - * @param int $errline Line the error occurred on. - */ - public static function errorHandler($errno, $errstr, $errfile, $errline) - { - // Remove ROOT path from the error string and file location - $errstr = str_replace(ROOT, '', $errstr); - $errfile = str_replace(ROOT, '', $errfile); - - switch ($errno) { - case E_ERROR: - case E_USER_ERROR: - $error = 'FATAL ERROR: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; - break; - - case E_WARNING: - case E_USER_WARNING: - $error = 'WARNING: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; - break; - - case E_NOTICE: - case E_USER_NOTICE: - $error = 'NOTICE: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; - break; - - default: - $error = 'Unknown error type [' . $errno . ']: ' . $errstr . ' on line ' . $errline - . ' in ' . $errfile; - } - - // Truncate all previous outputs - ob_clean(); - ob_end_clean(); - - // Check for dev mode - $detailed = Config::local('dev', 'show_errors'); - - // Build page - $errorPage = ' - - - - Sakura Internal Error - - - -
-

An error occurred while executing the script.

-
-

To prevent potential security risks or data loss Sakura has stopped execution of the script.

'; - - if (isset($errid)) { - $errorPage .= '

The error and surrounding data has been logged.

-

' . (!$detailed ? 'Report the following text to a staff member' : 'Logged as') . '

-
' . $errid . '
'; - } else { - $errorPage .= '

Sakura was not able to log this error which could mean that there was an error - with the database connection. If you\'re the system administrator check the database credentials - and make sure the server is running and if you\'re not please let the system administrator - know about this error if it occurs again.

'; - } - - if ($detailed) { - $errorPage .= '

Summary

-
' . $error . '
-

Backtraces

'; - - foreach (debug_backtrace() as $num => $trace) { - $errorPage .= '

#' . $num . '

';
-
-                foreach ($trace as $key => $val) {
-                    $errorPage .=
-                    str_pad(
-                        '[' . $key . ']',
-                        12
-                    ) . '=> ' . (
-                        is_array($val) || is_object($val) ?
-                        json_encode($val) :
-                        $val
-                    ) . "\r\n";
-                }
-
-                $errorPage .= '
'; - } - } - - $errorPage .= '
- -
- -'; - - // Die and display error message - die($errorPage); - } - - /** - * Send an e-mail. - * - * @param string $to Destination e-mail. - * @param string $subject E-mail subject. - * @param string $body Contents of the message. - * @return bool|string Return whatever PHPMailer returns. - */ - public static function sendMail($to, $subject, $body) - { - // Initialise PHPMailer - $mail = new PHPMailer(); - - // Set to SMTP - $mail->isSMTP(); - - // Set the SMTP server host - $mail->Host = Config::get('smtp_server'); - - // Do we require authentication? - $mail->SMTPAuth = Config::get('smtp_auth'); - - // Do we encrypt as well? - $mail->SMTPSecure = Config::get('smtp_secure'); - - // Set the port to the SMTP server - $mail->Port = Config::get('smtp_port'); - - // If authentication is required log in as well - if (Config::get('smtp_auth')) { - $mail->Username = Config::get('smtp_username'); - $mail->Password = base64_decode(Config::get('smtp_password')); - } - - // Add a reply-to header - $mail->addReplyTo(Config::get('smtp_replyto_mail'), Config::get('smtp_replyto_name')); - - // Set a from address as well - $mail->setFrom(Config::get('smtp_from_email'), Config::get('smtp_from_name')); - - // Set the addressee - foreach ($to as $email => $name) { - $mail->addBCC($email, $name); - } - - // Subject line - $mail->Subject = $subject; - - // Set body - $mail->Body = $body; - - // Send the message - $send = $mail->send(); - - // Clear the addressee list - $mail->clearAddresses(); - - // If we got an error return the error - if (!$send) { - return $mail->ErrorInfo; - } - - // Else just return whatever - return $send; - } - - /** - * Clean a string - * - * @param string $string Dirty string. - * @param bool $lower Make the string lowercase. - * @param bool $noSpecial String all special characters. - * @param bool $replaceSpecial Thing to replace special characters with. - * - * @return string Clean string. - */ - public static function cleanString($string, $lower = false, $noSpecial = false, $replaceSpecial = '') - { - // Run common sanitisation function over string - $string = htmlentities($string, ENT_NOQUOTES | ENT_HTML401, Config::get('charset')); - $string = stripslashes($string); - $string = strip_tags($string); - - // If set also make the string lowercase - if ($lower) { - $string = strtolower($string); - } - - // If set remove all characters that aren't a-z or 0-9 - if ($noSpecial) { - $string = preg_replace('/[^a-z0-9]/', $replaceSpecial, $string); - } - - // Return clean string - return $string; - } - - /** - * Validate MX records. - * - * @param string $email E-mail address. - * - * @return bool Success. - */ - public static function checkMXRecord($email) - { - // Get the domain from the e-mail address - $domain = substr(strstr($email, '@'), 1); - - // Check the MX record - $record = checkdnsrr($domain, 'MX'); - - // Return the record data - return $record; - } - - /** - * Get the country code of a visitor. - * - * @return string 2 character country code. - */ - public static function getCountryCode() - { - // Attempt to get country code using PHP's built in geo thing - if (function_exists("geoip_country_code_by_name")) { - try { - $code = geoip_country_code_by_name(Net::ip()); - - // Check if $code is anything - if ($code) { - return $code; - } - } catch (\Exception $e) { - } - } - - // Check if the required header is set and return it - if (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) { - return $_SERVER['HTTP_CF_IPCOUNTRY']; - } - - // Return XX as a fallback - return 'XX'; - } - - /** - * Check the entropy of a password. - * - * @param string $pw Password. - * - * @return double|int Entropy. - */ - public static function pwdEntropy($pw) - { - // Decode utf-8 chars - $pw = utf8_decode($pw); - - // Count the amount of unique characters in the password string and calculate the entropy - return count(count_chars($pw, 1)) * log(256, 2); - } - - /** - * Get the country name from a 2 character code. - * - * @param string $code The country code. - * - * @return string The country name. - */ - public static function getCountryName($code) - { - // Catch XX - if (strtolower($code) === 'xx') { - return 'Unknown'; - } - - // Catch proxy - if (strtolower($code) === 'a1') { - return 'Anonymous Proxy'; - } - - return locale_get_display_region("-{$code}", 'en'); - } - - /** - * Get the byte symbol for a unit from bytes. - * - * @param int $bytes The amount of bytes. - * - * @return string The converted amount with the symbol. - */ - public static function getByteSymbol($bytes) - { - // Return nothing if the input was 0 - if (!$bytes) { - return; - } - - // Array with byte symbols - $symbols = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; - - // Calculate byte entity - $exp = floor(log($bytes) / log(1024)); - - // Format the things - $bytes = sprintf("%.2f " . $symbols[$exp], ($bytes / pow(1024, floor($exp)))); - - // Return the formatted string - return $bytes; - } -} diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 69d1ee2..44cf7cd 100644 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -1277,12 +1277,12 @@ a.default:active { } .content .content-right { - width: 100%; + width: 100% !important; min-height: 0; } .content .content-left { - width: 100%; + width: 100% !important; min-height: 0; border-top: 1px solid #9475B2; } @@ -1558,6 +1558,13 @@ a.default:active { margin-left: 2em; list-style: square; } +.settings .content-left { + width: 850px; +} +.settings .content-right { + width: 174px; + text-align: right; +} .settings .right-menu-nav > div { background: #C2AFFE; padding: 4px; @@ -1573,7 +1580,7 @@ a.default:active { line-height: 25px; color: #22E; text-decoration: none; - padding-left: 10px; + padding: 0 10px; } .settings .right-menu-nav > a:hover { diff --git a/public/settings.php b/public/settings.php index 05749c4..38b23c1 100644 --- a/public/settings.php +++ b/public/settings.php @@ -244,145 +244,6 @@ if (isset($_POST['submit']) && isset($_POST['submit'])) { ]; break; - // Profile - case 'profile': - // Get profile fields and create storage var - $fields = Users::getProfileFields(); - - // Delete all profile fields - DB::table('user_profilefields') - ->where('user_id', $currentUser->id) - ->delete(); - - // Go over each field - foreach ($fields as $field) { - // Add to the store array - if (isset($_POST['profile_' . $field['field_identity']]) && !empty($_POST['profile_' . $field['field_identity']])) { - DB::table('user_profilefields') - ->insert([ - 'user_id' => $currentUser->id, - 'field_name' => $field['field_identity'], - 'field_value' => $_POST['profile_' . $field['field_identity']], - ]); - } - - // Check if there's additional values we should keep in mind - if (isset($field['field_additional']) && !empty($field['field_additional'])) { - // Go over each additional value - foreach ($field['field_additional'] as $addKey => $addVal) { - // Add to the array - $store = (isset($_POST['profile_additional_' . $addKey]) || !empty($_POST['profile_additional_' . $addKey])) ? $_POST['profile_additional_' . $addKey] : false; - DB::table('user_profilefields') - ->insert([ - 'user_id' => $currentUser->id, - 'field_name' => $addKey, - 'field_value' => $store, - ]); - } - } - } - - // Set render data - $renderData['page'] = [ - 'redirect' => $redirect, - 'message' => 'Your profile has been updated!', - 'success' => 1, - ]; - - // Birthdays - if (isset($_POST['birthday_day']) - && isset($_POST['birthday_month']) - && isset($_POST['birthday_year'])) { - // Check if the values aren't fucked with - if ($_POST['birthday_day'] < 0 - || $_POST['birthday_day'] > 31 - || $_POST['birthday_month'] < 0 - || $_POST['birthday_month'] > 12 - || ( - $_POST['birthday_year'] != 0 - && $_POST['birthday_year'] < (date("Y") - 100) - ) - || $_POST['birthday_year'] > date("Y")) { - $renderData['page']['message'] = 'Your birthdate is invalid.'; - $renderData['page']['success'] = 0; - break; - } - - // Check if the values aren't fucked with - if (( - $_POST['birthday_day'] < 1 - && $_POST['birthday_month'] > 0 - ) - || ( - $_POST['birthday_day'] > 0 - && $_POST['birthday_month'] < 1) - ) { - $renderData['page']['message'] = 'Only setting a day or month is disallowed.'; - $renderData['page']['success'] = 0; - break; - } - - // Check if the values aren't fucked with - if ($_POST['birthday_year'] > 0 - && ( - $_POST['birthday_day'] < 1 - || $_POST['birthday_month'] < 1 - ) - ) { - $renderData['page']['message'] = 'Only setting a year is disallowed.'; - $renderData['page']['success'] = 0; - break; - } - - $birthdate = implode( - '-', - [$_POST['birthday_year'], $_POST['birthday_month'], $_POST['birthday_day']] - ); - - DB::table('users') - ->where('user_id', $currentUser->id) - ->update([ - 'user_birthday' => $birthdate, - ]); - } - break; - - // Site Options - case 'options': - // Get profile fields and create storage var - $fields = Users::getOptionFields(); - - // Delete all option fields for this user - DB::table('user_optionfields') - ->where('user_id', $currentUser->id) - ->delete(); - - // Go over each field - foreach ($fields as $field) { - // Make sure the user has sufficient permissions to complete this action - if (!$currentUser->permission(constant('Sakura\Perms\Site::' . $field['option_permission']))) { - continue; - } - - if (isset($_POST['option_' . $field['option_id']]) - && !empty($_POST['option_' . $field['option_id']])) { - DB::table('user_optionfields') - ->insert([ - 'user_id' => $currentUser->id, - 'field_name' => $field['option_id'], - 'field_value' => $_POST['option_' . $field['option_id']], - ]); - } - } - - // Set render data - $renderData['page'] = [ - 'redirect' => $redirect, - 'message' => 'Changed your options!', - 'success' => 1, - ]; - break; - // Usertitle case 'usertitle': // Check permissions @@ -799,7 +660,7 @@ if (ActiveUser::$user->id) { 'menu' => true, ], 'profile' => [ - 'title' => 'Edit Profile', + 'title' => 'Profile', 'description' => [ 'These are the external account links etc. on your profile, shouldn\'t need any additional explanation for this one.', @@ -808,7 +669,7 @@ if (ActiveUser::$user->id) { 'menu' => true, ], 'options' => [ - 'title' => 'Site Options', + 'title' => 'Options', 'description' => [ 'These are a few personalisation options for the site while you\'re logged in.', ], @@ -837,44 +698,7 @@ if (ActiveUser::$user->id) { 'menu' => true, ], ], - ]/*, - 'messages' => [ - 'title' => 'Messages', - 'modes' => [ - 'inbox' => [ - 'title' => 'Inbox', - 'description' => [ - 'The list of messages you\'ve received.', ], - 'access' => $currentUser->permission(Site::USE_MESSAGES), - 'menu' => true, - ], - 'sent' => [ - 'title' => 'Sent', - 'description' => [ - 'The list of messages you\'ve sent to other users.', - ], - 'access' => $currentUser->permission(Site::USE_MESSAGES), - 'menu' => true, - ], - 'compose' => [ - 'title' => 'Compose', - 'description' => [ - 'Write a new message.', - ], - 'access' => $currentUser->permission(Site::SEND_MESSAGES), - 'menu' => true, - ], - 'read' => [ - 'title' => 'Read', - 'description' => [ - 'Read a message.', - ], - 'access' => $currentUser->permission(Site::USE_MESSAGES), - 'menu' => false, - ], - ], - ]*/, 'notifications' => [ 'title' => 'Notifications', 'modes' => [ @@ -949,7 +773,7 @@ if (ActiveUser::$user->id) { 'title' => 'Account', 'modes' => [ 'email' => [ - 'title' => 'E-mail Address', + 'title' => 'E-mail address', 'description' => [ 'You e-mail address is used for password recovery and stuff like that, we won\'t spam you ;).', ], @@ -966,7 +790,7 @@ if (ActiveUser::$user->id) { 'menu' => true, ], 'usertitle' => [ - 'title' => 'Usertitle', + 'title' => 'Title', 'description' => [ 'That little piece of text displayed under your username on your profile.', ], @@ -1011,7 +835,7 @@ if (ActiveUser::$user->id) { 'menu' => true, ], 'deactivate' => [ - 'title' => 'Deactivate Account', + 'title' => 'Deactivate', 'description' => [ 'You can deactivate your account here if you want to leave :(.', ], @@ -1069,39 +893,6 @@ if (ActiveUser::$user->id) { // Section specific switch ($category . '.' . $mode) { - // Profile - case 'general.profile': - $renderData['profile'] = [ - 'fields' => Users::getProfileFields(), - 'months' => [ - 1 => 'January', - 2 => 'February', - 3 => 'March', - 4 => 'April', - 5 => 'May', - 6 => 'June', - 7 => 'July', - 8 => 'August', - 9 => 'September', - 10 => 'October', - 11 => 'November', - 12 => 'December', - ], - ]; - break; - - // Options - case 'general.options': - $renderData['options'] = [ - 'fields' => Users::getOptionFields(), - ]; - break; - - // PM inbox - case 'messages.inbox': - $renderData['messages'] = []; - break; - // Avatar and background sizes case 'appearance.avatar': case 'appearance.background': @@ -1112,7 +903,7 @@ if (ActiveUser::$user->id) { 'min_width' => Config::get($mode . '_min_width'), 'min_height' => Config::get($mode . '_min_height'), 'max_size' => Config::get($mode . '_max_fsize'), - 'max_size_view' => Utils::getByteSymbol(Config::get($mode . '_max_fsize')), + 'max_size_view' => byte_symbol(Config::get($mode . '_max_fsize')), ]; break; diff --git a/routes.php b/routes.php index 3122921..9ae695d 100644 --- a/routes.php +++ b/routes.php @@ -94,8 +94,11 @@ Router::group(['prefix' => 'members', 'before' => 'loginCheck'], function () { }); // User -Router::get('/u/{id}', 'UserController@profile', 'user.profile'); -Router::get('/u/{id}/header', 'FileController@header', 'user.header'); +Router::group(['prefix' => 'u'], function () { + Router::get('/{id}', 'UserController@profile', 'user.profile'); + Router::get('/{id}/report', 'UserController@report', 'user.report'); + Router::get('/{id}/header', 'FileController@header', 'user.header'); +}); // Notifications Router::group(['prefix' => 'notifications'], function () { @@ -152,7 +155,9 @@ Router::group(['prefix' => 'settings', 'before' => 'loginCheck'], function () { Router::get('/home', 'Settings.GeneralController@home', 'settings.general.home'); Router::get('/profile', 'Settings.GeneralController@profile', 'settings.general.profile'); + Router::post('/profile', 'Settings.GeneralController@profile', 'settings.general.profile'); Router::get('/options', 'Settings.GeneralController@options', 'settings.general.options'); + Router::post('/options', 'Settings.GeneralController@options', 'settings.general.options'); }); // Friends section diff --git a/sakura.php b/sakura.php index 6374675..3e549da 100644 --- a/sakura.php +++ b/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', 20160331); +define('SAKURA_VERSION', 20160401); // Define Sakura Path define('ROOT', __DIR__ . '/'); @@ -30,33 +30,18 @@ if (version_compare(phpversion(), '7.0.0', '<')) { // Check if the composer autoloader exists if (!file_exists(ROOT . 'vendor/autoload.php')) { - throw new \Exception('Autoloader not found, did you run composer?'); + throw new \Exception('Autoloader not found, did you run composer install?'); } // Require composer libraries require_once ROOT . 'vendor/autoload.php'; -// Setup the autoloader -spl_autoload_register(function ($className) { - // Replace \ with / - $className = str_replace('\\', '/', $className); - - // Create a throwaway count variable - $i = 1; - - // Replace the sakura namespace with the libraries directory - $className = str_replace('Sakura/', 'libraries/', $className, $i); - - // Require the file - require_once ROOT . $className . '.php'; -}); - -// Set Error handler -set_error_handler(['Sakura\Utils', 'errorHandler']); - // Load the local configuration Config::init(ROOT . 'config/config.ini'); +// Set Error handler +set_error_handler('error_handler'); + // Change error reporting according to the dev configuration error_reporting(Config::local('dev', 'show_errors') ? -1 : 0); @@ -110,12 +95,9 @@ ActiveUser::init( // Create the Urls object $urls = new Urls(); -// Prepare the name of the template to load -$templateName = Config::get('site_style'); - if (!defined('SAKURA_NO_TPL')) { // Start templating engine - Template::set($templateName); + Template::set(Config::get('site_style')); // Set base page rendering data Template::vars([ @@ -128,8 +110,6 @@ if (!defined('SAKURA_NO_TPL')) { 'showChangelog' => Config::local('dev', 'show_changelog'), ], - 'resources' => Config::get('content_path') . '/data/' . $templateName, - 'currentPage' => $_SERVER['REQUEST_URI'] ?? null, 'referrer' => $_SERVER['HTTP_REFERER'] ?? null, ], diff --git a/templates/misaki/main/profile.twig b/templates/misaki/main/profile.twig index bc0d94c..130288e 100644 --- a/templates/misaki/main/profile.twig +++ b/templates/misaki/main/profile.twig @@ -96,7 +96,7 @@
  • Settings
  • {% else %}
  • {% if user.checkFriends(profile.id) == 0 %}Add friend{% else %}Friends{% endif %}
  • -
  • Report
  • +
  • Report
  • {% endif %} diff --git a/templates/yuuno/elements/comment.twig b/templates/yuuno/elements/comment.twig index b51c606..11dccd6 100644 --- a/templates/yuuno/elements/comment.twig +++ b/templates/yuuno/elements/comment.twig @@ -8,7 +8,7 @@ {% if comment.userData.id == user.id %}
  • {% else %} -
  • +
  • {% endif %}
  • diff --git a/templates/yuuno/forum/thread.twig b/templates/yuuno/forum/thread.twig index 45a2699..49847be 100644 --- a/templates/yuuno/forum/thread.twig +++ b/templates/yuuno/forum/thread.twig @@ -98,7 +98,7 @@ {% if not (post.poster.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) or post.poster.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) or user.id == post.poster.id) %} - + {% endif %} diff --git a/templates/yuuno/global/master.twig b/templates/yuuno/global/master.twig index b30b95a..73cc44e 100644 --- a/templates/yuuno/global/master.twig +++ b/templates/yuuno/global/master.twig @@ -50,7 +50,6 @@ "siteName": "{{ config('sitename') }}", "content": "{{ config('content_path') }}", - "resources": "{{ sakura.resources }}", "recaptchaEnabled": "{{ config('recaptcha') }}", "minUserLen": {{ config('username_min_length') }}, diff --git a/templates/yuuno/old-settings/friends.listing.twig b/templates/yuuno/old-settings/friends.listing.twig deleted file mode 100644 index a6a35e1..0000000 --- a/templates/yuuno/old-settings/friends.listing.twig +++ /dev/null @@ -1,37 +0,0 @@ -{% set friends = user.friends(1)|batch(12) %} - -{% set paginationPages = friends %} -{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['friends', 'listing']) }}{% endset %} - -{% block css %} - -{% endblock %} - -{% if friends|length %} -
    - {% for friend in friends[get.page|default(1) - 1] %} - - {% endfor %} -
    -
    - {% if friends|length > 1 %} -
    - {% include 'elements/pagination.twig' %} -
    - {% endif %} -{% else %} -

    You don't have any friends yet!

    -{% endif %} diff --git a/templates/yuuno/old-settings/friends.requests.twig b/templates/yuuno/old-settings/friends.requests.twig deleted file mode 100644 index e68eacc..0000000 --- a/templates/yuuno/old-settings/friends.requests.twig +++ /dev/null @@ -1,38 +0,0 @@ -{% set friends = user.friends(-1)|batch(12) %} - -{% set paginationPages = friends %} -{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}{% endset %} - -{% block css %} - -{% endblock %} - -{% if friends|length %} -
    - {% for friend in friends[get.page|default(1) - 1] %} - - {% endfor %} -
    -
    - {% if friends|length > 1 %} -
    - {% include 'elements/pagination.twig' %} -
    - {% endif %} -{% else %} -

    You don't have any pending requests!

    -{% endif %} diff --git a/templates/yuuno/old-settings/general.home.twig b/templates/yuuno/old-settings/general.home.twig deleted file mode 100644 index 16ae40c..0000000 --- a/templates/yuuno/old-settings/general.home.twig +++ /dev/null @@ -1,20 +0,0 @@ -
    -

    Common Tasks

    -

    Profile

    - -

    Messaging

    - -

    Account

    - -
    diff --git a/templates/yuuno/old-settings/general.options.twig b/templates/yuuno/old-settings/general.options.twig deleted file mode 100644 index c066b45..0000000 --- a/templates/yuuno/old-settings/general.options.twig +++ /dev/null @@ -1,31 +0,0 @@ -{% if options.fields %} -
    - - - - {% for field in options.fields %} -
    -
    -

    {{ field.option_name }}

    -
    - {{ field.option_description }} -
    -
    -
    - -
    -
    - {% endfor %} -
    - - -
    -
    - -{% else %} -

    There are currently no changeable options.

    -{% endif %} diff --git a/templates/yuuno/old-settings/general.profile.twig b/templates/yuuno/old-settings/general.profile.twig deleted file mode 100644 index 77a083b..0000000 --- a/templates/yuuno/old-settings/general.profile.twig +++ /dev/null @@ -1,59 +0,0 @@ -{% set birthday = user.birthday|split('-') %} - -
    - - - - {% for field in profile.fields %} -
    -
    -

    {{ field.field_name }}

    -
    -
    - -
    - {% if field.field_additional %} - {% for id,addit in field.field_additional %} -
    - - -
    - {% endfor %} - {% endif %} -
    - {% endfor %} -
    -
    -

    Birthday

    -
    -
    - Day: - Month: - Year: -
    -
    -
    - - -
    -
    - diff --git a/templates/yuuno/old-settings/messages.compose.twig b/templates/yuuno/old-settings/messages.compose.twig deleted file mode 100644 index e69de29..0000000 diff --git a/templates/yuuno/old-settings/messages.inbox.twig b/templates/yuuno/old-settings/messages.inbox.twig deleted file mode 100644 index c7d3455..0000000 --- a/templates/yuuno/old-settings/messages.inbox.twig +++ /dev/null @@ -1,23 +0,0 @@ -{% if messages|length %} - - - - - - - - - - {% for message in messages %} - - - - - - {% endfor %} - -
    FromSubjectSent on
    {{ message.data.from.user.username }}{{ message.subject }}{{ message.time|date(config('date_format')) }}
    -{% else %} -

    Nothing to view!

    -{% endif %} -

    Click Compose in the menu on the right side to write a new message!

    diff --git a/templates/yuuno/old-settings/messages.read.twig b/templates/yuuno/old-settings/messages.read.twig deleted file mode 100644 index e69de29..0000000 diff --git a/templates/yuuno/old-settings/messages.sent.twig b/templates/yuuno/old-settings/messages.sent.twig deleted file mode 100644 index e69de29..0000000 diff --git a/templates/yuuno/old-settings/notifications.history.twig b/templates/yuuno/old-settings/notifications.history.twig deleted file mode 100644 index 69f6442..0000000 --- a/templates/yuuno/old-settings/notifications.history.twig +++ /dev/null @@ -1,49 +0,0 @@ -{% set alerts = user.notifications(0, false)|batch(10) %} - -{% set paginationPages = alerts %} -{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['notifications', 'history']) }}{% endset %} - -{% block css %} - -{% endblock %} - -{% if alerts %} - - {% if alerts|length > 1 %} -
    - {% include 'elements/pagination.twig' %} -
    - {% endif %} -{% else %} -

    You don't have any notifications in your history!

    -{% endif %} diff --git a/templates/yuuno/settings/advanced/master.twig b/templates/yuuno/settings/advanced/master.twig new file mode 100644 index 0000000..7405e89 --- /dev/null +++ b/templates/yuuno/settings/advanced/master.twig @@ -0,0 +1,3 @@ +{% extends 'settings/master.twig' %} + +{% set category = 'Advanced' %} diff --git a/templates/yuuno/settings/advanced/sessions.twig b/templates/yuuno/settings/advanced/sessions.twig new file mode 100644 index 0000000..73df94e --- /dev/null +++ b/templates/yuuno/settings/advanced/sessions.twig @@ -0,0 +1,51 @@ +{% extends 'settings/advanced/master.twig' %} + +{% set mode = 'Home' %} + +{% block description %} +

    Welcome to the Settings Panel! From here you can monitor, view and update your profile and preferences.

    +{% endblock %} + +{% block settingsContent %} + + + + + + + + + {% for s in sessions %} + + + + + + + {% endfor %} + +
    IPUseragentLogin time
    IPUseragentLogin time
    + {{ s.user_ip }} + + {{ s.user_agent }} + + + +
    + + + + + +
    +
    +
    +
    + + + + + +
    +
    +{% endblock %} diff --git a/templates/yuuno/settings/friends/listing.twig b/templates/yuuno/settings/friends/listing.twig new file mode 100644 index 0000000..b712087 --- /dev/null +++ b/templates/yuuno/settings/friends/listing.twig @@ -0,0 +1,39 @@ +{% extends 'settings/general/master.twig' %} + +{% set friends = user.friends(1)|batch(12) %} + +{% set paginationPages = friends %} +{% set paginationUrl %}{{ route('settings.friends.listing') }}{% endset %} + +{% set mode = 'Listing' %} + +{% block description %} +

    Manage your friends.

    +{% endblock %} + +{% block settingsContent %} + {% if friends|length %} +
    + {% for friend in friends[get.page|default(1) - 1] %} + + {% endfor %} +
    +
    + {% if friends|length > 1 %} +
    + {% include 'elements/pagination.twig' %} +
    + {% endif %} + {% else %} +

    You don't have any friends yet!

    + {% endif %} +{% endblock %} diff --git a/templates/yuuno/settings/friends/master.twig b/templates/yuuno/settings/friends/master.twig new file mode 100644 index 0000000..7007d0e --- /dev/null +++ b/templates/yuuno/settings/friends/master.twig @@ -0,0 +1,11 @@ +{% extends 'settings/master.twig' %} + +{% set category = 'Friends' %} + +{% block css %} + +{% endblock %} diff --git a/templates/yuuno/settings/friends/requests.twig b/templates/yuuno/settings/friends/requests.twig new file mode 100644 index 0000000..e587a01 --- /dev/null +++ b/templates/yuuno/settings/friends/requests.twig @@ -0,0 +1,40 @@ +{% extends 'settings/general/master.twig' %} + +{% set friends = user.friends(-1)|batch(12) %} + +{% set paginationPages = friends %} +{% set paginationUrl %}{{ route('settings.friends.requests') }}{% endset %} + +{% set mode = 'Requests' %} + +{% block description %} +

    Handle friend requests.

    +{% endblock %} + +{% block settingsContent %} + {% if friends|length %} +
    + {% for friend in friends[get.page|default(1) - 1] %} + + {% endfor %} +
    +
    + {% if friends|length > 1 %} +
    + {% include 'elements/pagination.twig' %} +
    + {% endif %} + {% else %} +

    You don't have any pending requests!

    + {% endif %} +{% endblock %} diff --git a/templates/yuuno/settings/general/options.twig b/templates/yuuno/settings/general/options.twig new file mode 100644 index 0000000..cd73b80 --- /dev/null +++ b/templates/yuuno/settings/general/options.twig @@ -0,0 +1,33 @@ +{% extends 'settings/general/master.twig' %} + +{% set mode = 'Options' %} + +{% block description %} +

    These are a few personalisation options for the site while you're logged in.

    +{% endblock %} + +{% block settingsContent %} + {% if fields %} +
    + {% for field in fields %} +
    +
    +

    {{ field.name }}

    +
    + {{ field.description }} +
    +
    +
    + +
    +
    + {% endfor %} +
    + + +
    +
    + {% else %} +

    There are currently no changeable options.

    + {% endif %} +{% endblock %} diff --git a/templates/yuuno/settings/general/profile.twig b/templates/yuuno/settings/general/profile.twig new file mode 100644 index 0000000..0b22a13 --- /dev/null +++ b/templates/yuuno/settings/general/profile.twig @@ -0,0 +1,76 @@ +{% extends 'settings/general/master.twig' %} + +{% set mode = 'Profile' %} + +{% block description %} +

    These are the external account links etc. on your profile, shouldn't need any additional explanation for this one.

    +{% endblock %} + +{% set months = { + 1: "January", + 2: "February", + 3: "March", + 4: "April", + 5: "May", + 6: "June", + 7: "July", + 8: "August", + 9: "September", + 10: "October", + 11: "November", + 12: "December", +} %} + +{% set birthday = user.birthday|split('-') %} + +{% block settingsContent %} +
    + {% for field in fields %} +
    +
    +

    {{ field.name }}

    +
    +
    + +
    + {% if field.additional %} + {% for id,addit in field.additional %} +
    + + +
    + {% endfor %} + {% endif %} +
    + {% endfor %} +
    +
    +

    Birthday

    +
    +
    + Day: + Month: + Year: +
    +
    +
    + + +
    +
    +{% endblock %} diff --git a/templates/yuuno/settings/notifications/history.twig b/templates/yuuno/settings/notifications/history.twig new file mode 100644 index 0000000..fdbd42e --- /dev/null +++ b/templates/yuuno/settings/notifications/history.twig @@ -0,0 +1,59 @@ +{% extends 'settings/notifications/master.twig' %} + +{% set mode = 'History' %} + +{% block description %} +

    The history of notifications that have been sent to you.

    +{% endblock %} + +{% set alerts = user.notifications(0, false)|batch(10) %} + +{% set paginationPages = alerts %} +{% set paginationUrl %}{{ route('settings.notifications.history') }}{% endset %} + +{% block css %} + +{% endblock %} + +{% block settingsContent %} + {% if alerts %} + + {% if alerts|length > 1 %} +
    + {% include 'elements/pagination.twig' %} +
    + {% endif %} + {% else %} +

    You don't have any notifications in your history!

    + {% endif %} +{% endblock %} diff --git a/templates/yuuno/settings/notifications/master.twig b/templates/yuuno/settings/notifications/master.twig new file mode 100644 index 0000000..7af531f --- /dev/null +++ b/templates/yuuno/settings/notifications/master.twig @@ -0,0 +1,3 @@ +{% extends 'settings/master.twig' %} + +{% set category = 'Notifications' %} diff --git a/templates/yuuno/user/profile.twig b/templates/yuuno/user/profile.twig index 7c03e7b..c4bf5a1 100644 --- a/templates/yuuno/user/profile.twig +++ b/templates/yuuno/user/profile.twig @@ -115,7 +115,7 @@ {% else %} {% if user.isFriends(profile.id) != 0 %}{% endif %} - {##} + {% endif %} {% if user.permission(constant('Sakura\\Perms\\Manage::CAN_RESTRICT_USERS'), constant('Sakura\\Perms::MANAGE')) %} diff --git a/templates/yuuno/user/report.twig b/templates/yuuno/user/report.twig new file mode 100644 index 0000000..b982653 --- /dev/null +++ b/templates/yuuno/user/report.twig @@ -0,0 +1,5 @@ +{% extends 'global/master.twig' %} + +{% block content %} +

    I'll actually make reporting a thing, someday...

    +{% endblock %} diff --git a/utility.php b/utility.php new file mode 100644 index 0000000..2c68a1d --- /dev/null +++ b/utility.php @@ -0,0 +1,278 @@ +isSMTP(); + + // Set the SMTP server host + $mail->Host = Config::get('smtp_server'); + + // Do we require authentication? + $mail->SMTPAuth = Config::get('smtp_auth'); + + // Do we encrypt as well? + $mail->SMTPSecure = Config::get('smtp_secure'); + + // Set the port to the SMTP server + $mail->Port = Config::get('smtp_port'); + + // If authentication is required log in as well + if (Config::get('smtp_auth')) { + $mail->Username = Config::get('smtp_username'); + $mail->Password = base64_decode(Config::get('smtp_password')); + } + + // Add a reply-to header + $mail->addReplyTo(Config::get('smtp_replyto_mail'), Config::get('smtp_replyto_name')); + + // Set a from address as well + $mail->setFrom(Config::get('smtp_from_email'), Config::get('smtp_from_name')); + + // Set the addressee + foreach ($to as $email => $name) { + $mail->addBCC($email, $name); + } + + // Subject line + $mail->Subject = $subject; + + // Set body + $mail->Body = $body; + + // Send the message + $send = $mail->send(); + + // Clear the addressee list + $mail->clearAddresses(); + + // If we got an error return the error + if (!$send) { + return $mail->ErrorInfo; + } + + // Else just return whatever + return $send; +} + +function error_handler($errno, $errstr, $errfile, $errline) +{ + // Remove ROOT path from the error string and file location + $errstr = str_replace(ROOT, '', $errstr); + $errfile = str_replace(ROOT, '', $errfile); + + switch ($errno) { + case E_ERROR: + case E_USER_ERROR: + $error = 'FATAL ERROR: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; + break; + + case E_WARNING: + case E_USER_WARNING: + $error = 'WARNING: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; + break; + + case E_NOTICE: + case E_USER_NOTICE: + $error = 'NOTICE: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; + break; + + default: + $error = 'Unknown error type [' . $errno . ']: ' . $errstr . ' on line ' . $errline + . ' in ' . $errfile; + } + + // Truncate all previous outputs + ob_clean(); + ob_end_clean(); + + // Check for dev mode + $detailed = Config::local('dev', 'show_errors'); + + // Build page + $errorPage = ' + + + + Sakura Internal Error + + + +
    +

    An error occurred while executing the script.

    +
    +

    To prevent potential security risks or data loss Sakura has stopped execution of the script.

    '; + + if (isset($errid)) { + $errorPage .= '

    The error and surrounding data has been logged.

    +

    ' . (!$detailed ? 'Report the following text to a staff member' : 'Logged as') . '

    +
    ' . $errid . '
    '; + } else { + $errorPage .= '

    Sakura was not able to log this error which could mean that there was an error + with the database connection. If you\'re the system administrator check the database credentials + and make sure the server is running and if you\'re not please let the system administrator + know about this error if it occurs again.

    '; + } + + if ($detailed) { + $errorPage .= '

    Summary

    +
    ' . $error . '
    +

    Backtraces

    '; + + foreach (debug_backtrace() as $num => $trace) { + $errorPage .= '

    #' . $num . '

    ';
    +
    +            foreach ($trace as $key => $val) {
    +                $errorPage .=
    +                str_pad(
    +                    '[' . $key . ']',
    +                    12
    +                ) . '=> ' . (
    +                    is_array($val) || is_object($val) ?
    +                    json_encode($val) :
    +                    $val
    +                ) . "\r\n";
    +            }
    +
    +            $errorPage .= '
    '; + } + } + + $errorPage .= '
    + +
    + +'; + + // Die and display error message + die($errorPage); +}