plugins/SpecialUserPrefs.php
author Dan
Tue, 19 Feb 2008 08:32:57 -0500
changeset 435 a434d60e525d
parent 430 ec90736b9cb9
child 504 bc8e0e9ee01d
permissions -rw-r--r--
And might as well add theme-manager.js while I'm at it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
/*
343
eefe9ab7fe7c Localized the first parts of the admin panel. As a consequence, also wrote a brand new Admin:PageManager that doesn't suck like the old one did.
Dan
parents: 334
diff changeset
     3
Plugin Name: plugin_specialuserprefs_title
36
425261984266 Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents: 32
diff changeset
     4
Plugin URI: http://enanocms.org/
343
eefe9ab7fe7c Localized the first parts of the admin panel. As a consequence, also wrote a brand new Admin:PageManager that doesn't suck like the old one did.
Dan
parents: 334
diff changeset
     5
Description: plugin_specialuserprefs_desc
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
Author: Dan Fuhry
387
92664d2efab8 Rebranded source code as 1.1.1; added TinyMCE ACL rule as per Vadi's request: http://forum.enanocms.org/viewtopic.php?f=7&t=54
Dan
parents: 372
diff changeset
     7
Version: 1.1.1
36
425261984266 Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents: 32
diff changeset
     8
Author URI: http://enanocms.org/
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
*/
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
/*
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
430
ec90736b9cb9 Started (but disabled) work on the new theme manager, 1.1.2 is being released with this thing halfway done.
Dan
parents: 411
diff changeset
    13
 * Version 1.1.2 (Caoineag alpha 2)
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
 * Copyright (C) 2006-2007 Dan Fuhry
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
 *
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
 * This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
 *
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
 */
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
$userprefs_menu = Array();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    24
$userprefs_menu_links = Array();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
function userprefs_menu_add($section, $text, $link)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
  global $userprefs_menu;
286
b2f985e4cef3 Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents: 224
diff changeset
    28
  if ( isset($userprefs_menu[$section]) && is_array($userprefs_menu[$section]) )
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
    $userprefs_menu[$section][] = Array(
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
      'text' => $text,
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
      'link' => $link
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
      );
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
  else
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
    $userprefs_menu[$section] = Array(Array(
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
      'text' => $text,
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
      'link' => $link
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    40
      ));
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
103
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    44
$plugins->attachHook('compile_template', 'userprefs_jbox_setup($button, $tb, $menubtn);');
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    45
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    46
function userprefs_jbox_setup(&$button, &$tb, &$menubtn)
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    47
{
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    48
  global $db, $session, $paths, $template, $plugins; // Common objects
388
9829ca63b53a Localized stray string "list of registered members" in UCP
Dan
parents: 372
diff changeset
    49
  global $lang;
103
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    50
  
322
5f1cd51bf1be Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents: 317
diff changeset
    51
  if ( $paths->namespace != 'Special' || $paths->page_id != 'Preferences' )
103
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    52
    return false;
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    53
  
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    54
  $tb .= "<ul>$template->toolbar_menu</ul>";
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    55
  $template->toolbar_menu = '';
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    56
  
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    57
  $button->assign_vars(array(
388
9829ca63b53a Localized stray string "list of registered members" in UCP
Dan
parents: 372
diff changeset
    58
      'TEXT' => $lang->get('usercp_btn_memberlist'),
103
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    59
      'FLAGS' => '',
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    60
      'PARENTFLAGS' => '',
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    61
      'HREF' => makeUrlNS('Special', 'Memberlist')
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    62
    ));
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    63
  
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    64
  $tb .= $button->run();
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    65
}
a8891e108c95 Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents: 85
diff changeset
    66
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
function userprefs_menu_html()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    69
  global $userprefs_menu;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
  global $userprefs_menu_links;
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    71
  global $lang;
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
  $html = '';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
  $quot = '"';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
  foreach ( $userprefs_menu as $section => $buttons )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
  {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    78
    $section_name = $section;
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    79
    if ( preg_match('/^[a-z]+_[a-z_]+$/', $section) )
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    80
    {
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    81
      $section_name = $lang->get($section_name);
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    82
    }
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    83
    $html .= ( isset($userprefs_menu_links[$section]) ) ? "<a href={$quot}{$userprefs_menu_links[$section]}{$quot}>{$section_name}</a>\n        " : "<a>{$section_name}</a>\n        ";
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
    $html .= "<ul>\n          ";
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    85
    foreach ( $buttons as $button )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    86
    {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    87
      $buttontext = $button['text'];
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    88
      if ( preg_match('/^[a-z]+_[a-z_]+$/', $buttontext) )
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    89
      {
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    90
        $buttontext = $lang->get($buttontext);
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    91
      }
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
    92
      $html .= "  <li><a href={$quot}{$button['link']}{$quot}>{$buttontext}</a></li>\n          ";
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
    }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
    $html .= "</ul>\n        ";
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    97
  return $html;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    98
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    99
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
function userprefs_show_menu()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   101
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
  echo '<div class="menu_nojs">
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   103
          ' . userprefs_menu_html() . '
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
          <span class="menuclear"></span>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
        </div>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
        <br />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
        ';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
function userprefs_menu_init()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   111
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
  global $db, $session, $paths, $template, $plugins; // Common objects
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
  global $userprefs_menu_links;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
  
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   115
  userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_emailpassword', makeUrlNS('Special', 'Preferences/EmailPassword') . '" onclick="ajaxLoginNavTo(\'Special\', \'Preferences/EmailPassword\', '.USER_LEVEL_CHPREF.'); return false;');
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   116
  userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_signature', makeUrlNS('Special', 'Preferences/Signature'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   117
  userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_publicinfo', makeUrlNS('Special', 'Preferences/Profile'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   118
  userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_usergroups', makeUrlNS('Special', 'Usergroups'));
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   119
  if ( getConfig('avatar_enable') == '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   120
  {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   121
    userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_avatar', makeUrlNS('Special', 'Preferences/Avatar'));
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   122
  }
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   123
  userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   124
  userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_outbox', makeUrlNS('Special', 'PrivateMessages/Folder/Outbox'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   125
  userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_sent', makeUrlNS('Special', 'PrivateMessages/Folder/Sent'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   126
  userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_drafts', makeUrlNS('Special', 'PrivateMessages/Folder/Drafts'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   127
  userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_archive', makeUrlNS('Special', 'PrivateMessages/Folder/Archive'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   128
  
334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   129
  /*
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   130
  // Reserved for Enano's Next Big Innovation.(TM)
334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   131
  userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special',      'Private_Messages#folder:inbox'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   132
  userprefs_menu_add('Private messages', 'Starred', makeUrlNS('Special',     'Private_Messages#folder:starred'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   133
  userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'Private_Messages#folder:sent'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   134
  userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special',     'Private_Messages#folder:drafts'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   135
  userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special',    'Private_Messages#folder:archive'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   136
  userprefs_menu_add('Private messages', 'Trash', makeUrlNS('Special',    'Private_Messages#folder:trash'));
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   137
  */
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   138
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   139
  $userprefs_menu_links['Profile/membership'] = makeUrlNS('Special', 'Preferences');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   140
  $userprefs_menu_links['Private messages']  = makeUrlNS('Special', 'PrivateMessages');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   141
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   142
  $code = $plugins->setHook('userprefs_jbox');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   143
  foreach ( $code as $cmd )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   144
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   145
    eval($cmd);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   146
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   147
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   148
334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 329
diff changeset
   149
$plugins->attachHook('common_post', 'userprefs_menu_init();');
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   150
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   151
function page_Special_Preferences()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   152
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   153
  global $db, $session, $paths, $template, $plugins; // Common objects
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   154
  global $lang;
406
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   155
  global $timezone;
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   156
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   157
  // We need a login to continue
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   158
  if ( !$session->user_logged_in )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   159
    redirect(makeUrlNS('Special', 'Login/' . $paths->page), 'Login required', 'You need to be logged in to access this page. Please wait while you are redirected to the login page.');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   160
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
  // User ID - later this will be specified on the URL, but hardcoded for now
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   162
  $uid = intval($session->user_id);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   163
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   164
  // Instanciate the AES encryptor
286
b2f985e4cef3 Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents: 224
diff changeset
   165
  $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   166
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   167
  // Basic user info
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   168
  $q = $db->sql_query('SELECT username, password, email, real_name, signature, theme, style FROM '.table_prefix.'users WHERE user_id='.$uid.';');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   169
  if ( !$q )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   170
    $db->_die();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   171
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   172
  $row = $db->fetchrow();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
  $db->free_result();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   175
  $section = $paths->getParam(0);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   176
  if ( !$section )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   177
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   178
    $section = 'Home';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   179
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   180
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   181
  $errors = '';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   182
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   183
  switch ( $section )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   184
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   185
    case 'EmailPassword':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   186
      // Require elevated privileges (well sortof)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   187
      if ( $session->auth_level < USER_LEVEL_CHPREF )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   188
      {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   189
        redirect(makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . USER_LEVEL_CHPREF, true), 'Authentication required', 'You need to re-authenticate to access this page.', 0);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   190
      }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   191
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   192
      if ( isset($_POST['submit']) )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   193
      {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   194
        $email_changed = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   195
        // First do the e-mail address
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   196
        if ( strlen($_POST['newemail']) > 0 )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   197
        {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   198
          switch('foo') // Same reason as in the password code...
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   199
          {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   200
            case 'foo':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   201
              if ( $_POST['newemail'] != $_POST['newemail_conf'] )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   202
              {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   203
                $errors .= '<div class="error-box">' . $lang->get('usercp_emailpassword_err_email_no_match') . '</div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   204
                break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   205
              }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   206
          }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   207
          $q = $db->sql_query('SELECT password FROM '.table_prefix.'users WHERE user_id='.$session->user_id.';');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   208
          if ( !$q )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   209
            $db->_die();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   210
          $row = $db->fetchrow();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   211
          $db->free_result();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   212
          $old_pass = $aes->decrypt($row['password'], $session->private_key, ENC_HEX);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   213
          
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   214
          $new_email = $_POST['newemail'];
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   215
          
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   216
          $result = $session->update_user($session->user_id, false, $old_pass, false, $new_email);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   217
          if ( $result != 'success' )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   218
          {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   219
            $message = '<p>' . $lang->get('usercp_emailpassword_err_list') . '</p>';
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   220
            $message .= '<ul><li>' . implode("</li>\n<li>", $result) . '</li></ul>';
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   221
            die_friendly($lang->get('usercp_emailpassword_err_title'), $message);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   222
          }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   223
          $email_changed = true;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   224
        }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   225
        // Obtain password
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   226
        if ( $_POST['use_crypt'] == 'yes' && !empty($_POST['crypt_data']) )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   227
        {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   228
          $key = $session->fetch_public_key($_POST['crypt_key']);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   229
          if ( !$key )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   230
            die('Can\'t lookup key');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   231
          $key = hexdecode($key);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   232
          $newpass = $aes->decrypt($_POST['crypt_data'], $key, ENC_HEX);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   233
          // At this point we know if we _want_ to change the password...
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   234
          
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   235
          // We can't check the password to see if it matches the confirmation
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   236
          // because the confirmation was destroyed during the encryption. I figured
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   237
          // this wasn't a big deal because if the encryption worked, then either
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   238
          // the Javascript validated it or the user hacked the form. In the latter
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   239
          // case, if he's smart enough to hack the encryption code, he's probably
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   240
          // smart enough to remember his password.
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   241
          
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   242
          if ( strlen($newpass) > 0 )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   243
          {
224
6a4573507ff8 Fixed: invalid smartform input to Admin:UserManager when errors present and changing own account; [demo mode] default user can no longer change password
Dan
parents: 192
diff changeset
   244
            if ( defined('ENANO_DEMO_MODE') )
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   245
              $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_demo') . '</div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   246
            // Perform checks
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   247
            if ( strlen($newpass) < 6 )
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   248
              $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_password_too_short') . '</div>';
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   249
            if ( getConfig('pw_strength_enable') == '1' )
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   250
            {
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   251
              $score_inp = password_score($newpass);
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   252
              if ( $score_inp < $score_min )
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   253
                $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_password_too_weak', array('score' => $score_inp)) . '</div>';
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   254
            }
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   255
            // Encrypt new password
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   256
            if ( empty($errors) )
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   257
            {
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   258
              $newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX);
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   259
              // Perform the swap
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   260
              $q = $db->sql_query('UPDATE '.table_prefix.'users SET password=\'' . $newpass_enc . '\' WHERE user_id=' . $session->user_id . ';');
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   261
              if ( !$q )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   262
                $db->_die();
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   263
              // Log out and back in
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   264
              $username = $session->username;
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   265
              $session->logout();
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   266
              if ( $email_changed )
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
              {
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   268
                if ( getConfig('account_activation') == 'user' )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   269
                {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   270
                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   271
                }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   272
                else if ( getConfig('account_activation') == 'admin' )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   273
                {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   274
                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   275
                }
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
              }
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   277
              $session->login_without_crypto($session->username, $newpass);
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   278
              redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_pass_success'), $lang->get('usercp_emailpassword_msg_password_changed'), 5);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
            }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   280
          }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   281
        }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   282
        else
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   283
        {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   284
          switch('foo') // allow breaking out of our section...i can't wait until PHP6 (goto support!)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   285
          {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   286
            case 'foo':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   287
              $pass = $_POST['newpass'];
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   288
              if ( $pass != $_POST['newpass_conf'] )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   289
              {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   290
                $errors .= '<div class="error-box">' . $lang->get('usercp_emailpassword_err_password_no_match') . '</div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   291
                break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   292
              }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   293
              
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   294
              $session->logout();
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   295
              if ( $email_changed )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   296
              {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   297
                if ( getConfig('account_activation') == 'user' )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   298
                {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   299
                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   300
                }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   301
                else if ( getConfig('account_activation') == 'admin' )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   302
                {
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   303
                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   304
                }
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   305
              }
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   306
              else
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   307
              {
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   308
                $session->login_without_crypto($session->username, $newpass);
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   309
                redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_pass_success'), $lang->get('usercp_emailpassword_msg_password_changed'), 5);
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
              }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   311
              
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   312
              return;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   313
          }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   314
        }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   315
      }
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   316
      $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_emailpassword_title');
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   317
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   318
    case 'Signature':
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   319
      $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_signature_title');
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   320
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   321
    case 'Profile':
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   322
      $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_publicinfo_title');
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   323
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   324
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   325
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   326
  $template->header();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   327
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   328
  // Output the menu
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   329
  // This is not templatized because it conforms to the jBox menu standard.
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   330
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   331
  userprefs_show_menu();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   332
        
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   333
  switch ( $section )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   334
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   335
    case 'Home':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   336
      global $email;
175
1465f48faba0 AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents: 140
diff changeset
   337
      $userpage_id = $paths->nslist['User'] . sanitize_page_id($session->username);
1465f48faba0 AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents: 140
diff changeset
   338
      $userpage_exists = ( isPage($userpage_id) ) ? '' : ' class="wikilink-nonexistent"';
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   339
      $user_page = makeUrlNS('User', sanitize_page_id($session->username));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   340
      $site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', $lang->get('usercp_intro_para3_admin_link'));
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   341
      
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   342
      echo '<h3 style="margin-top: 0;">' . $lang->get('usercp_intro_heading_main', array('username' => $session->username)) . '</h3>';
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   343
      
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   344
      echo '<p>' . $lang->get('usercp_intro_para1') . '</p>
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   345
            <p>' . $lang->get('usercp_intro_para2', array('userpage_link' => $user_page)) . '</p>
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   346
            <p>' . $lang->get('usercp_intro_para3', array('admin_contact_link' => $site_admin)) . '</p>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   347
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   348
    case 'EmailPassword':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   349
      
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   350
      $errors = trim($errors);
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   351
      if ( !empty($errors) )
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   352
      {
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   353
        echo $errors;
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   354
      }
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   355
      
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   356
      echo '<form action="' . makeUrlNS('Special', 'Preferences/EmailPassword') . '" method="post" onsubmit="return runEncryption();" name="empwform" >';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   357
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   358
      // Password change form
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   359
      $pubkey = $session->rijndael_genkey();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   360
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   361
      echo '<fieldset>
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   362
        <legend>' . $lang->get('usercp_emailpassword_grp_chpasswd') . '</legend>
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   363
        ' . $lang->get('usercp_emailpassword_field_newpass') . '<br />
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   364
          <input type="password" name="newpass" size="30" tabindex="1" ' . ( getConfig('pw_strength_enable') == '1' ? 'onkeyup="password_score_field(this);" ' : '' ) . '/>' . ( getConfig('pw_strength_enable') == '1' ? '<span class="password-checker" style="font-weight: bold; color: #aaaaaa;"> Loading...</span>' : '' ) . '
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   365
        <br />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   366
        <br />
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   367
        ' . $lang->get('usercp_emailpassword_field_newpass_confirm') . '<br />
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   368
        <input type="password" name="newpass_conf" size="30" tabindex="2" />
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   369
        ' . ( getConfig('pw_strength_enable') == '1' ? '<br /><br /><div id="pwmeter"></div>
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   370
        <small>' . $lang->get('usercp_emailpassword_msg_password_min_score') . '</small>' : '' ) . '
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   371
      </fieldset><br />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   372
      <fieldset>
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   373
        <legend>' . $lang->get('usercp_emailpassword_grp_chemail') . '</legend>
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   374
        ' . $lang->get('usercp_emailpassword_field_newemail') . '<br />
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   375
          <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail" size="30" tabindex="3" />
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   376
        <br />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   377
        <br />
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   378
        ' . $lang->get('usercp_emailpassword_field_newemail_confirm') . '<br />
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   379
          <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail_conf" size="30" tabindex="4" />
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   380
      </fieldset>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   381
      <input type="hidden" name="use_crypt" value="no" />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   382
      <input type="hidden" name="crypt_key" value="' . $pubkey . '" />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   383
      <input type="hidden" name="crypt_data" value="" />
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   384
      <br />
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   385
      <div style="text-align: right;"><input type="submit" name="submit" value="' . $lang->get('etc_save_changes') . '" tabindex="5" /></div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   386
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   387
      echo '</form>';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   388
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   389
      // ENCRYPTION CODE
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   390
      ?>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   391
      <script type="text/javascript">
133
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   392
      <?php if ( getConfig('pw_strength_enable') == '1' ): ?>
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   393
      password_score_field(document.forms.empwform.newpass);
af0f6ec48de3 Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents: 103
diff changeset
   394
      <?php endif; ?>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   395
        disableJSONExts();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   396
        str = '';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   397
        for(i=0;i<keySizeInBits/4;i++) str+='0';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   398
        var key = hexToByteArray(str);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   399
        var pt = hexToByteArray(str);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   400
        var ct = rijndaelEncrypt(pt, key, "ECB");
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   401
        var ct = byteArrayToHex(ct);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   402
        switch(keySizeInBits)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   403
        {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   404
          case 128:
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   405
            v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   406
            break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   407
          case 192:
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   408
            v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   409
            break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   410
          case 256:
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   411
            v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   412
            break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   413
        }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   414
        var aes_testpassed = ( ct == v && md5_vm_test() );
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   415
        function runEncryption()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   416
        {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   417
          var frm = document.forms.empwform;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   418
          if ( frm.newpass.value.length < 1 )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   419
            return true;
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   420
          
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   421
          pass1 = frm.newpass.value;
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   422
          pass2 = frm.newpass_conf.value;
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   423
          if ( pass1 != pass2 )
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   424
          {
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   425
            alert($lang.get('usercp_emailpassword_err_password_no_match'));
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   426
            return false;
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   427
          }
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   428
          if ( pass1.length < 6 && pass1.length > 0 )
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   429
          {
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   430
            alert($lang.get('usercp_emailpassword_err_password_too_short'));
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   431
            return false;
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   432
          }
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   433
          
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   434
          if(aes_testpassed)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   435
          {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   436
            frm.use_crypt.value = 'yes';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   437
            var cryptkey = frm.crypt_key.value;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   438
            frm.crypt_key.value = hex_md5(cryptkey);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   439
            cryptkey = hexToByteArray(cryptkey);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   440
            if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   441
            {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   442
              frm.submit.disabled = true;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   443
              len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   444
              alert('The key is messed up\nType: '+typeof(cryptkey)+len);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   445
            }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   446
            pass = frm.newpass.value;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   447
            pass = stringToByteArray(pass);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   448
            cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   449
            if(!cryptstring)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   450
            {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   451
              return false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   452
            }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   453
            cryptstring = byteArrayToHex(cryptstring);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   454
            frm.crypt_data.value = cryptstring;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   455
            frm.newpass.value = "";
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   456
            frm.newpass_conf.value = "";
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   457
          }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   458
          return true;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   459
        }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   460
      </script>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   461
      <?php
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   462
      
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   463
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   464
    case 'Signature':
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   465
      if ( isset($_POST['new_sig']) )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   466
      {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   467
        $sig = $_POST['new_sig'];
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   468
        $sig = RenderMan::preprocess_text($sig, true, false);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   469
        $sql_sig = $db->escape($sig);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   470
        $q = $db->sql_query('UPDATE '.table_prefix.'users SET signature=\'' . $sql_sig . '\' WHERE user_id=' . $session->user_id . ';');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   471
        if ( !$q )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   472
          $db->_die();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   473
        $session->signature = $sig;
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   474
        echo '<div class="info-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_signature_msg_saved') . '</div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   475
      }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   476
      echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 36
diff changeset
   477
      echo $template->tinymce_textarea('new_sig', htmlspecialchars($session->signature));
362
02d315d1cc58 Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents: 343
diff changeset
   478
      echo '<input type="submit" value="' . $lang->get('usercp_signature_btn_save') . '" />';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   479
      echo '</form>';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   480
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   481
    case "Profile":
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   482
      if ( isset($_POST['submit']) )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   483
      {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   484
        $real_name = htmlspecialchars($_POST['real_name']);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   485
        $real_name = $db->escape($real_name);
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   486
        
406
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   487
        $timezone = intval($_POST['timezone']);
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   488
        $tz_local = $timezone + 1440;
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   489
        
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   490
        $imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   491
        $imaddr_aim = $db->escape($imaddr_aim);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   492
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   493
        $imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   494
        $imaddr_msn = $db->escape($imaddr_msn);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   495
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   496
        $imaddr_yahoo = htmlspecialchars($_POST['imaddr_yahoo']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   497
        $imaddr_yahoo = $db->escape($imaddr_yahoo);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   498
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   499
        $imaddr_xmpp = htmlspecialchars($_POST['imaddr_xmpp']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   500
        $imaddr_xmpp = $db->escape($imaddr_xmpp);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   501
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   502
        $homepage = htmlspecialchars($_POST['homepage']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   503
        $homepage = $db->escape($homepage);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   504
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   505
        $location = htmlspecialchars($_POST['location']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   506
        $location = $db->escape($location);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   507
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   508
        $occupation = htmlspecialchars($_POST['occupation']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   509
        $occupation = $db->escape($occupation);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   510
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   511
        $hobbies = htmlspecialchars($_POST['hobbies']);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   512
        $hobbies = $db->escape($hobbies);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   513
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   514
        $email_public = ( isset($_POST['email_public']) ) ? '1' : '0';
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   515
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   516
        $session->real_name = $real_name;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   517
        
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 31
diff changeset
   518
        if ( !preg_match('/@([a-z0-9-]+)(\.([a-z0-9-\.]+))?/', $imaddr_msn) && !empty($imaddr_msn) )
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   519
        {
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   520
          $imaddr_msn = "$imaddr_msn@hotmail.com";
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   521
        }
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   522
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   523
        if ( substr($homepage, 0, 7) != 'http://' )
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   524
        {
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   525
          $homepage = "http://$homepage";
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   526
        }
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   527
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   528
        if ( !preg_match('/^http:\/\/([a-z0-9-.]+)([A-z0-9@#\$%\&:;<>,\.\?=\+\(\)\[\]_\/\\\\]*?)$/i', $homepage) )
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   529
        {
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   530
          $homepage = '';
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   531
        }
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   532
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   533
        $session->user_extra['user_aim'] = $imaddr_aim;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   534
        $session->user_extra['user_msn'] = $imaddr_msn;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   535
        $session->user_extra['user_xmpp'] = $imaddr_xmpp;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   536
        $session->user_extra['user_yahoo'] = $imaddr_yahoo;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   537
        $session->user_extra['user_homepage'] = $homepage;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   538
        $session->user_extra['user_location'] = $location;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   539
        $session->user_extra['user_job'] = $occupation;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   540
        $session->user_extra['user_hobbies'] = $hobbies;
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   541
        $session->user_extra['email_public'] = intval($email_public);
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   542
        
406
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   543
        $q = $db->sql_query('UPDATE '.table_prefix."users SET real_name='$real_name', user_timezone = $tz_local WHERE user_id=$session->user_id;");
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   544
        if ( !$q )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   545
          $db->_die();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   546
        
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   547
        $q = $db->sql_query('UPDATE '.table_prefix."users_extra SET user_aim='$imaddr_aim',user_yahoo='$imaddr_yahoo',user_msn='$imaddr_msn',
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   548
                               user_xmpp='$imaddr_xmpp',user_homepage='$homepage',user_location='$location',user_job='$occupation',
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   549
                               user_hobbies='$hobbies',email_public=$email_public
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   550
                               WHERE user_id=$session->user_id;");
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   551
        
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   552
        if ( !$q )
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   553
          $db->_die();
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   554
        
372
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   555
        // verify language id
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   556
        $lang_id = strval(intval($_POST['lang_id']));
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   557
        $q = $db->sql_query('SELECT 1 FROM ' . table_prefix . 'language WHERE lang_id = ' . $lang_id . ';');
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   558
        if ( !$q )
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   559
          $db->_die();
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   560
        
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   561
        if ( $db->numrows() > 0 )
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   562
        {
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   563
          $db->free_result();
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   564
          
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   565
          // unload / reload $lang, this verifies that the selected language works
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   566
          unset($GLOBALS['lang']);
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   567
          unset($lang);
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   568
          $lang_id = intval($lang_id);
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   569
          $GLOBALS['lang'] = new Language($lang_id);
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   570
          global $lang;
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   571
          
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   572
          $q = $db->sql_query('UPDATE ' . table_prefix . 'users SET user_lang = ' . $lang_id . " WHERE user_id = {$session->user_id};");
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   573
          if ( !$q )
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   574
            $db->_die();
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   575
        }
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   576
        else
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   577
        {
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   578
          $db->free_result();
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   579
        }
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   580
        
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   581
        echo '<div class="info-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_publicinfo_msg_save_success') . '</div>';
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   582
      }
372
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   583
      
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   584
      $lang_box = '<select name="lang_id">';
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   585
      $q = $db->sql_query('SELECT lang_id, lang_name_native FROM ' . table_prefix . "language;");
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   586
      if ( !$q )
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   587
        $db->_die();
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   588
      
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   589
      while ( $row = $db->fetchrow_num() )
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   590
      {
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   591
        list($lang_id, $lang_name) = $row;
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   592
        $lang_name = htmlspecialchars($lang_name);
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   593
        $selected = ( $lang->lang_id == $lang_id ) ? ' selected="selected"' : '';
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   594
        $lang_box .= "<option value=\"$lang_id\"$selected>$lang_name</option>";
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   595
      }
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   596
      
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   597
      $lang_box .= '</select>';
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   598
      
406
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   599
      $tz_select = '<select name="timezone">';
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   600
      $tz_list = $lang->get('tz_list');
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   601
      try
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   602
      {
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   603
        $tz_list = enano_json_decode($tz_list);
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   604
      }
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   605
      catch(Exception $e)
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   606
      {
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   607
        die("Caught exception decoding timezone data: <pre>$e</pre>");
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   608
      }
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   609
      foreach ( $tz_list as $key => $i )
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   610
      {
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   611
        $i = ($i * 60);
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   612
        $title = $lang->get("tz_title_{$key}");
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   613
        $hrs = $lang->get("tz_hrs_{$key}");
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   614
        $selected = ( $i == $timezone ) ? ' selected="selected"' : '';
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   615
        $tz_select .= "<option value=\"$i\"$selected>$title</option>";
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   616
      }
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   617
      $tz_select .= '</select>';
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   618
      
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   619
      echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   620
      ?>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   621
      <div class="tblholder">
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   622
        <table border="0" cellspacing="1" cellpadding="4">
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   623
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   624
            <th colspan="2"><?php echo $lang->get('usercp_publicinfo_heading_main'); ?></th>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   625
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   626
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   627
            <td colspan="2" class="row3"><?php echo $lang->get('usercp_publicinfo_note_optional'); ?></td>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   628
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   629
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   630
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_realname'); ?></td>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   631
            <td class="row1" style="width: 50%;"><input type="text" name="real_name" value="<?php echo $session->real_name; ?>" size="30" /></td>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   632
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   633
          <tr>
372
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   634
            <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_language') . '<br /><small>' . $lang->get('usercp_publicinfo_field_language_hint') . '</small>'; ?></td>
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   635
            <td class="row1"><?php echo $lang_box; ?></td>
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   636
          </tr>
5bd429428101 A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents: 364
diff changeset
   637
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   638
            <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_changetheme_title'); ?></td>
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   639
            <td class="row1"><?php echo $lang->get('usercp_publicinfo_field_changetheme_hint'); ?> <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;"><?php echo $lang->get('usercp_publicinfo_field_changetheme'); ?></a></td>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   640
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   641
          <tr>
406
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   642
            <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_timezone'); ?><br /><small><?php echo $lang->get('usercp_publicinfo_field_timezone_hint'); ?></small></td>
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   643
            <td class="row1"><?php echo $tz_select; ?></td>
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   644
          </tr>
7468a663315f Added some basic timezone support; DST support is still to come.
Dan
parents: 389
diff changeset
   645
          <tr>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   646
            <th class="subhead" colspan="2">
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   647
              <?php echo $lang->get('usercp_publicinfo_th_im'); ?>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   648
            </th>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   649
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   650
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_aim'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   651
            <td class="row1" style="width: 50%;"><input type="text" name="imaddr_aim" value="<?php echo $session->user_extra['user_aim']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   652
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   653
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   654
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_wlm'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   655
            <td class="row1" style="width: 50%;"><input type="text" name="imaddr_msn" value="<?php echo $session->user_extra['user_msn']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   656
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   657
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   658
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_yim'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   659
            <td class="row1" style="width: 50%;"><input type="text" name="imaddr_yahoo" value="<?php echo $session->user_extra['user_yahoo']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   660
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   661
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   662
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_xmpp'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   663
            <td class="row1" style="width: 50%;"><input type="text" name="imaddr_xmpp" value="<?php echo $session->user_extra['user_xmpp']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   664
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   665
          <tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   666
            <th class="subhead" colspan="2">
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   667
              <?php echo $lang->get('usercp_publicinfo_th_contact'); ?>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   668
            </th>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   669
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   670
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   671
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_homepage'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   672
            <td class="row1" style="width: 50%;"><input type="text" name="homepage" value="<?php echo $session->user_extra['user_homepage']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   673
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   674
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   675
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_location'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   676
            <td class="row1" style="width: 50%;"><input type="text" name="location" value="<?php echo $session->user_extra['user_location']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   677
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   678
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   679
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_job'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   680
            <td class="row1" style="width: 50%;"><input type="text" name="occupation" value="<?php echo $session->user_extra['user_job']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   681
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   682
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   683
            <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_hobbies'); ?></td>
31
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   684
            <td class="row1" style="width: 50%;"><input type="text" name="hobbies" value="<?php echo $session->user_extra['user_hobbies']; ?>" size="30" /></td>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   685
          </tr>
dc8741857bde Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents: 0
diff changeset
   686
          <tr>
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   687
            <td class="row2" style="width: 50%;"><label for="chk_email_public"><?php echo $lang->get('usercp_publicinfo_field_email_public'); ?></label><br /><small><?php echo $lang->get('usercp_publicinfo_field_email_public_hint'); ?></small></td>
140
40f7fa5fd061 Revamped the administrator's user CP, big time. The admin module now uses a smart form and enables all profile fields, including users_extra, to be changed. Passwords are encrypted when sent. The whole CP has been split off into a different file to accomodate the large amount of code.
Dan
parents: 133
diff changeset
   688
            <td class="row1" style="width: 50%;"><input type="checkbox" id="chk_email_public" name="email_public" <?php if ($session->user_extra['email_public'] == 1) echo 'checked="checked"'; ?> size="30" /></td>
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   689
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   690
          <tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   691
            <th class="subhead" colspan="2">
364
390eb356cd49 Finished l10n on user CP
Dan
parents: 362
diff changeset
   692
              <input type="submit" name="submit" value="<?php echo $lang->get('usercp_publicinfo_btn_save'); ?>" />
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   693
            </th>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   694
          </tr>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   695
        </table>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   696
      </div>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   697
      <?php
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   698
      echo '</form>';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   699
      break;
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   700
    case 'Avatar':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   701
      if ( getConfig('avatar_enable') != '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   702
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   703
        echo '<div class="error-box"><b>' . $lang->get('usercp_avatar_err_disabled_title') . '</b><br />' . $lang->get('usercp_avatar_err_disabled_body') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   704
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   705
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   706
      // Determine current avatar
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   707
      $q = $db->sql_query('SELECT user_has_avatar, avatar_type FROM ' . table_prefix . 'users WHERE user_id = ' . $session->user_id . ';');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   708
      if ( !$q )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   709
        $db->_die('Avatar CP selecting user\'s avatar data');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   710
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   711
      list($has_avi, $avi_type) = $db->fetchrow_num();
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   712
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   713
      if ( isset($_POST['submit']) )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   714
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   715
        $action = ( isset($_POST['avatar_action']) ) ? $_POST['avatar_action'] : 'keep';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   716
        $avi_path = ENANO_ROOT . '/' . getConfig('avatar_directory') . '/' . $session->user_id . '.' . $avi_type;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   717
        switch($action)
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   718
        {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   719
          case 'keep':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   720
          default:
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   721
            break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   722
          case 'remove':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   723
            if ( $has_avi )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   724
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   725
              // First switch the avatar off
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   726
              $q = $db->sql_query('UPDATE ' . table_prefix . 'users SET user_has_avatar = 0 WHERE user_id = ' . $session->user_id . ';');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   727
              if ( !$q )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   728
                $db->_die('Avatar CP switching user avatar off');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   729
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   730
              if ( @unlink($avi_path) )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   731
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   732
                echo '<div class="info-box">' . $lang->get('usercp_avatar_delete_success') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   733
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   734
              $has_avi = 0;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   735
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   736
            break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   737
          case 'set_http':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   738
          case 'set_file':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   739
            // Hackish way to preserve the UNIX philosophy of reusing as much code as possible
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   740
            if ( $action == 'set_http' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   741
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   742
              // Check if this action is enabled
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   743
              if ( getConfig('avatar_upload_http') !== '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   744
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   745
                // non-localized, only appears on hack attempt
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   746
                echo '<div class="error-box">Uploads over HTTP are disabled.</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   747
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   748
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   749
              // Download the file
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   750
              require_once( ENANO_ROOT . '/includes/http.php' );
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   751
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   752
              if ( !preg_match('/^http:\/\/([a-z0-9-\.]+)(:([0-9]+))?\/(.+)$/', $_POST['avatar_http_url'], $match) )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   753
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   754
                echo '<div class="error-box">' . $lang->get('usercp_avatar_invalid_url') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   755
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   756
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   757
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   758
              $hostname = $match[1];
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   759
              $uri = '/' . $match[4];
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   760
              $port = ( $match[3] ) ? intval($match[3]) : 80;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   761
              $max_size = intval(getConfig('avatar_max_size'));
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   762
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   763
              // Get temporary file
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   764
              $tempfile = tempnam(false, "enanoavatar_{$session->user_id}");
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   765
              if ( !$tempfile )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   766
                echo '<div class="error-box">Error getting temp file.</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   767
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   768
              @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   769
              $request = new Request_HTTP($hostname, $uri, 'GET', $port);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   770
              $result = $request->write_response_to_file($tempfile, 50, $max_size);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   771
              if ( !$result || $request->response_code != HTTP_OK )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   772
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   773
                @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   774
                echo '<div class="error-box">' . $lang->get('usercp_avatar_bad_write') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   775
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   776
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   777
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   778
              // Response written. Proceed to validation...
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   779
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   780
            else
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   781
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   782
              // Check if this action is enabled
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   783
              if ( getConfig('avatar_upload_file') !== '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   784
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   785
                // non-localized, only appears on hack attempt
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   786
                echo '<div class="error-box">Uploads from the browser are disabled.</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   787
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   788
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   789
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   790
              $max_size = intval(getConfig('avatar_max_size'));
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   791
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   792
              $file =& $_FILES['avatar_file'];
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   793
              $tempfile =& $file['tmp_name'];
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   794
              if ( filesize($tempfile) > $max_size )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   795
              {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   796
                @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   797
                echo '<div class="error-box">' . $lang->get('usercp_avatar_file_too_large') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   798
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   799
              }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   800
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   801
            $file_type = get_image_filetype($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   802
            if ( !$file_type )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   803
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   804
              unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   805
              echo '<div class="error-box">' . $lang->get('usercp_avatar_bad_filetype') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   806
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   807
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   808
            
329
0437a7cf1acc Added update-checking function (still a little rough around the edges); added support into admin user CP for changing avatars
Dan
parents: 328
diff changeset
   809
            $avi_path_new = ENANO_ROOT . '/' . getConfig('avatar_directory') . '/' . $session->user_id . '.' . $file_type;
0437a7cf1acc Added update-checking function (still a little rough around the edges); added support into admin user CP for changing avatars
Dan
parents: 328
diff changeset
   810
            
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   811
            // The file type is good - validate dimensions and animation
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   812
            switch($file_type)
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   813
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   814
              case 'png':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   815
                $is_animated = is_png_animated($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   816
                $dimensions = png_get_dimensions($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   817
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   818
              case 'gif':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   819
                $is_animated = is_gif_animated($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   820
                $dimensions = gif_get_dimensions($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   821
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   822
              case 'jpg':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   823
                $is_animated = false;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   824
                $dimensions = jpg_get_dimensions($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   825
                break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   826
              default:
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   827
                echo '<div class="error-box">API mismatch</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   828
                break 2;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   829
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   830
            // Did we get invalid size data? If so the image is probably corrupt.
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   831
            if ( !$dimensions )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   832
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   833
              @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   834
              echo '<div class="error-box">' . $lang->get('usercp_avatar_corrupt_image') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   835
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   836
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   837
            // Is the image animated?
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   838
            if ( $is_animated && getConfig('avatar_enable_anim') !== '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   839
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   840
              @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   841
              echo '<div class="error-box">' . $lang->get('usercp_avatar_disallowed_animation') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   842
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   843
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   844
            // Check image dimensions
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   845
            list($image_x, $image_y) = $dimensions;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   846
            $max_x = intval(getConfig('avatar_max_width'));
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   847
            $max_y = intval(getConfig('avatar_max_height'));
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   848
            if ( $image_x > $max_x || $image_y > $max_y )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   849
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   850
              @unlink($tempfile);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   851
              echo '<div class="error-box">' . $lang->get('usercp_avatar_too_large') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   852
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   853
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   854
            // All good!
329
0437a7cf1acc Added update-checking function (still a little rough around the edges); added support into admin user CP for changing avatars
Dan
parents: 328
diff changeset
   855
            @unlink($avi_path);
0437a7cf1acc Added update-checking function (still a little rough around the edges); added support into admin user CP for changing avatars
Dan
parents: 328
diff changeset
   856
            if ( rename($tempfile, $avi_path_new) )
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   857
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   858
              $q = $db->sql_query('UPDATE ' . table_prefix . "users SET user_has_avatar = 1, avatar_type = '$file_type' WHERE user_id = {$session->user_id};");
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   859
              if ( !$q )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   860
                $db->_die('Avatar CP updating users table after successful avatar upload');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   861
              $has_avi = 1;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   862
              $avi_type = $file_type;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   863
              echo '<div class="info-box">' . $lang->get('usercp_avatar_upload_success') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   864
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   865
            else
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   866
            {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   867
              echo '<div class="error-box">' . $lang->get('usercp_avatar_move_failed') . '</div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   868
            }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   869
            break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   870
        }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   871
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   872
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   873
      ?>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   874
      <script type="text/javascript">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   875
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   876
        function avatar_select_field(elParent)
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   877
        {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   878
          switch(elParent.value)
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   879
          {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   880
            case 'keep':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   881
            case 'remove':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   882
              $('avatar_upload_http').object.style.display = 'none';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   883
              $('avatar_upload_file').object.style.display = 'none';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   884
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   885
            case 'set_http':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   886
              $('avatar_upload_http').object.style.display = 'block';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   887
              $('avatar_upload_file').object.style.display = 'none';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   888
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   889
            case 'set_file':
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   890
              $('avatar_upload_http').object.style.display = 'none';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   891
              $('avatar_upload_file').object.style.display = 'block';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   892
              break;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   893
          }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   894
        }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   895
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   896
      </script>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   897
      <?php
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   898
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   899
      echo '<form action="' . makeUrl($paths->fullpage) . '" method="post" enctype="multipart/form-data">';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   900
      echo '<div class="tblholder">';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   901
      echo '<table border="0" cellspacing="1" cellpadding="4">';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   902
      echo '<tr>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   903
              <th colspan="2">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   904
                ' . $lang->get('usercp_avatar_table_title') . '
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   905
              </th>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   906
            </tr>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   907
            
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   908
      echo '<tr>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   909
              <td class="row2" style="width: 50%;">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   910
                ' . $lang->get('usercp_avatar_label_current') . '
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   911
              </td>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   912
              <td class="row1" style="text-align: center;">';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   913
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   914
      if ( $has_avi == 1 )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   915
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   916
        echo '<img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $session->username)) . '" src="' . make_avatar_url($session->user_id, $avi_type) . '" />';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   917
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   918
      else
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   919
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   920
        echo $lang->get('usercp_avatar_image_none');
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   921
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   922
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   923
      echo '    </td>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   924
              </tr>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   925
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   926
      echo '  <tr>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   927
                <td class="row2">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   928
                  ' . $lang->get('usercp_avatar_lbl_change') . '
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   929
                </td>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   930
                <td class="row1">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   931
                  <label><input type="radio" name="avatar_action" value="keep" onclick="avatar_select_field(this);" checked="checked" /> ' . $lang->get('usercp_avatar_lbl_keep') . '</label><br />
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   932
                  <label><input type="radio" name="avatar_action" value="remove" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_remove') . '</label><br />';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   933
      if ( getConfig('avatar_upload_http') == '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   934
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   935
        echo '    <label><input type="radio" name="avatar_action" value="set_http" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_set_http') . '</label><br />
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   936
                  <div id="avatar_upload_http" style="display: none; margin: 10px 0 0 2.2em;">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   937
                    ' . $lang->get('usercp_avatar_lbl_url') . ' <input type="text" name="avatar_http_url" size="40" value="http://" /><br />
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   938
                    <small>' . $lang->get('usercp_avatar_lbl_url_desc') . ' ' . $lang->get('usercp_avatar_limits') . '</small>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   939
                  </div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   940
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   941
      else
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   942
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   943
        echo '    <div id="avatar_upload_http" style="display: none;"></div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   944
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   945
      if ( getConfig('avatar_upload_file') == '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   946
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   947
        echo '    <label><input type="radio" name="avatar_action" value="set_file" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_set_file') . '</label>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   948
                  <div id="avatar_upload_file" style="display: none; margin: 10px 0 0 2.2em;">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   949
                    ' . $lang->get('usercp_avatar_lbl_file') . ' <input type="file" name="avatar_file" size="40" /><br />
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   950
                    <small>' . $lang->get('usercp_avatar_lbl_file_desc') . ' ' . $lang->get('usercp_avatar_limits') . '</small>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   951
                  </div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   952
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   953
      else
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   954
      {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   955
        echo '    <div id="avatar_upload_file" style="display: none;"></div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   956
      }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   957
      echo '    </td>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   958
              </tr>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   959
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   960
      echo '  <tr>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   961
                <th class="subhead" colspan="2">
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   962
                  <input type="submit" name="submit" value="' . $lang->get('etc_save_changes') . '" />
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   963
                </th>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   964
              </tr>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   965
              
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   966
      echo '</table>
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   967
            </div>';
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   968
      
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 322
diff changeset
   969
      break;
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   970
    default:
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   971
      $good = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   972
      $code = $plugins->setHook('userprefs_body');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   973
      foreach ( $code as $cmd )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   974
      {
315
f49e3c8b638c Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents: 286
diff changeset
   975
        if ( eval($cmd) )
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   976
          $good = true;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   977
      }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   978
      if ( !$good )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   979
      {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   980
        echo '<h3>Invalid module</h3>
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   981
              <p>Userprefs module "'.$section.'" not found.</p>';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   982
      }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   983
      break;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   984
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   985
  
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   986
  $template->footer();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   987
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   988
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   989
?>