& Matías Parodi # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ## if (!defined("SECURITY")) { exit; } if (!empty($username)) { $action = safe_str($_GET['action']); if (empty($action)) $action = 'general'; if (is_numeric($action) === true) { $permalink = safe_str($action, true); unset($_GET['action'], $action); } if (empty($permalink)) { if ($_SESSION['USERNAME'] == $username) header("Location: {$base}notes"); $sql = " SELECT `users`.`id_user` FROM `users` WHERE (`users`.`username` = '" . $username . "');"; $result = mysql_query($sql); if (mysql_affected_rows() == 1) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $id_user = $row['id_user']; echo '

'; if ($_SESSION['LOGIN'] === true) { do_note_form(); } echo '
'; $page = safe_str($_GET['p']); if (empty($page)) { $page = '1'; } if ($page > 0) { $start_reg = ($page - 1) * $CONFIG['NOTES_2p']; } else { $start_reg = 0; } switch ($action) { case 'general': /* $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` INNER JOIN `suscriptions` ON `suscriptions`.`id_user` = `notes`.`id_user` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` WHERE ((`notes`.`id_user` = '" . $id_user . "') AND (`notes`.`type` != 'private') AND (`groups`.`type` = 'public')) ORDER BY `notes`.`date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; */ $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`notes`.`id_user` = '" . $id_user . "') AND (`notes`.`type` IN ('', 'reply', 'group'))) ORDER BY `notes`.`date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; break; case 'replies': $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`notes`.`type` = 'reply') AND ((`notes`.`id_user` = '" . $id_user . "') OR (`notes`.`to` LIKE '" . $username . "'))) ORDER BY `notes`.`date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; break; /* case 'groups': $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `suscriptions` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` INNER JOIN `notes` ON `notes`.`to` = `groups`.`name` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`suscriptions`.`id_user` = '" . $id_user ."') AND (`groups`.`type` = 'public') AND (`notes`.`type` = 'group')) ORDER BY `notes`.`date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; break; */ case 'friends': /* $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `followers` INNER JOIN `notes` ON `notes`.`id_user` = `followers`.`id_follower` INNER JOIN `users` ON `users`.`id_user` = `followers`.`id_follower` INNER JOIN `suscriptions` ON `suscriptions`.`id_user` = `notes`.`id_user` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` WHERE ((`followers`.`id_user` = '" . $id_user . "') AND (`groups`.`type` = 'public') AND (`notes`.`type` != 'private')) ORDER BY `notes`.`date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; */ $sql = " ( SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `followers` INNER JOIN `notes` ON `notes`.`id_user` = `followers`.`id_follower` INNER JOIN `users` ON `users`.`id_user` = `followers`.`id_follower` WHERE ((`followers`.`id_user` = '" . $id_user . "') AND (`notes`.`type` IN ('', 'reply', 'group'))) ORDER BY `date` DESC LIMIT {$CONFIG['NOTES_2p']} ) UNION DISTINCT ( SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`notes`.`id_user` = '" . $id_user . "') AND (`notes`.`type` IN ('', 'reply', 'group'))) ORDER BY `date` DESC LIMIT {$CONFIG['NOTES_2p']} ) ORDER BY `date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; break; case 'favorites': /* $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `favorites` INNER JOIN `notes` ON `notes`.`permalink` = `favorites`.`permalink` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` INNER JOIN `suscriptions` ON `suscriptions`.`id_user` = `notes`.`id_user` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` WHERE ((`favorites`.`id_user` = '" . $id_user . "') AND (`groups`.`type` = 'public') AND (`notes`.`type` != 'private')) ORDER BY `favorites`.`id_favorite` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; */ $sql = " SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `favorites` INNER JOIN `notes` ON `notes`.`permalink` = `favorites`.`permalink` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE (`favorites`.`id_user` = '" . $id_user . "') ORDER BY `date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; break; default: $action = 'favorites'; $sql = " ( SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `followers` INNER JOIN `notes` ON `notes`.`id_user` = `followers`.`id_follower` INNER JOIN `users` ON `users`.`id_user` = `followers`.`id_follower` WHERE ((`followers`.`id_user` = '" . $id_user . "') AND (`notes`.`type` != 'private')) LIMIT {$CONFIG['NOTES_2p']} ORDER BY `date` DESC ) UNION DISTINCT ( SELECT `notes`.*, `users`.`avatar`, `users`.`username` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`notes`.`id_user` = '" . $id_user . "') AND (`notes`.`type` IN ('', 'reply', 'group') )) LIMIT {$CONFIG['NOTES_2p']} ORDER BY `date` DESC ) ORDER BY `date` DESC LIMIT " . $start_reg . ", " . $CONFIG['NOTES_2p'] . ";"; } $result = mysql_query($sql); if (mysql_num_rows($result) != 0) { $first_note = true; while ($row = mysql_fetch_assoc($result)) { $note = html_entity_decode($row['note']); preg_match_all('/[^\s]{40,}/', $note, $matches); for ($i=0; $i" . $matches[2] . ""; case "/": return "" . $matches[2] . ""; case "_": return "" . $matches[2] . ""; case "-": return "" . $matches[2] . ""; } '), $note); $note = preg_replace('/(?:[\w^_]{3,}:\/\/)(?:(?:[\w^_]{2,}\.)?[\w\-]{2,}(?:\.[\w^_]{2,})+){1}[^\s\[\]\(\)<>,";\.]*(?:\.\w+)*[^\s\[\]\(\)<>,";\.]*/', '$0', $note); if ($row['twitter'] == 1) { $note = preg_replace('/(\s|\A)(@|!){1}(\w+)/', '$1$2$3', $note); } else { $note = preg_replace('/(\s|\A)(@|!){1}(\w+)/', '$1$2$3', $note); } $note = preg_replace($emoticons_shooter, $emoticons, $note); $avatar = 'images/avatar/' . $row['username'] . '/thumb_note.' . $row['avatar']; $avatar = (file_exists($avatar) === true) ? $avatar : 'images/avatar/default_note.png'; if (($first_note === false) or ($action != 'general')) { // echo ($row['type'] == 'group') ? '
' : '
'; if (($_SESSION['LOGIN'] === true) and ($_SESSION['USERNAME'] != $row['username'])) { echo (strstr(strtolower($row['to']), strtolower($_SESSION['USERNAME']))) ? '
' : '
'; } else { echo '
'; } echo '
'; if (!empty($row['attached_file'])) echo '[D] '; if (($_SESSION['LOGIN'] === true) and ($_SESSION['USERNAME'] == $row['username'])) echo ' '; if (($_SESSION['LOGIN'] === true) and ($row['type'] != 'private')) { $sql = " SELECT * FROM `favorites` WHERE ((`id_user` = '" . $_SESSION['ID_USER'] . "') AND (`permalink` = '" . $row['permalink'] . "'));"; mysql_query($sql); if (mysql_affected_rows() == 0) { echo ' '; } else { echo ' '; } } if ($row['type'] != 'private') echo ''; if (($_SESSION['LOGIN'] === true) and ($row['id_user'] != $_SESSION['ID_USER'])) echo ' '; echo '
' . get_difference($row['date'], $get_difference_lang) . ' (' . $row['from'] . ')
' . $note . '
'; } else if (($first_note === true) and ($action == 'general')) { // echo ($row['type'] == 'group') ? '
' : '
'; echo '
'; if (!empty($row['attached_file'])) echo '[D] '; if (($_SESSION['LOGIN'] === true) and ($_SESSION['USERNAME'] == $row['username'])) echo ' '; if (($_SESSION['LOGIN'] === true) and ($row['type'] != 'private')) { $sql = " SELECT * FROM `favorites` WHERE ((`id_user` = '" . $_SESSION['ID_USER'] . "') AND (`permalink` = '" . $row['permalink'] . "'));"; mysql_query($sql); if (mysql_affected_rows() == 0) { echo ' '; } else { echo ' '; } } if ($row['type'] != 'private') echo ''; if (($_SESSION['LOGIN'] === true) and ($row['id_user'] != $_SESSION['ID_USER'])) echo ' '; echo '
' . get_difference($row['date'], $get_difference_lang) . ' (' . $row['from'] . ')
' . $note . '
'; $first_note = false; } } mysql_free_result($result); switch ($action) { case 'general': $sql = " SELECT COUNT(*) FROM `notes` WHERE ((`notes`.`id_user` = '" . $id_user . "') AND (`notes`.`type` != 'private'));"; break; case 'replies': $sql = " SELECT COUNT(*) FROM `notes` WHERE ((`notes`.`type` = 'reply') AND ((`notes`.`id_user` = '" . $id_user . "') OR (`notes`.`to` LIKE '" . $username . "')));"; break; /* case 'groups': $sql = " SELECT COUNT(`notes`.`id_note`) FROM `suscriptions` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` INNER JOIN `notes` ON `notes`.`note` LIKE CONCAT('#', `groups`.`name`, ' %') WHERE ((`suscriptions`.`id_user` = '" . $id_user ."' AND (`notes`.`type` = 'group'));"; break; */ case 'friends': $sql = " SELECT SUM(val) FROM ( ( SELECT COUNT(*) AS val FROM `followers` INNER JOIN `notes` ON `notes`.`id_user` = `followers`.`id_follower` INNER JOIN `users` ON `users`.`id_user` = `followers`.`id_follower` WHERE ((`followers`.`id_user` = '" . $_SESSION['ID_USER'] . "') AND (`notes`.`type` != 'private')) ) UNION DISTINCT ( SELECT COUNT(*) FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`notes`.`id_user` = '" . $_SESSION['ID_USER'] . "') AND (`notes`.`type` != 'private')) ) ) AS tmp;"; break; case 'favorites': $sql = " SELECT COUNT(*) FROM `favorites` INNER JOIN `notes` ON `notes`.`permalink` = `favorites`.`permalink` WHERE (`favorites`.`id_user` = '" . $id_user . "');"; } $result = mysql_query($sql); $row = mysql_fetch_array($result); mysql_free_result($result); if ($row[0] > $CONFIG['NOTES_2p']) { $pagination_href = array ("action" => $action, "p" => "[-]"); require("./includes/pagination_class.php"); $pagination = new pagination($page, $row[0], $CONFIG['NOTES_2p'], $username, $pagination_components_enabled, $pagination_components_text, $pagination_href, $pagination_classes, true); $result_pagination = $pagination->show_pagination(); echo '

'; } } else { echo '
' . _('No hay notas para este usuario.') . '
'; } } else { echo '
' . _('El usuario no existe.') . '
'; } } else { /* $sql = " SELECT `notes`.*, `users`.`avatar` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` INNER JOIN `suscriptions` ON `suscriptions`.`id_user` = `notes`.`id_user` INNER JOIN `groups` ON `groups`.`id_group` = `suscriptions`.`id_group` WHERE ((`users`.`username` = '" . $username . "') AND (`notes`.`type` != 'private') AND (`groups`.`type` = 'public') AND (`notes`.`permalink` = '" . $permalink . "')) LIMIT 1;"; */ $sql = " SELECT `notes`.*, `users`.`avatar` FROM `notes` INNER JOIN `users` ON `users`.`id_user` = `notes`.`id_user` WHERE ((`users`.`username` = '" . $username . "') AND (`notes`.`permalink` = '" . $permalink . "') AND (`notes`.`type` IN ('', 'reply', 'group') )) LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); if (mysql_num_rows($result) == 1) { $note = html_entity_decode($row['note']); preg_match_all('/[^\s]{40,}/', $note, $matches); for ($i=0; $i" . $matches[2] . ""; case "/": return "" . $matches[2] . ""; case "_": return "" . $matches[2] . ""; case "-": return "" . $matches[2] . ""; } '), $note); $note = preg_replace('/(?:[\w^_]{3,}:\/\/)(?:(?:[\w^_]{2,}\.)?[\w\-]{2,}(?:\.[\w^_]{2,})+){1}[^\s\[\]\(\)<>,";\.]*(?:\.\w+)*[^\s\[\]\(\)<>,";\.]*/', '$0', $note); if ($row['twitter'] == 1) { $note = preg_replace('/(\s|\A)(@|!){1}(\w+)/', '$1$2$3', $note); } else { $note = preg_replace('/(\s|\A)(@|!){1}(\w+)/', '$1$2$3', $note); } $note = preg_replace($emoticons_shooter, $emoticons, $note); $avatar = 'images/avatar/' . $username . '/thumb_note.' . $row['avatar']; $avatar = (file_exists($avatar) === true) ? $avatar : 'images/avatar/default_note.png'; // echo ($row['type'] == 'group') ? '
' : '
'; echo '
'; if (!empty($row['attached_file'])) echo '[D] '; if (($_SESSION['LOGIN'] === true) and ($_SESSION['USERNAME'] == $username)) echo ' '; if ($_SESSION['LOGIN'] === true) { $sql = " SELECT * FROM `favorites` WHERE ((`id_user` = '" . $_SESSION['ID_USER'] . "') AND (`permalink` = '" . $row['permalink'] . "'));"; mysql_query($sql); if (mysql_affected_rows() == 0) { echo ' '; } else { echo ' '; } } if ($row['type'] != 'private') echo ''; echo '
' . get_difference($row['date'], $get_difference_lang) . ' (' . $row['from'] . ')
' . $note . '
'; } else { echo '
' . _('Esa nota no existe') . '
'; } } } ?>