Exemple #1
0
 private function addBot(BotNick $nick, $dateBorn, BotData $data = null)
 {
     $bot = new sfGuardUser();
     $botProfile = new sfGuardUserProfile();
     $botProfile->setUser($bot);
     $Bot = new Bot();
     $bot->username = $nick->nick;
     $bot->email_address = ($data ? $data->uid : md5($nick->nick . "uberlov mail")) . "@uberlov.ru";
     $bot->created_at = $dateBorn;
     $bot->updated_at = $dateBorn;
     $bot->last_login = $dateBorn;
     if (!empty($data)) {
         if (isset($data->userpic) && strstr($data->userpic, 'jpg')) {
             $userpic = new sfThumbnail(48, 48, false);
             $userpic->loadFile("Z:/home/ht/www/images/userpic/bot/" . $data->userpic);
             $name = md5($data->uid . 'userpic f**k yea') . '.png';
             $userpic->save(sfConfig::get('sf_user_pic_dir') . $name, 'image/png');
             $botProfile->userpic = $name;
         }
         if (isset($data->name)) {
             $names = explode(" ", $data->name);
             $bot->last_name = isset($names[1]) ? $names[1] : "";
             $bot->first_name = isset($names[0]) ? $names[0] : "";
         }
         $Bot->setBotDataId($data->id);
         $this->activeBots->add($bot);
     }
     $botProfile->sex = 1;
     $botProfile->validate_at = $dateBorn;
     $botProfile->created_at = $dateBorn;
     $botProfile->updated_at = $dateBorn;
     $bot->save();
     $botProfile->save();
     $Bot->setBotNickId($nick->id);
     $Bot->setProfileId($botProfile->id);
     $Bot->save();
     $this->totalBots++;
 }