public function login() { $uid = $this->session->user->id; $token = md5(date('Ymd') . $this->session->user->id . $this->session->user->login . $this->session->user->login . 'HAHAAHAVOACABARCOMISSOJAJA'); $v = new Views(); $v->username = $this->session->user->login; $v->link = HOST . "meu-perfil/redes-sociais/nerdtrack/callback/?uid={$uid}&token={$token}"; $message = $v->render('mail/nerdtrack-link-account.phtml'); Phalanx::loadExtension('phpmailer'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail_status = true; try { $mail->AddReplyTo(MAIL_FROM, MAIL_ALIAS); $mail->AddAddress($this->post->email_address, $this->session->user->login); $mail->Subject = 'SkyNerd: Vínculo de conta da Nerdtrack'; $mail->MsgHTML($message); $mail->Send(); } catch (phpmailerException $e) { $mail_status = false; } header("Content-type: text/html; charset=utf-8"); if ($mail_status) { Phalanx::loadClasses('SocialNetwork'); SocialNetwork::link_account($this->session->user->id, NERDTRACK, $this->post->email_address, false); die('SUCCESS'); } else { die('FAIL'); } }
public function SendCancelAccountMail() { if ($this->session->took_the_first_step_to_cancel != 'yes') { Request::redirect(HOST . 'perfil/configuracoes/cancelar-conta'); return; } $v = new Views(); $v->link = HOST . 'perfil/configuracoes/cancelar-conta/confirmar?token=' . md5(date('Ymd') . $this->session->user->id . $this->session->user->login . $this->session->user->login . 'Na0NERDNa0CANC3LAAC0NTaCARa'); $v->username = $this->session->user->login; $message = $v->render('mail/cancel_account_request.phtml'); Phalanx::loadExtension('phpmailer'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail_status = true; try { $mail->AddReplyTo(MAIL_FROM, MAIL_ALIAS); $mail->AddAddress($this->session->user->email, $this->session->user->login); $mail->Subject = 'SkyNerd: Pedido de cancelamento de conta'; $mail->MsgHTML($message); $mail->Send(); } catch (phpmailerException $e) { $mail_status = false; print_r($mail); } if ($mail_status) { $this->session->message = 'AccountCancelationRequestReceived'; } else { $this->session->message = ''; } Request::redirect(HOST . 'perfil/configuracoes'); }
private function send_password_reset_email($token, $email, $login) { $v = new Views(); $v->username = $login; $v->link = HOST . 'esqueci-minha-senha/' . $token . '/'; $message = $v->render('mail/password_change_request.phtml'); Phalanx::loadExtension('phpmailer'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail_status = true; try { $mail->AddReplyTo(MAIL_FROM, MAIL_ALIAS); $mail->AddAddress($email, $login); $mail->Subject = 'SkyNerd: Troca de senha'; $mail->MsgHTML($message); $mail->Send(); } catch (phpmailerException $e) { $mail_status = false; var_dump($mail); } if ($mail_status) { $this->session->message = 'PasswordChangeEmailSent'; } else { $this->session->message = 'PasswordChangeEmailNOTSent'; } Request::redirect(HOST . 'login'); }
public function confirm_avatar_change() { #Goodbye, XSS if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); return; } $filename = $this->session->new_avatar_tmp_name; $fileext = @strtolower(end(explode('.', $filename))); $resource = imagecreatetruecolor($this->post->w, $this->post->h); switch ($fileext) { case 'jpg': case 'jpeg': $imageTmp = imagecreatefromjpeg($filename); break; case 'png': $imageTmp = imagecreatefrompng($filename); break; } $x = $this->post->x; $y = $this->post->y; $w = $this->post->w; $h = $this->post->h; imagecopyresampled($resource, $imageTmp, 0, 0, $x, $y, $w, $h, $w, $h); //Cria o novo, com os tamanhos que o usuário enviou $filename = md5(date('YmdHis') . $this->session->user->id . $filename) . '.jpg'; imagejpeg($resource, AVATAR_UPLOAD_DIR . $filename); //Agora eu crio as minhas imagens $xscale = $w / 278; $yscale = $h / 466; if ($yscale > $xscale) { $new_width = round($w * (1 / $yscale)); $new_height = round($h * (1 / $yscale)); } else { $new_width = round($w * (1 / $xscale)); $new_height = round($h * (1 / $xscale)); } $imageTmp = imagecreatefromjpeg(AVATAR_UPLOAD_DIR . $filename); $imageResized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $w, $h); imagejpeg($imageResized, AVATAR_UPLOAD_DIR . 'big/' . $filename, 100); $xscale = $w / 113; $yscale = $h / 192; if ($yscale > $xscale) { $new_width = round($w * (1 / $yscale)); $new_height = round($h * (1 / $yscale)); } else { $new_width = round($w * (1 / $xscale)); $new_height = round($h * (1 / $xscale)); } $imageTmp = imagecreatefromjpeg(AVATAR_UPLOAD_DIR . $filename); $imageResized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $w, $h); imagejpeg($imageResized, AVATAR_UPLOAD_DIR . 'small/' . $filename, 100); $xscale = $w / 45; $yscale = $h / 75; if ($yscale > $xscale) { $new_width = round($w * (1 / $yscale)); $new_height = round($h * (1 / $yscale)); } else { $new_width = round($w * (1 / $xscale)); $new_height = round($h * (1 / $xscale)); } $imageTmp = imagecreatefromjpeg(AVATAR_UPLOAD_DIR . $filename); $imageResized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $w, $h); imagejpeg($imageResized, AVATAR_UPLOAD_DIR . 'square/' . $filename, 100); imagedestroy($imageResized); @unlink(AVATAR_UPLOAD_DIR . $filename); @unlink($this->session->new_avatar_tmp_name); unset($this->session->new_avatar_tmp_name); $m = Model::Factory('user_data'); $m->avatar = $filename; $m->where("user_id='{$this->session->user->id}'"); if (!$m->update()) { $m->user_id = $this->session->user->id; $m->insert(); } # Phalanx::loadClasses('Notification'); # $n = new Notification(Notification::CHANGED_AVATAR, $this->session->user->id, null); $this->session->user->other_data->avatar = $filename; Phalanx::loadExtension('S3'); $s3 = new S3(S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY); $s3->putObjectFile(AVATAR_UPLOAD_DIR . "big/{$filename}", S3_BUCKET_NAME, "media/images/avatar/big/{$filename}", S3::ACL_PUBLIC_READ); $s3->putObjectFile(AVATAR_UPLOAD_DIR . "small/{$filename}", S3_BUCKET_NAME, "media/images/avatar/small/{$filename}", S3::ACL_PUBLIC_READ); $s3->putObjectFile(AVATAR_UPLOAD_DIR . "square/{$filename}", S3_BUCKET_NAME, "media/images/avatar/square/{$filename}", S3::ACL_PUBLIC_READ); header("Content-type: text/html; charset=utf-8"); die($filename); }
public function Export() { Phalanx::loadClasses('Profile', 'Badges'); $profile = Profile::get_profile($this->session->user->login, 0, 0, 0, 0, 1, 1, 1); $profile->badges = Badges::from_user($this->sessio->user->id, false); $t = new Template("export"); $t->show_login_bar = true; $userPosts = Posts::exportFromUser($this->session->user->id); $postsImages = array(); $avatarImages = array(); $posts = array(); Phalanx::loadExtension('simple_html_dom'); foreach ($userPosts as $key => $each) { $html = str_get_html($each->content); /* * Em alguns casos o objeto não está sendo criado, gerando um fatal error. * Conteúdo vazio? Estranho, ainda não sei o que está rolando. * Isso aqui resolve. * */ if (is_object($html)) { $images = $html->find('img'); foreach ($images as &$image) { if (stripos($image, HOST)) { $postsImages[] = basename($image->src); $image->src = "./images/posts/" . basename($image->src); } } $each->content = $html; } $avatarImages[] = $each->avatar; $v = new Views(); $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id); $v->current_user = $this->session->user->login; $v->user = $each->user; $v->name = $each->name; $v->when = $each->date; $v->title = $each->title; $v->content = $each->content; $v->comments = $each->comments; $v->comments_array = $each->comments_array; $v->replies = $each->replies; $v->post_id = $each->id; $v->original_id = $each->original_id; $v->is_reblogged = $each->is_reblogged; $v->avatar = $each->avatar; $v->rating = $each->rating; $v->my_rating = $each->my_rating; $v->categories = $each->categories; $v->its_mine = $profile_data->id == $this->session->user->id ? true : false; $v->is_favorite = $each->is_favorite; $v->user_points = $each->user_points; foreach ($each->comments_array as $eachComment) { $avatarImages[] = $eachComment->user->avatar; foreach ($eachComment->replies as $eachReply) { $avatarImages[] = $eachReply->user->avatar; } } if (!empty($each->original_id)) { //Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações $originalPost = Posts::from_user(false, $v->original_id); $originalPost = reset($originalPost); $v->content = $originalPost->content; $v->title = $originalPost->title; $v->reblogged_from = $originalPost->user; $v->reblog_avatar = $originalPost->avatar; $v->reblog_points = $originalPost->user_points; $v->original_date = $originalPost->date; $v->comments = $originalPost->comments; $v->replies = $originalPost->replies; $v->is_favorite = $originalPost->is_favorite; $v->categories = $originalPost->categories; $v->rating = $originalPost->rating; $v->id = $v->post_id; $v->post_id = $originalPost->id; } $content = $v->render("export/post_body.phtml"); $posts[] = $content; } $v = new Views($t); $v->data = $profile; $v->data->timeline = $posts; ob_start(); $v->display("export/profile.phtml"); $profile_html_data = ob_get_contents(); ob_end_clean(); if (!is_dir(TMP_DIR . DIRECTORY_SEPARATOR . 'export')) { mkdir(TMP_DIR . DIRECTORY_SEPARATOR . 'export', 0755, true); } $dirname = TMP_DIR . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . $this->session->user->login . DIRECTORY_SEPARATOR; if (!is_dir($dirname)) { mkdir($dirname, 0755, true); } $filename = "perfil-{$this->session->user->login}.html"; file_put_contents($dirname . $filename, $profile_html_data); $zip = new ZipArchive(); if ($zip->open("{$dirname}data.zip", ZipArchive::CREATE) === TRUE) { $zip->addEmptyDir('css'); foreach (glob(TEMPLATE_DIR . '/export/css/*') as $file) { $zip->addFile($file, "/css/" . basename($file)); } $zip->addEmptyDir('js'); foreach (glob(TEMPLATE_DIR . '/export/js/*') as $file) { $zip->addFile($file, "/js/" . basename($file)); } $zip->addEmptyDir('fonts'); $zip->addEmptyDir('fonts/Engschrift'); foreach (glob(TEMPLATE_DIR . '/export/fonts/Engschrift/*') as $file) { $zip->addFile($file, "/fonts/Engschrift/" . basename($file)); } $zip->addEmptyDir('images'); foreach (glob(TEMPLATE_DIR . '/export/images/*.*') as $file) { $zip->addFile($file, "/images/" . basename($file)); } $zip->addEmptyDir('images/socialnetworks'); foreach (glob(TEMPLATE_DIR . '/export/images/socialnetworks/*') as $file) { $zip->addFile($file, "/images/socialnetworks/" . basename($file)); } $zip->addEmptyDir('images/images'); foreach (glob(TEMPLATE_DIR . '/export/images/images/*') as $file) { $zip->addFile($file, "/images/images/" . basename($file)); } $zip->addEmptyDir('images/avatar'); $zip->addEmptyDir('images/avatar/big'); $zip->addEmptyDir('images/avatar/small'); $zip->addEmptyDir('images/avatar/square'); foreach ($avatarImages as $avatar) { $zip->addFile(AVATAR_UPLOAD_DIR . "/big/{$avatar}", "/images/avatar/big/{$avatar}"); $zip->addFile(AVATAR_UPLOAD_DIR . "/small/{$avatar}", "/images/avatar/small/{$avatar}"); $zip->addFile(AVATAR_UPLOAD_DIR . "/square/{$avatar}", "/images/avatar/square/{$avatar}"); } $zip->addEmptyDir('images/posts'); foreach ($postsImages as $image) { $zip->addFile(POST_IMAGES_UPLOAD_DIR . "/{$image}", "/images/posts/{$image}"); } $zip->addEmptyDir('images/badges'); foreach (glob(ROOT . PROJECT_DIR . '/media/images/badges/*') as $file) { $zip->addFile($file, "/images/badges/" . basename($file)); } $zip->addFile("{$dirname}{$filename}", "/{$filename}"); } $zip->close(); header("Content-disposition: attachment; filename={$this->session->user->login}.zip"); header("Content-type: application/zip"); readfile("{$dirname}data.zip"); $t = new Template("export", "thankyou.phtml"); $v = new Views($t); $v->display(""); $c = new Cookies(); $c->setExpire(strtotime("+15 days")); $c->data_exported = 1; }
public function proccess() { Phalanx::loadClasses('Cats'); $cat_id = $this->get->cat_id; $c = Model::Factory('cats'); $c->where("id = {$cat_id}"); $gato = $c->get(); $m = Model::Factory('cats_interests'); $m->cats_id = $this->post->cat_id; $m->name = $this->post->name; $m->email = $this->post->email; $m->telephone = $this->post->telephone; $m->age = $this->post->age; $m->address = $this->post->address; $m->address_number = $this->post->address_number; $m->address_complement = $this->post->address_complement; $m->address_neighborhood = $this->post->address_neighborhood; $m->address_city = $this->post->address_city; $m->address_state = $this->post->address_state; $m->number_of_adults_at_home = $this->post->number_of_adults_at_home; $m->number_of_kids_at_home = $this->post->number_of_kids_at_home; $m->kids_age = $this->post->kids_age; $m->why_adopt_a_cat = $this->post->why_adopt_a_cat; $m->owner_accept_pets = $this->post->owner_accept_pets; $m->lives_in = $this->post->lives_in; $items_that_block_ur_cat = array(); foreach ($this->post->items_that_block_your_cat as $item) { $items_that_block_ur_cat[] = $item; } $m->items_that_block_your_cat = implode("\n", $items_that_block_ur_cat); ////////AIEEE $have_other_petss = array(); foreach ($this->post->have_other_pets as $item) { $have_other_petss[] = $item; } $m->have_other_pets = implode("\n", $have_other_petss); $items_that_your_house_have = array(); foreach ($this->post->items_that_your_house_have as $item) { $items_that_your_house_have[] = $item; } $m->items_that_your_house_have = implode("\n", $items_that_your_house_have); $house_window_types = array(); foreach ($this->post->house_window_types as $item) { $house_window_types[] = $item; } $m->house_window_types = implode("\n", $house_window_types); $m->already_had_a_cat = $this->post->already_had_a_cat; $m->what_happened_to_your_cats = $this->post->what_happened_to_your_cats; $m->have_other_pets = $this->post->have_other_pets; $m->cat_qtty = $this->post->cat_qtty; $m->have_monetary_conditions = $this->post->have_monetary_conditions; $m->someone_has_allergy = $this->post->someone_has_allergy; $m->what_youll_do_when_someone_gets_pregnant = $this->post->what_youll_do_when_someone_gets_pregnant; $m->what_youll_do_if_the_cat_scratches_your_son = $this->post->what_youll_do_if_the_cat_scratches_your_son; $m->what_youll_do_if_you_lose_your_cat = $this->post->what_youll_do_if_you_lose_your_cat; $m->what_youll_do_if_you_cant_take_care_of_the_cat_anymore = $this->post->what_youll_do_if_you_cant_take_care_of_the_cat_anymore; $m->cats_can_live_more_than_fifteen_years = $this->post->cats_can_live_more_than_fifteen_years; $m->house_can_be_revisited = $this->post->house_can_be_revisited; $m->deliver_the_cat_back = $this->post->deliver_the_cat_back; $m->do_not_repass_the_cat = $this->post->do_not_repass_the_cat; $m->tell_us_about_address_change = $this->post->tell_us_about_address_change; $m->sign_an_adoption_contract = $this->post->sign_an_adoption_contract; $m->comments = $this->post->comments; $how_you_met_aug = array(); foreach ($this->post->how_you_met_aug as $item) { $how_you_met_aug[] = $item; } $m->how_you_met_aug = implode("\n", $how_you_met_aug); $status = $m->insert(); if ($status) { $msg = nl2br("Olá! Recebemos um pedido de adoção:\n\n Gato: {$gato->name}\n \n <b>Sobre você e sua família</b>\n\n <em>Nome:</em> {$this->post->name}\n <em>E-Mail:</em> {$this->post->email}\n <em>Telefone:</em> {$this->post->telephone}\n <em>Idade:</em> {$this->post->age}\n <em>Endereço:</em> {$this->post->address}\n <em>Número:</em> {$this->post->address_number}\n <em>Complemento:</em> {$this->post->address_complement}\n <em>Bairro:</em> {$this->post->address_neighborhood}\n <em>Cidade:</em> {$this->post->address_city}\n <em>Estado:</em> {$this->post->address_state}\n <em>Número de adultos na casa:</em> {$this->post->number_of_adults_at_home}\n\n "); if ($this->post->number_of_kids_at_home > 0) { $msg .= nl2br("<em>Tenho</em> {$this->post->number_of_kids_at_home} <em>crianças de</em> {$this->post->kids_age} <em>anos</em>\n "); } $msg .= nl2br("\n <em>Por que adotar um gatinho?</em>\n {$this->post->why_adopt_a_cat}\n\n <b>Sobre a sua casa</b>\n\n <em>Se sua casa é alugada, o proprietário permite animais?</em> {$this->post->owner_accept_pets}\n\n <em>Você mora em:</em> {$this->post->lives_in}\n "); if ($this->post->lives_in == "CASA FECHADA") { $msg .= nl2br("\n <em>Itens que impedem o gatinho de sair para rua e telhados:</em>\n {$m->items_that_block_your_cat}\n "); } if ($this->post->lives_in == "APARTAMENTO COM TELAS") { $msg .= nl2br("<em>Se assinalou \"Apartamento com telas\":</em>\n {$m->items_that_block_your_cat}\n "); } if ($this->post->lives_in == "APARTAMENTO SEM TELAS") { $msg .= nl2br("<em>Se assinalou \"Apartamento sem telas\":</em>\n {$m->items_that_block_your_cat}\n "); } if ($this->post->lives_in == "COBERTURA COM TELAS") { $msg .= nl2br("<em>Se assinalou \"Cobertura com telas\":</em>\n {$m->items_that_block_your_cat}\n "); } if ($this->post->lives_in == "COBERTURA SEM TELAS") { $msg .= nl2br("<em>Se assinalou \"Cobertura sem telas\":</em>\n {$m->items_that_block_your_cat}\n "); } $msg .= nl2br("\n <em>Para qualquer tipo de casa ou apartamento, responda se você possui:</em>\n {$m->items_that_your_house_have}\n "); $msg .= nl2br("\n <em>E sobre as basculantes, elas são de que tipo:</em>\n {$m->house_window_types}\n "); $msg .= nl2br("\n <b>Seus animais</b>\n\n <em>Já teve gatos?</em> {$this->post->already_had_a_cat}\n "); if ($this->post->already_had_a_cat == "SIM") { $msg .= nl2br("<em>Se você já teve gatos, o que aconteceu com eles?</em>\n {$this->post->what_happened_to_your_cats}\n\n "); } ////AIEE // $msg .= nl2br("<em>Tem outros animais em casa?</em> {$this->post->have_other_pets} // "); $msg .= nl2br("<em>Tem outros animais em casa?</em> {$m->have_other_petss}\n "); if ($this->post->have_other_pets == "SIM GATO") { $msg .= nl2br("<em>Quantos gatos você tem?</em> {$this->post->cat_qtty}\n "); } $msg .= nl2br("\n <b>Adoção é compromisso e responsabilidade</b>\n\n <em>Você tem condições de acrescentar no seu orçamento os gastos que terá com alimentação de boa qualidade (aproximadamente R\$70 por mês), vacinas e atendimento veterinário (aproximadamente R\$180 anualmente)?</em>\n {$this->post->have_monetary_conditions}\n\n <em>Alguém em casa tem alergia?</em>\n {$this->post->someone_has_allergy}\n\n <em>O que fará com o gatinho se alguém na casa engravidar?</em>\n {$this->post->what_youll_do_when_someone_gets_pregnant}\n\n <em>O que fará se o gato arranhar o seu filho?</em>\n {$this->post->what_youll_do_if_the_cat_scratches_your_son}\n\n <em>O que fará se perder o gatinho?</em>\n {$this->post->what_youll_do_if_you_lose_your_cat}\n\n <em>O que fará se não puder cuidar mais do gatinho?</em>\n {$this->post->what_youll_do_if_you_cant_take_care_of_the_cat_anymore}\n \n <em>O que fará se tiver que mudar de cidade ou país?</em>\n {$this->post->what_youll_do_if_you_move_from_city_or_country}\n\n <em>Gatos podem viver 15 anos ou mais. Você está preparado para este compromisso?</em>\n {$this->post->cats_can_live_more_than_fifteen_years}\n\n <b>Condições</b>\n\n <em>Você concorda que sua casa seja vistoriada para averiguação das respostas acima?</em>\n {$this->post->house_can_be_revisited}\n\n <em>Você concorda em nos devolver o gatinho se por qualquer motivo não puder continuar com ele?</em>\n {$this->post->deliver_the_cat_back}\n\n <em>Você concorda em não repassar o gatinho a ninguém sem antes nos consultar?</em>\n {$this->post->do_not_repass_the_cat}\n\n <em>Você concorda em nos avisar em caso de alteração de endereço, telefone, etc?</em>\n {$this->post->tell_us_about_address_change}\n\n <em>Você concorda em assinar um contrato de adoção no ato da entrega, responsabilizando pelos cuidados com o animal e sua segurança?</em>\n {$this->post->sign_an_adoption_contract}\n\n <b>Comentários</b>\n\n <em>Escreva neste espaço tudo o que julgar necessário, inclusive qualquer dúvida que você tiver sobre a adoção:</em>\n {$this->post->comments}\n\n <em>Como você conheceu o AUG?</em>\n {$m->how_you_met_aug}\n\n --\n Adote um Gatinho\n " . date("d/m/Y H:i") . ""); // foreach($this->post->items_that_block_your_cat as $item) // { // $items_that_block_ur_cat[] = $item; // } $user = Cats::get_responsible($this->post->cat_id); Phalanx::loadExtension('phpmailer'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = "smtp.adoteumgatinho.com.br"; $mail->Port = 587; $mail->Username = "******"; $mail->Password = "******"; $mail->IsHTML(true); $mail->CharSet = 'UTF-8'; $mail->SetFrom("*****@*****.**", "Adote um Gatinho"); $mail->AddReplyTo($this->post->email, $this->post->nome); $mail->AddAddress($user[0]->email); if (!$user) { $mail->AddAddress("*****@*****.**"); } $mail->Subject = "Formulário de Adoção - Gato: {$gato->name} - AUG"; $mail->MsgHTML($msg); //$mail->SMTPDebug = 1; if (!$mail->Send()) { echo 'Mailer error: ' . $mail->ErrorInfo; } $mail->ClearAllRecipients(); $mail->ClearAttachments(); Request::redirect(HOST . 'pedido-processado-com-sucesso'); } else { Request::redirect(HOST . 'falha-ao-processar-pedido'); } }