Beispiel #1
0
function index()
{
    global $path;
    global $template;
    $conditionspre = '';
    $conditionspost = '';
    $conditionsselect = '';
    $extratitle = '';
    $orderby = "newest";
    $order = 'created desc';
    $defaultorder = 1;
    $nopagination = 0;
    $page = 1;
    $searchstringoriginal = '';
    if (!empty($_GET['search'])) {
        $searchstringoriginal = sanitize($_GET['search'], "string");
    }
    if (!empty($_GET['order'])) {
        if ($_GET['order'] == "votes") {
            $order = "votes desc";
            $orderby = "votes";
            $defaultorder = 0;
        } else {
            if ($_GET['order'] == "oldest") {
                $order = "created asc";
                $orderby = "oldest";
                $defaultorder = 0;
            } else {
                if ($_GET['order'] == "relevance") {
                    $order = "score desc";
                    $orderby = "relevance";
                    $defaultorder = 0;
                } else {
                    if ($_GET['order'] == "newest") {
                        $defaultorder = 0;
                    }
                }
            }
        }
    }
    if (!empty($_GET['page'])) {
        $page = sanitize($_GET['page'], "int");
    }
    $type = '';
    if (!empty($_GET['type'])) {
        $type = "&type=" . sanitize($_GET['type'], "string");
        if (sanitize($_GET['type'], "string") == "unanswered") {
            //	$conditionspost .= " questions.id NOT IN (select questions.id from questions,answers where questions.id = answers.questionid and answers.accepted = 1) and ";
            $conditionspost .= " questions.accepted = 0 and questions.kb = 0 and ";
            $extratitle = " " . _("not yet answered");
        } else {
            $extratitle = " " . _("active");
            $order = " updated desc ";
            $nopagination = 1;
        }
    }
    $template->set('nopagination', $nopagination);
    $search = '';
    $searchstring = urldecode($searchstringoriginal);
    if (!empty($searchstringoriginal)) {
        $search = "&search=" . urlencode($searchstring);
        $conditionspost .= " MATCH(title, description) AGAINST ('" . escape($searchstring) . "') and ";
        $conditionsselect .= ",MATCH(title, description) AGAINST ('" . escape($searchstring) . "') AS score  ";
        $extratitle = " " . _("showing") . " " . $searchstring;
        if ($defaultorder == 1) {
            $orderby = "relevance";
            $order = 'score desc';
        }
    }
    $template->set('searchstring', $searchstring);
    $tag = '';
    if (!empty($_GET['tag'])) {
        $tag = "&tag=" . createSlug($_GET['tag']);
        $conditionspre .= ",tags_questions, tags";
        $conditionspost .= " tags_questions.questionid = questions.id and tags.id = tags_questions.tagid and tags.tag LIKE '" . escape(createSlug($_GET['tag'])) . "' and ";
        $extratitle = " " . _("tagged") . " " . createSlug($_GET['tag']);
    }
    $offset = ($page - 1) * QUESTIONS_PER_PAGE;
    $sql = "select count(questions.id) count from questions {$conditionspre} WHERE {$conditionspost} 1";
    $query = mysql_query($sql);
    $result = mysql_fetch_array($query);
    $template->set('questionscount', $result['count']);
    $paging = new Pagination();
    $paging->set('urlscheme', '?order=' . $orderby . $tag . $type . $search . '&page=%page%');
    $paging->set('perpage', QUESTIONS_PER_PAGE);
    $paging->set('page', $page);
    $paging->set('total', $result['count']);
    $paging->set('order', $orderby);
    $paging->set('search', $search);
    $template->set('pagination', $paging->display());
    $paging->set('urlscheme', '?order=%label%' . $tag . $type . $search . '&page=1');
    $template->set('orderOptions', $paging->displayOptions());
    $template->set('extratitle', $extratitle);
    $sql = "select questions.* {$conditionsselect} from questions {$conditionspre} WHERE {$conditionspost} 1 order by {$order}, created desc LIMIT " . QUESTIONS_PER_PAGE . " OFFSET {$offset}";
    $query = mysql_query($sql);
    $questions = array();
    while ($result = mysql_fetch_array($query)) {
        $sql_nest = "select tag from tags_questions, tags where questionid = '" . escape($result['id']) . "' and tags.id = tags_questions.tagid order by tag";
        $query_nest = mysql_query($sql_nest);
        $tags = array();
        while ($result_nest = mysql_fetch_array($query_nest)) {
            $tags[] = $result_nest['tag'];
        }
        $description = truncate(trim(sanitize(Markdown($result['description']), "string")));
        if (!empty($searchstring)) {
            $description = highlight(excerpt(trim(sanitize(Markdown($result['description']), "string")), $searchstring), $searchstring);
            $result['title'] = highlight($result['title'], $searchstring);
        }
        $questions[] = array("title" => $result['title'], "created" => $result['created'], "updated" => $result['updated'], "userid" => $result['userid'], "link" => $result['link'], "slug" => $result['slug'], "answers" => $result['answers'], "accepted" => $result['accepted'], "kb" => $result['kb'], "votes" => $result['votes'], "id" => $result['id'], "tags" => $tags, "description" => $description);
    }
    $template->set('questions', $questions);
}
Beispiel #2
0
?>
 Users</h1>

<div style="clear:both"></div>

<div class="tags_list">
<ul class="holder noborder">
<?php 
foreach ($users as $user) {
    ?>
<li class="bit-box nopadding"><a href="<?php 
    echo BASE_PATH;
    ?>
/users/view/<?php 
    echo $user['id'];
    ?>
/<?php 
    echo createSlug($user['name']);
    ?>
"><?php 
    echo $user['name'];
    ?>
</a> <?php 
    echo $user['points'];
    ?>
</li>
<?php 
}
?>
</ul>
</div>
Beispiel #3
0
<?php

session_start();
include "../db_connect.php";
include "../include/ust.php";
$target_dir = "../images/ad/";
$adName = htmlspecialchars($_POST['name']);
$target_file = $target_dir . basename($_FILES["plik1"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
$new_filename = createSlug($adName) . "." . $imageFileType;
$new_target_file = $target_dir . $new_filename;
// Check if image file is a actual image or fake image
if (isset($_POST["submit"])) {
    $check = getimagesize($_FILES["plik1"]["tmp_name"]);
    if ($check !== false) {
        $msg = "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        $msg = "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
//if (file_exists($target_file)) {
//    $msg = "Sorry, file already exists.";
//    $uploadOk = 0;
//}
// Check file size
if ($_FILES["plik1"]["size"] > 500000) {
    $msg = "Sorry, your file is too large.";
Beispiel #4
0
if (isset($_POST["submit"])) {
    $check = getimagesize($_FILES["plik1"]["tmp_name"]);
    if ($check !== false) {
        $msg = "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        $msg = "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
$key = 1;
while (file_exists($new_target_file)) {
    //    $msg = "Plik już istnieje";
    //    $uploadOk = 0;
    $new_target_file = $target_dir . createSlug($adName) . $key . "." . $imageFileType;
    $key++;
}
// Check file size
if ($_FILES["plik1"]["size"] > 2097152) {
    $msg = "Za duży plik";
    $uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
    $msg = "Akceptowany format to jpg,png oraz gif.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    $msg2 = "Sorry, your file was not uploaded.";
Beispiel #5
0
        echo $value->id;
        ?>
-<?php 
        echo createSlug($value->blog_title);
        ?>
'><?php 
        echo $value->blog_title;
        ?>
</a></h4><?php 
        echo substr(filter_string($value->blog_content), 0, 200);
        ?>
<div class="text-right"><a href='/blog/detail/<?php 
        echo $value->id;
        ?>
-<?php 
        echo createSlug($value->blog_title);
        ?>
' class="btn btn-info">Read more »</a></div>
			<?php 
        if ($this->session->userdata('user')) {
            ?>
<p><a href="/blog/input/<?php 
            echo $value->id;
            ?>
"><i class="fa fa-pencil"></i></a></p><?php 
        }
        ?>
			
			<hr>
			<?php 
    }
 public function test_createSlug()
 {
     $this->assertEquals(createSlug("Con gái yêu dấu"), "Con-gai-yeu-dau");
 }