From ab2c8df958ec6888b8bdecd3b56594c80eb62296 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 26 Sep 2015 18:12:42 +0200 Subject: [PATCH] r20150926 Signed-off-by: Flashwave --- .gitignore | 227 +- _sakura/.htaccess | 12 - _sakura/changelog.json | 53 +- _sakura/components/Main.php | 15 +- _sakura/components/User.php | 103 + _sakura/sakura.php | 2 +- _sakura/templates/yuuno/elements/captcha.tpl | 14 + _sakura/templates/yuuno/global/master.tpl | 12 +- _sakura/templates/yuuno/main/authenticate.tpl | 17 +- .../yuuno/settings/account.email.tpl | 6 +- .../yuuno/settings/account.password.tpl | 6 +- .../yuuno/settings/advanced.deactivate.tpl | 35 + .../yuuno/settings/appearance.userpage.tpl | 44 +- .../yuuno/settings/friends.listing.tpl | 16 +- .../yuuno/settings/friends.requests.tpl | 16 +- api/api.php | 2 +- cache/.htaccess | 12 - cache/.sakura | 1 + public/content/.htaccess | 39 - public/content/data/yuuno/css/markdown.css | 2 +- public/content/data/yuuno/css/yuuno.css | 23 +- public/content/data/yuuno/js/yuuno.js | 8 + public/content/libraries/showdown.js | 2295 +++++++++++++++++ public/settings.php | 131 +- uploads/.htaccess | 12 - uploads/.sakura | 1 + 26 files changed, 2705 insertions(+), 399 deletions(-) delete mode 100644 _sakura/.htaccess create mode 100644 _sakura/templates/yuuno/elements/captcha.tpl delete mode 100755 cache/.htaccess create mode 100644 cache/.sakura delete mode 100644 public/content/.htaccess create mode 100644 public/content/libraries/showdown.js delete mode 100755 uploads/.htaccess create mode 100644 uploads/.sakura diff --git a/.gitignore b/.gitignore index 767b6f8..81bfaf3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,237 +1,14 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## PHP Storm -################# - .idea/ - - -################# -## Sakura -################# - errors.log _sakura/config/config.ini BingSiteAuth.xml google*.html cache/* -!cache/.htaccess +!cache/.sakura uploads/* -!uploads/.htaccess - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml -*.publishproj - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches +!uploads/.sakura [Tt]humbs.db ehthumbs.db - -# Folder config file Desktop.ini - -# Recycle Bin used on file shares $RECYCLE.BIN/ - -# Mac crap .DS_Store - - -############# -## Python -############# - -*.py[cod] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg diff --git a/_sakura/.htaccess b/_sakura/.htaccess deleted file mode 100644 index 642aa21..0000000 --- a/_sakura/.htaccess +++ /dev/null @@ -1,12 +0,0 @@ -# Disallow external connections - -# Apache <= 2.2 - - Order deny,allow - deny from all - - -# Apache 2.4 => - - Require all denied - diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 62d0e6e..468f0c8 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -2869,7 +2869,58 @@ }, { "type": "ADD", - "change": "Implement username changing.", + "change": "Implemented username changing.", + "user": "Flashwave" + } + + ], + + "20150926": [ + + "eminence", + { + "type": "UPD", + "change": "Improved the ajaxBusyView thing.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added AJAX methods to the friend actions in the settings panel.", + "user": "Flashwave" + }, + { + "type": "REM", + "change": "Removed unneeded .htaccess files.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Removed unneeded lines from .gitignore.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added userpages back in.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added live preview for userpages.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed sanitising in userpages code.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added 4 of the 5 Account section pages (all except Ranks as this system is getting a change soon probably).", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added Deactivate Account template and placeholder logic.", "user": "Flashwave" } diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index 5b0eae7..5e5cd6c 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -29,10 +29,14 @@ class Main } // Parse markdown - public static function mdParse($text) + public static function mdParse($text, $escape = false) { - return (new Parsedown())->text($text); + $pd = new Parsedown(); + + return $escape ? + $pd->setMarkupEscaped(true)->text($text) : + $pd->text($text); } @@ -140,8 +144,11 @@ class Main if ($past = Database::fetch( 'error_log', false, - ['backtrace' => [$backtrace, '=', true], - 'error_string' => [$errstr, '=']] + [ + 'backtrace' => [$backtrace, '=', true], + 'error_string' => [$errstr, '='], + 'error_line' => [$errstr, '='], + ] )) { // If so assign the errid $errid = $past['id']; diff --git a/_sakura/components/User.php b/_sakura/components/User.php index d5fe45f..e6da47c 100644 --- a/_sakura/components/User.php +++ b/_sakura/components/User.php @@ -337,6 +337,21 @@ class User } + // Get all warnings issued to the user + public function userPage() + { + + return isset($this->data['userData']['userPage']) ? + Main::mdParse( + base64_decode( + $this->data['userData']['userPage'] + ), + true + ) : + null; + + } + // Get username change history public function getUsernameHistory() { @@ -414,4 +429,92 @@ class User return [1, 'SUCCESS', $username]; } + + // Set a new e-mail address + public function setEMailAddress($email) + { + + // Validate e-mail address + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + return [0, 'INVALID']; + } + + // Check if the username is already in use + $getInUse = Database::fetch('users', false, [ + 'email' => [$email, '='], + ]); + + // Check if anything was returned + if ($getInUse) { + return [0, 'IN_USE', $getInUse['id']]; + } + + // Update userrow + Database::update('users', [ + [ + 'email' => $email, + ], + [ + 'id' => [$this->data['id'], '='], + ], + ]); + + // Return success + return [1, 'SUCCESS', $email]; + + } + + // Set a new password + public function setPassword($old, $new, $confirm) + { + // Validate password + switch ($this->data['password_algo']) { + // Abyssing + case 'nologin': + return [0, 'NO_LOGIN']; + + // Default hashing method + default: + if (!Hashing::validatePassword($old, [ + $this->data['password_algo'], + $this->data['password_iter'], + $this->data['password_salt'], + $this->data['password_hash'], + ])) { + return [0, 'INCORRECT_PASSWORD', $this->data['password_chan']]; + } + + } + + // Check password entropy + if (Main::pwdEntropy($new) < Configuration::getConfig('min_entropy')) { + return [0, 'PASS_TOO_SHIT']; + } + + // Passwords do not match + if ($new != $confirm) { + return [0, 'PASS_NOT_MATCH']; + } + + // Create hash + $password = Hashing::createHash($new); + + // Update userrow + Database::update('users', [ + [ + 'password_hash' => $password[3], + 'password_salt' => $password[2], + 'password_algo' => $password[0], + 'password_iter' => $password[1], + 'password_chan' => time(), + ], + [ + 'id' => [$this->data['id'], '='], + ], + ]); + + // Return success + return [1, 'SUCCESS']; + + } } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index bb1562f..c897aae 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150923'); +define('SAKURA_VERSION', '20150926'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); diff --git a/_sakura/templates/yuuno/elements/captcha.tpl b/_sakura/templates/yuuno/elements/captcha.tpl new file mode 100644 index 0000000..1e6744a --- /dev/null +++ b/_sakura/templates/yuuno/elements/captcha.tpl @@ -0,0 +1,14 @@ + +
+ diff --git a/_sakura/templates/yuuno/global/master.tpl b/_sakura/templates/yuuno/global/master.tpl index d47a736..1be95fa 100644 --- a/_sakura/templates/yuuno/global/master.tpl +++ b/_sakura/templates/yuuno/global/master.tpl @@ -143,13 +143,11 @@ // Error reporter window.onerror = function(msg, url, line, col, error) { - - notifyUI({ - "title": "An error has occurred!", - "text": "There was a problem while executing the JavaScript code for this page: " + msg + ", URL: " + url + ", Line: " + line + ", Column: " + col + ". Please report this to a developer.", - "img": "FONT:fa-warning" - }); - + notifyUI({ + "title": "An error has occurred!", + "text": "There was a problem while executing the JavaScript code for this page: " + msg + ", URL: " + url + ", Line: " + line + ", Column: " + col + ". Please report this to a developer.", + "img": "FONT:fa-warning" + }); } diff --git a/_sakura/templates/yuuno/main/authenticate.tpl b/_sakura/templates/yuuno/main/authenticate.tpl index af1b2f9..55ed623 100644 --- a/_sakura/templates/yuuno/main/authenticate.tpl +++ b/_sakura/templates/yuuno/main/authenticate.tpl @@ -61,7 +61,7 @@ @@ -113,20 +113,7 @@
- -
- + {% include 'elements/captcha.tpl' %}
{% endif %}