Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

User registration done: register/confirm/reconfirm/rest_password

++fixes
  • Loading branch information...
commit 9995511c1d037e5c80aa18ca038da89b721f2d7a 1 parent 1325892
@lefedor authored
Showing with 1,130 additions and 19,406 deletions.
  1. +6 −5 DOCS/INSTALL
  2. +1 −4 DOCS/TODO
  3. +22 −12 DOCS/db_dump/demo.sql
  4. +201 −127 LICENSES/ArtisticLicense
  5. +2 −2 NCMS/cgi-bin/MjNCMS/Content.pm
  6. +11 −1 NCMS/cgi-bin/MjNCMS/Date.pm
  7. +28 −10 NCMS/cgi-bin/MjNCMS/Mail.pm
  8. +2 −2 NCMS/cgi-bin/MjNCMS/Menus.pm
  9. +8 −4 NCMS/cgi-bin/MjNCMS/Plugin/{MjncmsInit.pm → MjncmsInit.pm.example}
  10. +0 −1  NCMS/cgi-bin/MjNCMS/Service.pm
  11. +2 −2 NCMS/cgi-bin/MjNCMS/Translations.pm
  12. +129 −29 NCMS/cgi-bin/MjNCMS/User.pm
  13. +563 −25 NCMS/cgi-bin/MjNCMS/Usercontroller.pm
  14. +13 −7 NCMS/cgi-bin/mj_daemon.pl.example
  15. +7 −0 NCMS/public_html/tt_tpls/mjncms/mail/signature.html.tpl
  16. +7 −0 NCMS/public_html/tt_tpls/mjncms/mail/signature.txt.tpl
  17. +2 −2 NCMS/public_html/tt_tpls/mjncms/user/mail/confirm.html.tpl
  18. +1 −1  NCMS/public_html/tt_tpls/mjncms/user/mail/confirm.txt.tpl
  19. +10 −0 NCMS/public_html/tt_tpls/mjncms/user/mail/forgot.html.tpl
  20. +10 −0 NCMS/public_html/tt_tpls/mjncms/user/mail/forgot.txt.tpl
  21. +9 −0 NCMS/public_html/tt_tpls/mjncms/user/mail/new_pass.html.tpl
  22. +9 −0 NCMS/public_html/tt_tpls/mjncms/user/mail/new_pass.txt.tpl
  23. +42 −0 NCMS/public_html/tt_tpls/mjncms/user/user_forgot.tpl
  24. +1 −1  NCMS/public_html/tt_tpls/mjncms/user/user_login.tpl
  25. +2 −0  NCMS/public_html/tt_tpls/mjncms/user/user_profile.tpl
  26. +42 −0 NCMS/public_html/tt_tpls/mjncms/user/user_reconfirm.tpl
  27. +0 −409 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_awpslist_fmt.tpl.ttc
  28. +0 −142 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_blocks_fmt.tpl.ttc
  29. +0 −491 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_catlist_fmt.tpl.ttc
  30. +0 −390 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_langlist_fmt.tpl.ttc
  31. +0 −483 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_roleslist_fmt.tpl.ttc
  32. +0 −408 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_sugrpslist_fmt.tpl.ttc
  33. +0 −521 NCMS/tmp/tt_ctpls/public_html/tt_tpls/_common/common_userlist_fmt.tpl.ttc
  34. +0 −124 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_auth.tpl.ttc
  35. +0 −461 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_awproles.tpl.ttc
  36. +0 −227 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_awproles_awp_edit.tpl.ttc
  37. +0 −108 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_awproles_role_add.tpl.ttc
  38. +0 −543 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_awproles_setperm_awp.tpl.ttc
  39. +0 −625 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_awproles_setperm_role.tpl.ttc
  40. +0 −447 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_blocks.tpl.ttc
  41. +0 −296 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_blocks_add.tpl.ttc
  42. +0 −432 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_blocks_edit.tpl.ttc
  43. +0 −618 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_cats.tpl.ttc
  44. +0 −64 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_filemanager.tpl.ttc
  45. +0 −621 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_page_add.tpl.ttc
  46. +0 −838 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_page_edit.tpl.ttc
  47. +0 −506 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_pages.tpl.ttc
  48. +0 −999 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_content_short_urls.tpl.ttc
  49. +0 −899 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_index.html.tpl.ttc
  50. +0 −70 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_index.tpl.ttc
  51. +0 −426 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_menus.tpl.ttc
  52. +0 −348 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_menus_add.tpl.ttc
  53. +0 −1,094 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_menus_edit.tpl.ttc
  54. +0 −474 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_menus_managetrans.tpl.ttc
  55. +0 −300 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_navleft.tpl.ttc
  56. +0 −59 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_no_access_perm.tpl.ttc
  57. +0 −347 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_permissions.tpl.ttc
  58. +0 −108 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_permissions_add.tpl.ttc
  59. +0 −246 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_permissions_edit.tpl.ttc
  60. +0 −367 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_translations_poollist.tpl.ttc
  61. +0 −900 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_users.tpl.ttc
  62. +0 −479 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_users_add.tpl.ttc
  63. +0 −666 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/admin/admin_users_edit.tpl.ttc
  64. +0 −56 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/common/common_logout.tpl.ttc
  65. +0 −286 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/content/content_category.tpl.ttc
  66. +0 −174 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/content/content_page.tpl.ttc
  67. +0 −97 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/content/content_shortlink_add.tpl.ttc
  68. +0 −169 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/content/content_shortlink_add_result.tpl.ttc
  69. +0 −31 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/not_found.html.tpl.ttc
  70. +0 −278 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/site_index.html.tpl.ttc
  71. +0 −162 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/mail/confirm.html.tpl.ttc
  72. +0 −55 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/mail/confirm.txt.tpl.ttc
  73. +0 −249 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_confirm.tpl.ttc
  74. +0 −62 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_confirm_req.tpl.ttc
  75. +0 −137 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_confirm_result.tpl.ttc
  76. +0 −96 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_login.tpl.ttc
  77. +0 −316 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_profile.tpl.ttc
  78. +0 −235 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/user/user_register.tpl.ttc
  79. +0 −232 NCMS/tmp/tt_ctpls/public_html/tt_tpls/mjncms/wrapper_index.tpl.ttc
View
11 DOCS/INSTALL
@@ -5,12 +5,13 @@
http://github.com/lefedor/mojo/commit/2a0d5fa8d75467a489d5d66426b9e8e974fa14d5
3. Rename mj_daemon.pl.example to mj_daemon.pl
4. Rename MjNCMS::Config.pm.example to MjNCMS::Config.pm
-5. Setup data @ config, basically just DB settings, random strings for crypt/md5 checks, recaptcha private/public keys
+5. Rename MjNCMS::Plugin::MjncmsInit.pm.example to MjNCMS::MjncmsInit.pm
+6. Setup data @ config, basically just DB settings, random strings for crypt/md5 checks, recaptcha private/public keys
(there are filled keys for host 'mojotest', so u can start up host with same name for *just testing* reasons)
-6. Start MjNCMS daemon: by typing `perl mjn_daemon.pl`
+7. Start MjNCMS daemon: by typing `perl mjn_daemon.pl`
(FCGI start, default options at mj_daemon.pl, near "Mojolicious->start" [fcgi_prefork --listen mojotest:3042 by default])
I've tested MjNCMS with nginx, nginx config example is nginx.conf just here, @ DOCS.
-7. OR! Start MjNCMS with your command line params, like `perl mjn_daemon.pl daemon` (localhost:3000 demo server)
+8. OR! Start MjNCMS with your command line params, like `perl mjn_daemon.pl daemon` (localhost:3000 demo server)
check 'help' command output.
-8. go to demo site. default admin path is /mjadmin/, default login/pass is austin/powers
-9. Profit!
+9. go to demo site. default admin path is /mjadmin/, default login/pass is austin/powers
+10. Profit!
View
5 DOCS/TODO
@@ -1,10 +1,6 @@
#Things in mind, volunteers/suggestions are welcome:
HOT:
- User reg/login/confirm @ content-side
- with lame predefined role
- profile page
- change email/pass form
MEMD use @ pages, @categories, @blocks
Paging @ category list - adv ..slug/[index|page_(2..n)].htm
Paging @ pages display - adv ..[slug|slug_page_(2..n)].html
@@ -75,5 +71,6 @@
Update all JS dialogs and evrything as Mootools locales, not hash like now,
which was about temporary solution, before locales extension man was read )
Update FileManager.js to use locales
+ Add namespace not visible from TT to prevent call some functions from templates. Like some of {'USR'}->new_salt/change_email. (more secure then)
..not complete...
View
34 DOCS/db_dump/demo.sql
@@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
--- Generation Time: Apr 19, 2010 at 04:05 PM
+-- Generation Time: Apr 22, 2010 at 12:25 AM
-- Server version: 5.0.51
-- PHP Version: 5.3.1-5
@@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `mjsmf_members` (
KEY `lastLogin` (`lastLogin`),
KEY `lngfile` (`lngfile`(30)),
KEY `ID_POST_GROUP` (`ID_POST_GROUP`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=38 ;
--
-- Dumping data for table `mjsmf_members`
@@ -97,7 +97,9 @@ INSERT INTO `mjsmf_members` (`ID_MEMBER`, `memberName`, `dateRegistered`, `posts
(0, 'guest', 0, 0, 0, '', 0, 'Guest', 0, 0, '', '', '', '9474d8c82a7bdef16bb503f7dbd1b02f5aaf601f', '', 'I''m guest', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 0, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 0, 'oyaebu', 0, '', '', 0, 0, '!QAZa'),
(1, 'austin', 0, 0, 0, '', 0, 'Austin Powers', 0, 0, '', '', '', 'affed750772acc7816bdfb3740357b6e40c9e18f', 'austin@powers.ap', '', 0, '1939-11-12', '', '', '', '', '', '', '', 0, 1, '', '', 3, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 1, '', 0, '', '', 0, 0, 'AuSt!'),
(20, 'Morbo', 1271615794, 0, 0, '', 0, 'Morbo', 0, 0, '', '', '', 'ecafe79de815678b999f15a90b4e1cc32a35c09f', 'morbo@powers.app', '', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 1, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 0, '395bd7cd21', 0, '', '', 0, 0, '5a71'),
-(21, 'pepyaka', 1271627335, 0, 0, '', 0, 'pepyaka', 0, 0, '', '', '', '39c17d4c979a0312c04c074e4cde55ad96601d2f', 'pepyaka21@powers.apw', '', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 1, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 1, '', 0, '', '', 0, 0, 'b7f7');
+(21, 'pepyaka', 1271627335, 0, 0, '', 0, 'pepyaka', 0, 0, '', '', '', '39c17d4c979a0312c04c074e4cde55ad96601d2f', 'pepyaka21@powers.apw', '', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 1, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 1, '', 0, '', '', 0, 0, 'b7f7'),
+(22, 'chupakabra', 1271687788, 0, 0, '', 0, 'chupakabra', 0, 0, '', '', '', '8976fe787e7a12ef44d2237c94abee426125aa3c', 'chupakabra@powers.app', '', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 1, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 1, '', 0, '', '', 0, 0, 'e2af'),
+(37, 'Fry', 1271880017, 0, 0, '', 0, 'Fry', 0, 0, '', '', '', 'ccd720c03d4e26501f09c8c9a573fbc86898c74e', 'ffl-public@yandex.ru', '', 0, '0001-01-01', '', '', '', '', '', '', '', 1, 1, '', '', 0, '', 0, 0, 0, '', 1, 1, 0, 2, '', '', '', '', 0, 0, 'e6a22296d4', 0, '', '', 0, 0, '494d');
-- --------------------------------------------------------
@@ -129,7 +131,11 @@ INSERT INTO `mjsmf_sessions` (`session_id`, `last_update`, `data`) VALUES
('f1b76994a7fb9002ad35b5d77f0f91a1', 1271409820, 'rand_code|s:32:"2058676fc8c3afeefc3c6ab774cd1b67";USER_AGENT|s:103:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceweasel/3.5.8 (like Firefox/3.5.8)";'),
('4f5b80a66385d1267dfd5224cf72eead', 1271490299, 'rand_code|s:32:"07b3030d1d51cdac8c8d53be10bc16b1";USER_AGENT|s:103:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceweasel/3.5.8 (like Firefox/3.5.8)";'),
('8dd646045c2f0d2acac397ecff2103a6', 1271571671, 'rand_code|s:32:"31181c61db465da7ac91b5bf25fcb798";USER_AGENT|s:103:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceweasel/3.5.8 (like Firefox/3.5.8)";'),
-('d5dee676a0f02fdd4a5fb020b83f06a8', 1271668450, 'rand_code|s:32:"8a0322a4f4845231fd3241b2bc292b31";USER_AGENT|s:79:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceape/2.0.3";');
+('d5dee676a0f02fdd4a5fb020b83f06a8', 1271668450, 'rand_code|s:32:"8a0322a4f4845231fd3241b2bc292b31";USER_AGENT|s:79:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceape/2.0.3";'),
+('020c416d56fc9facbce6bc3ec05ff8fb', 1271687691, 'rand_code|s:32:"0af7678245fd9e847b7fd40d241de6da";USER_AGENT|s:103:"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceweasel/3.5.8 (like Firefox/3.5.8)";'),
+('bb7b92305f6279d6b9aebae1bedc4392', 1271709968, 'rand_code|s:32:"f718429cbc6ded2b57212cbcbe1eba38";USER_AGENT|s:107:"Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.366.2 Safari/533.4";'),
+('be667308e54455a1eb7326dcfa6e807b', 1271710216, 'rand_code|s:32:"b3b3c921c82bc2b949f6518d1d75af2a";USER_AGENT|s:71:"Mozilla/5.0 (compatible; Konqueror/4.3; Linux) KHTML/4.3.4 (like Gecko)";'),
+('dd89f87ffc64922daa25a81a7277bea7', 1271710353, 'rand_code|s:32:"32a34f42ab302248da5179ef944a24d2";USER_AGENT|s:63:"Opera/9.80 (X11; Linux i686; U; ru) Presto/2.2.15 Version/10.10";');
-- --------------------------------------------------------
@@ -464,7 +470,7 @@ INSERT INTO `mj_pages` (`page_id`, `is_published`, `cat_id`, `lang`, `slug`, `in
(1, 1, 0, 'en', 'justpage', '<p>\n <img alt="" ilo-full-src="http://mojotest:82/userfiles/mjncms/1/avopingvo.jpg" src="/userfiles/mjncms/1/avopingvo.jpg" style="width: 96px; height: 96px;" /></p>\n<p>\n This is justpage intro. hi! cool!</p>\n<p>\n &nbsp;</p>\n<p>\n', '<p>\n This is justpagebody</p>\n', 'just single page', '', '', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-12 14:14:38', '2010-04-14 22:38:35', '2010-04-12 02:13:00', '2010-04-12 02:13:00', NULL),
(2, 1, 8, 'en', 'd1cp1', '<p>\n iintro</p>\n', '<p>\n bbody</p>\n', 'demo1 cat page 1', '', '', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 0, '2010-04-12 14:15:14', '2010-04-12 14:15:14', '2010-04-12 03:14:00', '2010-04-12 03:14:00', NULL),
(3, 1, 8, 'en', 'd1cp2', '<p>\n introoo</p>\n', '<p>\n bodyyy</p>\n', 'demo1 cat page 2', '', '', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-12 14:15:44', '2010-04-12 14:18:35', '2010-04-12 04:15:00', '2010-04-12 04:15:00', NULL),
-(4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n &nbsp;</p>\n<p>\n be careful this demo runs on lowerclocked NAS :)</p>\n<p>\n &nbsp;</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n<p>\n &nbsp;</p>\n<p>\n btw, <a href="/mjadmin">admin side</a></p>', 'Main index page', 'MjNCMS project - PERL Mojolicious CMS demo site index page', 'MjNCMS, Mojolicious, Mojo, CMS', 1, 1, 'MjNCMS project demo site index page', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-18 10:36:08', '2010-04-15 11:45:00', '2010-04-15 11:45:00', NULL);
+(4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p some="thing">\n bla</p>\n<p>\n bla</p>\n<p>\n &nbsp;</p>\n<p>\n be careful this demo runs on lowerclocked NAS :)</p>\n<p>\n &nbsp;</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n<p>\n &nbsp;</p>\n<p>\n btw, <a href="/mjadmin">admin side</a></p>\n', 'Main index page', 'MjNCMS project - PERL Mojolicious CMS demo site index page', 'MjNCMS, Mojolicious, Mojo, CMS', 1, 1, 'MjNCMS project demo site index page', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-19 22:33:50', '2010-04-15 12:45:00', '2010-04-15 12:45:00', NULL);
-- --------------------------------------------------------
@@ -522,7 +528,7 @@ CREATE TABLE IF NOT EXISTS `mj_pages_archive` (
`dt_publishstart` datetime NOT NULL,
`dt_publishend` datetime NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Archive posts table' AUTO_INCREMENT=20 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Archive posts table' AUTO_INCREMENT=21 ;
--
-- Dumping data for table `mj_pages_archive`
@@ -547,7 +553,8 @@ INSERT INTO `mj_pages_archive` (`id`, `page_id`, `is_published`, `cat_id`, `lang
(16, 1, 1, 0, 'en', 'justpage', '<p>\n <img alt="" ilo-full-src="http://mojotest:82/userfiles/mjcms/1/avopingvo.jpg" src="/userfiles/mjcms/1/avopingvo.jpg" style="width: 96px; height: 96px;" /></p>\n<p>\n This is justpage intro. hi! cool!</p>\n<p>\n &nbsp;</p>\n<p>\n А вот хуй!</p>\n', '<p>\n This is justpagebody</p>\n', 'just single page', '', '', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-12 14:14:38', '2010-04-14 22:38:35', '2010-04-12 01:13:00', '2010-04-12 01:13:00', '0000-00-00 00:00:00'),
(17, 4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n', 'Main index page', '', '', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-15 20:40:43', '2010-04-15 08:45:00', '2010-04-15 08:45:00', '0000-00-00 00:00:00'),
(18, 4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n', 'Main index page', 'MjNCMS project demo site index page', 'MjNCMS, Mojolicious, Mojo', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-18 01:16:18', '2010-04-15 09:45:00', '2010-04-15 09:45:00', '0000-00-00 00:00:00'),
-(19, 4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n &nbsp;</p>\n<p>\n be careful this demo runs on lowerclocked NAS :)</p>\n<p>\n &nbsp;</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n<p>\n &nbsp;</p>\n<p>\n btw, <a href="/mjadmin">admin side</a></p>\n<p>\n &nbsp;</p>', 'Main index page', 'MjNCMS project demo site index page', 'MjNCMS, Mojolicious, Mojo', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-18 10:36:08', '2010-04-15 10:45:00', '2010-04-15 10:45:00', '0000-00-00 00:00:00');
+(19, 4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n &nbsp;</p>\n<p>\n be careful this demo runs on lowerclocked NAS :)</p>\n<p>\n &nbsp;</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n<p>\n &nbsp;</p>\n<p>\n btw, <a href="/mjadmin">admin side</a></p>\n<p>\n &nbsp;</p>', 'Main index page', 'MjNCMS project demo site index page', 'MjNCMS, Mojolicious, Mojo', 1, 0, '', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-18 10:36:08', '2010-04-15 10:45:00', '2010-04-15 10:45:00', '0000-00-00 00:00:00'),
+(20, 4, 1, 0, 'en', 'index', '<p>\n Index page</p>\n', '<p>\n bla</p>\n<p>\n bla</p>\n<p>\n &nbsp;</p>\n<p>\n be careful this demo runs on lowerclocked NAS :)</p>\n<p>\n &nbsp;</p>\n<p>\n bla</p>\n<p>\n Index so index....</p>\n<p>\n &nbsp;</p>\n<p>\n btw, <a href="/mjadmin">admin side</a></p>', 'Main index page', 'MjNCMS project - PERL Mojolicious CMS demo site index page', 'MjNCMS, Mojolicious, Mojo, CMS', 1, 1, 'MjNCMS project demo site index page', 1, 'comment', 0, '', 0, 0, 1, 1, 1, '2010-04-15 19:45:55', '2010-04-19 22:33:50', '2010-04-15 11:45:00', '2010-04-15 11:45:00', '0000-00-00 00:00:00');
-- --------------------------------------------------------
@@ -815,6 +822,7 @@ CREATE TABLE IF NOT EXISTS `mj_users` (
`role_id` smallint(5) unsigned NOT NULL default '0',
`name` tinytext NOT NULL,
`site_lng` char(4) default NULL,
+ `salt` char(16) default NULL,
`ins` datetime NOT NULL default '0000-00-00 00:00:00',
`upd` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`whoedit` mediumint(8) unsigned default NULL,
@@ -828,11 +836,13 @@ CREATE TABLE IF NOT EXISTS `mj_users` (
-- Dumping data for table `mj_users`
--
-INSERT INTO `mj_users` (`member_id`, `replace_member_id`, `is_cms_active`, `role_id`, `name`, `site_lng`, `ins`, `upd`, `whoedit`, `startpage`) VALUES
-(0, NULL, 1, 0, 'Guest', NULL, '2010-02-09 00:00:00', '2010-03-22 21:07:38', NULL, '/'),
-(1, 1, 1, 1, 'Austin Powers', 'en', '2010-02-09 00:00:00', '2010-04-19 00:14:28', 1, '/mjadmin/pages'),
-(20, NULL, 1, 5, 'Morbo', 'en', '0000-00-00 00:00:00', '2010-04-18 22:36:34', 1, '/'),
-(21, NULL, 1, 2, 'pepyaka222', 'en', '0000-00-00 00:00:00', '2010-04-19 15:59:47', 0, '/');
+INSERT INTO `mj_users` (`member_id`, `replace_member_id`, `is_cms_active`, `role_id`, `name`, `site_lng`, `salt`, `ins`, `upd`, `whoedit`, `startpage`) VALUES
+(0, NULL, 1, 0, 'Guest', NULL, '', '2010-02-09 00:00:00', '2010-03-22 21:07:38', NULL, '/'),
+(1, 1, 1, 1, 'Austin Powers', 'en', '', '2010-02-09 00:00:00', '2010-04-19 00:14:28', 1, '/mjadmin/pages'),
+(20, NULL, 1, 5, 'Morbo', 'en', '', '0000-00-00 00:00:00', '2010-04-18 22:36:34', 1, '/'),
+(21, NULL, 1, 2, 'pepyaka222', 'en', '', '0000-00-00 00:00:00', '2010-04-19 15:59:47', 0, '/'),
+(22, NULL, 1, 2, 'chupakabra', 'ru', '', '0000-00-00 00:00:00', '2010-04-19 18:37:20', 0, '/'),
+(37, NULL, 0, 2, 'Fry', 'ru', 'aed9e1cf5984603e', '0000-00-00 00:00:00', '2010-04-22 00:00:17', 0, '/');
-- --------------------------------------------------------
View
328 LICENSES/ArtisticLicense
@@ -1,127 +1,201 @@
- The "Artistic License"
-
- Preamble
-
-The intent of this document is to state the conditions under which a
-Package may be copied, such that the Copyright Holder maintains some
-semblance of artistic control over the development of the package,
-while giving the users of the package the right to use and distribute
-the Package in a more-or-less customary fashion, plus the right to make
-reasonable modifications.
-
-Definitions:
-
- "Package" refers to the collection of files distributed by the
- Copyright Holder, and derivatives of that collection of files
- created through textual modification.
-
- "Standard Version" refers to such a Package if it has not been
- modified, or has been modified in accordance with the wishes
- of the Copyright Holder as specified below.
-
- "Copyright Holder" is whoever is named in the copyright or
- copyrights for the package.
-
- "You" is you, if you're thinking about copying or distributing
- this Package.
-
- "Reasonable copying fee" is whatever you can justify on the
- basis of media cost, duplication charges, time of people involved,
- and so on. (You will not be required to justify it to the
- Copyright Holder, but only to the computing community at large
- as a market that must bear the fee.)
-
- "Freely Available" means that no fee is charged for the item
- itself, though there may be fees involved in handling the item.
- It also means that recipients of the item may redistribute it
- under the same conditions they received it.
-
-1. You may make and give away verbatim copies of the source form of the
-Standard Version of this Package without restriction, provided that you
-duplicate all of the original copyright notices and associated disclaimers.
-
-2. You may apply bug fixes, portability fixes and other modifications
-derived from the Public Domain or from the Copyright Holder. A Package
-modified in such a way shall still be considered the Standard Version.
-
-3. You may otherwise modify your copy of this Package in any way, provided
-that you insert a prominent notice in each changed file stating how and
-when you changed that file, and provided that you do at least ONE of the
-following:
-
- a) place your modifications in the Public Domain or otherwise make them
- Freely Available, such as by posting said modifications to Usenet or
- an equivalent medium, or placing the modifications on a major archive
- site such as uunet.uu.net, or by allowing the Copyright Holder to include
- your modifications in the Standard Version of the Package.
-
- b) use the modified Package only within your corporation or organization.
-
- c) rename any non-standard executables so the names do not conflict
- with standard executables, which must also be provided, and provide
- a separate manual page for each non-standard executable that clearly
- documents how it differs from the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-4. You may distribute the programs of this Package in object code or
-executable form, provided that you do at least ONE of the following:
-
- a) distribute a Standard Version of the executables and library files,
- together with instructions (in the manual page or equivalent) on where
- to get the Standard Version.
-
- b) accompany the distribution with the machine-readable source of
- the Package with your modifications.
-
- c) give non-standard executables non-standard names, and clearly
- document the differences in manual pages (or equivalent), together
- with instructions on where to get the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-5. You may charge a reasonable copying fee for any distribution of this
-Package. You may charge any fee you choose for support of this
-Package. You may not charge a fee for this Package itself. However,
-you may distribute this Package in aggregate with other (possibly
-commercial) programs as part of a larger (possibly commercial) software
-distribution provided that you do not advertise this Package as a
-product of your own. You may embed this Package's interpreter within
-an executable of yours (by linking); this shall be construed as a mere
-form of aggregation, provided that the complete Standard Version of the
-interpreter is so embedded.
-
-6. The scripts and library files supplied as input to or produced as
-output from the programs of this Package do not automatically fall
-under the copyright of this Package, but belong to whoever generated
-them, and may be sold commercially, and may be aggregated with this
-Package. If such scripts or library files are aggregated with this
-Package via the so-called "undump" or "unexec" methods of producing a
-binary executable image, then distribution of such an image shall
-neither be construed as a distribution of this Package nor shall it
-fall under the restrictions of Paragraphs 3 and 4, provided that you do
-not represent such an executable image as a Standard Version of this
-Package.
-
-7. C subroutines (or comparably compiled subroutines in other
-languages) supplied by you and linked into this Package in order to
-emulate subroutines and variables of the language defined by this
-Package shall not be considered part of this Package, but are the
-equivalent of input as in Paragraph 6, provided these subroutines do
-not change the language in any way that would cause it to fail the
-regression tests for the language.
-
-8. Aggregation of this Package with a commercial distribution is always
-permitted provided that the use of this Package is embedded; that is,
-when no overt attempt is made to make this Package's interfaces visible
-to the end user of the commercial distribution. Such use shall not be
-construed as a distribution of this Package.
-
-9. The name of the Copyright Holder may not be used to endorse or promote
-products derived from this software without specific prior written permission.
-
-10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-The End
+ The Artistic License 2.0
+
+ Copyright (c) 2000-2006, The Perl Foundation.
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+This license establishes the terms under which a given free software
+Package may be copied, modified, distributed, and/or redistributed.
+The intent is that the Copyright Holder maintains some artistic
+control over the development of that Package while still keeping the
+Package available as open source and free software.
+
+You are always permitted to make arrangements wholly outside of this
+license directly with the Copyright Holder of a given Package. If the
+terms of this license do not permit the full use that you propose to
+make of the Package, you should contact the Copyright Holder and seek
+a different licensing arrangement.
+
+Definitions
+
+ "Copyright Holder" means the individual(s) or organization(s)
+ named in the copyright notice for the entire Package.
+
+ "Contributor" means any party that has contributed code or other
+ material to the Package, in accordance with the Copyright Holder's
+ procedures.
+
+ "You" and "your" means any person who would like to copy,
+ distribute, or modify the Package.
+
+ "Package" means the collection of files distributed by the
+ Copyright Holder, and derivatives of that collection and/or of
+ those files. A given Package may consist of either the Standard
+ Version, or a Modified Version.
+
+ "Distribute" means providing a copy of the Package or making it
+ accessible to anyone else, or in the case of a company or
+ organization, to others outside of your company or organization.
+
+ "Distributor Fee" means any fee that you charge for Distributing
+ this Package or providing support for this Package to another
+ party. It does not mean licensing fees.
+
+ "Standard Version" refers to the Package if it has not been
+ modified, or has been modified only in ways explicitly requested
+ by the Copyright Holder.
+
+ "Modified Version" means the Package, if it has been changed, and
+ such changes were not explicitly requested by the Copyright
+ Holder.
+
+ "Original License" means this Artistic License as Distributed with
+ the Standard Version of the Package, in its current version or as
+ it may be modified by The Perl Foundation in the future.
+
+ "Source" form means the source code, documentation source, and
+ configuration files for the Package.
+
+ "Compiled" form means the compiled bytecode, object code, binary,
+ or any other form resulting from mechanical transformation or
+ translation of the Source form.
+
+
+Permission for Use and Modification Without Distribution
+
+(1) You are permitted to use the Standard Version and create and use
+Modified Versions for any purpose without restriction, provided that
+you do not Distribute the Modified Version.
+
+
+Permissions for Redistribution of the Standard Version
+
+(2) You may Distribute verbatim copies of the Source form of the
+Standard Version of this Package in any medium without restriction,
+either gratis or for a Distributor Fee, provided that you duplicate
+all of the original copyright notices and associated disclaimers. At
+your discretion, such verbatim copies may or may not include a
+Compiled form of the Package.
+
+(3) You may apply any bug fixes, portability changes, and other
+modifications made available from the Copyright Holder. The resulting
+Package will still be considered the Standard Version, and as such
+will be subject to the Original License.
+
+
+Distribution of Modified Versions of the Package as Source
+
+(4) You may Distribute your Modified Version as Source (either gratis
+or for a Distributor Fee, and with or without a Compiled form of the
+Modified Version) provided that you clearly document how it differs
+from the Standard Version, including, but not limited to, documenting
+any non-standard features, executables, or modules, and provided that
+you do at least ONE of the following:
+
+ (a) make the Modified Version available to the Copyright Holder
+ of the Standard Version, under the Original License, so that the
+ Copyright Holder may include your modifications in the Standard
+ Version.
+
+ (b) ensure that installation of your Modified Version does not
+ prevent the user installing or running the Standard Version. In
+ addition, the Modified Version must bear a name that is different
+ from the name of the Standard Version.
+
+ (c) allow anyone who receives a copy of the Modified Version to
+ make the Source form of the Modified Version available to others
+ under
+
+ (i) the Original License or
+
+ (ii) a license that permits the licensee to freely copy,
+ modify and redistribute the Modified Version using the same
+ licensing terms that apply to the copy that the licensee
+ received, and requires that the Source form of the Modified
+ Version, and of any works derived from it, be made freely
+ available in that license fees are prohibited but Distributor
+ Fees are allowed.
+
+
+Distribution of Compiled Forms of the Standard Version
+or Modified Versions without the Source
+
+(5) You may Distribute Compiled forms of the Standard Version without
+the Source, provided that you include complete instructions on how to
+get the Source of the Standard Version. Such instructions must be
+valid at the time of your distribution. If these instructions, at any
+time while you are carrying out such distribution, become invalid, you
+must provide new instructions on demand or cease further distribution.
+If you provide valid instructions or cease distribution within thirty
+days after you become aware that the instructions are invalid, then
+you do not forfeit any of your rights under this license.
+
+(6) You may Distribute a Modified Version in Compiled form without
+the Source, provided that you comply with Section 4 with respect to
+the Source of the Modified Version.
+
+
+Aggregating or Linking the Package
+
+(7) You may aggregate the Package (either the Standard Version or
+Modified Version) with other packages and Distribute the resulting
+aggregation provided that you do not charge a licensing fee for the
+Package. Distributor Fees are permitted, and licensing fees for other
+components in the aggregation are permitted. The terms of this license
+apply to the use and Distribution of the Standard or Modified Versions
+as included in the aggregation.
+
+(8) You are permitted to link Modified and Standard Versions with
+other works, to embed the Package in a larger work of your own, or to
+build stand-alone binary or bytecode versions of applications that
+include the Package, and Distribute the result without restriction,
+provided the result does not expose a direct interface to the Package.
+
+
+Items That are Not Considered Part of a Modified Version
+
+(9) Works (including, but not limited to, modules and scripts) that
+merely extend or make use of the Package, do not, by themselves, cause
+the Package to be a Modified Version. In addition, such works are not
+considered parts of the Package itself, and are not subject to the
+terms of this license.
+
+
+General Provisions
+
+(10) Any use, modification, and distribution of the Standard or
+Modified Versions is governed by this Artistic License. By using,
+modifying or distributing the Package, you accept this license. Do not
+use, modify, or distribute the Package, if you do not accept this
+license.
+
+(11) If your Modified Version has been derived from a Modified
+Version made by someone other than you, you are nevertheless required
+to ensure that your Modified Version complies with the requirements of
+this license.
+
+(12) This license does not grant you the right to use any trademark,
+service mark, tradename, or logo of the Copyright Holder.
+
+(13) This license includes the non-exclusive, worldwide,
+free-of-charge patent license to make, have made, use, offer to sell,
+sell, import and otherwise transfer the Package with respect to any
+patent claims licensable by the Copyright Holder that are necessarily
+infringed by the Package. If you institute patent litigation
+(including a cross-claim or counterclaim) against any party alleging
+that the Package constitutes direct or contributory patent
+infringement, then this Artistic License to you shall terminate on the
+date that such litigation is filed.
+
+(14) Disclaimer of Warranty:
+THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
+IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
+LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
4 NCMS/cgi-bin/MjNCMS/Content.pm
@@ -12,11 +12,11 @@ package MjNCMS::Content;
#
use common::sense;
-use base 'Mojolicious::Controller';
-
use FindBin;
use lib "$FindBin::Bin/../";
+use base 'Mojolicious::Controller';
+
use MjNCMS::Config qw/:vars /;
use MjNCMS::Service qw/:subs /;
View
12 NCMS/cgi-bin/MjNCMS/Date.pm
@@ -272,15 +272,25 @@ sub date_sql ($;$) {
return " DATE('" . time2str('%Y-%m-%d', $date) . "') ";
} #-- date_sql
-
sub datetime_sql () {
my ($self, $date) = @_;
$date = $self->epoch() unless $date;
+
#for sql caching && get_inserted items by lock && insert date - no NOW()
return q~ TIMESTAMP('~ . time2str('%Y-%m-%d %H:%M:%S', $date) . q~') ~;
} #-- datetime_sql
+sub get_by_fmt () {
+ my ($self, $fmt, $date) = @_;
+
+ $date = $self->epoch() unless $date;
+
+ return undef unless $fmt;
+
+ return time2str($fmt, $date);
+}
+
sub strptime_and_sql () {
#reformat date between sql, strptime anf JS, not finished
my ($self, ) = @_;
View
38 NCMS/cgi-bin/MjNCMS/Mail.pm
@@ -25,6 +25,7 @@ use MjNCMS::Config qw/:vars /;
#use MjNCMS::Service qw/:subs /;
use MIME::Lite;
+use MIME::Types;
use MIME::Base64 qw/encode_base64 /;
sub new () {
@@ -35,6 +36,7 @@ sub new () {
#allow new()->new(), allow send logs youself, etc
#return undef unless $$cfg{'to'};
+
$$cfg{'to'} = $SESSION{'SITE_CONTACTEMAIL'}
unless $$cfg{'to'};
$$cfg{'to'} =
@@ -100,7 +102,13 @@ sub new () {
Cc => $$cfg{'cc_enc'} || $$cfg{'cc'},
Subject => $$cfg{'subject_enc'} || $$cfg{'subject_enc'},
Type => $$cfg{'type'} || 'multipart/alternative', #'multipart/mixed', one of html|txt || both
- 'X-Mailer' => 'MjNCMS Mailer',
+ );
+
+ #Delete first X-Mailer entry [MIME::Lite vXXX]
+ $self->{'MESSAGE'}->delete('X-Mailer');
+ $self->{'MESSAGE'}->add(
+ 'X-Mailer',
+ $SESSION{'MAILER_ID'} || 'MjNCMS Mailer'
);
$self->{'MIMETYPES'} = MIME::Types->new();
@@ -112,7 +120,8 @@ sub new () {
}
if ($$cfg{'html'}){
$self->attach_html($$cfg{'html'});
- }
+ }
+
return $self
} #-- new
@@ -122,14 +131,19 @@ sub rest ($$) {
my $cfg = shift;
$cfg = {} unless ($cfg && ref $cfg && ref $cfg eq 'HASH');
+ my $xmailer = $self->{'MESSAGE'}->get('X-Mailer');
+
$self->{'MESSAGE'} = MIME::Lite->new(
- From => $self->{'MESSAGE'}->get('From'),
- To => $self->{'MESSAGE'}->get('To'),
- Cc => $self->{'MESSAGE'}->get('Cc'),
- Subject => $self->{'MESSAGE'}->get('Subject'),
- Type => 'multipart/mixed'
+ From => $self->{'MESSAGE'}->get('From'),
+ To => $self->{'MESSAGE'}->get('To'),
+ Cc => $self->{'MESSAGE'}->get('Cc'),
+ Subject => $self->{'MESSAGE'}->get('Subject'),
+ Type => $self->{'MESSAGE'}->get('Type'),
);
+ $self->{'MESSAGE'}->delete('X-Mailer');
+ $self->{'MESSAGE'}->add('X-Mailer', $xmailer || 'MjNCMS');
+
return $self;
} #-- rest
@@ -292,6 +306,7 @@ sub as_string ($) {
return $self->{'MESSAGE'}->as_string();
} #-- as_string
+#Mojo::ByteSteream style alias
sub to_string ($) {
my $self = shift;
@@ -300,7 +315,10 @@ sub to_string ($) {
sub sign ($$) {
- #is it broken?
+ #
+ # Warning, not for type='multipart/alternative' emails!
+ # Include signature @ html/text definition stage.
+ #
my ($self, $cfg) = @_;
@@ -319,10 +337,10 @@ sub sign ($$) {
$$cfg{'data'} = &_field_to_base($$cfg{'data'})
if $$cfg{'data'};
- $self->{'MESSAGE'}->sign({
+ $self->{'MESSAGE'}->sign(
Data => $$cfg{'data'},
Path => $$cfg{'path'}
- });
+ );
return $self;
} #-- sign
View
4 NCMS/cgi-bin/MjNCMS/Menus.pm
@@ -10,11 +10,11 @@ package MjNCMS::Menus;
#
use common::sense;
-use base 'Mojolicious::Controller';
-
use FindBin;
use lib "$FindBin::Bin/../";
+use base 'Mojolicious::Controller';
+
use MjNCMS::Config qw/:vars /;
use MjNCMS::Service qw/:subs /;
use MjNCMS::NS;
View
12 NCMS/cgi-bin/MjNCMS/Plugin/MjncmsInit.pm → NCMS/cgi-bin/MjNCMS/Plugin/MjncmsInit.pm.example
@@ -96,7 +96,7 @@ sub register {
$SESSION{'SHORTLINKS_REDIR_URL'} = $$cfg{'shortlinks_url'} || '/r';
$SESSION{'FORUM_URL'} = $$cfg{'forum_url'} || undef;
- $SESSION{'THEME_URLPATH'} = $$cfg{'tt_tpls_theme_urlpath'} || '/tt_tpls/mjcms';
+ $SESSION{'THEME_URLPATH'} = $$cfg{'tt_tpls_theme_urlpath'} || '/tt_tpls/mjncms';
$SESSION{'SITE_URL_EXTENSIONS'} = $$cfg{'site_url_extensions'} || {};
foreach my $ext (keys %{$SESSION{'SITE_URL_EXTENSIONS'}}){
@@ -152,7 +152,7 @@ sub register {
$c->app->renderer->root($$cfg{'tt_tpls_root'});
}
else {
- $c->app->renderer->root('../public_html/tt_tpls/mjcms');
+ $c->app->renderer->root('../public_html/tt_tpls/mjncms');
}
@{$TT_CFG{'includepath'}} = ();
@@ -577,15 +577,19 @@ sub register {
$SESSION{'DATE'} = MjNCMS::Date->new();
+ #Not much sense, but looks c00l :)
+ $SESSION{'MAILER_ID'} = $$cfg{'email_signature'} || 'MjNCMS Mailer';
+
$SESSION{'MAILER'} = MjNCMS::Mail->new({});
$SESSION{'EMAIL_SIGNATURE'} = $$cfg{'email_signature'} ||
-#>>>>>>>>>>>
+#=>=>=>=>=>=>
qq~
Sincerely yours,
${SESSION{SITE_NAME}} support team
$SESSION{'SERVER_NAME'} ~;
-#<<<<<<<<<<<
+#<=<=<=<=<=<=
+
$SESSION{'SHORT_URLS_ALLOW_MULTIALIAS'} = $$cfg{'short_urls_allow_multialias'} || 0;
$SESSION{'PREROUTE_CALLS'} = $$cfg{'preroute_calls'} if (
View
1  NCMS/cgi-bin/MjNCMS/Service.pm
@@ -10,7 +10,6 @@ package MjNCMS::Service;
#
use common::sense;
-
use FindBin;
use lib "$FindBin::Bin/../";
View
4 NCMS/cgi-bin/MjNCMS/Translations.pm
@@ -12,11 +12,11 @@ package MjNCMS::Translations;
#
use common::sense;
-use base 'Mojolicious::Controller';
-
use FindBin;
use lib "$FindBin::Bin/../";
+use base 'Mojolicious::Controller';
+
use MjNCMS::Config qw/:vars /;
use MjNCMS::Service qw/:subs /;
View
158 NCMS/cgi-bin/MjNCMS/User.pm
@@ -456,7 +456,7 @@ sub _smf_reg_confirm ($$) {
} unless (
$res &&
ref $res &&
- ref $res eq 'HASH' &&
+ ref $res eq 'HASH' &&
${$res}{'auth_success'}
);
@@ -668,9 +668,23 @@ sub _smf_get_users ($$) {
}
if (defined ${$cfg}{'login'} && length ${$cfg}{'login'}){
- ${$cfg}{'login'} = $dbh->quote(${$cfg}{'login'});
- ${$cfg}{'login'} =~ s/^\'|\*|\'$/%/g;
- $where_rule .= ' AND m.memberName LIKE \'' . ${$cfg}{'login'} . '\' ';
+ $where_rule .= ' AND m.memberName = ' . ($dbh->quote(${$cfg}{'login'})) . ' ';
+ }
+
+ if (defined ${$cfg}{'login_like'} && length ${$cfg}{'login_like'}){
+ ${$cfg}{'login_like'} = $dbh->quote(${$cfg}{'login_like'});
+ ${$cfg}{'login_like'} =~ s/^\'|\*|\'$/%/g;
+ $where_rule .= ' AND m.memberName LIKE \'' . ${$cfg}{'login_like'} . '\' ';
+ }
+
+ if (defined ${$cfg}{'email'} && length ${$cfg}{'email'}){
+ $where_rule .= ' AND m.emailAddress = ' . ($dbh->quote(${$cfg}{'email'})) . ' ';
+ }
+
+ if (defined ${$cfg}{'email_like'} && length ${$cfg}{'email_like'}){
+ ${$cfg}{'email_like'} = $dbh->quote(${$cfg}{'email_like'});
+ ${$cfg}{'email_like'} =~ s/^\'|\*|\'$/%/g;
+ $where_rule .= ' AND m.emailAddress LIKE \'' . ${$cfg}{'email_like'} . '\' ';
}
if (
@@ -800,12 +814,14 @@ sub _smf_get_users ($$) {
u.startpage, #10
+ u.salt, #10.5 :)
+
m.memberName AS login, #11
m.realName AS forum_name, #12
m.emailAddress AS email, #13
m.timeOffset AS time_offset, #14
m.is_activated AS is_forum_active, #15
- m. validation_code AS val_code, #16
+ m.validation_code AS val_code, #16
a.awp_id, a.name AS awp_name, #17
r.role_id, r.name AS role_name, #20
@@ -848,12 +864,14 @@ sub _smf_get_users ($$) {
NULL, #10
+ NULL, #10.5
+
m.memberName AS login, #11
m.realName AS forum_name, #12
m.emailAddress AS email, #13
m.timeOffset AS time_offset, #14
m.is_activated, #15
- m. validation_code AS val_code, #16
+ m.validation_code AS val_code, #16
NULL, NULL, #18
NULL, NULL, #20
@@ -926,9 +944,11 @@ sub _smf_get_users ($$) {
pages => \%pages,
foundrows => $foundrows,
}
+
} #-- _smf_get_user
sub _smf_change_email ($$$) {
+
my $self = $_[0];
my $email = $_[1];
my $member_id = $_[2];
@@ -967,9 +987,11 @@ sub _smf_change_email ($$$) {
}
return 1;
+
} #-- _smf_change_email
sub _smf_change_password ($$$$) {
+
my $self = $_[0];
my $pass = $_[1];
my $pass_retype = $_[2];
@@ -1043,9 +1065,11 @@ sub _smf_change_password ($$$$) {
}
return 1;
-} #-- _smf_changepass
+
+} #-- _smf_change_password
sub _smf_change_active ($$$) {
+
my $self = $_[0];
my $status = $_[1];
my $member_id = $_[2];
@@ -1102,6 +1126,7 @@ sub _smf_change_active ($$$) {
}
return 1;
+
} #-- _smf_change_active
########################################################################
@@ -1508,6 +1533,8 @@ sub register ($$$) {
my $is_cms_active = $_[6]? 1:0;
my $is_forum_active = $_[7]? 1:0;
+ my $salt = undef;
+
unless ($role_id =~ m/^\d+$/) {
$self->{'last_state'} = 'wrong_role';
return undef;
@@ -1537,6 +1564,8 @@ sub register ($$$) {
if (ref $member_id && ref $member_id eq 'HASH' && ${$member_id}{'member_id'} =~ /^\d+$/) {
+ $salt = substr($SESSION{'BS'}(rand() . time())->md5_sum()->to_string(), 0, 16);
+
$dbh -> do(qq~ LOCK TABLES ${SESSION{PREFIX}}users WRITE ; ~);
$q = qq~
@@ -1544,7 +1573,8 @@ sub register ($$$) {
${SESSION{PREFIX}}users (
member_id, role_id, name, # 0 1 2
site_lng, whoedit, startpage, # 3 4 5
- is_cms_active #6
+ salt, #6
+ is_cms_active #7
) VALUES (
~ . ($dbh->quote(${$member_id}{'member_id'})) . q~, #0
~ . ($dbh->quote($role_id)) . q~, #1
@@ -1552,7 +1582,8 @@ sub register ($$$) {
~ . ($dbh->quote($lang)) . q~, #3
~ . ($dbh->quote($SESSION{'USR'}->{'member_id'})) . q~, #4
~ . ($dbh->quote($startpage)) . q~, #5
- ~ . ($dbh->quote($is_cms_active)) . q~ #5
+ ~ . ($dbh->quote($salt)) . q~, #6
+ ~ . ($dbh->quote($is_cms_active)) . q~ #7
) ; ~;
eval {
@@ -1950,18 +1981,31 @@ sub users_get ($;$) {
} #-- users_get
+sub get_users ($;$) {
+
+ my $self = $_[0];
+ my $cfg = $_[1];
+
+ return $self->users_get($cfg);
+
+} #-- get_users
+
sub change_email ($$;$){
my $self = $_[0];
my $email = $_[1];
my $member_id = defined($_[2])? $_[2]:$self->{'member_id'};
+ return undef unless $member_id; #No guests id = 0
+
#?
- return undef unless (
- $member_id == $self->{'member_id'} ||
- $self->is_user_writable( $member_id ) ||
- $self->chk_access('users', 'manage', 'w')
- );
+ #
+ #return undef unless (
+ # $member_id == $self->{'member_id'} ||
+ # $self->is_user_writable( $member_id ) ||
+ # $self->chk_access('users', 'manage', 'w')
+ #);
+ #
my $mode = $self->{'MODE'};
@@ -1985,12 +2029,16 @@ sub change_password ($$$;$) {
my $pass_retype = $_[2];
my $member_id = defined($_[3])? $_[3]:$self->{'member_id'};
+ return undef unless $member_id; #No guests id = 0
+
#?
- return undef unless (
- $member_id == $self->{'member_id'} ||
- $self->is_user_writable( $member_id ) ||
- $self->chk_access('users', 'manage', 'w')
- );
+ #
+ #return undef unless (
+ # $member_id == $self->{'member_id'} ||
+ # $self->is_user_writable( $member_id ) ||
+ # $self->chk_access('users', 'manage', 'w')
+ #);
+ #
my $mode = $self->{'MODE'};
@@ -2016,11 +2064,13 @@ sub set_cms_active ($$;$) {
$status = $status? 1:0;
#?
- return undef unless (
- $member_id == $self->{'member_id'} ||
- $self->is_user_writable( $member_id ) ||
- $self->chk_access('users', 'manage', 'w')
- );
+ #
+ #return undef unless (
+ # $member_id == $self->{'member_id'} ||
+ # $self->is_user_writable( $member_id ) ||
+ # $self->chk_access('users', 'manage', 'w')
+ #);
+ #
my (
$dbh, $q,
@@ -2042,6 +2092,7 @@ sub set_cms_active ($$;$) {
if (scalar $updcnt) {
return 1;
}
+
return undef;
} #-- set_cms_active
@@ -2076,6 +2127,51 @@ sub set_forum_active ($$;$){
} #-- set_forum_active
+sub set_new_salt ($;$$){
+
+ my $self = $_[0];
+ my $salt = $_[1];
+ my $member_id = defined($_[2])? $_[2]:$self->{'member_id'};
+
+ return undef unless $member_id; #No guests id = 0
+
+ $salt = substr($SESSION{'BS'}(rand())->md5_sum()->to_string(), 0, 16)
+ unless $salt;
+
+ #?
+ #
+ #return undef unless (
+ # $member_id == $self->{'member_id'} ||
+ # $self->is_user_writable( $member_id ) ||
+ # $self->chk_access('users', 'manage', 'w')
+ #);
+ #
+
+ my (
+ $dbh, $q,
+ $updcnt,
+ ) = ($SESSION{'DBH'}, );
+
+ $q = qq~
+ UPDATE
+ ${SESSION{PREFIX}}users
+ SET
+ salt = ~ . ($dbh->quote($salt)) . qq~
+ WHERE member_id = ~ . ($dbh->quote($member_id)) . qq~ ;
+ ~;
+
+ eval{
+ $updcnt = $dbh -> do($q);
+ };
+
+ if (scalar $updcnt) {
+ return $salt;
+ }
+
+ return undef;
+
+} #-- set_new_salt
+
sub chk_pass ($$$;$) {
#Check if typed pass correct - profile update, etc
@@ -2089,12 +2185,16 @@ sub chk_pass ($$$;$) {
my $member_id = $self->{'member_id'}
unless defined $member_id;
+ return undef unless $member_id; #No guests id = 0
+
#?
- return undef unless (
- $member_id == $self->{'member_id'} ||
- $self->is_user_writable( $member_id ) ||
- $self->chk_access('users', 'manage', 'w')
- );
+ #
+ #return undef unless (
+ # $member_id == $self->{'member_id'} ||
+ # $self->is_user_writable( $member_id ) ||
+ # $self->chk_access('users', 'manage', 'w')
+ #);
+ #
my $mode = $self->{'MODE'};
View
588 NCMS/cgi-bin/MjNCMS/Usercontroller.pm
@@ -43,11 +43,11 @@ package MjNCMS::Usercontroller;
#
use common::sense;
-use base 'Mojolicious::Controller';
-
use FindBin;
use lib "$FindBin::Bin/../";
+use base 'Mojolicious::Controller';
+
use MjNCMS::Config qw/:vars /;
use MjNCMS::Service qw/:subs /;
@@ -135,7 +135,7 @@ sub usercontroller_rt_permissions_add_post () {
$url = $SESSION{'ADM_URL'}.'/permissions' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -209,7 +209,7 @@ sub usercontroller_rt_permissions_edit_post () {
$url = $SESSION{'ADM_URL'}.'/permissions' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -253,7 +253,7 @@ sub usercontroller_rt_permissions_delete_get () {
$url = $SESSION{'ADM_URL'}.'/permissions' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -348,7 +348,7 @@ sub usercontroller_rt_awproles_add_awp_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -421,7 +421,7 @@ sub usercontroller_rt_awproles_edit_awp_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -465,7 +465,7 @@ sub usercontroller_rt_awproles_delete_awp_get () {
$url = $SESSION{'ADM_URL'}.'/permissions' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -507,6 +507,7 @@ sub usercontroller_rt_awproles_add_role_get () {
sub usercontroller_rt_awproles_add_role_post () {
+
my $self = shift;
unless ($SESSION{'USR'}->chk_access('awp_roles', 'manage', 'w')) {
@@ -537,7 +538,7 @@ sub usercontroller_rt_awproles_add_role_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -611,7 +612,7 @@ sub usercontroller_rt_awproles_edit_role_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -655,7 +656,7 @@ sub usercontroller_rt_awproles_delete_role_get () {
$url = $SESSION{'ADM_URL'}.'/permissions' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -732,7 +733,7 @@ sub usercontroller_rt_awproles_setperm_awp_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -809,7 +810,7 @@ sub usercontroller_rt_awproles_setperm_role_post () {
$url = $SESSION{'ADM_URL'}.'/awp_roles' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -917,7 +918,7 @@ sub usercontroller_rt_users_add_post () {
$url = $SESSION{'ADM_URL'}.'/users' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1002,7 +1003,7 @@ sub usercontroller_rt_users_edit_post () {
$url = $SESSION{'ADM_URL'}.'/users' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1046,7 +1047,7 @@ sub usercontroller_rt_users_delete_get () {
$url = $SESSION{'ADM_URL'}.'/users' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1142,7 +1143,7 @@ sub usercontroller_rt_user_login_post () {
$SESSION{'REDIR'} = {
url => $$res{'url'},
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1202,7 +1203,7 @@ sub usercontroller_rt_user_logout_any () {
$url = '/' unless $url;
$SESSION{'REDIR'} = {
url => $url,
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1321,7 +1322,7 @@ sub usercontroller_rt_user_rolesw_post () {
$SESSION{'REDIR'} = {
url => $$res{'url'},
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1404,7 +1405,7 @@ sub usercontroller_rt_user_usersw_post () {
#we update original user, so 'member_id_real' is must
$replace_member_id = undef
- if $replace_member_id == $dbh->quote($SESSION{'USR'}->{'member_id_real'});
+ if $replace_member_id == $SESSION{'USR'}->{'member_id_real'};
$q = qq~
UPDATE
@@ -1445,7 +1446,7 @@ sub usercontroller_rt_user_usersw_post () {
$SESSION{'REDIR'} = {
url => $$res{'url'},
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1650,7 +1651,7 @@ sub usercontroller_rt_user_profile_post () {
$SESSION{'REDIR'} = {
url => $$res{'url'},
- msg => $res->{'message'},
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
};
return;
}
@@ -1816,12 +1817,15 @@ sub usercontroller_rt_user_register_post () {
$TT_VARS{'make_it_simple'} = 1;
$html = $self->render_partial(template => 'user/mail/confirm', format => 'html');
- $text = $self->render_partial('user/mail/confirm', format => 'txt');
+ $text = $self->render_partial(template => 'user/mail/confirm', format => 'txt');
$TT_VARS{'make_it_simple'} = 0;
if (
$SESSION{'MAILER'}->new({
- to => scalar $SESSION{'REQ'}->param('usr_email'),
+ to => (scalar $SESSION{'REQ'}->param('usr_name')) .
+ ' <' .
+ (scalar $SESSION{'REQ'}->param('usr_email')) .
+ '>',
subject => $SESSION{'LOC'}->loc('Confirm registartion at') . ' ' . $SESSION{'SITE_NAME'},
html => $html,
text => $text,
@@ -1846,7 +1850,6 @@ sub usercontroller_rt_user_register_post () {
}
-
my $body = $self->render_partial;
} #-- usercontroller_rt_user_register_post
@@ -1951,6 +1954,218 @@ sub usercontroller_rt_user_confirm_post () {
} #-- usercontroller_rt_user_confirm_post
+sub usercontroller_rt_user_forgot_password_get () {
+
+ my $self = shift;
+
+ unless ($SESSION{'USR'}->chk_access('users', 'auth')) {
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'commmon';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'no_access_perm';
+ $self->render('site_index', format => 'html');
+ return;
+ }
+ else {
+ $SESSION{'PAGE_CACHABLE'} = 1;
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'user';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'forgot';
+ }
+ $self->render('site_index', format => 'html');
+
+} #-- usercontroller_rt_user_forgot_password_get
+
+sub usercontroller_rt_user_forgot_password_post () {
+
+ my $self = shift;
+
+ unless ($SESSION{'USR'}->chk_access('users', 'auth')) {
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'commmon';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'no_access_perm';
+ $self->render('site_index', format => 'html');
+ return;
+ }
+
+ if (
+ $SESSION{'CAPTCHA'} &&
+ !$SESSION{'CAPTCHA'}->{'check_mjcaptcha'}()
+ ) {
+ $SESSION{'REDIR'} = {
+ url => $SESSION{'USR_URL'} . '/forgot_password',
+ msg => $SESSION{'LOC'}->loc('Captcha typed incorrectly'),
+ };
+ return;
+ }
+
+ my $res = &MjNCMS::Usercontroller::forgot_password({
+ c => $self,
+ login => scalar $SESSION{'REQ'}->param('login'),
+ email => scalar $SESSION{'REQ'}->param('email'),
+ });
+
+ my $url;
+ unless ($SESSION{'REQ_ISAJAX'}) {
+ if ($SESSION{'REFERER'}) {
+ $url = $SESSION{'REFERER'};
+ }
+ elsif ($SESSION{'HTTP_REFERER'}) {
+ $url = $SESSION{'HTTP_REFERER'};
+ }
+ $url = $SESSION{'USR_URL'}.'/forgot_password' unless $url;
+ $SESSION{'REDIR'} = {
+ url => $url,
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
+ };
+ return;
+ }
+ else {
+ $self->render_json({
+ status => $res->{'status'},
+ message => $SESSION{'LOC'}->loc($res->{'message'}),
+ role_id => $res->{'role_id'},
+
+ });
+ }
+
+} #-- usercontroller_rt_user_forgot_password_post
+
+sub usercontroller_rt_user_rest_pass_get () {
+
+ my $self = shift;
+
+ unless ($SESSION{'USR'}->chk_access('users', 'auth')) {
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'commmon';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'no_access_perm';
+ $self->render('site_index', format => 'html');
+ return;
+ }
+ else {
+ my $res = &MjNCMS::Usercontroller::rest_password({
+ c => $self,
+ login => scalar $self->param('login'),
+ crc => scalar $self->param('crc'),
+ });
+
+ my $url;
+ if ($SESSION{'REFERER'}) {
+ $url = $SESSION{'REFERER'};
+ }
+ elsif ($SESSION{'HTTP_REFERER'}) {
+ $url = $SESSION{'HTTP_REFERER'};
+ }
+ $url = $SESSION{'USR_URL'}.'/login' unless $url;
+ $SESSION{'REDIR'} = {
+ url => $url,
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
+ };
+ return;
+
+ }
+
+ return;
+
+} #-- usercontroller_rt_user_rest_pass_get
+
+sub usercontroller_rt_user_reconfirm_email_get () {
+
+ my $self = shift;
+
+ unless ($SESSION{'USR'}->chk_access('users', 'auth')) {
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'commmon';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'no_access_perm';
+ $self->render('site_index', format => 'html');
+ return;
+ }
+ else {
+ $SESSION{'PAGE_CACHABLE'} = 1;
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'user';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'reconfirm';
+ }
+ $self->render('site_index', format => 'html');
+
+} #-- usercontroller_rt_user_reconfirm_email_get
+
+
+sub usercontroller_rt_user_reconfirm_email_post () {
+
+ my $self = shift;
+
+ unless ($SESSION{'USR'}->chk_access('users', 'auth')) {
+ $TT_CFG{'tt_controller'} =
+ $TT_VARS{'tt_controller'} =
+ 'commmon';
+ $TT_CFG{'tt_action'} =
+ $TT_VARS{'tt_action'} =
+ 'no_access_perm';
+ $self->render('site_index', format => 'html');
+ return;
+ }
+
+ if (
+ $SESSION{'CAPTCHA'} &&
+ !$SESSION{'CAPTCHA'}->{'check_mjcaptcha'}()
+ ) {
+ $SESSION{'REDIR'} = {
+ url => $SESSION{'USR_URL'} . '/forgot_password',
+ msg => $SESSION{'LOC'}->loc('Captcha typed incorrectly'),
+ };
+ return;
+ }
+
+ my $res = &MjNCMS::Usercontroller::reconfirm_email({
+ c => $self,
+ login => scalar $SESSION{'REQ'}->param('login'),
+ email => scalar $SESSION{'REQ'}->param('email'),
+ });
+
+ my $url;
+ unless ($SESSION{'REQ_ISAJAX'}) {
+ if ($SESSION{'REFERER'}) {
+ $url = $SESSION{'REFERER'};
+ }
+ elsif ($SESSION{'HTTP_REFERER'}) {
+ $url = $SESSION{'HTTP_REFERER'};
+ }
+ $url = $SESSION{'USR_URL'}.'/login' unless $url;
+ $SESSION{'REDIR'} = {
+ url => $url,
+ msg => $SESSION{'LOC'}->loc($res->{'message'}),
+ };
+ return;
+ }
+ else {
+ $self->render_json({
+ status => $res->{'status'},
+ message => $SESSION{'LOC'}->loc($res->{'message'}),
+ role_id => $res->{'role_id'},
+
+ });
+ }
+
+} #-- usercontroller_rt_user_reconfirm_email_post
+
########################################################################
# INTERNAL SUBS
########################################################################
@@ -3935,4 +4150,327 @@ sub users_delete ($) {
} #-- users_delete
+sub forgot_password ($) {
+
+ my $cfg = shift;
+
+ return {
+ status => 'fail',
+ message => 'no input cfg',
+ } unless ($cfg && ref $cfg && ref $cfg eq 'HASH');
+
+ return {
+ status => 'fail',
+ message => 'no input data',
+ } unless (
+ ${$cfg}{'c'} &&
+ (
+ ${$cfg}{'login'} ||
+ ${$cfg}{'email'}
+ )
+ );
+
+ my (
+ $dbh, $q ,
+ $res, $ttv_save,
+ $html, $text,
+
+ ) = ($SESSION{'DBH'}, );
+
+ if (${$cfg}{'login'}){
+
+ $res = $SESSION{'USR'}->get_users({
+ login => ${$cfg}{'login'},
+ });
+
+ $res = pop @{$$res{'users'}};
+
+ }
+
+ if (!$res && ${$cfg}{'email'}){
+
+ $res = $SESSION{'USR'}->get_users({
+ email => ${$cfg}{'email'},
+ });
+
+ $res = pop @{$$res{'users'}};
+
+ }
+
+ if ($res && $$res{'member_id'}) { #Also guest protection :)
+
+ $ttv_save = $TT_VARS{'make_it_simple'};
+ $TT_VARS{'make_it_simple'} = 1;
+
+ $TT_VARS{'passrest_login'} = $$res{'login'};
+ $TT_VARS{'passrest_crc'} =
+ $SESSION{'BS'}(
+ $$res{'member_id'} .
+ $$res{'salt'} .
+ $$res{'ut_ins'} .
+ $SESSION{'MD_CHK_KEY'} .
+ ($SESSION{'DATE'}->get_by_fmt('-%Y-%m-%d-'))
+ )->md5_sum()->to_string();
+
+ $html = ${$cfg}{'c'}->render_partial(template => 'user/mail/forgot', format => 'html');
+ $text = ${$cfg}{'c'}->render_partial(template => 'user/mail/forgot', format => 'txt');
+
+ $TT_VARS{'make_it_simple'} = $ttv_save;
+ delete $TT_VARS{'passrest_login'};
+ delete $TT_VARS{'passrest_crc'};
+
+ if (
+ $SESSION{'MAILER'}->new({
+ to => ($$res{'name'}) .
+ ' <' .
+ ($$res{'email'}) .
+ '>',
+ subject => $SESSION{'LOC'}->loc('Rest password at') . ' ' . $SESSION{'SITE_NAME'},
+ html => $html,
+ text => $text,
+ })->send()
+ ){
+ return {
+ status => 'ok',
+ message => 'Check your email for password rest link',
+ }
+ }
+ else {
+ return {
+ status => 'fail',
+ message => 'fail to send password rest email',
+ }
+ }
+ }
+
+ return {
+ status => 'fail',
+ message => 'user not found',
+ }
+
+}
+
+sub rest_password ($) {
+
+ my $cfg = shift;
+
+ return {
+ status => 'fail',
+ message => 'no input cfg',
+ } unless ($cfg && ref $cfg && ref $cfg eq 'HASH');
+
+ return {
+ status => 'fail',
+ message => 'no input data',
+ } unless (
+ ${$cfg}{'login'} &&
+ ${$cfg}{'crc'} &&
+ ${$cfg}{'c'}
+ );
+
+ my (
+ $dbh, $q ,
+ $res, $ttv_save,
+ $html, $text, $new_pass,
+
+ ) = ($SESSION{'DBH'}, );
+
+ if (${$cfg}{'login'}){
+
+ $res = $SESSION{'USR'}->get_users({
+ login => ${$cfg}{'login'},
+ });
+
+ $res = pop @{$$res{'users'}};
+
+ }
+
+ if ($res && $$res{'member_id'}) { #Also guest protection :)
+
+ $ttv_save = $TT_VARS{'make_it_simple'};
+ $TT_VARS{'make_it_simple'} = 1;
+
+ $TT_VARS{'passrest_login'} = $$res{'login'};
+ $TT_VARS{'passrest_name'} = $$res{'name'};
+
+ $TT_VARS{'passrest_crc'} =
+ $SESSION{'BS'}(
+ $$res{'member_id'} .
+ $$res{'salt'} .
+ $$res{'ut_ins'} .
+ $SESSION{'MD_CHK_KEY'} .
+ ($SESSION{'DATE'}->get_by_fmt('-%Y-%m-%d-'))
+ )->md5_sum()->to_string();
+
+ unless (
+ $TT_VARS{'passrest_crc'} eq
+ ${$cfg}{'crc'}
+ ) {
+ return {
+ status => 'fail',
+ message => 'Password rest link You\'ve followed is not valid',
+ }
+ }
+
+ unless (
+ $SESSION{'USR'}->set_new_salt(undef, $$res{'member_id'})
+ ) {
+ return {
+ status => 'fail',
+ message => 'Password rest failed. Try please again or contact administrator. Error E01.',
+ }
+ }
+
+ $new_pass = substr($SESSION{'BS'}(rand())->md5_sum()->to_string(), 0, (int(rand(27))+5));
+
+ unless (
+ $SESSION{'USR'}->change_password($new_pass, $new_pass, $$res{'member_id'})
+ ) {
+ return {
+ status => 'fail',
+ message => 'Password rest failed. Try please again or contact administrator. Error E02.',
+ }
+ }
+
+ $TT_VARS{'passrest_password'} = $new_pass;
+
+ $html = ${$cfg}{'c'}->render_partial(template => 'user/mail/new_pass', format => 'html');
+ $text = ${$cfg}{'c'}->render_partial(template => 'user/mail/new_pass', format => 'txt');
+
+ $TT_VARS{'make_it_simple'} = $ttv_save;
+ delete $TT_VARS{'passrest_login'};
+ delete $TT_VARS{'passrest_crc'};
+ delete $TT_VARS{'passrest_password'};
+
+ if (
+ $SESSION{'MAILER'}->new({
+ to => ($$res{'name'}) .
+ ' <' .
+ ($$res{'email'}) .
+ '>',
+ subject => $SESSION{'LOC'}->loc('Your new password at') . ' ' . $SESSION{'SITE_NAME'},
+ html => $html,
+ text => $text,
+ })->send()
+ ){
+ return {
+ status => 'ok',
+ message => 'Check your email for new password',
+ }
+ }
+ else {
+ return {
+ status => 'fail',
+ message => 'fail to send new password email',
+ }
+ }
+ }
+
+ return {
+ status => 'fail',
+ message => 'user not found',
+ }
+
+} #-- rest_password
+
+sub reconfirm_email ($) {
+
+ my $cfg = shift;
+
+ return {
+ status => 'fail',
+ message => 'no input cfg',
+ } unless ($cfg && ref $cfg && ref $cfg eq 'HASH');
+
+ return {
+ status => 'fail',
+ message => 'no input data',
+ } unless (
+ ${$cfg}{'c'} &&
+ (
+ ${$cfg}{'login'} ||
+ ${$cfg}{'email'}
+ )
+ );
+
+ my (
+ $dbh, $q ,
+ $res, $ttv_save,
+ $html, $text,
+
+ ) = ($SESSION{'DBH'}, );
+
+ if (${$cfg}{'login'}){
+
+ $res = $SESSION{'USR'}->get_users({
+ login => ${$cfg}{'login'},
+ });
+
+ $res = pop @{$$res{'users'}};
+
+ }
+
+ if (!$res && ${$cfg}{'email'}){
+
+ $res = $SESSION{'USR'}->get_users({
+ email => ${$cfg}{'email'},
+ });
+
+ $res = pop @{$$res{'users'}};
+
+ }
+
+ if ($res && $$res{'member_id'}) { #Also guest protection :)
+
+ unless (
+ $$res{'val_code'} &&
+ !$$res{'is_forum_active'}
+ ) {
+ return {
+ status => 'fail',
+ message => 'Seems like user email alredy confirmed',
+ }
+ }
+
+ $ttv_save = $TT_VARS{'make_it_simple'};
+ $TT_VARS{'make_it_simple'} = 1;
+ $TT_VARS{'confirmation_code'} = $$res{'val_code'};
+
+ $html = ${$cfg}{'c'}->render_partial(template => 'user/mail/confirm', format => 'html');
+ $text = ${$cfg}{'c'}->render_partial(template => 'user/mail/confitm', format => 'txt');
+
+ $TT_VARS{'make_it_simple'} = $ttv_save;
+ delete $TT_VARS{'confirmation_code'};
+
+ if (
+ $SESSION{'MAILER'}->new({
+ to => ($$res{'name'}) .
+ ' <' .
+ ($$res{'email'}) .
+ '>',
+ subject => $SESSION{'LOC'}->loc('New confirmation email for') . ': ' . $SESSION{'SITE_NAME'},
+ html => $html,
+ text => $text,
+ })->send()
+ ){
+ return {
+ status => 'ok',
+ message => 'Check your mail for confirmation link',
+ }
+ }
+ else {
+ return {
+ status => 'fail',
+ message => 'fail to send confirmation email',
+ }
+ }
+ }
+
+ return {
+ status => 'fail',
+ message => 'user not found',
+ }
+
+}
+
1;
View
20 NCMS/cgi-bin/mj_daemon.pl.example
@@ -338,6 +338,8 @@ package MjNCMS;
#Public user routes - login/logout/edit/reg/reg_confirm
my $usr_r = $r->route($user_root);
+ $usr_r->route('/')->via('get')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_profile_get');
$usr_r->route('/login')->via('get')->
to(controller => 'usercontroller', action => 'usercontroller_rt_user_login_get');
$usr_r->route('/login')->via('post')->
@@ -356,16 +358,20 @@ package MjNCMS;
to(controller => 'usercontroller', action => 'usercontroller_rt_user_confirm_get');
$usr_r->route('/confirm')->via('post')->
to(controller => 'usercontroller', action => 'usercontroller_rt_user_confirm_post');
- $usr_r->route('/')->via('get')->
- to(controller => 'usercontroller', action => 'usercontroller_rt_user_profile_get');
+ $usr_r->route('/reconfirm_email')->via('get')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_reconfirm_email_get');
+ $usr_r->route('/reconfirm_email')->via('post')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_reconfirm_email_post');
$usr_r->route('/profile')->via('get')->
to(controller => 'usercontroller', action => 'usercontroller_rt_user_profile_get');
- $usr_r->route('/profile')->via('post')->#update profile post
+ $usr_r->route('/profile')->via('post')->
to(controller => 'usercontroller', action => 'usercontroller_rt_user_profile_post');
- $usr_r->route('/remind_password')->via('get')->#ask email/login
- to(controller => 'usercontroller', action => 'usercontroller_rt_user_remind_password_get');
- $usr_r->route('/remind_password')->via('post')->
- to(controller => 'usercontroller', action => 'usercontroller_rt_user_remind_password_post');
+ $usr_r->route('/forgot_password')->via('get')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_forgot_password_get');
+ $usr_r->route('/forgot_password')->via('post')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_forgot_password_post');
+ $usr_r->route('/rest_pass/(:login)/(:crc)')->via('get')->
+ to(controller => 'usercontroller', action => 'usercontroller_rt_user_rest_pass_get');
#Shortlinks thing
my $sl_r = $r->route($shortlinks_root);
View
7 NCMS/public_html/tt_tpls/mjncms/mail/signature.html.tpl
@@ -0,0 +1,7 @@
+[% USE loc -%]
+<br />
+<br />
+--<br />
+[% ('Sincerely yours') | html %],<br />
+[% SESSION.SITE_NAME | html %] [% loc('support team') | html %]<br />
+<a href="[% SESSION.SERVER_URL | html %]">[% SESSION.SERVER_URL | html %]</a>
View
7 NCMS/public_html/tt_tpls/mjncms/mail/signature.txt.tpl
@@ -0,0 +1,7 @@
+[% USE loc -%]
+
+
+--
+[% ('Sincerely yours') %],
+[% SESSION.SITE_NAME %] [% loc('support team') %]
+[% SESSION.SERVER_URL %]
View
4 NCMS/public_html/tt_tpls/mjncms/user/mail/confirm.html.tpl
@@ -1,9 +1,9 @@
[% USE loc -%]
-
[% loc('Hello, You\'re just one step far') | html %]<br />
-[% loc('to become registred member at') | html %] <b>&quot;[% SESSION.SITE_NAME %]&quot;</b><br />
+[% loc('to become registred member at') | html %] <b>&quot;[% SESSION.SITE_NAME | html %]&quot;</b><br />
<br />
[% loc('Please, follow this link to confirm your registration') | html %]:<br />
<br />
<a href="[% SESSION.SERVER_URL | html %][% SESSION.USR_URL | html %]/confirm/[% TT_VARS.confirmation_code | html %]">[% SESSION.SERVER_URL | html %][% SESSION.USR_URL | html %]/confirm/[% TT_VARS.confirmation_code | html %]</a>
+[% INCLUDE mail/signature.html.tpl -%]
View
2  NCMS/public_html/tt_tpls/mjncms/user/mail/confirm.txt.tpl
@@ -1,5 +1,4 @@
[% USE loc -%]
-
[% loc('Hello, You\'re just one step far') %]
[% loc('to become registred member at') %] "[% SESSION.SITE_NAME %]"
@@ -7,3 +6,4 @@
[% SESSION.SERVER_URL %][% SESSION.USR_URL %]/confirm/[% TT_VARS.confirmation_code %]