/** * Init scan process. * Solution for realtime output find on: http://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php * Maybe ugly, but sometimes at 3AM it's only what is getting out of head ;-) */ public function initScan() { $view = new Views('templates/head.tpl.php'); $view->set('class', 'scanner'); print $view->render(); set_time_limit(0); $handle = popen(PHP . " scanner.php " . $this->project_id, "r"); if (ob_get_level() == 0) { ob_start(); } while (!feof($handle)) { $buffer = fgets($handle); $buffer = trim(htmlspecialchars($buffer)); $data = explode(';', $buffer); switch ($data[0]) { case 'FOUND': print "<div class=\"infobox\"><h3>Found something</h3><p><strong>Time:</strong> " . $data[1] . "<br><strong>Filter name:</strong> " . $data[2] . "<br><strong>Line:</strong> " . $data[3] . "<br><strong>File:</strong> " . $data[4] . "</p><a href=\"/report/" . $data[5] . "\" target=\"_blank\"><span class=\"button warning_button\" style=\"\">Show report</span></a></div>"; break; case 'NOT_FOUND': print "<div class=\"infobox\"><h3>WOW!</h3><p>Scanner didn't found anything. So your project is sooo secure. You are security mastah, or the filters are too weak ;-) Anyway, I recommend to do a manual code review, to be 100% sure ;-)</p></div>"; break; case 'SCANNED': print "<div class=\"infobox\"><h3>Hmmmm...</h3><p>Your project has been scanned before. Please go to project to check your reports. <br><a href=\"/show/" . $this->project_id . "\" target=\"_parent\"><span class=\"button\">Go to project page</span></a></p></div>"; break; } ob_flush(); flush(); time_nanosleep(0, 10000000); } pclose($handle); ob_end_flush(); }
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'); }
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'); } }
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'); }
function main() { session_start(); $views = new Views(); $models = new Models('localhost', 'hallas', '40352246', 'thehallas'); $route = new Route($_SERVER['REQUEST_URI']); require_once CONTROLLERS . '/' . $route->getParam(1) . '.php'; $controller = eval('return new ' . $route->getParam(1) . '($views, $models, $route);'); if (!$route->getParam(2)) { $controller->index(); } else { eval('$controller->' . $route->getParam(2) . '();'); } $views->render(); }
public function UserCard() { Phalanx::loadController("LoginController"); $loginController = new LoginController(); $status = $loginController->isLoggedIn(); if ($status) { $v = new Views(); $v->login = $this->session->user->login; $v->avatar = $this->session->user->other_data->avatar; $v->experience = Profile::experience($this->session->user->id); $v->badges = Badges::from_user($this->session->user->id, 4); echo $v->render("user_mini_card.phtml"); } else { $v = new Views(); echo $v->render("user_mini_card_login.phtml"); } }
function main() { session_start(); $views = new Views(); $models = new Models('localhost', 'fadl', 'vaip', 'fadl'); $route = new Route($_SERVER['REQUEST_URI']); if ($route->getParam(1)) { require_once CONTROLLERS . '/' . $route->getParam(1) . '.php'; $controller = eval('return new ' . $route->getParam(1) . '($views, $models, $route);'); } else { header('location: /Welcome/'); } if (!$route->getParam(2)) { $controller->index(); } else { eval('$controller->' . $route->getParam(2) . '();'); } $views->render(); }
public function DisplayWordpressPost() { Phalanx::loadController('LoginController'); $loginController = new LoginController(); $this->isLoggedIn = $loginController->isLoggedIn(); Phalanx::loadClasses('public.Posts', 'public.PostComments'); $post = Posts::GetWPPostData($this->get->post_id, $this->session->user->id, true); $slug = mb_strtolower(preg_replace('/--+/u', '-', preg_replace('/[^\\w\\-]+/u', '-', $post->content->post_title))); if ($slug != $this->get->slug) { Request::redirect_301(HOST . "site/post/{$this->get->post_id}-{$slug}"); } $v = new Views(); $v->title = $post->content->post_title; $v->content = $post->content->post_content; $v->comments = $post->comments; $v->comments_array = PostComments::get($post->post_id); $v->replies = $post->replies; $v->post_id = $post->post_id; $v->rating = $post->rating; $v->when = Date::RelativeTime($post->content->post_date); $v->my_rating = $p->my_rating; $v->current_user = $this->session->user->login; $v->is_favorite = $p->is_favorite; $content = $v->render("post_body_wp.phtml"); $template = new Template("default"); $template->og = new stdClass(); $template->og->title = $v->title; $template->og->description = substr(strip_tags($content), 0, 250); //$template->og->img = MEDIA_DIR . 'images/avatar/big/' . $profile_data->aditional_info->avatar; if (!$this->isLoggedIn) { $template->show_login_bar = true; } $v = new Views($template); $v->data = new stdClass(); $v->data->post = $content; $v->display("single_post_display.phtml"); }
public function Render($data) { Phalanx::loadClasses('Profile'); $posts = array(); foreach ($data as $key => $each) { $v = new Views(); $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id); $v->original_id = $each->original_id; $v->reblog_count = $each->reblog_count; $v->is_reblogged = $each->is_reblogged; $v->current_user = $this->session->user->login; $v->user = $each->user; $v->title = $each->title; $v->name = $each->name; $v->when = $each->when ? $each->when : $each->date; $v->content = $each->content; $v->via = $each->via; $v->comments = $each->comments; $v->replies = $each->replies; $v->rating = $each->rating; $v->my_rating = $each->my_rating; $v->post_id = $each->id; $v->avatar = $each->avatar; $v->categories = $each->categories; $v->is_favorite = $each->is_favorite; $v->is_reblogged = $each->is_reblogged; $v->its_mine = $each->user_id == $this->session->user->id ? true : false; $v->user_points = $each->user_points; $v->promoted = (bool) $each->promoted; 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("post_body.phtml"); $posts[] = $content; } return $posts; }
public function avatar_upload_frame() { $v = new Views(); echo $v->render("iframe_avatar_upload_fallback.phtml"); }
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 report($report_file_signature) { $reports = $this->db->getReports($report_file_signature); //Check if report exists if (!empty($reports)) { $project = $this->db->getProjectInfo($reports[0]['project_id']); $file_name = $reports[0]['report_file']; $reports_template = new Views('templates/reports.tpl.php'); $reports_template->set('header', $reports_template->addHeader()); $reports_template->set('footer', $reports_template->addFooter()); $reports_template->set('file_name', $file_name); foreach ($project as $key => $value) { $reports_template->set($key, $value); } foreach ($reports as $id => $reports_list) { $code = (array) json_decode($reports_list['report_code']); $reports_table = new Views('templates/report_info.tpl.php'); $reports_table->set('report_id', $reports_list['report_id']); $reports_table->set('report_language', $reports_list['report_language']); $reports_table->set('report_type', $reports_list['report_type']); $reports_table->set('report_line', $reports_list['report_line']); $reports_table->set('report_code', htmlentities(implode($code))); $reports_table->set('report_first_line', key($code)); $reports_table->set('report_ticket', $reports_list['report_ticket']); $reports_table->set('report_false', $reports_list['report_false'] == 0 ? 'false' : ''); $reports_data[$id] = $reports_table; } $reports_contest = Views::merge($reports_data); $reports_template->set('project_reports', $reports_contest); print $reports_template->render(); } //If not redirect to / header('Location: /'); die; }
public function DisplayOldPosts() { $profile_data = Profile::get_profile($this->post->profile, 0, 0, 0, 0, 0, 0, 0); $profile = $this->post->profile; if (property_exists($this->session->times_reloaded, "profile_{$profile}")) { $this->session->times_reloaded->{"profile_{$profile}"} += 1; } else { $this->session->times_reloaded->{"profile_{$profile}"} = 1; } $p = Posts::from_user($profile_data->id, false, $this->post->min_id, $this->post->max_id); $posts = array(); foreach ($p as $key => $each) { $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->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; 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->rating->reblog_count = $originalPost->rating->reblog_count; $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("post_body.phtml"); $posts[] = $content; } header("Content-type: text/html; charset=utf-8"); foreach ($posts as $postHTML) { echo $postHTML; } }
public function GetComments() { $post_id = $this->post->post_id != '' ? $this->post->post_id : false; $cache_time = MEMCACHE_SECONDS; if (!$post_id) { Phalanx::loadClasses('Posts'); $post = Posts::GetWPPost($this->get->wpid); $post_id = $post ? $post->id : false; $cache_time = 180; } $comments = array(''); header("Content-type: text/html; charset=utf-8"); if ($post_id) { Phalanx::loadClasses("PostComments"); $comments = PostComments::get($post_id, $cache_time, $this->get->sort); foreach ($comments as &$comment) { $comment->comment = preg_replace('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', '<a class="profile-link" href="' . HOST . 'perfil/$1"e>@$1</a>', nl2br($comment->comment)); foreach ($comment->replies as &$reply) { $reply->comment = preg_replace('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', '<a class="profile-link" href="' . HOST . 'perfil/$1"e>@$1</a>', nl2br($reply->comment)); } } } if ($this->get->render) { Phalanx::loadController('LoginController'); $loginController = new LoginController(); $v = new Views(); $v->comments = $post->comment_count; $v->replies = $post->reply_count; $v->comments_array = $comments; $v->post_id = $post_id; $v->logged_in = $loginController->isLoggedIn(); echo $v->render('post_comments.phtml'); } else { die(json_encode($comments)); } }