コード例 #1
0
ファイル: rebuild.php プロジェクト: mover5/imobackup
 /**
  * 3.2.x Tools: Convert photos
  *
  * @return	@e void
  */
 public function tools320photos()
 {
     /* INIT */
     $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
     $st = intval($this->request['st']);
     $did = 0;
     $each = 200;
     /* Photo library */
     require_once IPS_ROOT_PATH . 'sources/classes/member/photo.php';
     /*noLibHook*/
     $photo = new classes_member_photo($this->registry);
     /* Loop over members */
     $this->DB->build(array('select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array($st, $each)));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $did++;
         $update = array();
         if ($r['fb_photo']) {
             $update['pp_photo_type'] = 'facebook';
         } else {
             if ($r['tc_photo']) {
                 $update['pp_photo_type'] = 'twitter';
             } else {
                 if ($convertFrom == 'avatars') {
                     if ($r['avatar_type'] == 'upload' and $r['avatar_location']) {
                         $update['pp_photo_type'] = 'custom';
                         $update['pp_main_photo'] = $r['avatar_location'];
                         $_dims = @getimagesize($this->settings['upload_dir'] . '/' . $r['avatar_location']);
                         $update['pp_main_width'] = $_dims[0];
                         $update['pp_main_height'] = $_dims[1];
                     } else {
                         if ($r['avatar_type'] == 'gravatar') {
                             $update['pp_photo_type'] = 'gravatar';
                             $update['pp_gravatar'] = $r['avatar_location'];
                             $md5Gravatar = md5($update['pp_gravatar']);
                             $_url = "http://www.gravatar.com";
                             if ($this->registry->output->isHTTPS) {
                                 $_url = "https://secure.gravatar.com";
                             }
                             $update['pp_main_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                             $update['pp_main_width'] = 100;
                             $update['pp_main_height'] = 100;
                             $update['pp_thumb_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                             $update['pp_thumb_width'] = 100;
                             $update['pp_thumb_height'] = 100;
                         }
                     }
                 } else {
                     if ($r['pp_main_photo']) {
                         $update['pp_photo_type'] = 'custom';
                         $update['pp_main_photo'] = $r['pp_main_photo'];
                     }
                 }
             }
         }
         if ($update['pp_photo_type'] == 'custom') {
             $info = $photo->buildSizedPhotos(str_replace('upload:', '', $update['pp_main_photo']), $r['pp_member_id'], true);
             $update['pp_main_width'] = intval($info['final_width']);
             $update['pp_main_height'] = intval($info['final_height']);
             $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
             $update['pp_thumb_width'] = intval($info['t_final_width']);
             $update['pp_thumb_height'] = intval($info['t_final_height']);
         }
         if (count($update)) {
             $this->DB->update('profile_portal', $update, 'pp_member_id=' . $r['pp_member_id']);
         }
     }
     /* Show message and redirect */
     if ($did > 0) {
         $this->request['st'] = $st + $did;
         $url = "{$this->settings['base_url']}{$this->form_code}&do=" . $this->request['do'] . '&from=' . $this->request['from'] . '&st=' . $this->request['st'];
         $this->_specialRedirect($url, sprintf($this->lang->words['tools320photos'], $this->request['st'], $did));
     } else {
         $this->registry->output->redirect($this->settings['base_url'] . $this->form_code . '&do=tools', $this->lang->words['re_photosconverted']);
     }
 }
コード例 #2
0
    /**
     * Convert and rebuild photos
     * 
     * @param	int
     * @return	@e void
     */
    public function convertPhotos()
    {
        /* Is this the first cycle? */
        if (!$this->request['from']) {
            $this->_output = <<<EOF
<h2>Конвертация фотографий пользователей</h2>
<div class='message unspecified'>
\tIP.Board 3.2 теперь использует только одно изображение для идентификации пользователя. Вы должны выбрать, что именно (аватар или фотография из профиля) будет сохранено и использовано новой версией.
\t<br />
\t<select name='from'>
\t\t<option value='avatars'>Использвать аватары</option>
\t\t<option value='photos'>Использовать фотографии из профиля</option>
\t</select>
\t<br />
\tВ процессе конвертации также будут изменены размеры существующих изображений и созданы новые превью. Вы можете отложить этот процесс, отметив чекбокс. Процесс перестроения изображений может быть запущен вами после обновления в админ-центре форума.
\t<br /><br />
\t<input type='radio' name='skip' value='0' checked='checked' /> Перестроить сейчас<br />
\t<input type='radio' name='skip' value='1' /> Пропустить
EOF;
            return;
        }
        /* Our options */
        $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
        $skipRebuild = intval($this->request['skip']);
        /* Init */
        $st = intval($this->request['st']);
        $did = 0;
        $each = 200;
        require_once IPS_ROOT_PATH . 'sources/classes/member/photo.php';
        /*noLibHook*/
        $photo = new classes_member_photo($this->registry);
        /* Loop over members */
        $this->DB->build(array('select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array($st, $each)));
        $outer = $this->DB->execute();
        while ($r = $this->DB->fetch($outer)) {
            $did++;
            $update = array();
            if ($r['fb_photo']) {
                $update['pp_photo_type'] = 'facebook';
            } else {
                if ($r['tc_photo']) {
                    $update['pp_photo_type'] = 'twitter';
                } else {
                    if ($r['vc_photo']) {
                        $update['pp_photo_type'] = 'vkontakte';
                    } else {
                        if ($convertFrom == 'avatars') {
                            if ($r['avatar_type'] == 'upload' and $r['avatar_location']) {
                                $update['pp_photo_type'] = 'custom';
                                $update['pp_main_photo'] = $r['avatar_location'];
                                $_dims = @getimagesize($this->settings['upload_dir'] . '/' . $r['avatar_location']);
                                $update['pp_main_width'] = $_dims[0] ? $_dims[0] : 1;
                                $update['pp_main_height'] = $_dims[1] ? $_dims[1] : 1;
                            } else {
                                if ($r['avatar_type'] == 'gravatar') {
                                    $update['pp_photo_type'] = 'gravatar';
                                    $update['pp_gravatar'] = $r['avatar_location'];
                                    $md5Gravatar = md5($update['pp_gravatar']);
                                    $_url = "http://www.gravatar.com";
                                    if ($this->registry->output->isHTTPS) {
                                        $_url = "https://secure.gravatar.com";
                                    }
                                    $update['pp_main_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                                    $update['pp_main_width'] = 100;
                                    $update['pp_main_height'] = 100;
                                    $update['pp_thumb_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                                    $update['pp_thumb_width'] = 100;
                                    $update['pp_thumb_height'] = 100;
                                }
                            }
                        } else {
                            if ($r['pp_main_photo']) {
                                $update['pp_photo_type'] = 'custom';
                                $update['pp_main_photo'] = $r['pp_main_photo'];
                            }
                        }
                    }
                }
            }
            if (!$skipRebuild and $update['pp_photo_type'] == 'custom') {
                $info = $photo->buildSizedPhotos(str_replace('upload:', '', $update['pp_main_photo']), $r['pp_member_id'], true);
                $update['pp_main_width'] = intval($info['final_width']);
                $update['pp_main_height'] = intval($info['final_height']);
                $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
                $update['pp_thumb_width'] = intval($info['t_final_width']);
                $update['pp_thumb_height'] = intval($info['t_final_height']);
            }
            if (count($update)) {
                $this->DB->update('profile_portal', $update, 'pp_member_id=' . $r['pp_member_id']);
            }
        }
        /* Show message and redirect */
        if ($did > 0) {
            $this->request['st'] = $st + $did;
            $this->request['workact'] = 'photos';
            $message = $skipRebuild ? "{$this->request['st']} фотографий сконвертировано ..." : "{$this->request['st']} фотографий сконвертировано и перестроено...";
            $this->registry->output->addMessage($message);
            /* Yes, we are being sneaky here.  Shhhhh */
            $this->request['st'] = $this->request['st'] . '&amp;from=' . $this->request['from'] . '&amp;skip=' . $skipRebuild;
        } else {
            $this->request['st'] = 0;
            $this->request['workact'] = '';
            $this->registry->output->addMessage("Все фотографии сконвертированы...");
        }
        /* Next Page */
        return;
    }
コード例 #3
0
    /**
     * Convert and rebuild photos
     * 
     * @param	int
     * @return	@e void
     */
    public function convertPhotos()
    {
        /* Is this the first cycle? */
        if (!$this->request['from']) {
            $this->_output = <<<EOF

<h2>Profile Photo Conversion</h2>
<div class='message unspecified'>
\tIP.Board 3.2 supports one image to identify each user.  You can choose to retain your existing avatars or your existing profile photos for this image.
\t<br />
\t<select name='from'>
\t\t<option value='avatars'>Use avatars</option>
\t\t<option value='photos'>Use profile photos</option>
\t</select>
\t<br />
\tThe image you save will need to be rebuilt.  You can let the upgrader handle this now, or you can skip this step and complete it later from the ACP.
\t<br /><br />
\t<input type='radio' name='skip' value='0' checked='checked' /> Rebuild thumbnails now<br />
\t<input type='radio' name='skip' value='1' /> Skip this step and rebuild thumbnails from the ACP later
EOF;
            return;
        }
        /* Our options */
        $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
        $skipRebuild = intval($this->request['skip']);
        /* Init */
        $st = intval($this->request['st']);
        $did = 0;
        $each = 200;
        require_once IPS_ROOT_PATH . 'sources/classes/member/photo.php';
        /*noLibHook*/
        $photo = new classes_member_photo($this->registry);
        /* Loop over members */
        $this->DB->build(array('select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array($st, $each)));
        $outer = $this->DB->execute();
        while ($r = $this->DB->fetch($outer)) {
            $did++;
            $update = array();
            if ($r['fb_photo']) {
                $update['pp_photo_type'] = 'facebook';
            } else {
                if ($r['tc_photo']) {
                    $update['pp_photo_type'] = 'twitter';
                } else {
                    if ($convertFrom == 'avatars') {
                        if ($r['avatar_type'] == 'upload' and $r['avatar_location']) {
                            $update['pp_photo_type'] = 'custom';
                            $update['pp_main_photo'] = $r['avatar_location'];
                            $_dims = @getimagesize($this->settings['upload_dir'] . '/' . $r['avatar_location']);
                            $update['pp_main_width'] = $_dims[0] ? $_dims[0] : 1;
                            $update['pp_main_height'] = $_dims[1] ? $_dims[1] : 1;
                        } else {
                            if ($r['avatar_type'] == 'gravatar') {
                                $update['pp_photo_type'] = 'gravatar';
                                $update['pp_gravatar'] = $r['avatar_location'];
                                $md5Gravatar = md5($update['pp_gravatar']);
                                $_url = "http://www.gravatar.com";
                                if ($this->registry->output->isHTTPS) {
                                    $_url = "https://secure.gravatar.com";
                                }
                                $update['pp_main_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                                $update['pp_main_width'] = 100;
                                $update['pp_main_height'] = 100;
                                $update['pp_thumb_photo'] = $_url . "/avatar/" . $md5Gravatar . "?s=100";
                                $update['pp_thumb_width'] = 100;
                                $update['pp_thumb_height'] = 100;
                            }
                        }
                    } else {
                        if ($r['pp_main_photo']) {
                            $update['pp_photo_type'] = 'custom';
                            $update['pp_main_photo'] = $r['pp_main_photo'];
                        }
                    }
                }
            }
            if (!$skipRebuild and $update['pp_photo_type'] == 'custom') {
                $info = $photo->buildSizedPhotos(str_replace('upload:', '', $update['pp_main_photo']), $r['pp_member_id'], true);
                $update['pp_main_width'] = intval($info['final_width']);
                $update['pp_main_height'] = intval($info['final_height']);
                $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
                $update['pp_thumb_width'] = intval($info['t_final_width']);
                $update['pp_thumb_height'] = intval($info['t_final_height']);
            }
            if (count($update)) {
                $this->DB->update('profile_portal', $update, 'pp_member_id=' . $r['pp_member_id']);
            }
        }
        /* Show message and redirect */
        if ($did > 0) {
            $this->request['st'] = $st + $did;
            $this->request['workact'] = 'photos';
            $message = $skipRebuild ? "Up to {$this->request['st']} profile photos converted ..." : "Up to {$this->request['st']} profile photos converted and rebuilt...";
            $this->registry->output->addMessage($message);
            /* Yes, we are being sneaky here.  Shhhhh */
            $this->request['st'] = $this->request['st'] . '&amp;from=' . $this->request['from'] . '&amp;skip=' . $skipRebuild;
        } else {
            $this->request['st'] = 0;
            $this->request['workact'] = '';
            $this->registry->output->addMessage("All profile photos converted...");
        }
        /* Next Page */
        return;
    }