Example #1
0
 function do_search($terms)
 {
     global $mysqli;
     $terms = $this->search_split_terms($terms);
     $terms_db = $this->search_db_escape_terms($terms);
     $terms_rx = $this->search_rx_escape_terms($terms);
     $parts = array();
     foreach ($terms_db as $term_db) {
         $parts[] = "content RLIKE '{$term_db}'";
     }
     $parts = implode(' AND ', $parts);
     $sql = "SELECT id FROM items WHERE {$parts}";
     $query = mysqli_query($mysqli, $sql);
     $items = array();
     while ($query && ($result = mysqli_fetch_assoc($query))) {
         $item = Item::get_by_id($result['id']);
         $item->content = process_content($item->content);
         $item->score = 0;
         foreach ($terms_rx as $term_rx) {
             $item->score += preg_match_all("/{$term_rx}/i", $item->content, $null);
         }
         $items[] = $item;
     }
     if (count($items) > 1) {
         uasort($items, array($this, 'search_sort_results'));
     }
     return $items;
 }
Example #2
0
 private function show($q)
 {
     include 'lib/search.php';
     $search = new Search();
     $items = $search->do_search($q);
     foreach ($items as $item) {
         $item->content = process_content($item->content);
         foreach ($item->comments as $comment) {
             $comment->content = process_content($comment->content);
         }
         foreach ($item->likes as $like) {
             if (isset($_SESSION['user_id']) && $like->user_id == $_SESSION['user_id']) {
                 $item->i_like = true;
             } else {
                 $item->i_like = false;
             }
         }
     }
     if (isset($this->plugins->log)) {
         $result_count = count($items);
         $this->plugins->log->add($_SESSION['user_id'], 'search', NULL, 'new', "Term = {$q}\nResult_count = {$result_count}");
     }
     if ($this->json) {
         $this->render_json($items);
     } else {
         $this->loadView('search/index', array('items' => $items));
     }
 }
Example #3
0
 private function show($item_id)
 {
     $item = Item::get_by_id($item_id);
     $item->content = process_content($item->content);
     // Copying the work of loadView
     $params = array('app' => $this, 'session' => $_SESSION, 'item' => $item);
     echo $this->twig->render("partials/likes.html", $params);
 }
Example #4
0
 private function show($item_id)
 {
     $item = Item::get_by_id($item_id);
     $item->content = process_content($item->content);
     foreach ($item->comments as $comment) {
         $comment->content = process_content($comment->content);
     }
     // Copying the work of loadView
     $params = array('app' => $this, 'session' => $_SESSION);
     $params['item'] = $item;
     echo $this->twig->render("partials/comments.html", $params);
 }
Example #5
0
 function show($id)
 {
     $user = User::get_by_id($id);
     // id failed so try username (used by routes)
     if ($user == null) {
         $user = User::get_by_username($id);
     }
     // username failed so error out
     if ($user == null) {
         throw new RoutingException($this->uri, "User not found");
     }
     // Page zero so overwrite to 1
     if (!isset($this->uri['params']['page'])) {
         $this->uri['params']['page'] = 1;
     }
     // items per page, change this to test pagination
     $limit = 10;
     if ($this->uri['params']['page'] == 1) {
         $offset = 0;
     } else {
         $offset = ($this->uri['params']['page'] - 1) * $limit;
     }
     $items = $user->items($limit, $offset);
     foreach ($items as $item) {
         $item->content = process_content($item->content);
         foreach ($item->comments as $comment) {
             $comment->content = process_content($comment->content);
         }
         foreach ($item->likes as $like) {
             if (isset($_SESSION['user_id']) && $like->user_id == $_SESSION['user_id']) {
                 $item->i_like = true;
             } else {
                 $item->i_like = false;
             }
         }
     }
     if ($this->config->friends->enabled == TRUE) {
         $friends = $user->friend_check($_SESSION['user_id']);
     }
     if ($this->json) {
         $this->render_json($user);
     } else {
         $vars = array('user' => $user, 'items' => $items);
         if (isset($friends)) {
             $vars['friends'] = $friends;
         }
         if (isset($user->username)) {
             $vars['title'] = $user->username;
         }
         $this->loadView('users/show', $vars);
     }
 }
Example #6
0
function import_article($url)
{
    $md5 = md5($url);
    $path = GRID_DIR . "/import/{$md5}.html";
    $token = READABILITY_API_KEY;
    $url_encoded = urlencode($url);
    $request = "https://readability.com/api/content/v1/parser?url={$url_encoded}&token={$token}";
    $json = download_file($request);
    $result = json_decode($json);
    if (!empty($result->title)) {
        $content = process_content($result);
        if (!empty($content)) {
            file_put_contents($path, $content);
            return $path;
        }
    }
    return null;
}
         if (!empty($_POST['submitEditComm'])) {
             $edition = $_POST['the_key'];
         }
     } else {
         $error['validation'] = 'What are you trying to do?';
     }
 }
 // COMMENT SENT
 if (!empty($_POST['submitComm']) && !empty($_POST['comment_body']) && !empty($arrUser)) {
     // Arrange the content
     $comm_userId = $arrUser['idUser'];
     if (!empty($_POST['comment_body'])) {
         if (!are_tags_closed($_POST['comment_body'])) {
             $error['comm'] = 'Some tags are unclosed. Fix your message before send it again.';
         } else {
             $comm_content = process_content($_POST['comment_body']);
         }
         if (empty($comm_content)) {
             $error['comm'] = 'No content, no comment';
         } else {
             $comm_content = mysql_real_escape_string($comm_content);
         }
     } else {
         $error['comm'] = 'You have to write something if you want to comment.';
     }
     // Store comment
     if (empty($error)) {
         if (empty($_POST['the_key'])) {
             // Adding a new comment
             $query = "INSERT INTO comments (userId, postId, content) VALUES ('{$comm_userId}', '{$p_idPost}', '{$comm_content}');";
             $result = mysql_query($query, $dbConn);
include_once '../admin/send_mail.php';
// for sending emails
//Sanitize inputs
if (isset($_POST['to_user'])) {
    $to_user = mysql_real_escape_string($_POST['to_user']);
} else {
    $error['to_user'] = '******';
}
if (isset($_POST['subject'])) {
    $subject = mysql_real_escape_string($_POST['subject']);
}
if (isset($_POST['message']) && $_POST['message'] != "") {
    if (!are_tags_closed($_POST['message'])) {
        $error['message'] = 'Tags need to be closed.';
    }
    $message = mysql_real_escape_string(process_content($_POST['message']));
} else {
    $error['message'] = 'Message cannot have an empty body.';
}
//load sender's id
if (isset($arrUser)) {
    $idUser = $arrUser['idUser'];
} else {
    $error['user'] = "******";
}
//check to see if recipient exists
$q = "SELECT email, idUser, notify FROM users WHERE username='******' LIMIT 1";
if (!($r = mysql_query($q, $dbConn)) || mysql_num_rows($r) == 0) {
    $error['db'] = 'Error locating recepient\'s data.';
} else {
    // else load the recepient's data
        $error['cBody'] = 'No message, no contact. Please, write something if you want to contact.';
    }
    // Captcha
    if (!empty($_POST['captcha_code'])) {
        if ($securimage->check($_POST['captcha_code']) == false) {
            $error['captcha'] = 'The captcha code is wrong.';
        }
    } else {
        $error['captcha_code'] = 'You have to enter the captha code.';
    }
    if (empty($error)) {
        // SEND A MAIL WITH THE VALIDATION URL
        $to = array('*****@*****.**', '*****@*****.**');
        $subject = "NC CONTACT: {$cName} // {$cSubject}";
        $date = date("F d, Y / l");
        $cBody = process_content($cBody);
        $body = trim("{$date}<br/>\n<br/>\n\n\t\t\t\t\t\tName: <strong>{$cName}</strong><br/>\n\n\t\t\t\t\t\temail: <strong>{$cEmail}</strong><br/>\n\n\t\t\t\t\t\tSubject: <strong>{$cSubject}</strong><br/>\n\n\t\t\t\t\t\t<br/>\n<br/>\n\n\t\t\t\t\t\t{$cBody}\n\t\t\t\t\t\t<br/>\n<br/>\n");
        if (send_mail($to, $subject, $body)) {
            $location = rurl() . '/contact.php?done=sent';
            header("Location: {$location}");
        } else {
            $error['send_mail'] = 'There was a problem on the validation email process. Did you sent a valid email?';
        }
    }
}
// page info
$page_title = "NoClan: Contact";
// used at 'includes/head.inc'
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
/**
 * Print table body from directory
 *
 * @param $pdf
 * @param $p_version_id
 * @param $work_packages
 * @param $no_work_package_bug_ids
 * @param $option_show_duration
 * @param $detail_flag
 * @return Array
 */
function generate_content(PDF $pdf, $p_version_id, $work_packages, $no_work_package_bug_ids, $option_show_duration, $detail_flag)
{
    $specmanagement_database_api = new specmanagement_database_api();
    $specmanagement_editor_api = new specmanagement_editor_api();
    $directory_depth = $specmanagement_editor_api->calculate_directory_depth($work_packages);
    $chapter_counter_array = $specmanagement_editor_api->prepare_chapter_counter($directory_depth);
    $last_chapter_depth = 0;
    $version_id = $_POST['version_id'];
    $version = version_get($version_id);
    $version_date = $version->date_order;
    /** Iterate through defined work packages */
    if (!is_null($work_packages)) {
        foreach ($work_packages as $work_package) {
            if (strlen($work_package) > 0) {
                $work_package_spec_bug_ids = $specmanagement_database_api->get_workpackage_spec_bugs($p_version_id, $work_package);
                $chapters = explode('/', $work_package);
                $chapter_depth = count($chapters);
                if ($chapter_depth == 1) {
                    $specmanagement_editor_api->reset_chapter_counter($chapter_counter_array);
                }
                $chapter_prefix_data = $specmanagement_editor_api->generate_chapter_prefix($chapter_counter_array, $chapter_depth, $last_chapter_depth);
                $chapter_counter_array = $chapter_prefix_data[0];
                $chapter_prefix = $chapter_prefix_data[1];
                $chapter_suffix = $specmanagement_editor_api->generate_chapter_suffix($chapters, $chapter_depth);
                $chapter_duration = $specmanagement_database_api->get_workpackage_duration($p_version_id, $work_package);
                if ($detail_flag) {
                    $pdf->ChapterTitle($chapter_prefix, utf8_decode($chapter_suffix), $option_show_duration, $chapter_duration);
                } else {
                    $pdf->SetFont('Arial', 'B', 12);
                    $pdf->SetFillColor(255, 255, 255);
                    $pdf->Cell(95, 6, $chapter_prefix . ' ' . utf8_decode($chapter_suffix), 0, 0, 'L', 1);
                    $pdf->Cell(95, 6, $pdf->PageNo(), 0, 0, 'R', 1);
                    $pdf->SetFont('Arial', '', 12);
                    $pdf->Ln();
                }
                process_content($pdf, $work_package_spec_bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag);
                $last_chapter_depth = $chapter_depth;
            }
            if ($detail_flag) {
                $pdf->Cell(0, 0, '', 'T');
            }
            $pdf->Ln(7);
        }
    }
    /** Iterate through issues without defined work package */
    $chapter_prefix = $chapter_counter_array[0] + 1;
    if (count($no_work_package_bug_ids) > 0) {
        $chapter_suffix = plugin_lang_get('editor_no_workpackage');
        $chapter_duration = $specmanagement_database_api->get_workpackage_duration($p_version_id, '');
        if ($detail_flag) {
            $pdf->ChapterTitle($chapter_prefix, utf8_decode($chapter_suffix), $option_show_duration, $chapter_duration);
        } else {
            $pdf->SetFont('Arial', 'B', 12);
            $pdf->SetFillColor(255, 255, 255);
            $pdf->Cell(0, 6, $chapter_prefix . ' ' . utf8_decode($chapter_suffix), 0, 0, 'L', 1);
            $pdf->SetFont('Arial', '', 12);
            $pdf->Ln();
        }
        process_content($pdf, $no_work_package_bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag);
        if ($detail_flag) {
            $pdf->Cell(0, 0, '', 'T');
        }
        $pdf->Ln(7);
        $chapter_prefix++;
    }
    $content_package = array();
    $content_package[0] = $pdf;
    $content_package[1] = $chapter_prefix;
    return $content_package;
}
Example #11
0
 function feed()
 {
     if ($this->config->friends->enabled == TRUE || isset($_SESSION['user_id'])) {
         // If friends enabled then show feed of friends' activity
         $user = User::get_by_id($_SESSION['user_id']);
         // Page zero so overwrite to 1
         if (!isset($this->uri['params']['page'])) {
             $this->uri['params']['page'] = 1;
         }
         // Items per page, change this to test pagination
         $limit = 10;
         if ($this->uri['params']['page'] == 1) {
             $offset = 0;
         } else {
             $offset = ($this->uri['params']['page'] - 1) * $limit;
         }
         $this->items = $user->list_feed($limit, $offset);
         foreach ($items as $item) {
             $item->content = process_content($item->content);
             foreach ($item->comments as $comment) {
                 $comment->content = process_content($comment->content);
             }
             foreach ($item->likes as $like) {
                 if (isset($_SESSION['user_id']) && $like->user_id == $_SESSION['user_id']) {
                     $item->i_like = true;
                 } else {
                     $item->i_like = false;
                 }
             }
         }
         $this->loadView('items/index');
     } else {
         // Friends not enabled so fall back to showing everyone's activity
         $this->index();
     }
 }
    die;
}
if (MT_ERR) {
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
} else {
    error_reporting(0);
}
if (basename(__FILE__) == 'mytracking.php') {
    die('For your safety: you should really change the name of this file');
}
if (!empty($_GET['test'])) {
    die("OK: " . MT_RELEASE);
}
$hop = isset($_GET['hop']) ? $_GET['hop'] : '';
process_content(retrieve_content(calculate_url($hop)));
exit;
function calculate_url($link)
{
    $returnurl = '';
    if ($link == '') {
        $returnurl = 'http://trkapi.com/mytrackingok.gif';
    } else {
        if (preg_match("/.+/", $link)) {
            $src = array('/m/', '/r/', '/l/');
            $rpl = array('', '/', '/');
            $link = str_replace($src, $rpl, $link);
            $returnurl = 'http://trkapi.com/' . $link;
            // 2.0 format
        }
    }