Page 1 of 1

Please help me make a NEW user_level and add it to group?

PostPosted: Wed Jul 11, 2007 9:31 am
Author: cutegothpirate
Your phpBB Version: 2.0.22
phpBB Type: Integramod 141
MODs: Yes! Advanced Group Color Management for IntegraMOD 1.4.1
Your knowledge:
I suppose I am advanced.... Sometimes I claim I don't know anything because some php coding has to be dumbed down a bit.
Though I did add a bunch of things to my site by myself with codes I found on the internet that I spliced and diced and put together
(with the help of the odd people that IMed me out of the blue).
Other Things MODded:
Made new users called forum_bots.
Made user forms that post into forums that all users cannot see with the forum_bot posting the topic. Also takes their username from the site and includes it within the post.
Made one of the forms upload files into a folder on the site and post a message in the forums with the link to the file with the forum_bot posting the topic.
Made a user form that emails the result to a specified email account.
All of the forms use the portal pages and the template for my site with the error and success pages.
I have modified some tpl files to make things on my site show up in certain ways.
Plus I modified some other php files to make certain things to work the way I want them to.
(but I can't remember ALL of the ones I modified, because I have been modifying a lot over the past 3 weeks).

Board URL: http://www.wkservers.com/

PHP Version: 4.3.11

MySQL Version: 4.0.23-standard

phpMyAdmin Version: 2.6.2-pl1

My Problem
I would like to make a new user_level group.
I want to hide blocks in the qbar, or an entire qbar from all users but users in a user group. Not just so they can't be USED, but so they can't be SEEN either. The only way I found out how to do this is with the "view by" drop down list. Since there are only "All, Guests Only, Registered Users, Moderators, and Administrators" in the list, I guess I will have to add a new user_level. I don't know how though!!
I know it is very involved.
I just need a starting point; like what file to start with that holds the information.
If it is a php file I need to know the structure you use to add in php code. Like
"if you want to add a new user_level, find 'this', add 'this' with changing 'this' to the new level.
If you help me by writing it like that, I would be able to add more user_levels later on.
And then tell me how to get the user_level to show up in ONE drop down menu in ONE of the configuration pages that uses it.
Then maybe list the other files I need to change for adding the user_level in the other drop down menus on those pages.
If I need to add data to the database, I can, just tell me what I need to add <img>.

For the groups....
Tell me how to add code to a group to have it attach to the new user_level I created. I have no idea where to start with this, or how to write the code for it!

I need to do this because I just launched my site 4 days ago and am expecting 300 some odd users by the end of the month. I already have 105. I made it for a counter-strike community to replace their old plain phpbb site that was not the portal kind.
The thing is, they have administrators on their servers (10 servers) so there are around 100 or so, and the administrators change all the time.
The levels of the server admins are different depending on the server owner. So, I have seperated them into user groups on the website.
Some have moderator status, some do not, and some only moderate certain parts of the forum.
So, the only way to set it so that I can manage the newly created user_level without having to enter it in the user permissions admin panel one by one, would be to attatch the user_levels to the groups.
So any help here please? I need help with it ASAP! I am going to try and figure out how in the meantime, but It would take me weeks to figure it out all by myself.
So please help me??
If we end up needing to go back and forth with it you can contact me by:
AIM cutegothpirate
MSN cutegothpirate
Steam cutegothpirate
xfire cutegothpirate
email <a>cutegothpirate@aol.com</a>

Re: Please help me make a NEW user_level and add it to group

PostPosted: Wed Jul 11, 2007 10:09 am
Author: tmotley
I'm a little confused by 'I want to hide blocks in the qbar.' Do you mean hide links?

Here's an easy way to have only certain groups be authorized to see/use links in a qbar.

Create a private forum called "whatever only"
Create a group called "whatever" and give them permission to see "whatever only" forum.
Add users to that group that you want to have access. This gives them access to that forum.
Edit the qbar link and assign that forum in Forum Tree under Authorizations. Now only users with access to that forum will be authorized to use the qbar link.

If that's not what you want, then I apologize.

Re: Please help me make a NEW user_level and add it to group

PostPosted: Wed Jul 11, 2007 12:58 pm
Author: cutegothpirate
"tmotley";p="27193" wrote:I'm a little confused by 'I want to hide blocks in the qbar.' Do you mean hide links?

Here's an easy way to have only certain groups be authorized to see/use links in a qbar.

Create a private forum called "whatever only"
Create a group called "whatever" and give them permission to see "whatever only" forum.
Add users to that group that you want to have access. This gives them access to that forum.
Edit the qbar link and assign that forum in Forum Tree under Authorizations. Now only users with access to that forum will be authorized to use the qbar link.

If that's not what you want, then I apologize.


Then I accept your appology, lol <img>
Having user groups does what you just described, but as you said
Now only users with access to that forum will be authorized to use the qbar link.

It still does not stop them from being able to view it.
It seems that only the "registered users, moderators, guests, and administrators" access configurations are sitewide, while the "groups" access is only forum wide.
how does the site know that the user_level for administrator is '1' and moderators are '2'?
If I made a new user_level '3' where can I give it a name? how do I add it in to the things I want to add it to?

Re: Please help me make a NEW user_level and add it to group

PostPosted: Wed Jul 11, 2007 2:21 pm
Author: cutegothpirate
Ok! I figured out that the file that holds this information is profilcp/functions_profile.php
in it it defines the admin levels. And the user levels.
Code: Select all
<php>get('mod' . strval($userdata['user_id']), 200000, 'mod');             }             if($num_rows === FALSE)             {                 $sql = "SELECT * FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug                         WHERE ug.user_id = " . $userdata['user_id'] . "                             AND aa.group_id = ug.group_id                             AND aa.auth_mod = 1                             AND ug.user_pending = 0";                 if ( !$result = $db->sql_query($sql) )                 {                     message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);                 }                 $num_rows = $db->sql_numrows($result);                 if($portal_config['cache_enabled'])                 {                     $var_cache->save($num_rows, 'mod' . strval($userdata['user_id']), 'mod');                 }             }             if ($num_rows <0>get('jadmin', 200000, 'jadmin');         }                 if($jadmin_ary === FALSE)         {             $sql = "SELECT user_id FROM " . JR_ADMIN_TABLE . "                     WHERE user_jr_admin <if>sql_query($sql) )             {                 message_die(GENERAL_ERROR, 'Could not obtain junior admin status', '', __LINE__, __FILE__, $sql);             }               while( $row = $db->sql_fetchrow($result) )             {                 $jadmin_ary[] = $row['user_id'];             }             if($db->sql_fetchrow($result) == 0)             {                 $jadmin_ary[] = -10;             }             if($portal_config['cache_enabled'])             {                 $var_cache->save($jadmin_ary, 'jadmin', 'jadmin');             }         }           $res = USER;         if ( ($userdata['user_level'] == ADMIN) && ($userdata['user_id'] == ) )         {             $res = ADMIN_FOUNDER;         }         else if ($userdata['user_level'] == ADMIN)         {             $res = ADMIN;         }         else if (is_array($jadmin_ary))         {             if (in_array($userdata['user_id'], $jadmin_ary))             {                 $res = JADMIN;             }             else if ($userdata['user_level'] == MOD)             {                 $res = MOD;             }             else             {                 $res = USER;             }         }         else if ($userdata['user_level'] == MOD)         {             $res = MOD;         }         else         {             $res = USER;         }         return $res;     }       function is_admin($userdata)     {         global $admin_level;           return in_array(get_user_level($userdata),$admin_level);     }       function get_user_level_class($user_level, $default='gen', $user=array())     {         $ret = $default;         if (!empty($user)) $user_level = get_user_level($user);         switch( $user_level )         {                 case ADMIN_FOUNDER:                     $ret = 'foundercolor';                     break;                 case ADMIN:                     $ret = 'admincolor';                     break;                 case JADMIN:                     $ret = 'jadmincolor';                     break;                 case MOD:                     $ret = 'modcolor';                     break;                 default:                     $ret = 'usercolor';                     break;         }         return $ret;     }       function get_users_online_color()     {         global $lang;         global $level_prior, $level_desc;           $res = '';           // read the defined levels         @arsort($level_prior);         @reset($level_prior);         while ( list($key, $value) = @each($level_prior) )         {             if ( !empty($lang[ $level_desc[$key] ]) )             {                 $res .= ( empty($res) ? '' : '  ' ) . sprintf($lang[ $level_desc[$key] ], '[ <span>', '</span> ]');             }         }         return $res;     }       //-------------------------------------------     //     //   ranks management     //     //-------------------------------------------     function init_ranks(&$ranks)     {         global $db;           $sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_special DESC, rank_min";         if ( !$result = $db->sql_query($sql) )         {             message_die(GENERAL_ERROR, 'Could not obtain ranks information.', '', __LINE__, __FILE__, $sql);         }         while ( $row = $db->sql_fetchrow($result) )         {             $ranks[] = $row;         }         $db->sql_freeresult($result);           $rank_maxi = 99999999;         for ($i=count($ranks)-1; $i >= 0; $i--)         {             if ( $row['rank_special'] ) $row['rank_mini'] = 0;             $row['rank_maxi'] = $rank_maxi;             if (!$row['rank_special'] )             {                 $rank_maxi = $row['rank_mini'];             }             else $rank_maxi = 99999999;         }     }       $all_ranks = array();     init_ranks($all_ranks);       function get_user_rank($userrow)     {         global $all_ranks;           if(empty($all_ranks)){             $all_ranks = array();             init_ranks($all_ranks);         }           $rank_title = '';         $rank_image = '';         if ($userrow['user_id'] != ANONYMOUS)         {             if ( $userrow['user_rank'] )             {                 $found = false;                 for ($i = 0; ( ($i < count($all_ranks)) && !$found); $i++)                 {                     $found = ( ($userrow['user_rank'] == $all_ranks[$i]['rank_id']) && $all_ranks[$i]['rank_special']);                     if ($found)                     {                         $ranks = explode( "|", $all_ranks[$i]['rank_title']);                         $rank_title = ( isset($ranks[$userrow['user_gender']]) && ($ranks[$userrow['user_gender']] != '') ) ? $ranks[$userrow['user_gender']] : $ranks[0];                         $rank_image = ( $all_ranks[$i]['rank_image'] ) ? '<img>' : '';                     }                 }             }             else             {                 for($i = 0; $i <count>= $all_ranks[$i]['rank_min'] && !$all_ranks[$i]['rank_special'] )                     {                         $ranks = explode( "|", $all_ranks[$i]['rank_title']);                         $rank_title = ( isset($ranks[$userrow['user_gender']]) && ($ranks[$userrow['user_gender']] != '') ) ? $ranks[$userrow['user_gender']] : $ranks[0];                         $rank_image = ( $all_ranks[$i]['rank_image'] ) ? '<img>' : '';                     }                 }             }         }           // result         $res = array();         $res['rank_title'] = $rank_title;         $res['rank_image'] = $rank_image;         return $res;     }       //-------------------------------------------     //     //   others functions     //     //-------------------------------------------     function pcp_gen_rand_string($hash)     {       $rand_str = dss_rand();       return ( $hash ) ? md5($rand_str) : substr($rand_str, 0, 8);     }       function prepare_signature( $signature, $view_userdata )     {         global $board_config, $lang;           $preview_sig = ($signature != '') ? $signature : '';         $user_sig_bbcode_uid = $view_userdata['user_sig_bbcode_uid'];           // delete html tags         if ( $preview_sig != '' && $view_userdata['user_allowhtml'] && !$board_config['allow_html'] )         {             $preview_sig = preg_replace('#(<41>)#is', "&lt;\2&gt;", $preview_sig);         }           // parse bbcodes         if ( $preview_sig != '' && $user_sig_bbcode_uid != '' && $board_config['allow_bbcode'])         {             $preview_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($preview_sig, $user_sig_bbcode_uid) : preg_replace('/:[0-9a-z:]+]/si', ']', $preview_sig);         }           // add links         if ( $preview_sig != '' ) $preview_sig = make_clickable($preview_sig);           // parse smilies         if ( $preview_sig != '' && $view_userdata['user_allowsmile'] && $board_config['allow_smilies'] )         {             $preview_sig = smilies_pass($preview_sig);         }           // formate n         if ( $preview_sig != '' ) $preview_sig = str_replace("n", "n<br>n", $preview_sig);           return $preview_sig;     }       function pcp_check_image_type(&$type, &$error, &$error_msg)     {         global $lang;           switch( $type )         {             case 'jpeg':             case 'pjpeg':             case 'jpg':                 return '.jpg';                 break;             case 'gif':                 return '.gif';                 break;             case 'png':                 return '.png';                 break;             default:                 $error = true;                 $error_msg = (!empty($error_msg)) ? $error_msg . '<br>' . $lang['Avatar_filetype'] : $lang['Avatar_filetype'];                 break;         }           return false;     }       function pcp_user_avatar_delete($avatar_type, $avatar_file)     {         global $board_config, $userdata;           if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' )         {             if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $avatar_file)) )             {                 @unlink('./' . $board_config['avatar_path'] . '/' . $avatar_file);             }         }           return " user_avatar = '', user_avatar_type = " . USER_AVATAR_NONE;     }       function pcp_user_avatar_gallery(&$error, &$error_msg, $avatar_filename, $avatar_category)     {         global $board_config;           if(!preg_match('/(.gif$|.png$|.jpg|.jpeg)$/is', $avatar_filename))         {             return '';         }           if ( file_exists(@phpbb_realpath($board_config['avatar_gallery_path'] . '/' . $avatar_category . '/' . $avatar_filename)) )         {             $return = " user_avatar = '" . str_replace("'", "''", $avatar_category . '/' . $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;         }         else         {             $return = '';         }         return $return;     }       function pcp_user_avatar_url(&$error, &$error_msg, $avatar_filename)     {         global $lang;           $width = $height = 0;           if ( !preg_match('#^(http)|(ftp)://#i', $avatar_filename) )         {             $avatar_filename = 'http://' . $avatar_filename;         }           if ( !preg_match("#^((ht|f)tp://)([^ ?&=#"nrt<]*?(.(jpg|jpeg|gif|png))$)#is", $avatar_filename) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];             return;         }         list($width, $height, $type) = @getimagesize($tmp_filename);         if ( ($width > $board_config['avatar_max_width']) || ($height > $board_config['avatar_max_height']) )       {          $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);            $error = true;          $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;          return;       }         return " user_avatar = '" . str_replace("'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE;      }  function pcp_user_avatar_upload($avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype){     global $board_config, $db, $lang;       $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';       $width = $height = 0;     $type = '';       if ( $avatar_mode == 'remote' && preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $avatar_filename, $url_ary) )     {         if ( empty($url_ary[4]) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Incomplete_URL'] : $lang['Incomplete_URL'];             return;         }           $base_get = '/' . $url_ary[4];         $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;           if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['No_connection_URL'] : $lang['No_connection_URL'];             return;         }           @fputs($fsock, "GET $base_get HTTP/1.1rn");         @fputs($fsock, "HOST: " . $url_ary[2] . "rn");         @fputs($fsock, "Connection: closernrn");           unset($avatar_data);         while( !@feof($fsock) )         {             // Start replacement - Signatures control MOD             $avatar_data .= @fread($fsock, ( $board_config['sig_max_img_av_files_size'] ) ? $board_config['sig_max_img_av_files_size'] : $board_config['avatar_filesize']);             // End replacement - Signatures control MOD         }         @fclose($fsock);           if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $avatar_data, $file_data1) || !preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $avatar_data, $file_data2))         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['File_no_data'] : $lang['File_no_data'];             return;         }           $avatar_filesize = $file_data1[1];         $avatar_filetype = $file_data2[1];           if ( ($avatar_filesize > 0 && $avatar_filesize < $board_config['avatar_filesize']) || $board_config['sig_max_img_av_files_size'] )         {             $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize);               $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['avatar_path'] . '/tmp';             $tmp_filename = tempnam($tmp_path, uniqid(rand()) . '-');               $fptr = @fopen($tmp_filename, 'wb');             $bytes_written = @fwrite($fptr, $avatar_data, $avatar_filesize);             @fclose($fptr);               if ( $bytes_written != $avatar_filesize )             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Could not write avatar file to local storage. Please contact the board administrator with this message', '', __LINE__, __FILE__);             }               list($width, $height, $type) = @getimagesize($tmp_filename);         }         else         {             $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;         }     }     else if ( ( file_exists(@phpbb_realpath($avatar_filename)) ) && preg_match('/.(jpg|jpeg|gif|png)$/i', $avatar_realname) )     {         if ( $avatar_filesize <board_config> 0) || $board_config['sig_max_img_av_files_size'])         {             preg_match('#image/[x-]*([a-z]+)#', $avatar_filetype, $avatar_filetype);             $avatar_filetype = $avatar_filetype[1];         }         else         {             $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;             return;         }           list($width, $height, $type) = @getimagesize($avatar_filename);     }       if ( !($imgtype = pcp_check_image_type($avatar_filetype, $error, $error_msg)) )     {         return;     }       switch ($type)     {         // GIF         case 1:             if ($imgtype != '.gif')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           // JPG, JPC, JP2, JPX, JB2         case 2:         case 9:         case 10:         case 11:         case 12:             if ($imgtype != '.jpg' && $imgtype != '.jpeg')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           // PNG         case 3:             if ($imgtype != '.png')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           default:             @unlink($tmp_filename);             message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);     }       if ( $width > 0 && $height > 0 && $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )     {         $new_filename = uniqid(rand()) . $imgtype;           if ( $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' )         {             pcp_user_avatar_delete($current_type, $current_avatar);         }           if( $avatar_mode == 'remote' )         {             @copy($tmp_filename, './' . $board_config['avatar_path'] . "/$new_filename");             @unlink($tmp_filename);         }         else         {             if ( @$ini_val('open_basedir') != '' )             {                 if ( @phpversion() < '4.0.3' )                 {                     message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__);                 }                   $move_file = 'move_uploaded_file';             }             else             {                 $move_file = 'copy';             }               $move_file($avatar_filename, './' . $board_config['avatar_path'] . "/$new_filename");         }           @chmod('./' . $board_config['avatar_path'] . "/$new_filename", 0777);           $avatar_sql = " user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD;     }     else     {         $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;     }       return $avatar_sql;}     function create_birthday_date($format, $date, $timezone)     {         global $board_config, $lang;         static $translate;           $birthday = '';         if (intval($date) != 0)         {             // create a date on year 1971             $day = intval(substr($date, 6, 2));             $month = intval(substr($date, 4, 2));             $year = substr($date, 0, 4);             $temp_date = date($format, mktime( 0, 0, 1, $month, $day, 1971));             $birthday = str_replace( '1971', $year, $temp_date );             if ( empty($translate) && $board_config['default_lang'] != 'english' )             {                 @reset($lang['datetime']);                 while ( list($match, $replace) = @each($lang['datetime']) )                 {                     $translate[$match] = $replace;                 }             }             if (!empty($translate))             {                 $birthday = strtr($birthday, $translate);             }         }         return $birthday;     }  function pcp_user_photo_delete($photo_type, $photo_file){     global $board_config, $userdata;       if ( $photo_type == USER_AVATAR_UPLOAD && $photo_file != '' )     {         if ( @file_exists(@phpbb_realpath('./' . $board_config['photo_path'] . '/' . $photo_file)) )         {             @unlink('./' . $board_config['photo_path'] . '/' . $photo_file);         }     }       return " user_photo = '', user_photo_type = " . USER_AVATAR_NONE;}  function pcp_user_photo_gallery(&$error, &$error_msg, $photo_filename){     global $board_config;     if ( file_exists(@phpbb_realpath($board_config['photo_gallery_path'] . '/' . $photo_filename)) )     {         $return = " user_photo = '" . str_replace("'", "''", $photo_filename) . "', user_photo_type = " . USER_AVATAR_GALLERY;     }     else     {         $return = '';     }     return $return;}  function pcp_user_photo_url(&$error, &$error_msg, $photo_filename){     global $board_config, $lang;       if ( !preg_match('#^(http)|(ftp)://#i', $photo_filename) )     {         $photo_filename = 'http://' . $photo_filename;     }       if ( !preg_match('#^((http)|(ftp)://[w-]+?.([w-]+.)+[w]+(:[0-9]+)*/.*?.(gif|jpg|jpeg|png)$)#is', $photo_filename) )     {         $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Wrong_remote_photo_format'] : $lang['Wrong_remote_photo_format'];         return;     }     list($width, $height) = @getimagesize($photo_filename);         if ( ($width > $board_config['photo_max_width']) || ($height > $board_config['photo_max_height']) )     {         $l_photo_size = sprintf($lang['Photo_imagesize'], $board_config['photo_max_width'], $board_config['photo_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;         return;     }     return " user_photo = '" . str_replace("'", "''", $photo_filename) . "', user_photo_type = " . USER_AVATAR_REMOTE;  }  function pcp_user_photo_upload($photo_mode, &$current_photo, &$current_type, &$error, &$error_msg, $photo_filename, $photo_realname, $photo_filesize, $photo_filetype){     global $board_config, $db, $lang;       $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';       if ( $photo_mode == 'remote' && preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $photo_filename, $url_ary) )     {         if ( empty($url_ary[4]) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Incomplete_URL'] : $lang['Incomplete_URL'];             return;         }           $base_get = '/' . $url_ary[4];         $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;           if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['No_connection_URL'] : $lang['No_connection_URL'];             return;         }           @fputs($fsock, "GET $base_get HTTP/1.1rn");         @fputs($fsock, "HOST: " . $url_ary[2] . "rn");         @fputs($fsock, "Connection: closernrn");           unset($photo_data);         while( !@feof($fsock) )         {             $photo_data .= @fread($fsock, $board_config['photo_filesize']);         }         @fclose($fsock);           if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $photo_data, $file_data1) || !preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $photo_data, $file_data2))         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['File_no_data'] : $lang['File_no_data'];             return;         }           $photo_filesize = $file_data1[1];         $photo_filetype = $file_data2[1];           if ( !$error && $photo_filesize > 0 && $photo_filesize < $board_config['photo_filesize'] )         {             $photo_data = substr($photo_data, strlen($photo_data) - $photo_filesize, $photo_filesize);               $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['photo_path'] . '/tmp';             $tmp_filename = tempnam($tmp_path, uniqid(rand()) . '-');               $fptr = @fopen($tmp_filename, 'wb');             $bytes_written = @fwrite($fptr, $photo_data, $photo_filesize);             @fclose($fptr);               if ( $bytes_written != $photo_filesize )             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Could not write photo file to local storage. Please contact the board administrator with this message', '', __LINE__, __FILE__);             }               list($width, $height) = @getimagesize($tmp_filename);         }         else         {             $l_photo_size = sprintf($lang['Photo_filesize'], round($board_config['photo_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;         }     }     else if ( ( file_exists(@phpbb_realpath($photo_filename)) ) && preg_match('/.(jpg|jpeg|gif|png)$/i', $photo_realname) )     {         if ( $photo_filesize <board_config> 0 )         {             preg_match('#image/[x-]*([a-z]+)#', $photo_filetype, $photo_filetype);             $photo_filetype = $photo_filetype[1];         }         else         {             $l_photo_size = sprintf($lang['Photo_filesize'], round($board_config['photo_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;             return;         }           list($width, $height) = @getimagesize($photo_filename);     }       if ( !($imgtype = pcp_check_image_type($photo_filetype, $error, $error_msg)) )     {         return;     }       if ( $width > 0 && $height > 0 )     {         $new_filename = uniqid(rand()) . $imgtype;           if ( $current_type == USER_AVATAR_UPLOAD && $current_photo != '' )         {             if ( file_exists(@phpbb_realpath('./' . $board_config['photo_path'] . '/' . $current_photo)) )             {                 @unlink('./' . $board_config['photo_path'] . '/' . $current_photo);             }         }           if( $photo_mode == 'remote' )         {             @copy($tmp_filename, './' . $board_config['photo_path'] . "/$new_filename");             @unlink($tmp_filename);         }         else         {             if ( @$ini_val('open_basedir') != '' )             {                 if ( @phpversion() < '4.0.3' )                 {                     message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__);                 }                   $move_file = 'move_uploaded_file';             }             else             {                 $move_file = 'copy';             }               $move_file($photo_filename, './' . $board_config['photo_path'] . "/$new_filename");         }           @chmod('./' . $board_config['photo_path'] . "/$new_filename", 0777);           if ($width > $board_config['photo_max_width'] || $height > $board_config['photo_max_height'])         {             $width_old = $width;             $height_old = $height;             if ($width > $board_config['photo_max_width'])             {                 $height = ($board_config['photo_max_width'] / $width) * $height;                 $width = $board_config['photo_max_width'];             }             if ($height > $board_config['photo_max_height'])             {                 $width = ($board_config['photo_max_height'] / $height) * $width;                 $height = $board_config['photo_max_height'];             }             $width = round ($width);   // to avoid float->integer conversion problems             $height = round ($height); // to avoid float->integer conversion problems             switch ($imgtype)             {                 case '.jpg':                     $imagecreatefrom_function = imagecreatefromjpeg;                     $image_function = imagejpeg;                     break;                 case '.gif':                     $imagecreatefrom_function = imagecreatefromgif;                     $image_function = imagegif;                     break;                 case '.png':                     $imagecreatefrom_function = imagecreatefrompng;                     $image_function = imagepng;                     break;             }             $img_old = $imagecreatefrom_function ('./' . $board_config['photo_path'] . "/$new_filename");             $img_new = imagecreatetruecolor ($width, $height);             imagecopyresampled ($img_new, $img_old, 0, 0, 0, 0, $width, $height, $width_old, $height_old);             $image_function ($img_new, './' . $board_config['photo_path'] . "/$new_filename");             imagedestroy ($img_new);         }         $photo_sql = " user_photo = '$new_filename', user_photo_type = " . USER_AVATAR_UPLOAD;     }     else     {         $l_photo_size = sprintf($lang['Photo_imagesize'], $board_config['photo_max_width'], $board_config['photo_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;     }       return $photo_sql;}       //-------------------------------------------     //     //   fields definitions     //     //-------------------------------------------     if ( !defined('DEF_INCLUSION_DONE') )     {         $dir = @opendir($phpbb_root_path . './profilcp/def');         while( $file = @readdir($dir) )         {             if( preg_match("/^def_.*?." . $phpEx . "$/", $file) )             {                 include_once($phpbb_root_path . './profilcp/def/' . $file);             }         }         @closedir($dir);         define('DEF_INCLUSION_DONE', true);     }       //-------------------------------------------     //     //   menu service function     //     //-------------------------------------------     function pcp_set_menu($mode, $sort='', $url='', $shortcut='', $page_title='')     {         global $lang;         global $module;         global $user_maps;           // get the menu idx         $idx = count($module['mode']);         $new = false;         $found = false;         for ( $i = 0; $i < count($module['mode']); $i++ )         {             $found = ( $module['mode'][$i] == $mode );             if ( $found )             {                 $idx = $i;                 break;             }         }           // init         if ( !$found )         {             $module['sort'][$idx]             = '';             $module['url'][$idx]             = '';             $module['shortcut'][$idx]         = '';             $module['page_title'][$idx]       = '';             $module['sub'][$idx]             = array();         }           // add it         $module['mode'][$idx]             = $mode;         $module['sort'][$idx]             = empty($module['sort'][$idx]) ? $sort : $module['sort'][$idx];         $module['url'][$idx]             = empty($module['url'][$idx]) ? basename($url) : $module['url'][$idx];         $module['shortcut'][$idx]         = empty($module['shortcut'][$idx]) ? $lang[$shortcut] : $module['shortcut'][$idx];         $module['page_title'][$idx]       = empty($module['page_title'][$idx]) ? $lang[$page_title] : $module['page_title'][$idx];           if ( isset($user_maps['PCP.' . $mode]) )         {             $module['sort'][$idx] = $user_maps['PCP.' . $mode]['order'];         }           return $idx;     }       function pcp_set_sub_menu($mode, $sub_mode, $sub_sort='', $sub_url='', $sub_shortcut='', $sub_page_title='' )     {         global $lang;         global $module;         global $user_maps;           // ensure the main menu exists         $idx = pcp_set_menu($mode);           // check if the sub_menu exists         $sub_idx = count($module['sub'][$idx]['mode']);         $found = false;         for ( $i = 0; $i </b>

$admin_level = array(ADMIN_FOUNDER, ADMIN, JADMIN);
it must be the order so that
ADMIN_FOUNDER = user_level 1
ADMIN = user_level 2
JADMIN = user_level 3

Seems that I can add another one to that, so I will try it.

I don't however understand the second line
$level_prior = array(ADMIN_FOUNDER => 99, ADMIN => 9, JADMIN => 7, MOD => 5, USER => 0);
What does level_prior mean?
I know it means that the level used to be those numbers, but I don't know if I have to add anything to that line if I add anything to the first line.
Also, I am not sure how to add to the rest of the code to add the new user_level to the board functions.
I am going to guess for now.

Re: Please help me make a NEW user_level and add it to group

PostPosted: Thu Jul 12, 2007 3:06 pm
Author: .QUACK.Major.Pain
I think that when an admin changes a users status, be admin, junior admin, moderator, the user is assigned a corresponding value (a sort of rank #).

I think the secound line works like

if ADMIN_FOUNDER => 99 - means if users assigned value is equal to or less than 99, he could be admin founder
or, if ADMIN => 9 - if value => 99 and => 9 he could be admin
or, if JADMIN =>7 - if value =>99 and => 9 and =>7 he could be junior admin
or, ETC

EG: if USER value = 6 - he would fall into Jadmin - value =>7 but not =>5

Just my interpretation, but I could be way off. LOL
I find trying to decifer some of this can be a little retarded.

I think what your trying might be a little difficult, but could be done.

Re: Please help me make a NEW user_level and add it to group

PostPosted: Fri Jul 13, 2007 9:15 am
Author: cutegothpirate
Nope, still don't get it. I have figured out all the other files to add to, except for this one file. Very confused.
is it really equal to or less than? It seems like it would be.
So then because I already know that all USERs are level 0
And all GUESTS are level -1
And it gets the info of REGISTERED USERS if they are registered or not.
I know that MODs are level 2
And that JAdmins are determined by what you set their access to within their user profile. So i guess I need to make one to see what level they become.
And I know that the Board founder is set to a user_id. So it really didn't need that number except to have one set in the code so the code could use
@arsort($level_prior);
@reset($level_prior);
while ( list($key, $value) = @each($level_prior) )
later.
So since there are so many $level_prior between admin_founder and admin, does this mean that those are the ones I should use for any other user_level that I want to add?
Like say I wanted to add a VIP to that list, I could just grab a number and use it?
VIP => 80, NEWLEVEL => 70 ANOTHER => 60...etc Like that? does it really matter? Have these values already been defined by another file?

Re: Please help me make a NEW user_level and add it to group

PostPosted: Fri Jul 13, 2007 12:26 pm
Author: .QUACK.Major.Pain
You could do that, but remember that a user value greater than 9 would allow admin status I would think.

I think I'd want to figure out how to set admin at say 80, junior admin at 70, moderator at 60 and other levels below moderator lower that 60. If you wanted a senior admin, you could use 85.

Re: Please help me make a NEW user_level and add it to group

PostPosted: Mon Jul 16, 2007 7:13 am
Author: cutegothpirate
Ok, I found the files I needed to modify. Or at least it looks like I did.
For what I want, I have to add to some of the language files where the legend shows up, like [administrators] [moderators] stuff like that. Thats the easy part.
problem I am running into now is that my else ifs are wrong in functions_profile.php
The regular users keep stealing my color!!
Larry is coming out correct, same as the administrator.
I have narrowed it down to just this file as being the problem by switching back and forth with an unchanged file. Also I have changed MY color to be Larry's color, and ALL the users by administrator changes to Larry's color. The only thing I can think of are the else ifs being wrong.
Also, I don't know how to grab the info I want from the database to make the other people show up right.
I DO have those auth access fields in there, and they are selected as one for those groups. like auth_wk is 1 for the wkadmin group. I set it in the database by hand. I still don't know if that would even work.
If you have a better idea of what info I should tell it to get, and how to tell it to get it, that would be awesome too!
Could you look at this and help me please?? Thanks!
Code: Select all
 <php> 99, CUTE => 90, LARRY => 80, ADMIN => 70, SUPER => 60, MOD => 50, WKADMIN => 20, FRIENDS => 10, USER => 0);     $level_desc = array(ADMIN_FOUNDER => 'Admin_founder_online_color', CUTE => 'Cute_online_color', LARRY => 'Larry_online_color', ADMIN => 'Admin_online_color', SUPER => 'Super_online_color', MOD => 'Mod_online_color', WKADMIN => 'Wkadmin_online_color', FRIENDS => 'Friend_online_color', USER => 'User_online_color');       function get_user_level($userdata)     {         // fix a phpBB bug         global $db, $portal_config, $var_cache;         if ($userdata['user_level'] == MOD)         {             $num_rows = FALSE;             if($portal_config['cache_enabled'])             {                 $num_rows = $var_cache->get('mod' . strval($userdata['user_id']), 200000, 'mod');             }             if($num_rows === FALSE)             {                 $sql = "SELECT * FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug                         WHERE ug.user_id = " . $userdata['user_id'] . "                             AND aa.group_id = ug.group_id                             AND aa.auth_mod = 1                             AND ug.user_pending = 0";                 if ( !$result = $db->sql_query($sql) )                 {                     message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);                 }                 $num_rows = $db->sql_numrows($result);                 if($portal_config['cache_enabled'])                 {                     $var_cache->save($num_rows, 'mod' . strval($userdata['user_id']), 'mod');                 }             }             if ($num_rows <0>get('wkadmin' . strval($userdata['user_id']), 200000, 'wkadmin');             }             if($num_rows === FALSE)             {                 $sql = "SELECT * FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug                         WHERE ug.user_id = " . $userdata['user_id'] . "                             AND aa.group_id = ug.group_id                             AND aa.auth_wk = 1                             AND ug.user_pending = 0";                 if ( !$result = $db->sql_query($sql) )                 {                     message_die(GENERAL_ERROR, 'Could not obtain wk admin status', '', __LINE__, __FILE__, $sql);                 }                 $num_rows = $db->sql_numrows($result);                 if($portal_config['cache_enabled'])                 {                     $var_cache->save($num_rows, 'wkadmin' . strval($userdata['user_id']), 'wkadmin');                 }             }             if ($num_rows <0>get('super' . strval($userdata['user_id']), 200000, 'super');             }             if($num_rows === FALSE)             {                 $sql = "SELECT * FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug                         WHERE ug.user_id = " . $userdata['user_id'] . "                             AND aa.group_id = ug.group_id                             AND aa.auth_sa = 1                             AND ug.user_pending = 0";                 if ( !$result = $db->sql_query($sql) )                 {                     message_die(GENERAL_ERROR, 'Could not obtain SA status', '', __LINE__, __FILE__, $sql);                 }                 $num_rows = $db->sql_numrows($result);                 if($portal_config['cache_enabled'])                 {                     $var_cache->save($num_rows, 'super' . strval($userdata['user_id']), 'super');                 }             }             if ($num_rows <0>get('friend' . strval($userdata['user_id']), 200000, 'friend');             }             if($num_rows === FALSE)             {                 $sql = "SELECT * FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug                         WHERE ug.user_id = " . $userdata['user_id'] . "                             AND aa.group_id = 96                             AND aa.auth_fr = 1                             AND ug.user_pending = 0";                 if ( !$result = $db->sql_query($sql) )                 {                     message_die(GENERAL_ERROR, 'Could not obtain friend status', '', __LINE__, __FILE__, $sql);                 }                 $num_rows = $db->sql_numrows($result);                 if($portal_config['cache_enabled'])                 {                     $var_cache->save($num_rows, 'friend' . strval($userdata['user_id']), 'friend');                 }             }             if ($num_rows </span>sql_query($sql) )         {             message_die(GENERAL_ERROR, 'Could not obtain ranks information.', '', __LINE__, __FILE__, $sql);         }         while ( $row = $db->sql_fetchrow($result) )         {             $ranks[] = $row;         }         $db->sql_freeresult($result);           $rank_maxi = 99999999;         for ($i=count($ranks)-1; $i >= 0; $i--)         {             if ( $row['rank_special'] ) $row['rank_mini'] = 0;             $row['rank_maxi'] = $rank_maxi;             if (!$row['rank_special'] )             {                 $rank_maxi = $row['rank_mini'];             }             else $rank_maxi = 99999999;         }     }       $all_ranks = array();     init_ranks($all_ranks);       function get_user_rank($userrow)     {         global $all_ranks;           if(empty($all_ranks)){             $all_ranks = array();             init_ranks($all_ranks);         }           $rank_title = '';         $rank_image = '';         if ($userrow['user_id'] != ANONYMOUS)         {             if ( $userrow['user_rank'] )             {                 $found = false;                 for ($i = 0; ( ($i < count($all_ranks)) && !$found); $i++)                 {                     $found = ( ($userrow['user_rank'] == $all_ranks[$i]['rank_id']) && $all_ranks[$i]['rank_special']);                     if ($found)                     {                         $ranks = explode( "|", $all_ranks[$i]['rank_title']);                         $rank_title = ( isset($ranks[$userrow['user_gender']]) && ($ranks[$userrow['user_gender']] != '') ) ? $ranks[$userrow['user_gender']] : $ranks[0];                         $rank_image = ( $all_ranks[$i]['rank_image'] ) ? '<img>' : '';                     }                 }             }             else             {                 for($i = 0; $i <count>= $all_ranks[$i]['rank_min'] && !$all_ranks[$i]['rank_special'] )                     {                         $ranks = explode( "|", $all_ranks[$i]['rank_title']);                         $rank_title = ( isset($ranks[$userrow['user_gender']]) && ($ranks[$userrow['user_gender']] != '') ) ? $ranks[$userrow['user_gender']] : $ranks[0];                         $rank_image = ( $all_ranks[$i]['rank_image'] ) ? '<img>' : '';                     }                 }             }         }           // result         $res = array();         $res['rank_title'] = $rank_title;         $res['rank_image'] = $rank_image;         return $res;     }       //-------------------------------------------     //     //   others functions     //     //-------------------------------------------     function pcp_gen_rand_string($hash)     {       $rand_str = dss_rand();       return ( $hash ) ? md5($rand_str) : substr($rand_str, 0, 8);     }       function prepare_signature( $signature, $view_userdata )     {         global $board_config, $lang;           $preview_sig = ($signature != '') ? $signature : '';         $user_sig_bbcode_uid = $view_userdata['user_sig_bbcode_uid'];           // delete html tags         if ( $preview_sig != '' && $view_userdata['user_allowhtml'] && !$board_config['allow_html'] )         {             $preview_sig = preg_replace('#(<41>)#is', "&lt;\2&gt;", $preview_sig);         }           // parse bbcodes         if ( $preview_sig != '' && $user_sig_bbcode_uid != '' && $board_config['allow_bbcode'])         {             $preview_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($preview_sig, $user_sig_bbcode_uid) : preg_replace('/:[0-9a-z:]+]/si', ']', $preview_sig);         }           // add links         if ( $preview_sig != '' ) $preview_sig = make_clickable($preview_sig);           // parse smilies         if ( $preview_sig != '' && $view_userdata['user_allowsmile'] && $board_config['allow_smilies'] )         {             $preview_sig = smilies_pass($preview_sig);         }           // formate n         if ( $preview_sig != '' ) $preview_sig = str_replace("n", "n<br>n", $preview_sig);           return $preview_sig;     }       function pcp_check_image_type(&$type, &$error, &$error_msg)     {         global $lang;           switch( $type )         {             case 'jpeg':             case 'pjpeg':             case 'jpg':                 return '.jpg';                 break;             case 'gif':                 return '.gif';                 break;             case 'png':                 return '.png';                 break;             default:                 $error = true;                 $error_msg = (!empty($error_msg)) ? $error_msg . '<br>' . $lang['Avatar_filetype'] : $lang['Avatar_filetype'];                 break;         }           return false;     }       function pcp_user_avatar_delete($avatar_type, $avatar_file)     {         global $board_config, $userdata;           if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' )         {             if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $avatar_file)) )             {                 @unlink('./' . $board_config['avatar_path'] . '/' . $avatar_file);             }         }           return " user_avatar = '', user_avatar_type = " . USER_AVATAR_NONE;     }       function pcp_user_avatar_gallery(&$error, &$error_msg, $avatar_filename, $avatar_category)     {         global $board_config;           if(!preg_match('/(.gif$|.png$|.jpg|.jpeg)$/is', $avatar_filename))         {             return '';         }           if ( file_exists(@phpbb_realpath($board_config['avatar_gallery_path'] . '/' . $avatar_category . '/' . $avatar_filename)) )         {             $return = " user_avatar = '" . str_replace("'", "''", $avatar_category . '/' . $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;         }         else         {             $return = '';         }         return $return;     }       function pcp_user_avatar_url(&$error, &$error_msg, $avatar_filename)     {         global $lang;           $width = $height = 0;           if ( !preg_match('#^(http)|(ftp)://#i', $avatar_filename) )         {             $avatar_filename = 'http://' . $avatar_filename;         }           if ( !preg_match("#^((ht|f)tp://)([^ ?&=#"nrt<]*?(.(jpg|jpeg|gif|png))$)#is", $avatar_filename) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];             return;         }         list($width, $height, $type) = @getimagesize($tmp_filename);         if ( ($width > $board_config['avatar_max_width']) || ($height > $board_config['avatar_max_height']) )       {          $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);            $error = true;          $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;          return;       }         return " user_avatar = '" . str_replace("'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE;      }  function pcp_user_avatar_upload($avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype){     global $board_config, $db, $lang;       $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';       $width = $height = 0;     $type = '';       if ( $avatar_mode == 'remote' && preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $avatar_filename, $url_ary) )     {         if ( empty($url_ary[4]) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Incomplete_URL'] : $lang['Incomplete_URL'];             return;         }           $base_get = '/' . $url_ary[4];         $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;           if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['No_connection_URL'] : $lang['No_connection_URL'];             return;         }           @fputs($fsock, "GET $base_get HTTP/1.1rn");         @fputs($fsock, "HOST: " . $url_ary[2] . "rn");         @fputs($fsock, "Connection: closernrn");           unset($avatar_data);         while( !@feof($fsock) )         {             // Start replacement - Signatures control MOD             $avatar_data .= @fread($fsock, ( $board_config['sig_max_img_av_files_size'] ) ? $board_config['sig_max_img_av_files_size'] : $board_config['avatar_filesize']);             // End replacement - Signatures control MOD         }         @fclose($fsock);           if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $avatar_data, $file_data1) || !preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $avatar_data, $file_data2))         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['File_no_data'] : $lang['File_no_data'];             return;         }           $avatar_filesize = $file_data1[1];         $avatar_filetype = $file_data2[1];           if ( ($avatar_filesize > 0 && $avatar_filesize < $board_config['avatar_filesize']) || $board_config['sig_max_img_av_files_size'] )         {             $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize);               $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['avatar_path'] . '/tmp';             $tmp_filename = tempnam($tmp_path, uniqid(rand()) . '-');               $fptr = @fopen($tmp_filename, 'wb');             $bytes_written = @fwrite($fptr, $avatar_data, $avatar_filesize);             @fclose($fptr);               if ( $bytes_written != $avatar_filesize )             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Could not write avatar file to local storage. Please contact the board administrator with this message', '', __LINE__, __FILE__);             }               list($width, $height, $type) = @getimagesize($tmp_filename);         }         else         {             $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;         }     }     else if ( ( file_exists(@phpbb_realpath($avatar_filename)) ) && preg_match('/.(jpg|jpeg|gif|png)$/i', $avatar_realname) )     {         if ( $avatar_filesize <board_config> 0) || $board_config['sig_max_img_av_files_size'])         {             preg_match('#image/[x-]*([a-z]+)#', $avatar_filetype, $avatar_filetype);             $avatar_filetype = $avatar_filetype[1];         }         else         {             $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;             return;         }           list($width, $height, $type) = @getimagesize($avatar_filename);     }       if ( !($imgtype = pcp_check_image_type($avatar_filetype, $error, $error_msg)) )     {         return;     }       switch ($type)     {         // GIF         case 1:             if ($imgtype != '.gif')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           // JPG, JPC, JP2, JPX, JB2         case 2:         case 9:         case 10:         case 11:         case 12:             if ($imgtype != '.jpg' && $imgtype != '.jpeg')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           // PNG         case 3:             if ($imgtype != '.png')             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);             }         break;           default:             @unlink($tmp_filename);             message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);     }       if ( $width > 0 && $height > 0 && $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )     {         $new_filename = uniqid(rand()) . $imgtype;           if ( $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' )         {             pcp_user_avatar_delete($current_type, $current_avatar);         }           if( $avatar_mode == 'remote' )         {             @copy($tmp_filename, './' . $board_config['avatar_path'] . "/$new_filename");             @unlink($tmp_filename);         }         else         {             if ( @$ini_val('open_basedir') != '' )             {                 if ( @phpversion() < '4.0.3' )                 {                     message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__);                 }                   $move_file = 'move_uploaded_file';             }             else             {                 $move_file = 'copy';             }               $move_file($avatar_filename, './' . $board_config['avatar_path'] . "/$new_filename");         }           @chmod('./' . $board_config['avatar_path'] . "/$new_filename", 0777);           $avatar_sql = " user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD;     }     else     {         $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_avatar_size : $l_avatar_size;     }       return $avatar_sql;}     function create_birthday_date($format, $date, $timezone)     {         global $board_config, $lang;         static $translate;           $birthday = '';         if (intval($date) != 0)         {             // create a date on year 1971             $day = intval(substr($date, 6, 2));             $month = intval(substr($date, 4, 2));             $year = substr($date, 0, 4);             $temp_date = date($format, mktime( 0, 0, 1, $month, $day, 1971));             $birthday = str_replace( '1971', $year, $temp_date );             if ( empty($translate) && $board_config['default_lang'] != 'english' )             {                 @reset($lang['datetime']);                 while ( list($match, $replace) = @each($lang['datetime']) )                 {                     $translate[$match] = $replace;                 }             }             if (!empty($translate))             {                 $birthday = strtr($birthday, $translate);             }         }         return $birthday;     }  function pcp_user_photo_delete($photo_type, $photo_file){     global $board_config, $userdata;       if ( $photo_type == USER_AVATAR_UPLOAD && $photo_file != '' )     {         if ( @file_exists(@phpbb_realpath('./' . $board_config['photo_path'] . '/' . $photo_file)) )         {             @unlink('./' . $board_config['photo_path'] . '/' . $photo_file);         }     }       return " user_photo = '', user_photo_type = " . USER_AVATAR_NONE;}  function pcp_user_photo_gallery(&$error, &$error_msg, $photo_filename){     global $board_config;     if ( file_exists(@phpbb_realpath($board_config['photo_gallery_path'] . '/' . $photo_filename)) )     {         $return = " user_photo = '" . str_replace("'", "''", $photo_filename) . "', user_photo_type = " . USER_AVATAR_GALLERY;     }     else     {         $return = '';     }     return $return;}  function pcp_user_photo_url(&$error, &$error_msg, $photo_filename){     global $board_config, $lang;       if ( !preg_match('#^(http)|(ftp)://#i', $photo_filename) )     {         $photo_filename = 'http://' . $photo_filename;     }       if ( !preg_match('#^((http)|(ftp)://[w-]+?.([w-]+.)+[w]+(:[0-9]+)*/.*?.(gif|jpg|jpeg|png)$)#is', $photo_filename) )     {         $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Wrong_remote_photo_format'] : $lang['Wrong_remote_photo_format'];         return;     }     list($width, $height) = @getimagesize($photo_filename);         if ( ($width > $board_config['photo_max_width']) || ($height > $board_config['photo_max_height']) )     {         $l_photo_size = sprintf($lang['Photo_imagesize'], $board_config['photo_max_width'], $board_config['photo_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;         return;     }     return " user_photo = '" . str_replace("'", "''", $photo_filename) . "', user_photo_type = " . USER_AVATAR_REMOTE;  }  function pcp_user_photo_upload($photo_mode, &$current_photo, &$current_type, &$error, &$error_msg, $photo_filename, $photo_realname, $photo_filesize, $photo_filetype){     global $board_config, $db, $lang;       $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';       if ( $photo_mode == 'remote' && preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $photo_filename, $url_ary) )     {         if ( empty($url_ary[4]) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['Incomplete_URL'] : $lang['Incomplete_URL'];             return;         }           $base_get = '/' . $url_ary[4];         $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;           if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) )         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['No_connection_URL'] : $lang['No_connection_URL'];             return;         }           @fputs($fsock, "GET $base_get HTTP/1.1rn");         @fputs($fsock, "HOST: " . $url_ary[2] . "rn");         @fputs($fsock, "Connection: closernrn");           unset($photo_data);         while( !@feof($fsock) )         {             $photo_data .= @fread($fsock, $board_config['photo_filesize']);         }         @fclose($fsock);           if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $photo_data, $file_data1) || !preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $photo_data, $file_data2))         {             $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $lang['File_no_data'] : $lang['File_no_data'];             return;         }           $photo_filesize = $file_data1[1];         $photo_filetype = $file_data2[1];           if ( !$error && $photo_filesize > 0 && $photo_filesize < $board_config['photo_filesize'] )         {             $photo_data = substr($photo_data, strlen($photo_data) - $photo_filesize, $photo_filesize);               $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['photo_path'] . '/tmp';             $tmp_filename = tempnam($tmp_path, uniqid(rand()) . '-');               $fptr = @fopen($tmp_filename, 'wb');             $bytes_written = @fwrite($fptr, $photo_data, $photo_filesize);             @fclose($fptr);               if ( $bytes_written != $photo_filesize )             {                 @unlink($tmp_filename);                 message_die(GENERAL_ERROR, 'Could not write photo file to local storage. Please contact the board administrator with this message', '', __LINE__, __FILE__);             }               list($width, $height) = @getimagesize($tmp_filename);         }         else         {             $l_photo_size = sprintf($lang['Photo_filesize'], round($board_config['photo_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;         }     }     else if ( ( file_exists(@phpbb_realpath($photo_filename)) ) && preg_match('/.(jpg|jpeg|gif|png)$/i', $photo_realname) )     {         if ( $photo_filesize <board_config> 0 )         {             preg_match('#image/[x-]*([a-z]+)#', $photo_filetype, $photo_filetype);             $photo_filetype = $photo_filetype[1];         }         else         {             $l_photo_size = sprintf($lang['Photo_filesize'], round($board_config['photo_filesize'] / 1024));               $error = true;             $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;             return;         }           list($width, $height) = @getimagesize($photo_filename);     }       if ( !($imgtype = pcp_check_image_type($photo_filetype, $error, $error_msg)) )     {         return;     }       if ( $width > 0 && $height > 0 )     {         $new_filename = uniqid(rand()) . $imgtype;           if ( $current_type == USER_AVATAR_UPLOAD && $current_photo != '' )         {             if ( file_exists(@phpbb_realpath('./' . $board_config['photo_path'] . '/' . $current_photo)) )             {                 @unlink('./' . $board_config['photo_path'] . '/' . $current_photo);             }         }           if( $photo_mode == 'remote' )         {             @copy($tmp_filename, './' . $board_config['photo_path'] . "/$new_filename");             @unlink($tmp_filename);         }         else         {             if ( @$ini_val('open_basedir') != '' )             {                 if ( @phpversion() < '4.0.3' )                 {                     message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__);                 }                   $move_file = 'move_uploaded_file';             }             else             {                 $move_file = 'copy';             }               $move_file($photo_filename, './' . $board_config['photo_path'] . "/$new_filename");         }           @chmod('./' . $board_config['photo_path'] . "/$new_filename", 0777);           if ($width > $board_config['photo_max_width'] || $height > $board_config['photo_max_height'])         {             $width_old = $width;             $height_old = $height;             if ($width > $board_config['photo_max_width'])             {                 $height = ($board_config['photo_max_width'] / $width) * $height;                 $width = $board_config['photo_max_width'];             }             if ($height > $board_config['photo_max_height'])             {                 $width = ($board_config['photo_max_height'] / $height) * $width;                 $height = $board_config['photo_max_height'];             }             $width = round ($width);   // to avoid float->integer conversion problems             $height = round ($height); // to avoid float->integer conversion problems             switch ($imgtype)             {                 case '.jpg':                     $imagecreatefrom_function = imagecreatefromjpeg;                     $image_function = imagejpeg;                     break;                 case '.gif':                     $imagecreatefrom_function = imagecreatefromgif;                     $image_function = imagegif;                     break;                 case '.png':                     $imagecreatefrom_function = imagecreatefrompng;                     $image_function = imagepng;                     break;             }             $img_old = $imagecreatefrom_function ('./' . $board_config['photo_path'] . "/$new_filename");             $img_new = imagecreatetruecolor ($width, $height);             imagecopyresampled ($img_new, $img_old, 0, 0, 0, 0, $width, $height, $width_old, $height_old);             $image_function ($img_new, './' . $board_config['photo_path'] . "/$new_filename");             imagedestroy ($img_new);         }         $photo_sql = " user_photo = '$new_filename', user_photo_type = " . USER_AVATAR_UPLOAD;     }     else     {         $l_photo_size = sprintf($lang['Photo_imagesize'], $board_config['photo_max_width'], $board_config['photo_max_height']);           $error = true;         $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br>' . $l_photo_size : $l_photo_size;     }       return $photo_sql;}       //-------------------------------------------     //     //   fields definitions     //     //-------------------------------------------     if ( !defined('DEF_INCLUSION_DONE') )     {         $dir = @opendir($phpbb_root_path . './profilcp/def');         while( $file = @readdir($dir) )         {             if( preg_match("/^def_.*?." . $phpEx . "$/", $file) )             {                 include_once($phpbb_root_path . './profilcp/def/' . $file);             }         }         @closedir($dir);         define('DEF_INCLUSION_DONE', true);     }       //-------------------------------------------     //     //   menu service function     //     //-------------------------------------------     function pcp_set_menu($mode, $sort='', $url='', $shortcut='', $page_title='')     {         global $lang;         global $module;         global $user_maps;           // get the menu idx         $idx = count($module['mode']);         $new = false;         $found = false;         for ( $i = 0; $i < count($module['mode']); $i++ )         {             $found = ( $module['mode'][$i] == $mode );             if ( $found )             {                 $idx = $i;                 break;             }         }           // init         if ( !$found )         {             $module['sort'][$idx]             = '';             $module['url'][$idx]             = '';             $module['shortcut'][$idx]         = '';             $module['page_title'][$idx]       = '';             $module['sub'][$idx]             = array();         }           // add it         $module['mode'][$idx]             = $mode;         $module['sort'][$idx]             = empty($module['sort'][$idx]) ? $sort : $module['sort'][$idx];         $module['url'][$idx]             = empty($module['url'][$idx]) ? basename($url) : $module['url'][$idx];         $module['shortcut'][$idx]         = empty($module['shortcut'][$idx]) ? $lang[$shortcut] : $module['shortcut'][$idx];         $module['page_title'][$idx]       = empty($module['page_title'][$idx]) ? $lang[$page_title] : $module['page_title'][$idx];           if ( isset($user_maps['PCP.' . $mode]) )         {             $module['sort'][$idx] = $user_maps['PCP.' . $mode]['order'];         }           return $idx;     }       function pcp_set_sub_menu($mode, $sub_mode, $sub_sort='', $sub_url='', $sub_shortcut='', $sub_page_title='' )     {         global $lang;         global $module;         global $user_maps;           // ensure the main menu exists         $idx = pcp_set_menu($mode);           // check if the sub_menu exists         $sub_idx = count($module['sub'][$idx]['mode']);         $found = false;         for ( $i = 0; $i </b>