示例#1
0
if (Session::exists("user_id") && !empty($_POST)) {
    $image = null;
    $image_id = 0;
    $handle = new Upload($_FILES['image']);
    if ($handle->uploaded) {
        $url = "storage/users/{$_SESSION['user_id']}/images/";
        $handle->Process($url);
        // $handle->file_dst_name;
        $image = new ImageData();
        $image->src = $handle->file_dst_name;
        $image->level_id = $_POST["level_id"];
        $image->user_id = $_SESSION["user_id"];
        $image_id = $image->add();
    }
    $post_id = 0;
    if ($_POST["content"] != "") {
        $post = new PostData();
        $post->content = $_POST["content"];
        $post->level_id = $_POST["level_id"];
        $post->author_ref_id = $_SESSION["user_id"];
        $post->receptor_ref_id = $_SESSION["user_id"];
        $post_id = $post->add();
        if ($handle->uploaded) {
            $pi = new PostImageData();
            $pi->post_id = $post_id[1];
            $pi->image_id = $image_id[1];
            $pi->add();
        }
    }
    Core::redir("./?view=home");
}
示例#2
0
<div class="clearfix"></div>
      <hr style="margin:5px;">

<?php 
        $url = '/(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/';
        $content = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $p->content);
        ?>
<p style="font-size:14px;"><?php 
        echo $content;
        ?>
</p>



<?php 
        $pis = PostImageData::getAllByPostId($p->id);
        if (count($pis) == 1) {
            foreach ($pis as $pi) {
                $fullpath = $pi->getImage()->getFullpath();
                if (file_exists($fullpath)) {
                    ?>
<a data-toggle="modal" href="#imgModal-<?php 
                    echo $pi->image_id;
                    ?>
"><img src="<?php 
                    echo $fullpath;
                    ?>
" class="img-responsive"></a>

<!-- Button trigger modal -->