Exemple #1
0
 /**
  * Feturn HTML block
  *
  * @param	array		Member information
  * @return	string		HTML block
  */
 public function return_html_block($member = array())
 {
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!is_array($member) or !count($member)) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show');
     }
     $friends = array();
     //-----------------------------------------
     // Grab the friends
     //-----------------------------------------
     /* How many friends do we have? */
     $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1'));
     /* Sort out pagination */
     $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
     $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => self::FRIENDS_PER_PAGE, 'currentStartValue' => $st, 'baseUrl' => "showuser={$member['member_id']}&tab=friends", 'seoTemplate' => 'showuser', 'seoTitle' => $member['members_seo_name']));
     /* Get em! */
     $queryData = array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => 'f.friends_member_id=' . $member['member_id'] . ' AND f.friends_approved=1 AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')', 'add_join' => array(1 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=f.friends_friend_id', 'type' => 'left'), 2 => array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id', 'type' => 'left')));
     // Ordering is bad because it causes a filesort, but if they have more than 100 members, we're going to have
     // to order so we can paginate
     if ($count['dracula'] > self::FRIENDS_PER_PAGE) {
         $queryData['order'] = 'm.members_display_name';
         $queryData['limit'] = array($st, self::FRIENDS_PER_PAGE);
     }
     $this->DB->build($queryData);
     $outer = $this->DB->execute();
     //-----------------------------------------
     // Get and store...
     //-----------------------------------------
     while ($row = $this->DB->fetch($outer)) {
         if ($row['member_id']) {
             $friends[IPSText::mbstrtolower($row['members_display_name'])] = IPSMember::buildDisplayData($row, 0);
         }
     }
     ksort($friends);
     $content = $this->registry->getClass('output')->getTemplate('profile')->tabFriends($friends, $member, $pagination);
     //-----------------------------------------
     // Macros...
     //-----------------------------------------
     $content = $this->registry->output->replaceMacros($content);
     //-----------------------------------------
     // Return content..
     //-----------------------------------------
     return $content ? $content : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show');
 }
Exemple #2
0
 /**
  * Display the list of apps (board, gallery, etc)
  *
  * @access	private
  * @return	void
  */
 private function show_apps()
 {
     foreach (ipsRegistry::$applications as $app_dir => $application) {
         if ($app_dir == 'core') {
             $app_dir = 'board';
         }
         if (isset(_interface::$software[$app_dir])) {
             _interface::$software[$app_dir]['enabled'] = true;
             _interface::$software[$app_dir]['software'] = array();
             // Get options
             foreach (glob(IPSLib::getAppDir('convert') . '/modules_admin/' . $app_dir . '/*.php') as $file) {
                 require_once $file;
                 _interface::$software[$app_dir]['software'][$info['key']] = $info['name'];
             }
         } else {
             if ($application['app_location'] == 'other' && is_dir(IPSLib::getAppDir('convert') . '/modules_admin/' . $application['app_directory']) or $application['app_location'] == 'other' && is_dir(IPSLib::getAppDir(IPSText::mbstrtolower($application['app_title'])) . '/extensions/convert/' . $application['app_directory'])) {
                 _interface::$software[$app_dir] = array('title' => $application['app_title'], 'enabled' => true, 'third_party' => true);
             }
         }
     }
     $this->registry->output->html .= $this->html->convertShowSoftware(_interface::$software);
 }
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => 'p.*', 'from' => array('picture' => 'p'), 'add_join' => array(array('select' => 'l.*', 'from' => array('albumpicture' => 'l'), 'where' => "p.pictureid=l.pictureid", 'type' => 'left')), 'order' => 'p.pictureid ASC');
     $loop = $this->lib->load('gallery_images', $main);
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where gallery images are saved (no trailing slash - if using database storage, enter "."):')), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         // Have a stab at the mimetype
         $ext = IPSText::mbstrtolower($row['extension']);
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         // What's the mimetype?
         //$type = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments_type', 'where' => "atype_extension='{$row['extension']}'" ) );
         $save = array('image_member_id' => $row['userid'], 'image_album_id' => $row['albumid'] ? $row['albumid'] : $us['orphans'], 'image_directory' => floor($row['pictureid'] / 1000), 'image_caption' => $row['caption'], 'image_file_name' => $row['pictureid'] . '.' . $row['extension'], 'image_file_size' => $row['filesize'], 'image_file_type' => $mime, 'image_approved' => $row['state'] == 'visible' ? 1 : 0, 'image_date' => $row['dateline'], 'image_caption_seo' => IPSText::makeSeoTitle($row['caption']), 'image_feature_flag' => $us['feature_all']);
         //-----------------------------------------
         // Database
         //-----------------------------------------
         if ($row['filedata']) {
             $save['data'] = $row['filedata'];
             $this->lib->convertImage($row['pictureid'], $save, '', true);
         } else {
             if ($path == '.') {
                 $this->lib->error('You entered "." for the path but you have some attachments in the file system');
             }
             $save['masked_file_name'] = floor($row['pictureid'] / 1000);
             //*sigh* More weird stuff.
             $save['masked_file_name'] .= '/' . $row['pictureid'] . '.picture';
             $this->lib->convertImage($row['pictureid'], $save, $us['gallery_path'], false);
         }
     }
     $this->lib->next();
 }
Exemple #4
0
 /**
  * Convert members
  *
  * @access	private
  * @return void
  **/
 private function convert_members()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $pcpf = array('icqIM' => 'ICQ Number', 'aolIM' => 'AIM ID', 'yahooIM' => 'Yahoo ID', 'msnIM' => 'MSN ID', 'webAddress' => 'Website', 'occupation' => 'Occupation', 'interests' => 'Interests', 'webGallery' => 'Web Gallery', 'webLog' => 'Web Blog');
     $this->lib->saveMoreInfo('members', array_keys($pcpf));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => 'u.UserID, u.LastActivity, CAST(u.MembershipID AS CHAR(36)) as MembershipID', 'from' => array('cs_users' => 'u'), 'add_join' => array(array('select' => 'm.Email,m.CreateDate,m.LastLoginDate, m.Password, m.PasswordSalt', 'from' => array('aspnet_Membership' => 'm'), 'where' => 'u.MembershipID = m.UserId', 'type' => 'left'), array('select' => 'CAST(ap.PropertyNames AS text) as PropertyNames, CAST(ap.PropertyValuesString AS text) as PropertyValuesString', 'from' => array('aspnet_Profile' => 'ap'), 'where' => 'u.MembershipID = ap.UserId', 'type' => 'left'), array('select' => 'CAST(a.UserName AS varchar) as UserName', 'from' => array('aspnet_Users' => 'a'), 'where' => 'u.MembershipID = a.UserId', 'type' => 'left'), array('select' => 'p.TotalPosts, p.TimeZone', 'from' => array('cs_UserProfile' => 'p'), 'where' => 'u.UserID = p.UserID', 'type' => 'left')), 'order' => 'u.UserID ASC');
     $loop = $this->lib->load('members', $main);
     //-----------------------------------------
     // Tell me what you know!
     //-----------------------------------------
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $ask = array();
     // And those custom profile fields
     $options = array('x' => '-Skip-');
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $options[$row['pf_id']] = $row['pf_title'];
     }
     foreach ($pcpf as $id => $name) {
         $ask[$id] = array('type' => 'dropdown', 'label' => 'Custom profile field to store ' . $name . ': ', 'options' => $options, 'extra' => $extra);
     }
     $this->lib->getMoreInfo('members', $loop, $ask, 'path');
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         $propertyNamesArray = explode(':', $row['PropertyNames']);
         // Ditch extra empty cell
         array_pop($propertyNamesArray);
         for ($i = 0; $i < count($propertyNamesArray) - 1; $i += 4) {
             $row[$propertyNamesArray[$i]] = substr($row['PropertyValuesString'], $propertyNamesArray[$i + 2], $propertyNamesArray[$i + 3]);
         }
         unset($propertyNamesArray);
         ipsRegistry::DB('hb')->build(array('select' => 'RoleId', 'from' => 'aspnet_UsersInRoles', 'where' => "UserId='{$row['MembershipID']}'"));
         $groupRes = ipsRegistry::DB('hb')->execute();
         $groups = array();
         while ($group = ipsRegistry::DB('hb')->fetch($groupRes)) {
             $groups[] = $group['RoleId'];
         }
         $primaryGroup = count($groups) > 0 ? array_shift($groups) : null;
         //-----------------------------------------
         // Set info
         //-----------------------------------------
         // Basic info
         $info = array('id' => $row['UserID'], 'group' => $primaryGroup, 'secondary_groups' => implode(', ', $groups), 'joined' => $this->lib->myStrToTime($row['CreateDate']), 'username' => $row['UserName'], 'email' => $row['Email'], 'password' => $row['Password']);
         // Member info
         preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/", $time, $birthday);
         $members = array('ip_address' => '127.0.0.1', 'posts' => $row['TotalPosts'], 'allow_admin_mails' => 1, 'time_offset' => intval($row['TimeZone']), 'bday_day' => $birthday && $birthday[1] != '0001' ? $birthday[3] : '', 'bday_month' => $birthday && $birthday[1] != '0001' ? $birthday[2] : '', 'bday_year' => $birthday && $birthday[1] != '0001' ? $birthday[1] : '', 'hide_email' => 1, 'email_pm' => 0, 'view_sigs' => 1, 'view_avs' => 1, 'msg_show_notification' => 1, 'last_visit' => $this->lib->myStrToTime($row['LastLoginDate']), 'last_activity' => $this->lib->myStrToTime($row['LastLoginDate']), 'dst_in_use' => 0, 'coppa_user' => 0, 'misc' => $row['PasswordSalt']);
         // Profile
         $profile = array('signature' => $this->fixPostData($row['signature']));
         //-----------------------------------------
         // Avatars and profile pictures
         //-----------------------------------------
         $avatar = ipsRegistry::DB('hb')->buildAndFetch(array('select' => 'Length, ContentType, Content', 'from' => 'cs_UserAvatar', 'where' => "UserId='{$row['UserID']}'"));
         if ($avatar != '') {
             $profile['photo_type'] = 'custom';
             $profile['photo_location'] = str_replace('/', '.', IPSText::mbstrtolower($avatar['ContentType']));
             $profile['photo_data'] = $avatar['Content'];
             $profile['photo_filesize'] = $avatar['Length'];
         }
         //-----------------------------------------
         // Custom Profile fields
         //-----------------------------------------
         // Pseudo
         foreach ($pcpf as $id => $name) {
             if ($us[$id] != 'x') {
                 $custom['field_' . $us[$id]] = $row['PropertyNames'][$id];
             }
         }
         //-----------------------------------------
         // And go!
         //-----------------------------------------
         $this->lib->convertMember($info, $members, $profile, array());
     }
     $this->lib->next();
 }
Exemple #5
0
 /**
  * Convert a Database
  *
  * @access	public
  * @param 	integer		Foreign ID number
  * @param 	array 		Data to insert to table
  * @return 	boolean		Success or fail
  **/
 public function convertDatabase($id, $info)
 {
     //-----------------------------------------
     // Make sure we have everything we need
     //-----------------------------------------
     if (!$id) {
         $this->logError($id, 'No ID number provided');
         return false;
     }
     //-----------------------------------------
     // Just merging?
     //-----------------------------------------
     $us = unserialize($this->settings['conv_extra']);
     $extra = $us[$this->app['name']];
     if ($extra['ccs_databases'][$id] != 'x') {
         $this->addLink($extra['ccs_databases'][$id], $id, 'ccs_databases', 1);
     } else {
         if (!$info['database_name']) {
             $this->logError($id, 'No name provided');
             return false;
         }
         if (!$info['database_key']) {
             $this->logError($id, 'No key provided');
             return false;
         }
         $_key = $this->DB->buildAndFetch(array('select' => 'database_id', 'from' => 'ccs_databases', 'where' => "database_key='{$info['database_key']}'"));
         if ($_key['database_id']) {
             $key = $info['database_key'] . time();
             $this->logError($info['id'], "Database key {$info['database_key']} was already in use. Database was created with key {$key}");
             $info['database_key'] = $key;
         }
         //unset($info['database_comment_approve']);
         //-----------------------------------------
         // Insert
         //-----------------------------------------
         $this->DB->insert('ccs_databases', $info);
         $inserted_id = $this->DB->getInsertId();
         //-----------------------------------------
         // Add link
         //-----------------------------------------
         $this->addLink($inserted_id, $id, 'ccs_databases');
         //-----------------------------------------
         // Create new table
         //-----------------------------------------
         require_once IPSLib::getAppDir('ccs') . '/sources/databases/' . IPSText::mbstrtolower($this->settings['sql_driver']) . '.php';
         $_dbAbstraction = new ccs_database_abstraction($this->registry);
         $_dbAbstraction->createTable($this->settings['sql_tbl_prefix'] . 'ccs_custom_database_' . $inserted_id);
         $this->DB->update('ccs_databases', array('database_database' => 'ccs_custom_database_' . $inserted_id), 'database_id=' . $inserted_id);
         $this->databaseAddField(array('field_database_id' => $inserted_id, 'field_name' => 'Title', 'field_key' => 'article_title', 'field_type' => 'input', 'field_required' => '1', 'field_user_editable' => '1', 'field_max_length' => '500', 'field_truncate' => '50'));
         $this->databaseAddField(array('field_database_id' => $inserted_id, 'field_name' => 'Body', 'field_key' => 'article_body', 'field_type' => 'editor', 'field_required' => '1', 'field_user_editable' => '1', 'field_extra' => 'short'));
         $this->databaseAddField(array('field_database_id' => $inserted_id, 'field_name' => 'Public Date', 'field_key' => 'article_date', 'field_type' => 'date', 'field_required' => '1', 'field_user_editable' => '1', 'field_extra' => 'short', 'field_default_value' => 'Today'));
     }
     //-----------------------------------------
     // Rebuild cache
     //-----------------------------------------
     //$this->rebuildCache();
     return true;
 }
Exemple #6
0
 /**
  * Check the name or display name
  *
  * @return	@e void		[Outputs to screen]
  */
 public function checkDisplayName($field = 'members_display_name')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_register'));
     $name = '';
     $member = array();
     if (is_string($_POST['name'])) {
         $name = trim(rawurldecode($_POST['name']));
         $name = IPSText::mbstrtolower($name);
     }
     if (!$name) {
         $this->returnString(sprintf(ipsRegistry::getClass('class_localization')->words['reg_error_no_name'], ipsRegistry::$settings['max_user_name_length']));
     }
     /* Bug where Twitter sets a username but you can't use it when you try and sign up with a new account using username as display name */
     if (!$this->memberData['member_id'] and $this->request['mpid']) {
         $reg = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . intval($this->request['mpid'])));
         if ($reg['partial_member_id']) {
             $member = IPSMember::load($reg['partial_member_id'], 'all');
         }
     }
     /* Check the username */
     $user_check = IPSMember::getFunction()->cleanAndCheckName($name, $member, $field);
     $errorField = $field == 'members_display_name' ? 'dname' : 'username';
     $nameField = $field == 'members_display_name' ? 'members_display_name' : 'username';
     if (is_array($user_check['errors'][$errorField]) && count($user_check['errors'][$errorField])) {
         $this->returnString(ipsRegistry::getClass('class_localization')->words[$user_check['errors'][$errorField][0]] ? ipsRegistry::getClass('class_localization')->words[$user_check['errors'][$errorField][0]] : $user_check['errors'][$errorField][0]);
         return;
     } else {
         if ($user_check['errors'][$errorField]) {
             $this->returnString(ipsRegistry::getClass('class_localization')->words[$user_check['errors'][$errorField]] ? ipsRegistry::getClass('class_localization')->words[$user_check['errors'][$errorField]] : $user_check['errors'][$errorField]);
         } else {
             $this->returnString('notfound');
         }
     }
 }
Exemple #7
0
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'photos', 'order' => 'id ASC');
     $loop = $this->lib->load('gallery_images', $main);
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where images are saved (no trailing slash - usually path_to_photopost/data):')), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     if (!is_readable($path)) {
         $this->lib->error('Your remote upload path is not readable.');
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //-----------------------------------------
         // Do the image
         //-----------------------------------------
         // Have a stab at the mimetype
         $explode = explode('.', $row['filename']);
         $ext = IPSText::mbstrtolower(array_pop($explode));
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         // Basic info
         $save = array('member_id' => $row['userid'], 'img_album_id' => $row['cat'], 'caption' => $row['title'], 'description' => $row['description'], 'directory' => $row['cat'], 'file_name' => $row['bigimage'], 'file_size' => $row['filesize'], 'file_type' => $mime, 'approved' => $row['approved'], 'views' => $row['views'], 'comments' => $row['numcom'], 'idate' => $row['date'], 'ratings_total' => $row['rating'] * $row['votes'], 'ratings_count' => $row['votes'], 'rating' => $row['rating']);
         //Photopost 8?
         $this->lib->convertImage($row['id'], $save, $path . '/' . $row['cat'], false, true);
     }
     $this->lib->next();
 }
Exemple #8
0
 /**
  * Works out the SMF-style encrypted filename
  *
  * @access	private
  * @param 	string		The file name
  * @param	int			The file ID (foreign)
  * @return void
  **/
 private function _getEncryptedFilename($name, $id)
 {
     $clean_name = preg_replace(array('/\\s/', '/[^\\w_\\.-]/'), array('_', ''), $name);
     $e = explode('.', $name);
     $ext = array_pop($e);
     $enc_name = $id . '_' . strtr($clean_name, '.', '_') . md5($clean_name) . '_ext' . IPSText::mbstrtolower($ext);
     $clean_name = preg_replace('~\\.[\\.]+~', '.', $clean_name);
     return $enc_name;
 }
Exemple #9
0
 /**
  * Convert groups
  *
  * @access	private
  * @return void
  **/
 private function convert_groups()
 {
     $this->lib->useKey('groupid');
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('groups', 'map');
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'common_usergroup', 'order' => 'groupid ASC');
     $loop = $this->lib->load('groups', $main, array(), array(), TRUE);
     //-----------------------------------------
     // We need to know how to map these
     //-----------------------------------------
     $this->lib->getMoreInfo('groups', $loop, array('new' => '--Create new group--', 'ot' => 'Old group', 'nt' => 'New group'), '', array('idf' => 'groupid', 'nf' => 'grouptitle'));
     //---------------------------
     // Loop
     //---------------------------
     foreach ($loop as $row) {
         $prefix = '';
         $suffix = '';
         if ($row['color']) {
             $prefix = "<span style='color:" . IPSText::mbstrtolower($row['color']) . "'>";
             $suffix = '</span>';
         }
         $save = array('g_title' => $row['grouptitle'], 'g_perm_id' => $row['groupid'], 'prefix' => $prefix, 'suffix' => $suffix);
         $this->lib->convertGroup($row['groupid'], $save);
         $this->lib->setLastKeyValue($row['groupid']);
     }
     $this->lib->next();
 }
Exemple #10
0
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'photos', 'order' => 'id ASC');
     $loop = $this->lib->load('gallery_images', $main);
     $cats = array();
     $this->DB->build(array('select' => '*', 'from' => 'gallery_categories', 'category_type=2'));
     // fetch all Images Only Categories
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $cats[$r['category_id']] = $r['category_name'];
     }
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $featuredOpts['1'] = 'Yes';
     $featuredOpts['0'] = 'No';
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where images are saved (no trailing slash - usually path_to_photopost/data):'), 'orphans' => array('type' => 'dropdown', 'label' => 'Where do you want to put orphaned images?', 'options' => $cats), 'feature_all' => array('type' => 'dropdown', 'label' => 'Feature All Images?', 'options' => $featuredOpts)), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     if (!is_readable($path)) {
         $this->lib->error('Your remote upload path is not readable.');
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //-----------------------------------------
         // Do the image
         //-----------------------------------------
         // Have a stab at the mimetype
         $explode = explode('.', $row['bigimage']);
         $ext = IPSText::mbstrtolower(array_pop($explode));
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         // Basic info
         $save = array('image_member_id' => $row['userid'], 'image_category_id' => $row['cat'] ? $row['cat'] : $us['orphans'], 'image_album_id' => $row['cat'] ? $row['cat'] : $us['orphans'], 'image_directory' => $row['cat'], 'image_caption' => $row['title'], 'image_description' => $row['description'], 'image_file_name' => $row['bigimage'], 'image_file_size' => $row['filesize'], 'image_file_type' => $mime, 'image_approved' => $row['approved'], 'image_views' => $row['views'], 'image_comments' => $row['numcom'], 'image_date' => $row['date'], 'image_rating' => $row['rating'], 'image_last_comment' => $row['lastpost'], 'image_caption_seo' => IPSText::makeSeoTitle($row['title']), 'image_feature_flag' => $us['feature_all']);
         // I'm 98% sure I'm doing it wrong here - feel free to point it out.
         $app = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'conv_apps', 'where' => "name='{$this->settings['conv_current']}'"));
         // Go!
         $this->lib->convertImage($row['id'], $save, $path, false, $app['parent']);
     }
     $this->lib->next();
 }
Exemple #11
0
 /**
  * Convert members
  *
  * @access	private
  * @return void
  **/
 private function convert_members()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $pcpf = array('Location' => 'Location', 'Occupation' => 'Occupation', 'Interests' => 'Interests', 'RealName' => 'Real Name', 'HomePage' => 'Website URL', 'ICQ' => 'ICQ', 'AIM' => 'AIM', 'YIM' => 'YIM', 'MSN' => 'MSN');
     $this->lib->saveMoreInfo('members', array_keys($pcpf));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => 'u.*', 'from' => array('User' => 'u'), 'order' => 'u.UserID ASC');
     $loop = $this->lib->load('members', $main);
     //-----------------------------------------
     // Tell me what you know!
     //-----------------------------------------
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $ask = array();
     // And those custom profile fields
     $options = array('x' => '-Skip-');
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $options[$row['pf_id']] = $row['pf_title'];
     }
     foreach ($pcpf as $id => $name) {
         $ask[$id] = array('type' => 'dropdown', 'label' => 'Custom profile field to store ' . $name . ': ', 'options' => $options);
     }
     $this->lib->getMoreInfo('members', $loop, $ask, 'path');
     //-----------------------------------------
     // Get our custom profile fields
     //-----------------------------------------
     if (isset($us['pfield_group'])) {
         $this->DB->build(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_group_id=' . $us['pfield_group']));
         $this->DB->execute();
         $pfields = array();
         while ($row = $this->DB->fetch()) {
             $pfields[] = $row;
         }
     } else {
         $pfields = array();
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //-----------------------------------------
         // Set info
         //-----------------------------------------
         // Secondary groups
         ipsRegistry::DB('hb')->build(array('select' => '*', 'from' => 'UserGroup', 'where' => "UserID='{$row['UserID']}'"));
         ipsRegistry::DB('hb')->execute();
         $sgroups = array();
         while ($group = ipsRegistry::DB('hb')->fetch()) {
             $sgroups[] = $group['GroupID'];
         }
         $group = array_shift($sgroups);
         // Basic info
         $info = array('id' => $row['UserID'], 'username' => $row['Name'], 'email' => $row['Email'], 'md5pass' => IPSText::mbstrtolower($row['Password']), 'joined' => $this->_fixTime($row['Joined']), 'secondary_groups' => implode(',', $sgroups), 'group' => $group);
         // Member info
         $members = array('ip_address' => $row['IP'], 'last_activity' => $this->_fixTime($row['LastVisit']), 'last_visit' => $this->_fixTime($row['LastVisit']), 'posts' => $row['NumPosts'], 'view_sigs' => 1, 'hide_email' => 1);
         // Profile
         $profile = array('signature' => $this->fixPostData($row['Signature']), 'photo_type' => $row['Avatar'] ? 'url' : '', 'photo_location' => $row['Avatar'] ? $row['Avatar'] : '');
         //-----------------------------------------
         // Avatars
         //-----------------------------------------
         if ($row['Avatar']) {
             $profile['photo_type'] = 'url';
             $profile['photo_location'] = $row['Avatar'];
         } elseif ($row['AvatarImage']) {
             $profile['photo_type'] = 'custom';
             $profile['photo_location'] = 'av-conv-' . $row['UserID'] . '.' . str_ireplace('image/', '', $row['AvatarImageType']);
             $profile['photo_data'] = $row['AvatarImage'];
             $profile['photo_filesize'] = strlen($row['AvatarImage']);
             //$profile['avatar_size'] = $customavatar['width'].'x'.$customavatar['height'];
         }
         //-----------------------------------------
         // Custom Profile fields
         //-----------------------------------------
         // Pseudo
         foreach ($pcpf as $id => $name) {
             if ($us[$id] != 'x') {
                 $custom['field_' . $us[$id]] = $row[$id];
             }
         }
         // Actual
         foreach ($pfields as $field) {
             $custom['field_' . $field['pf_id']] = $row[$field['pf_key']];
         }
         //-----------------------------------------
         // And go!
         //-----------------------------------------
         $this->lib->convertMember($info, $members, $profile, array());
     }
     $this->lib->next();
 }
Exemple #12
0
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'fileuploads', 'order' => 'fileid ASC');
     $loop = $this->lib->load('gallery_images', $main);
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where images are saved (no trailing slash - usually path_to_photoplog/images):')), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     if (!is_readable($path)) {
         $this->lib->error('Your remote upload path is not readable.');
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //-----------------------------------------
         // Do the image
         //-----------------------------------------
         // Have a stab at the mimetype
         $explode = explode('.', $row['filename']);
         $ext = IPSText::mbstrtolower(array_pop($explode));
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         // Do we have an image set?
         $set = $this->lib->getLink('s' . $row['setid'], 'gallery_albums', true);
         if (!$set && $row['catid'] && $row['userid']) {
             // Attempt to see if we already have one in database
             $cat = $this->DB->buildAndFetch(array('select' => 'a.album_id', 'from' => array('gallery_albums' => 'a'), 'add_join' => array(array('select' => 'cl.foreign_id', 'from' => array('conv_link' => 'cl'), 'where' => "cl.ipb_id=a.album_id AND cl.type='gallery_albums'", 'type' => 'left')), 'where' => 'a.album_category_id=' . $this->lib->getLink($row['catid'], 'gallery_categories') . ' AND a.album_owner_id=' . $this->lib->getLink($row['userid'], 'members', false, true) . " AND cl.foreign_id='s" . $row['setid'] . "'"));
             // We have a category
             if ($cat['foreign_id']) {
                 $row['setid'] = str_replace('s', '', $cat['foreign_id']);
             } else {
                 // Grab child albums
                 $save = array('album_owner_id' => $row['userid'], 'album_category_id' => $row['catid'], 'album_name' => $row['title'], 'album_description' => '', 'album_type' => 1);
                 $this->lib->convertAlbum('s' . $row['setid'], $save, array());
             }
         }
         // Basic info
         $save = array('member_id' => $row['userid'], 'image_category_id' => $row['catid'], 'image_album_id' => 's' . $row['setid'], 'image_caption' => $row['title'], 'image_description' => $row['description'], 'image_directory' => $row['userid'], 'image_file_name' => $row['filename'], 'image_file_size' => $row['filesize'], 'image_file_type' => $mime, 'image_approved' => $row['moderate'] == 1 ? 0 : 1, 'image_views' => $row['views'], 'image_comments' => $row['num_comments0'] + $row['num_comments1'], 'image_date' => $row['dateline'], 'image_ratings_total' => $row['sum_ratings1'], 'image_ratings_count' => $row['num_ratings1'], 'image_rating' => $row['num_ratings1'] > 0 ? intval($row['sum_ratings1'] / $row['num_ratings1']) : 0);
         // Go!
         $this->lib->convertImage($row['fileid'], $save, $path);
         //-----------------------------------------
         // Ratings
         //-----------------------------------------
         $rates = array('select' => '*', 'from' => 'ratecomment', 'order' => 'commentid ASC', 'where' => 'fileid=' . $row['fileid'] . ' AND rating=0');
         ipsRegistry::DB('hb')->build($rates);
         ipsRegistry::DB('hb')->execute();
         while ($rate = ipsRegistry::DB('hb')->fetch()) {
             $this->lib->convertRating($rate['commentid'], array('member_id' => $row['userid'], 'img_id' => $row['fileid'], 'date' => $row['dateline'], 'rate' => $row['rating']));
         }
     }
     $this->lib->next();
 }
Exemple #13
0
 /**
  * Convert Packages
  *
  * @access	private
  * @return void
  **/
 private function convert_subscriptions()
 {
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'subscription', 'order' => 'subscriptionid ASC');
     $loop = $this->lib->load('subscriptions', $main);
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         // Get local stuff
         $default_currency = $this->DB->buildAndFetch(array('select' => 'subcurrency_code', 'from' => 'subscription_currency', 'where' => "subcurrency_default=1"));
         $tco = $this->DB->buildAndFetch(array('select' => 'submethod_id', 'from' => 'subscription_methods', 'where' => "submethod_name='2checkout'"));
         // Get remote stuff
         $title = ipsRegistry::DB('hb')->buildAndFetch(array('select' => 'text', 'from' => 'phrase', 'where' => "varname = 'sub{$row['subscriptionid']}_title'"));
         $desc = ipsRegistry::DB('hb')->buildAndFetch(array('select' => 'text', 'from' => 'phrase', 'where' => "varname = 'sub{$row['subscriptionid']}_desc'"));
         // Loop through costs
         $costs = unserialize($row['cost']);
         foreach ($costs as $cost) {
             // Check we have a matching currency
             if (!in_array(IPSText::mbstrtolower($default_currency['subcurrency_code']), array_keys($cost['cost']))) {
                 $this->lib->logError($row['subscriptionid'], "No price for default currnecy ({$default_currency['subcurrency_code']})");
                 continue 2;
             }
             // Save to subscriptions
             $save = array('sub_title' => $title['text'], 'sub_desc' => $desc['text'], 'sub_new_group' => $row['nusergroupid'], 'sub_length' => $cost['length'], 'sub_unit' => IPSText::mbstrtolower($cost['units']), 'sub_cost' => $cost['cost'][IPSText::mbstrtolower($default_currency['subcurrency_code'])]);
             $this->lib->convertPackage($row['subscriptionid'], $save);
             // 2CO Product ID?
             if ($cost['twocheckout_prodid'] and $tco) {
                 $extra = array('subextra_sub_id' => $row['subscriptionid'], 'subextra_method_id' => $tco['submethod_id'], 'subextra_product_id' => $cost['twocheckout_prodid']);
                 $this->lib->convertPackageExtra($row['subscriptionid'], $extra);
             }
         }
     }
     $this->lib->next();
 }
Exemple #14
0
 public function fixFrenchDate($date)
 {
     // Make the months lowercase
     $date = IPSText::mbstrtolower($date);
     // Check if strtotime can create a unix timestamp.
     if (strtotime($date) !== FALSE) {
         return $date;
     }
     // Add seconds to the timestamp
     $date .= ':00';
     // Check again if strtotime can create a unix timestamp.
     if (strtotime($date) !== FALSE) {
         return $date;
     }
     $shortMonthTranslations = array('fév' => 'feb', 'fev' => 'feb', 'mars' => 'mar', 'avr' => 'apr', 'mai' => 'may', 'juin' => 'june', 'jui' => 'jul', 'aoû' => 'aug', 'aou' => 'aug', 'déc' => 'dec');
     // Time to replace all french months with english
     foreach ($shortMonthTranslations as $toFix => $theFix) {
         $date = str_replace($toFix, $theFix, $date);
     }
     // Replace slashes with spaces.
     $date = str_replace('/', ' ', $date);
     // Check again if strtotime can create a unix timestamp.
     if (strtotime($date) !== FALSE) {
         return $date;
     }
     print 'Error: ' . $date;
     exit;
 }
Exemple #15
0
 /**
  * Cleans incoming tags
  * @param	String or Array		Comma delim string or array of tags
  * @param	Bool				If TRUE, will check minimum and maximum amounts of tags - not necessary for searching
  * @return	Array				Array of cleaned tags
  */
 private function _cleanTags($tags, $checkForMinimumAndMaximum = TRUE)
 {
     /* Sort out tags */
     if (!is_array($tags)) {
         if (strstr($tags, ',')) {
             $_tags = explode(',', IPSText::cleanPermString($tags));
             $tags = array();
             foreach ($_tags as $t) {
                 if ($t) {
                     $tags[] = $this->_stripHtml(trim($this->_forceLower() ? IPSText::mbstrtolower($t) : $t));
                 }
             }
         } else {
             if (!strlen($tags)) {
                 return false;
             }
             $tags = array($this->_stripHtml($this->_forceLower() ? IPSText::mbstrtolower($tags) : $tags));
         }
     }
     /* So.. got tags to parse? */
     if (count($tags)) {
         /* Make sure they are all unique */
         $tags = array_unique($tags);
         /* Check for min/max string length */
         if ($checkForMinimumAndMaximum and ($this->_getMaxLen() or $this->_getMinLen())) {
             $_tags = $tags;
             $tags = array();
             foreach ($_tags as $tag) {
                 if ($this->_getMaxLen()) {
                     if (IPSText::mbstrlen($tag) > $this->_getMaxLen()) {
                         continue;
                     }
                 }
                 if ($this->_getMinLen()) {
                     if (IPSText::mbstrlen($tag) < $this->_getMinLen()) {
                         continue;
                     }
                 }
                 $tags[] = $tag;
             }
         }
         /* removes any bad words */
         $badwords = $this->cache->getCache('badwords');
         if ($this->_mustCleanWords() and is_array($badwords) && count($badwords)) {
             $_tags = $tags;
             $tags = array();
             foreach ($_tags as $tag) {
                 $_bad = false;
                 foreach ($badwords as $badword) {
                     if (strtolower($tag) == strtolower($badword['type'])) {
                         $_bad = true;
                         break;
                     }
                 }
                 if (!$_bad) {
                     $tags[] = $tag;
                 }
             }
         }
     }
     /* Now, do we have a sufficient number of tags? */
     if ($checkForMinimumAndMaximum && $this->_getMaxTags() && count($tags) > $this->_getMaxTags()) {
         $this->setErrorMsg('too_many_tags');
         return false;
     }
     /* Perhaps not enough? */
     if ($checkForMinimumAndMaximum && $this->_getMinTags() && count($tags) < $this->_getMinTags()) {
         $this->setErrorMsg('too_few_tags');
         return false;
     }
     /* Generic catch all in case min/max tags aren't set up. */
     if (!count($tags)) {
         $this->setErrorMsg('no_good_tags');
         return false;
     }
     /* Phew. */
     return $tags;
 }
Exemple #16
0
 /**
  * Convert groups
  *
  * @access	private
  * @return void
  **/
 private function convert_groups()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('groups', 'map');
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'groups', 'order' => 'groupid ASC');
     $loop = $this->lib->load('groups', $main, array(), array(), TRUE);
     //-----------------------------------------
     // We need to know how to map these
     //-----------------------------------------
     $this->lib->getMoreInfo('groups', $loop, array('new' => '--Create new group--', 'ot' => 'Old group', 'nt' => 'New group'), '', array('idf' => 'groupid', 'nf' => 'name'));
     //---------------------------
     // Loop
     //---------------------------
     foreach ($loop as $row) {
         $save = array('g_title' => $row['name'], 'g_perm_id' => $row['groupid'], 'g_access_cp' => strstr(IPSText::mbstrtolower($row['group_type']), 'admin') ? 1 : 0);
         $this->lib->convertGroup($row['groupid'], $save);
     }
     $this->lib->next();
 }
Exemple #17
0
 /**
  * Convert Attachments
  *
  * @access	private
  * @return void
  **/
 private function convert_attachments()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     //$this->lib->saveMoreInfo('attachments', array('attach_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => 'a.*', 'from' => array('InstantForum_Attachments' => 'a'), 'add_join' => array(array('select' => 'p.PostID, p.IsPrivateMessage', 'from' => array('InstantForum_AttachmentsPosts' => 'p'), 'where' => 'a.AttachmentID = p.AttachmentID', 'type' => 'inner')), 'order' => 'a.AttachmentID ASC');
     $loop = $this->lib->load('attachments', $main);
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     //$this->lib->getMoreInfo('attachments', $loop, array('attach_path' => array('type' => 'text', 'label' => 'The path to the folder where attachments are saved (no trailing slash - usually path_to_fusionbb/fbbuploads):')), 'path');
     //$get = unserialize($this->settings['conv_extra']);
     //$us = $get[$this->lib->app['name']];
     //$path = $us['attach_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['upload_dir'])) {
         $this->lib->error('Your IP.Board upload path is not writeable. ' . $this->settings['upload_dir']);
     }
     //if (!is_readable($path))
     //{
     //$this->lib->error('Your remote upload path is not readable.');
     //}
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         // What's the extension?
         $ext = explode('.', $row['Filename']);
         $extension = IPSText::mbstrtolower(array_pop($ext));
         // Is this an image?
         $image = in_array($extension, array('png', 'jpg', 'jpeg', 'gif')) ? TRUE : FALSE;
         $save = array('attach_ext' => $extension, 'attach_file' => $row['Filename'], 'data' => $row['AttachmentBLOB'], 'attach_is_image' => $image, 'attach_hits' => $row['Views'], 'attach_date' => $this->myStrToTime($row['DateStamp']), 'attach_member_id' => $row['UserID'], 'attach_filesize' => $row['ContentLength'], 'attach_rel_id' => $row['PostID'], 'attach_rel_module' => $row['IsPrivateMessage'] ? 'msg' : 'post');
         $this->lib->convertAttachment($row['AttachmentID'], $save, NULL, TRUE);
     }
     $this->lib->next();
 }
Exemple #18
0
 /**
  * Returns the file extension of the current filename
  *
  * @access	public
  * @param	string		Filename
  * @return	string		File extension
  */
 private function _getFileExtension($file)
 {
     return IPSText::mbstrtolower(str_replace(".", "", substr($file, strrpos($file, '.'))));
 }
Exemple #19
0
 private function convert_nexus_packages()
 {
     $main = array('select' => '*', 'from' => 'subscription', 'order' => 'subscriptionid ASC');
     $loop = $this->lib->load('nexus_packages', $main);
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         // Get local stuff
         $default_currency = $this->DB->buildAndFetch(array('select' => 'conf_value, conf_default, conf_key', 'from' => 'core_sys_conf_settings', 'where' => 'conf_key="nexus_currency"'));
         // Get remote stuff
         $title = ipsRegistry::DB('hb')->buildAndFetch(array('select' => 'text', 'from' => 'phrase', 'where' => "varname = 'sub{$row['subscriptionid']}_title'"));
         $desc = ipsRegistry::DB('hb')->buildAndFetch(array('select' => 'text', 'from' => 'phrase', 'where' => "varname = 'sub{$row['subscriptionid']}_desc'"));
         // Loop through costs
         $costs = unserialize($row['cost']);
         // Gotta set the cost, if it's not been filled we need to use default.
         $cost = empty($default_currency['conf_value']) ? $costs['0']['cost'][IPSText::mbstrtolower($default_currency['conf_default'])] : $costs['0']['cost'][IPSText::mbstrtolower($default_currency['conf_value'])];
         // set up renewal options
         $renewOpts = array('term' => $costs['0']['length'], 'unit' => IPSText::mbstrtolower($costs['0']['units']), 'price' => $cost, 'add' => FALSE);
         // serialize for db
         $renew = serialize(array($renewOpts));
         $save = array('p_name' => $title['text'], 'p_desc' => $desc['text'], 'p_stock' => -1, 'p_store' => 1, 'p_group' => $this->convertGroup, 'p_member_groups' => '*', 'p_base_price' => $cost, 'p_renew_options' => $renew, 'p_primary_group' => $row['nusergroupid'], 'p_return_primary' => 1, 'p_type' => 'product');
         $product = array('p_subscription' => 1);
         $this->lib->convertPackage($row['subscriptionid'], $save, $discounts, $product);
     }
     $this->lib->next();
 }
Exemple #20
0
 /**
  * Convert members
  *
  * @access	private
  * @return void
  **/
 private function convert_members()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $pcpf = array('icqnumber' => 'ICQ Number', 'aim' => 'AIM ID', 'yahoo' => 'Yahoo ID', 'msn' => 'MSN ID', 'website' => 'Website', 'location' => 'Location', 'interests' => 'Interests');
     $this->lib->saveMoreInfo('members', array_merge(array_keys($pcpf), array('pp_path', 'pp_type')));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => 'm.*', 'from' => array('members' => 'm'), 'add_join' => array(array('select' => 'i.PhotoImage, i.AvatarImage, i.PhotoFilename, i.AvatarFilename, i.photofileguid, i.avatarfileguid, i.photoinfilesystem', 'from' => array('memberphotos' => 'i'), 'where' => 'm.memberid = i.memberid', 'type' => 'left')), 'order' => 'm.memberid ASC');
     $loop = $this->lib->load('members', $main);
     //-----------------------------------------
     // Tell me what you know!
     //-----------------------------------------
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $ask = array();
     // We need to know the avatars path
     $ask['pp_path'] = array('type' => 'text', 'label' => 'Path to avatars uploads folder (no trailing slash, default /path_to_board/profile/uploads): ');
     $ask['pp_type'] = array('type' => 'dropdown', 'label' => 'Which Member Photo would you like to convert?', 'options' => array('avatar' => 'Avatars', 'profile' => 'Profile Photo'));
     // And those custom profile fields
     $options = array('x' => '-Skip-');
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $options[$row['pf_id']] = $row['pf_title'];
     }
     foreach ($pcpf as $id => $name) {
         $ask[$id] = array('type' => 'dropdown', 'label' => 'Custom profile field to store ' . $name . ': ', 'options' => $options, 'extra' => $extra);
     }
     $this->lib->getMoreInfo('members', $loop, $ask, 'path');
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         ipsRegistry::DB('hb')->build(array('select' => 'groupid', 'from' => 'groupmembers', 'where' => "memberid='{$row['memberid']}'"));
         $group_loop = ipsRegistry::DB('hb')->execute();
         $groups = array();
         while ($group = ipsRegistry::DB('hb')->fetch($group_loop)) {
             $groups[] = $group['groupid'];
         }
         $primaryGroup = array_shift($groups);
         //-----------------------------------------
         // Set info
         //-----------------------------------------
         // Basic info
         $info = array('id' => $row['memberid'], 'group' => $primaryGroup, 'secondary_groups' => implode(', ', $groups), 'joined' => strtotime($row['dateregistered']), 'username' => $row['username'], 'email' => $row['emailaddress'], 'pass_hash' => IPSText::mbstrtolower($row['password']));
         if (strlen($row['password']) > 32) {
             /* ' Encrypt the password
                dim vAttemptedUser
                vAttemptedUser = BBS.GetUserInfoByName(sPostUsername)
                sPostPassword = Encrypt.HashEncode(sPostPassword & vAttemptedUser(UI_Salt))*/
             unset($info['pass_hash']);
             $info['password'] = $row['password'];
         }
         // Member info
         //$birthday = ($row['bday']) ? explode('-', $row['bday']) : null;
         $members = array('ip_address' => '127.0.0.1', 'posts' => $row['totalposts'], 'allow_admin_mails' => $row['notificationpreference'] == 'none' ? 0 : 1, 'time_offset' => $row['timeoffset'], 'hide_email' => !$row['showemail'], 'view_sigs' => 1, 'msg_show_notification' => 1, 'last_visit' => strtotime($row['lastlogon']), 'last_activity' => strtotime($row['lastlogon']), 'dst_in_use' => 0, 'coppa_user' => 0, 'members_disable_pm' => 1, 'misc' => $row['salt']);
         // Profile
         $profile = array('signature' => $this->fixPostData($row['signature']));
         //-----------------------------------------
         // Avatars and profile pictures
         //-----------------------------------------
         $path = $us['pp_path'];
         if ($us['pp_type'] == 'avatar') {
             if (isset($row['avatarurl'])) {
                 $row['AvatarURL'] = $row['avatarurl'];
             }
             if (isset($row['avatarimage'])) {
                 $row['AvatarImage'] = $row['avatarimage'];
             }
             if ($row['AvatarURL'] != '' && $row['AvatarURL'] != NULL) {
                 // URL
                 if (preg_match('/http/', $row['AvatarURL'])) {
                     $profile['photo_type'] = 'url';
                     $profile['photo_location'] = $row['AvatarURL'];
                 }
             } elseif ($row['AvatarFilename']) {
                 $profile['photo_type'] = 'custom';
                 $profile['photo_location'] = $row['avatarfileguid'];
                 if (!$row['avatarinfilesystem']) {
                     $profile['photo_data'] = $customavatar['AvatarImage'];
                 }
             }
         } else {
             if (isset($row['photofilename'])) {
                 $row['PhotoFilename'] = $row['photofilename'];
             }
             if (isset($row['photoimage'])) {
                 $row['PhotoImage'] = $row['photoimage'];
             }
             if ($row['PhotoFilename']) {
                 $profile['pp_main_photo'] = $row['photofileguid'];
                 if (!$row['photoinfilesystem']) {
                     $profile['photo_data'] = $customprofilepic['PhotoImage'];
                 }
             }
         }
         //-----------------------------------------
         // And go!
         //-----------------------------------------
         $this->lib->convertMember($info, $members, $profile, array(), $path);
     }
     $this->lib->next();
 }
Exemple #21
0
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'pictures', 'order' => 'pid ASC');
     $loop = $this->lib->load('gallery_images', $main);
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where images are saved (no trailing slash - usually path_to_coppermine/albums):')), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     if (!is_readable($path)) {
         $this->lib->error('Your remote upload path is not readable.');
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //-----------------------------------------
         // Do the image
         //-----------------------------------------
         // Have a stab at the mimetype
         $explode = explode('.', $row['filename']);
         $ext = IPSText::mbstrtolower(array_pop($explode));
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         $rating = round($row['pic_rating'] / 2000, 1);
         // Basic info
         $save = array('image_member_id' => $row['owner_id'], 'image_album_id' => $row['aid'], 'image_caption' => $row['title'], 'image_description' => $row['caption'], 'image_directory' => $row['filepath'], 'image_file_name' => $row['filename'], 'image_file_size' => $row['filesize'], 'image_file_type' => $mime, 'image_approved' => $row['approved'] == 'YES' ? 1 : 0, 'image_views' => $row['hits'], 'image_comments' => $this->lib->countRows('comments', "pid={$row['pid']}"), 'image_date' => $row['ctime'], 'image_ratings_total' => $rating * $row['votes'], 'image_ratings_count' => $row['votes'], 'image_rating' => $rating);
         // 'Custom' fields
         /*$custom = array(
         		'field_user_field1'	=> $row['user1'],
         		'field_user_field2'	=> $row['user2'],
         		'field_user_field3'	=> $row['user3'],
         		'field_user_field4'	=> $row['user4'],
         		);*/
         // Go!
         $this->lib->convertImage($row['pid'], $save, $path);
     }
     $this->lib->next();
 }
 /**
  * Formats search term for SQL
  *
  * @access	private
  * @param	string		Raw IPB santized form input
  * @return	array		array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
  */
 public function formatSearchTerm($search_term)
 {
     $isBoolean = $this->isBoolean();
     $andor = isset($this->request['andor_type']) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
     $removedTerms = array();
     /* Fix up some sanitized HTML */
     $search_term = str_replace("&amp;", '&', IPSText::parseCleanValue(rawurldecode($search_term)));
     $search_term = str_replace("&quot;", '"', $search_term);
     $search_term = IPSText::mbstrtolower($search_term);
     /* Check for disallowed search terms */
     while (preg_match_all('/(?:^|\\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\\s+|$)/', $search_term, $removed_search_terms)) {
         $removedTerms[] = $removed_search_terms[0][0];
         $search_term = preg_replace('/(^|\\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\\s+|$)/', str_replace("  ", " ", "\$1\$2"), $search_term);
     }
     /* remove < min char words */
     if (substr_count($search_term, '"') != 2) {
         $_words = explode(' ', $search_term);
         $search_term = '';
         foreach ($_words as $_w) {
             if (IPSText::mbstrlen($_w) >= $this->settings['min_search_word']) {
                 $search_term .= $_w . ' ';
             } else {
                 if ($_w) {
                     $removedTerms[] = $_w;
                 }
             }
         }
     }
     /* Remove some formatting */
     //$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
     // | is an OR operator for sphinx - don't want to block globally
     if ($search_term) {
         $search_term = str_replace(array('\\', '/'), '', trim($search_term));
         /* Sphinx chars are not allowed */
         $search_term = str_replace(array('.', ')', '(', '!', '@', '[', ']', '~', '^'), '', $search_term);
         $search_term = preg_replace('#(?!\\s)-#', '\\1&#8208', $search_term);
         if ($andor == 'and' and !(substr_count($search_term, '"') == 2)) {
             $search_term = '+' . preg_replace('/\\s+(?!-|~)/', " +", $search_term);
         }
     }
     return array('search_term' => $search_term, 'removed' => $removedTerms);
 }
Exemple #23
0
 /**
  * Convert Images
  *
  * @access	private
  * @return void
  **/
 private function convert_gallery_images()
 {
     //-----------------------------------------
     // Were we given more info?
     //-----------------------------------------
     $this->lib->saveMoreInfo('gallery_images', array('gallery_path'));
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => 'images', 'order' => 'image_id ASC');
     $loop = $this->lib->load('gallery_images', $main, array());
     //-----------------------------------------
     // We need to know the path
     //-----------------------------------------
     $this->lib->getMoreInfo('gallery_images', $loop, array('gallery_path' => array('type' => 'text', 'label' => 'The path to the folder where images are saved (no trailing slash - usually path_to_4images/data/media):')), 'path');
     $get = unserialize($this->settings['conv_extra']);
     $us = $get[$this->lib->app['name']];
     $path = $us['gallery_path'];
     //-----------------------------------------
     // Check all is well
     //-----------------------------------------
     if (!is_writable($this->settings['gallery_images_path'])) {
         $this->lib->error('Your IP.Gallery upload path is not writeable. ' . $this->settings['gallery_images_path']);
     }
     if (!is_readable($path)) {
         $this->lib->error('Your remote upload path is not readable.');
     }
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         //---------------------------
         // Skip URL ones
         //---------------------------
         if (substr($row['image_media_file'], 0, 7) == 'http://' or substr($row['image_media_file'], 0, 8) == 'https://') {
             continue;
         }
         //-----------------------------------------
         // Do the image
         //-----------------------------------------
         // Have a stab at the mimetype
         $explode = explode('.', $row['image_media_file']);
         $ext = IPSText::mbstrtolower(array_pop($explode));
         $ext = $ext == 'jpg' ? 'jpeg' : $ext;
         $mime = "image/{$ext}";
         $media = 1;
         if (preg_match('/image/', $mime)) {
             $media = 0;
         }
         // Basic info
         $save = array('member_id' => $row['user_id'], 'img_album_id' => $row['cat_id'], 'caption' => $row['image_name'], 'description' => $row['image_description'], 'file_name' => $row['image_media_file'], 'file_type' => $mime, 'approved' => $row['image_active'], 'views' => $row['image_hits'], 'comments' => $row['image_comments'], 'idate' => $row['image_date'], 'ratings_total' => $row['image_rating'] * $row['image_votes'], 'ratings_count' => $row['image_votes'], 'rating' => $row['image_rating'], 'masked_file_name' => $row['cat_id'] . '/' . $row['image_media_file'], 'media' => $media);
         // Go!
         $this->lib->convertImage($row['image_id'], $save, $path);
     }
     $this->lib->next();
 }