Example #1
0
/**
 *递归获取评论列表
 */
function getComment($parent_id = 0, &$result = array())
{
    $sql = "select * from tuhao_comm where parent_id={$parent_id} order by reg_time desc";
    $rows = fetchAll($sql);
    if (empty($rows)) {
        return array();
    }
    foreach ($rows as $row) {
        $arr =& $result[];
        $row["children"] = getComment($row["id"], $thisArr);
        $arr = $row;
    }
    return $result;
}
Example #2
0
function about_media_detail()
{
    global $_MooClass, $dbTablePre, $user_arr, $name;
    include "./module/{$name}/function.php";
    //通过ID查找一条新闻的详细内容
    $id = $_GET['id'];
    $arr = explode("_", $id);
    $src = "module/about/templates/default/baodao/" . $arr[0] . "/" . $arr[1] . ".jpg";
    if (!file_exists($src)) {
        MooMessage('没有这个页面', 'index.php?n=about&h=media', '01');
    }
    $id = (isset($arr[0][3]) ? $arr[0] : '20' . $arr[0]) * 100 + $arr[1];
    $comment = getComment(1, $id);
    $left_menu = 'media';
    require MooTemplate('public/about_media_detail', 'module');
}
Example #3
0
function deletePost()
{
    $sess_user = $_SESSION['user_id'];
    if (isset($_POST['del_post'])) {
        $post_id = (int) $_POST['post_id'];
        dbAdd("DELETE FROM litter_posts\n\t\t\tWHERE post_id = '{$post_id}'  AND user_id = '{$sess_user}'");
        $comments = getComment($post_id);
        if (!empty($comments)) {
            foreach ($comments as $comments) {
                $user_id = $comments['user_id'];
                dbAdd("DELETE FROM litter_posts\n\t\t\t\t\tWHERE reply = '{$post_id}' AND user_id = '{$user_id}'");
            }
        }
        return "Your post was successfully trashed!";
    }
}
Example #4
0
function viewBlog()
{
    if (!isset($_GET["blogId"]) || !$_GET["blogId"]) {
        homepage();
        return;
    }
    $data = Page::getPageByTitle($_GET['action']);
    //body content
    echo "<div id='output'>";
    if ($data) {
        if ($data->page_protection == '1' && !isset($_SESSION['name'])) {
            echo "Please log-in to view this page.";
        } else {
            if ($data->page_status == 'draft') {
                echo "This page is not yet published. Contact the site admin.";
            } else {
                //show body and blog
                echo "<p>" . $data->page_body . "</p>";
                $results = array();
                $results['blog'] = Blog::getBlogById($_GET["blogId"]);
                $results['pageTitle'] = $results['blog']->title . " | Widget News";
                $row = $results['blog'];
                echo "<input type='hidden' value='" . $row->id . "' id='hBlogId'/>";
                echo '<h1 class="headSection">' . $row->title . '</h1><p class="smallText">' . $row->publicationDate . '</p><p>' . $row->content . '</p>';
                echo '<p style="font-weight:bold;">Share this!</p><a href="#"><img src="include/images/fb.png"/></a><a href="#"><img src="include/images/twit.png"/></a><a href="#"><img src="include/images/rss2.png"/></a><a href="#"><img src="include/images/google.png"/></a><a href="#"><img src="include/images/delicious.png"/></a><a href="#"><img src="include/images/stumbleupon.png"/></a><a href="#"><img src="include/images/digg.png"/></a><hr/>';
                echo '<div id="commentSection"><p class="smallText">Leave a comment...</p><textarea id="comment"  placeholder="Put your comment here" required maxlength="1000" style="height: 3em; width:90%; display: block;margin-left: auto;margin-right: auto;"></textarea><input type="button" id="submitComment" value="Post!" title="' . $_GET["blogId"] . '"/></div>';
                //existing comments
                getComment();
                //end of comment
            }
        }
    }
    echo "</div>";
    //end of body content
    //sidebar
    echo "<div id='sidebar'>";
    if ($data) {
        echo "<p>" . $data->page_sidebar . "</p>";
    }
    echo "</div>";
    //end of sidebar
}
Example #5
0
function story_content()
{
    global $_MooClass, $dbTablePre, $userid;
    global $user_arr;
    $sid = MooGetGPC('sid', 'integer');
    if ($sid) {
        //增加点击次数
        $_MooClass['MooMySQL']->query("update {$dbTablePre}story set hot=hot+1 where sid={$sid} and syscheck = 1");
    } else {
        $sid = 1;
    }
    $love_story = $_MooClass['MooMySQL']->getOne("SELECT * FROM {$dbTablePre}story WHERE sid = '{$sid}' and syscheck = 1");
    if (!$love_story) {
        MooMessage('没有对应故事', 'index.php?n=story');
        exit;
    }
    $comment = getComment(2, $sid);
    $show_pic = showPic($sid);
    include MooTemplate('public/story_content', 'module');
}
Example #6
0
/**
 * 新增歷史語法
 * 
 * @param string  $returnResult  pay2go 回傳資料
 * @param string  $add_status    新增狀態
 * @param int     $today         更新時間
 * @param string  $prefix        DB 前置
 */
function addSql($returnResult, $add_status, $today, $prefix)
{
    $sql = "INSERT INTO " . $prefix . "hikashop_history SET";
    $sql .= " history_order_id = " . $returnResult['MerchantOrderNo'];
    $sql .= ", history_created = " . $today;
    $sql .= ", history_ip = 'pay2go'";
    $sql .= ", history_new_status = '" . $add_status . "'";
    $sql .= ", history_reason = '" . getComment($returnResult);
    $sql .= $returnResult['Status'] != 'SUCCESS' ? "錯誤訊息: " . $returnResult['Message'] . "'" : "'";
    $sql .= ", history_type = 'callback'";
    return $sql;
}
    //echo $id." ".$pw." ".$Des." ".$BDes." ".$Loc." ".$Icon." ".$oid;
    UpdateInf($oid, $id, $pw, $Des, $BDes, $Loc, $Icon);
});
$app->get('/Comment/id/:mid/fid/:fid/Des/:Des/Rating/:rat', function () {
    $uri = $_SERVER['REQUEST_URI'];
    $arr_items = split('/', $uri);
    $Rat = $arr_items[count($arr_items) - 1];
    $Des = $arr_items[count($arr_items) - 3];
    $fid = $arr_items[count($arr_items) - 5];
    $id = $arr_items[count($arr_items) - 7];
    echo $id . " " . $fid . " " . $Des . " " . $Rat;
    Commend($id, $fid, $Des, $Rat);
});
$app->get('/Comment/id/:mid', function ($mid) {
    //echo $mid;
    getComment($mid);
});
$app->get('/Login/id/:mid/pw/:pw', function () {
    $uri = $_SERVER['REQUEST_URI'];
    $arr_items = split('/', $uri);
    $pw = $arr_items[count($arr_items) - 1];
    $id = $arr_items[count($arr_items) - 3];
    //echo $id." ".$pw;
    Login($id, $pw);
});
$app->get('/Check/id/:mid', function () {
    $uri = $_SERVER['REQUEST_URI'];
    $arr_items = split('/', $uri);
    $id = $arr_items[count($arr_items) - 1];
    //$id = $arr_items[count($arr_items) - 3];
    //echo $id;
Example #8
0
function deleteUser()
{
    if (isset($_POST['del_user'])) {
        $sess_id = $_SESSION['user_id'];
        $sess_username = $_SESSION['username'];
        /* DEL POSTS */
        $posts = getUserPosts($_SESSION['username']);
        foreach ($posts as $post) {
            $post_id = $post['post_id'];
            dbAdd("DELETE FROM litter_posts\n\t\t\tWHERE post_id = '{$post_id}' AND user_id = '{$sess_id}'");
            $comments = getComment($post_id);
            if (!empty($comments)) {
                foreach ($comments as $comments) {
                    $user_id = $comments['user_id'];
                    dbAdd("DELETE FROM litter_posts\n\t\t\t\t\t\tWHERE reply = '{$post_id}' AND user_id = '{$user_id}'");
                }
            }
        }
        /* CLEAN FOLLOWING */
        dbAdd("DELETE FROM litter_following\n\t\t\tWHERE user_id = '{$sess_id}'");
        /* CLEAN FOLLOWERS */
        dbAdd("DELETE FROM litter_following\n\t\t\tWHERE following = '{$sess_id}'");
        /* CLEAN FOLDER */
        $dir = 'userIMG/' . $sess_id . '/';
        // Open the directory
        $dirHandle = opendir($dir);
        // Loop over all of the files in the folder
        while ($file = readdir($dirHandle)) {
            // If $file is NOT a directory remove it
            if (!is_dir($file)) {
                unlink("{$dir}" . "{$file}");
                // unlink() deletes the files
            }
        }
        // Close the directory
        closedir($dirHandle);
        /* REMOVE FOLDER */
        rmdir($dir);
        /* DEL USER */
        dbAdd("DELETE FROM litter_users\n\t\tWHERE user_id = '{$sess_id}' AND username = '******'");
        session_destroy();
        session_start();
        $_SESSION['error'] = 'Your account has been deleted...';
        header('Location: form.php');
    }
}
Example #9
0
function comments_preview($atts)
{
    global $has_comments_preview;
    if (!ps('preview')) {
        return;
    }
    extract(lAtts(array('form' => 'comments', 'wraptag' => '', 'class' => __FUNCTION__), $atts));
    assert_article();
    $preview = psa(array('name', 'email', 'web', 'message', 'parentid', 'remember'));
    $preview['time'] = time();
    $preview['discussid'] = 0;
    $preview['name'] = strip_tags($preview['name']);
    $preview['email'] = clean_url($preview['email']);
    if ($preview['message'] == '') {
        $in = getComment();
        $preview['message'] = $in['message'];
    }
    $preview['message'] = markup_comment(substr(trim($preview['message']), 0, 65535));
    // it is called 'message', not 'novel'
    $preview['web'] = clean_url($preview['web']);
    $GLOBALS['thiscomment'] = $preview;
    $comments = parse_form($form) . n;
    unset($GLOBALS['thiscomment']);
    $out = doTag($comments, $wraptag, $class);
    # set a flag, to tell the comments_form tag that it doesn't have to show a preview
    $has_comments_preview = true;
    return $out;
}
Example #10
0
function sampleDetail($id, $code, $sampleID)
{
    $status = 2;
    if ($id == 16) {
        if ($code == 1) {
            $status = screenStatus($sampleID);
            if ($status == 0) {
                $sql = "SELECT pp_nama AS sampleName,pp_kod AS sampleCode,rkatp_class,rkatp_desc,pp_osa_kod_holder,pp_osa_kod_owner FROM p_product\n              LEFT JOIN ref_kat_produk ON pp_rkatp_kod = rkatp_kod\n              WHERE pp_kod='{$sampleID}'";
            } else {
                $sql = "SELECT pp_nama AS sampleName,pp_kod AS sampleCode,rkatp_class,rkatp_desc,pp_osa_kod_holder,pp_osa_kod_owner FROM p_product,ref_kat_produk\n                WHERE pp_kod='{$sampleID}' AND pp_rkatp_kod=rkatp_kod";
            }
        } elseif ($code == 2) {
            $sql = "SELECT product_name AS sampleName,adrSampleID  AS sampleCode,remarks AS remark\n              ,quantity,batchno FROM adr_sample WHERE adrSampleID='{$sampleID}'";
        } elseif ($code == 3 || $code == 4) {
            $sql = "SELECT product_name AS sampleName,pSampleID AS sampleCode,remarks_to_lab AS remark\n              ,quantity,batchno FROM c_surv_sample WHERE pSampleID='{$sampleID}'";
        } elseif ($code == 6) {
            $sql = "SELECT *,kp_kuantiti_htr AS quantity,kp_batch_no AS batchno FROM k_produk WHERE kp_id='{$sampleID}'";
        }
    } else {
        $sql = "SELECT * FROM k_produk WHERE kp_id='{$sampleID}'";
    }
    ///echo $sql;
    $result = selQuery($sql);
    $row = mysqli_fetch_assoc($result);
    if ($id == 20) {
        $title = "Redistribute";
    } else {
        $title = sampleTitle($code);
    }
    ?>
<div class="tab-content pn br-n admin-form">
  <div class="row">
    <input type="hidden" id="mainTitle" value="<?php 
    echo $title;
    ?>
" />
    <input type="hidden" id="sampleID" value="<?php 
    echo $sampleID;
    ?>
">
    <div class="alert alert-sm alert-border-left alert-alert">Sample Information</div>
  </div>
  <div class="row">
    <?php 
    if ($id != 16) {
        ?>
    <div class="col-md-12" align="right">
      <?php 
        getBarcode($row['kp_sampel_no']);
        ?>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <?php 
    }
    if ($code == 1 and $id == 16) {
        ?>
      <div class="col-md-3">Call No</div>
      <div class="col-md-1">:</div>
      <div class="col-md-5"><?php 
        echo $sampleID;
        ?>
</div>
      <div class="col-md-12">&nbsp;</div>
    <?php 
    }
    if ($id != 16) {
        ?>
      <div class="col-md-3">Sample No</div>
      <div class="col-md-1">:</div>
      <div class="col-md-4"><?php 
        echo $row['kp_sampel_no'];
        ?>
</div>
      <div class="col-md-2" align="right">Store Status :</div>
      <div class="col-md-2" align="left">
        <?php 
        if ($row['kp_requestSpl'] == 0) {
            echo "<i class='fa fa-close text-danger'></i> Not Available";
        } else {
            echo "<i class='fa fa-check text-success'></i> Ready to collect";
        }
        ?>
      </div>
      <div class="col-md-12">&nbsp;</div>
    <?php 
    }
    ?>
      <div class="col-md-3">Product Name</div>
      <div class="col-md-1">:</div>
      <div class="col-md-8">
      <?php 
    if ($id == 16) {
        if ($code == 6) {
            echo $row['kp_product_name'];
            echo "<input type=\"hidden\" id=\"txt_code\" value=\"" . $row['kp_id'] . "\">";
            echo "<input type=\"hidden\" id=\"txt_name\" value=\"" . $row['kp_product_name'] . "\">";
        } else {
            echo $row['sampleName'];
            echo "<input type=\"hidden\" id=\"txt_code\" value=\"" . $row['sampleCode'] . "\">";
            echo "<input type=\"hidden\" id=\"txt_name\" value=\"" . $row['sampleName'] . "\">";
        }
    } else {
        echo $row['kp_product_name'];
    }
    ?>
    </div>
  <?php 
    if ($code == 1) {
        ?>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Product Category</div>
    <div class="col-md-1">:</div>
    <div class="col-md-5"><?php 
        echo $row['rkatp_desc'] . " - " . $row['rkatp_class'];
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Manufacturer</div>
    <div class="col-md-1">:</div>
    <div class="col-md-5"><?php 
        echo isempty(osaDetail($row['pp_osa_kod_owner']));
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Holder</div>
    <div class="col-md-1">:</div>
    <div class="col-md-5"><?php 
        echo isempty(osaDetail($row['pp_osa_kod_holder']));
        ?>
</div>
  <?php 
    }
    if ($code == 2 || $code == 3 || $code == 4) {
        ?>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Remarks</div>
    <div class="col-md-1">:</div>
    <div class="col-md-6">
      <label class="field prepend-icon">
        <textarea class="gui-textarea" id="txt_remark" readonly><?php 
        echo $row['remark'];
        ?>
</textarea>
        <label for="comment" class="field-icon">
          <i class="fa fa-comments"></i>
        </label>
        <span class="input-footer">Remarks from Pasca</span>
      </label>
    </div>
  <?php 
    }
    if ($id == 16) {
        ?>
    <div class="col-md-12">
      <div class="section-divider mb40">
        <span><b>To be filled by QCC Officer</b></span>
      </div>
    </div>
    <div class="col-md-3">Batch No <font style="color:red;">*</font></div>
    <div class="col-md-1">:</div>
    <div class="col-md-3">
      <label class="field prepend-icon">
        <input type="text" name="txt_batch" id="txt_batch" class="gui-input"  value="<?php 
        echo $row['batchno'];
        ?>
">
        <label for="txt_batch" class="field-icon">
          <i class="fa fa-calculator"></i>
        </label>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Quantity Received <font style="color:red;">*</font></div>
    <div class="col-md-1">:</div>
    <div class="col-md-3">
      <label class="field prepend-icon">
        <input type="text" name="txt_quantity" id="txt_quantity" class="gui-input" value="<?php 
        echo $row['quantity'];
        ?>
">
        <label for="txt_quantity" class="field-icon">
          <i class="fa fa-calculator"></i>
        </label>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Dosage</div>
    <div class="col-md-1">:</div>
    <div class="col-md-4">
      <label class="field select">
        <select id="txt_dosage">
          <?php 
        getDosage();
        ?>
        </select>
        <i class="arrow"></i>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Unit</div>
    <div class="col-md-1">:</div>
    <div class="col-md-4">
      <label class="field select">
        <select id="txt_unit">
          <?php 
        getSukatan();
        ?>
        </select>
        <i class="arrow"></i>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Expiry Date</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3">
      <label class="field prepend-icon">
        <input type="text" name="txt_expiry" id="txt_expiry" class="gui-input" readonly <?php 
        if ($code == 6) {
            echo "value=\"" . displayDate($row['kp_tkh_luput']) . "\"";
        }
        ?>
>
        <label for="txt_expiry" class="field-icon">
          <i class="fa fa-calendar"></i>
        </label>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Received Date <font style="color:red;">*</font></div>
    <div class="col-md-1">:</div>
    <div class="col-md-3">
      <label class="field prepend-icon">
        <input type="text" name="txt_received" id="txt_received" class="gui-input" readonly <?php 
        if ($code == 6) {
            echo "value=\"" . displayDate($row['kp_tkh_htr']) . "\"";
        }
        ?>
>
        <label for="txt_received" class="field-icon">
          <i class="fa fa-calendar"></i>
        </label>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Expected Complete Day(s) <font style="color:red;">*</font></div>
    <div class="col-md-1">:</div>
    <div class="col-md-3">
      <label class="field prepend-icon">
        <input type="number" name="txt_complete" id="txt_complete" class="gui-input" <?php 
        if ($code == 6) {
            echo "value=\"" . $row['kp_complete_day'] . "\"";
        }
        ?>
>
        <label for="txt_complete" class="field-icon">
          <i class="fa fa-calculator"></i>
        </label>
      </label>
    </div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Sender <font style="color:red;">*</font></div>
    <div class="col-md-1">:</div>
    <div class="col-md-4">
      <label class="field prepend-icon">
        <input type="text" name="txt_sender" id="txt_sender" class="gui-input" <?php 
        if ($code == 6) {
            echo "value=\"" . $row['kp_sender'] . "\"";
        }
        ?>
>
        <label for="txt_sender" class="field-icon">
          <i class="fa fa-user"></i>
        </label>
      </label>
    </div>
  <?php 
    } else {
        ?>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Batch No</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3"><?php 
        echo $row['kp_batch_no'];
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Quantity Received</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3"><?php 
        echo $row['kp_kuantiti_htr'];
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Dosage</div>
    <div class="col-md-1">:</div>
    <div class="col-md-4"><?php 
        echo getSelDosage($row['kp_rdk_kod']);
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Unit</div>
    <div class="col-md-1">:</div>
    <div class="col-md-4"><?php 
        echo getSukatan($row['kp_rskt_kod']);
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Expiry Date</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3"><?php 
        echo displayDate($row['kp_tkh_luput']);
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Received Date</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3"><?php 
        echo displayDate($row['kp_tkh_terima']);
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Expected Complete Date</div>
    <div class="col-md-1">:</div>
    <div class="col-md-3"><?php 
        echo addDayswithdate($row['kp_tkh_terima'], $row['kp_complete_day']) . " (" . $row['kp_complete_day'] . " days)";
        ?>
</div>
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-3">Sender</div>
    <div class="col-md-1">:</div>
    <div class="col-md-4"><?php 
        echo $row['kp_sender'];
        ?>
</div>
  <?php 
    }
    ?>
  </div>
  <div class="row">
    <?php 
    if ($id == 19 || $id == 20) {
        ?>
      <div class="col-md-12">
        <div class="alert alert-sm alert-border-left alert-alert">Assign Sample</div>
      </div>
      <div class="col-md-3">Lab <font color="red">*</font></div>
      <div class="col-md-1">:</div>
      <div class="col-md-6">
        <select id="txt_lab" class="form-control">
            <option value='0'>-- Please Select --</option>
            <?php 
        getLab();
        ?>
        </select>
      </div>
      <div class="col-md-12">&nbsp;</div>
      <div class="col-md-3">Quantity <font color="red">*</font></div>
      <div class="col-md-1">:</div>
      <div class="col-md-3">
        <label class="field prepend-icon">
          <input type="text" name="txt_assign" id="txt_assign" class="gui-input">
          <label for="txt_assign" class="field-icon">
            <i class="fa fa-calculator"></i>
          </label>
        </label>
      </div>
      <div class="col-md-5">
        <button class="btn btn-alert" onclick="balance('<?php 
        echo $row['kp_id'];
        ?>
')"><i class="fa fa-plus"></i> Balance</button>
        <button class="btn btn-alert" onclick="assignSample('<?php 
        echo $sampleID;
        ?>
')"><i class="fa fa-pencil"></i> Assign Sample</button>
      </div>
      <div class="col-md-12">&nbsp;</div>
      <div class="col-md-12" id="sampleAssign"><?php 
        showTask($sampleID);
        ?>
</div>
      <div class="col-md-12">&nbsp;</div>
    <?php 
    } elseif ($id == 21 || $id == 23 || $id == 25 || $id == 27) {
        assignedTask($id, $sampleID, $_SESSION['ru_kod']);
    }
    if ($id != 27) {
        ?>
      <div class="col-md-12">&nbsp;</div>
      <div class="col-md-3"><?php 
        echo getComment($id);
        ?>
</div>
      <div class="col-md-1">:</div>
      <div class="col-md-6">
        <label class="field prepend-icon">
          <textarea class="gui-textarea" id="txt_comment" placeholder="Enter Comment..."><?php 
        echo getComments($id, $sampleID, $_SESSION['us_id']);
        ?>
</textarea>
          <label for="comment" class="field-icon">
            <i class="fa fa-comments"></i>
          </label>
          <span class="input-footer"><?php 
        echo getComment($id);
        ?>
</span>
        </label>
      </div>
      <div class="col-md-12"><font color="red">*</font> required field</div>
    <?php 
    }
    ?>
  </div>
  <div class="row">
    <div class="col-md-12">&nbsp;</div>
    <div class="col-md-12">
      <button class="btn btn-alert" onclick="content('<?php 
    echo $code;
    ?>
')"><i class="fa fa-arrow-left"></i> Back</button>
      <button class="btn btn-alert" onclick="showProduct('<?php 
    echo $code;
    ?>
')"><i class="fa fa-desktop"></i> Product Detail</button>
    <?php 
    if ($id == 16) {
        if (screenStatus($sampleID) != 1) {
            ?>
      <button class="btn btn-alert" onclick="receiveSample('<?php 
            echo $code;
            ?>
','<?php 
            echo $status;
            ?>
')"><i class="fa fa-check"></i> Receive Sample</button>
    <?php 
            if ($code == 1) {
                ?>
      <button class="btn btn-alert" onclick="rejectSample('<?php 
                echo $code;
                ?>
')"><i class="fa fa-close"></i> Reject Sample</button>
    <?php 
            }
        }
    } else {
        ?>
      <button class="btn btn-alert" onclick="printBarcode('<?php 
        echo $row['kp_sampel_no'];
        ?>
')"><i class="fa fa-print"></i> Print Barcode</button>
    <?php 
        if ($id == 23 and checkPharma($row['kp_id'], $_SESSION['ru_kod']) == 1) {
            ?>
      <button class="btn btn-alert" onclick="submitSample('<?php 
            echo $sampleID;
            ?>
','<?php 
            echo $row['kp_sampel_no'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-reply"></i> Send Back to Pharmacist</button>
    <?php 
        } elseif ($id == 25 and checkAssist($row['kp_id'], $_SESSION['ru_kod']) == 1) {
            ?>
      <button class="btn btn-alert" onclick="submitSample('<?php 
            echo $sampleID;
            ?>
','<?php 
            echo $row['kp_sampel_no'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-reply"></i> Send Back to Assistant Pharmacist</button>
    <?php 
        }
        ?>
      <button class="btn btn-alert" onclick="chronology(1,'<?php 
        echo $sampleID;
        ?>
')"><i class="fa fa-sort-alpha-asc"></i> Chronology</button>
    <?php 
        if ($id == 25 and checkAssist($row['kp_id'], $_SESSION['ru_kod']) == 1) {
            ?>
      <button class="btn btn-alert" onclick="approveAssist('<?php 
            echo $row['kp_id'];
            ?>
','<?php 
            echo $_SESSION['ru_kod'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-check"></i> Approve</button>
    <?php 
        } elseif ($id == 23 and checkPharma($row['kp_id'], $_SESSION['ru_kod']) == 1) {
            ?>
      <button class="btn btn-alert" onclick="approvePharma('<?php 
            echo $row['kp_id'];
            ?>
','<?php 
            echo $_SESSION['ru_kod'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-check"></i> Approve</button>
    <?php 
        } elseif ($id == 21) {
            ?>
      <button class="btn btn-alert" onclick="approveKU('<?php 
            echo $row['kp_id'];
            ?>
','<?php 
            echo $_SESSION['ru_kod'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-check"></i> Approve</button>
    <?php 
        } else {
            ?>
      <button class="btn btn-alert" onclick="submitSample('<?php 
            echo $sampleID;
            ?>
','<?php 
            echo $row['kp_sampel_no'];
            ?>
','<?php 
            echo $code;
            ?>
')"><i class="fa fa-send"></i> Submit</button>
    <?php 
        }
    }
    ?>
    </div>
  </div>
</div>
<?php 
}
Example #11
0
$uname = cleanit($_REQUEST['uname']);
if ($uname != "") {
    STemplate::assign('uname', $uname);
    $queryp = "select USERID, username, country, description, color1, color2, website from members where username='******' AND status='1'";
    $resultsp = $conn->execute($queryp);
    $p = $resultsp->getrows();
    STemplate::assign('p', $p[0]);
    $USERID = intval($p[0]['USERID']);
    $qry = "SELECT A.*, B.story, B.nsfw, B.pic\r\n\t\t\t\tFROM posts_comments A, posts B\r\n\t\t\t\t\tWHERE A.USERID = " . $USERID . " AND A.PID = B.PID\r\n\t\t\t\t\t\tGROUP BY A.CID\r\n\t\t\t\t\t\t\tORDER BY A.CID desc\r\n\t\t\t\t\t\t\t\tLIMIT {$pagingstart}, {$config['items_per_page']}";
    $qry_result = $conn->execute($qry);
    $data = $qry_result->getrows();
    if (!$data) {
        $t = 'empty.tpl';
        //STemplate::assign('tc',0);
    } else {
        $data = getComment($data);
        $data = getHash($data);
        STemplate::assign('data', $data);
        //STemplate::assign('tc',count($data));
    }
    if ($USERID > 0) {
        STemplate::assign('pagetitle', $uname . " " . $lang['194']);
        $eurl = base64_encode("/user/" . $uname . "/messages");
        STemplate::assign('eurl', $eurl);
        $query = "select count(*) as total from posts where USERID='" . mysql_real_escape_string($USERID) . "' AND active='1' limit 1";
        $executequery = $conn->execute($query);
        $tl = $executequery->fields['total'];
        STemplate::assign('tl', $tl);
        $query = "select count(*) as total from posts_favorited where USERID='" . mysql_real_escape_string($USERID) . "' limit 1";
        $executequery = $conn->execute($query);
        $tf = $executequery->fields['total'];
Example #12
0
        print '<p class="post_post">' . atLink($post['post']) . '</p>';
        if ($post['post_pic']) {
            print '<img src="userIMG/' . $post['user_id'] . '/' . $post['post_pic'] . '" class="post_img">';
        }
        print '<div class="time_stamp"><p>' . printTime($post['time_stamp']) . '</p></div>';
        /*REPLY_FORM*/
        print '<div class="reply">
				<form method="POST" action="#' . $post['post_id'] . '">
				<input type="hidden" name="post_id" value="' . $post['post_id'] . '">
				<input type="text" name="comment" value="' . $post['username'] . '">
				<input type="submit" name="postComment" value="Reply" class="button">
				</form>
				</div>';
        /*END REPLY_FORM*/
        print '<br></div>';
        $comments = getComment($post['post_id']);
        if (!empty($comments)) {
            print '<div class="postit"><ul>';
            foreach ($comments as $comments) {
                print '<li>';
                /*DELETE_BUTTON*/
                if ($sess['user_id'] == $comments['user_id']) {
                    print '<div class="del_post">';
                    print '<form method="POST" action="#' . $post['post_id'] . '">
											<input type="hidden" name="post_id" value="' . $comments['post_id'] . '">
											<button type="submit" name="del_comment"><img src="img/trashicon.png"></button>
										</form>';
                    print '</div>';
                }
                /*END DELETE_BUTTON*/
                /*COMMENT*/
Example #13
0
 function comment_evaluation()
 {
     global $prefs;
     extract(getComment());
     $this->status = array(SPAM => array(), MODERATE => array(), VISIBLE => array(), RELOAD => array());
     $this->status_text = array(SPAM => gTxt('spam'), MODERATE => gTxt('unmoderated'), VISIBLE => gTxt('visible'), RELOAD => gTxt('reload'));
     $this->message = $this->status;
     $this->txpspamtrace[] = "Comment on {$parentid} by {$name} (" . safe_strftime($prefs['archive_dateformat'], time()) . ")";
     if ($prefs['comments_moderate']) {
         $this->status[MODERATE][] = 0.5;
     } else {
         $this->status[VISIBLE][] = 0.5;
     }
 }
function handleCreateTable(&$schema, &$input, &$line)
{
    if (preg_match('/^CREATE\\ TABLE\\ ([a-z]*\\.)?([a-z_]+)$/', $line, $match) == 1) {
        $tabName = $match[2];
        // eat (
        getNextLine($input);
        $lastcolumn = false;
        while ($line = getNextLine($input)) {
            $comment = false;
            while ($commentLine = getComment($line)) {
                $comment = $comment . "\n" . $commentLine;
                $line = getNextLine($input);
            }
            $column = getColumnName($line);
            if ($column) {
                $lastcolumn = $column;
            }
            if (!isset($schema[$tabName]['fields'][$lastcolumn])) {
                $schema[$tabName]['fields'][$lastcolumn] = array('description' => "No description for column {$lastcolumn} available, please fix");
            }
            if ($comment) {
                $schema[$tabName]['fields'][$lastcolumn]['description'] = $comment;
            }
            if (getColumnType($schema[$tabName], $lastcolumn, $line)) {
                continue;
            }
            if (preg_match('/^\\) WITHOUT OIDS;/', $line)) {
                continue;
            }
            if ($uniqueconstraints = getUniqueConstraints($line)) {
                $keyname = $uniqueconstraints['name'];
                $schema[$tabName]['unique keys'][$keyname] = $uniqueconstraints['keys'];
                continue;
            }
            if ($primaryKey = getPrimaryKey($line)) {
                $schema[$tabName]['primary key'] = $primaryKey;
                continue;
            }
            fwrite(STDERR, "Unknown statements within CREATE TABLE: {$line}\n");
        }
        return true;
    }
    return false;
}
Example #15
0
<?php

include "functions.php";
checkLogin();
$id = (int) $_GET['id'];
include_once 'modele/news/getComments.php';
$commentArray = getComment($id);
foreach ($commentArray as $com) {
    $pseudo = $com['pseudo'];
    $id_user = $com['ID_membre'];
    $id_news = $com['ID_news'];
}
if (!isset($pseudo)) {
    $js = false;
    $redirect[0] = 'javascript:history.go(-1)';
    $redirect[1] = '1';
    $page = 'accueil';
    $titreErreur = 'news - erreur';
    $erreur = 'Ce commentaire n\'existe pas !';
    include_once 'vue/erreur.php';
    die;
}
$admin = areYouAdmin();
if (!$admin and (!$_SESSION['login'] or $id_user != $_SESSION['ID'])) {
    $js = false;
    $redirect[0] = 'javascript:history.go(-1)';
    $redirect[1] = '1';
    $page = 'accueil';
    $titreErreur = 'news - erreur';
    $erreur = 'Vous n\'êtes pas autorisé à supprimer un commentaire qui ne vous appartient pas!';
    include_once 'vue/erreur.php';
Example #16
0
<?php

require 'get.php';
$post = $_GET['post'];
echo json_encode(array('comment' => getComment($post)));
Example #17
0
function deleteComment($data)
{
    $results = [];
    //checks if requests needed are present and not empty
    $dataNeeded = array("commentID");
    if (checkData($data, $dataNeeded)) {
        //check if comment provided exists
        $comment = getComment($data["commentID"]);
        if ($comment["count"] > 0) {
            $db = new pdodb();
            $query = "DELETE FROM Comment WHERE ID = :commentID;";
            $bindings = array(":commentID" => $data["commentID"]);
            $row = $db->query($query, $bindings);
            //if deletion was ok
            if ($row["count"] > 0) {
                $results["meta"]["ok"] = true;
                $results["rows"]["commentID"] = $data["commentID"];
            } else {
                //check if database provided any meta data if so problem with executing query
                if (isset($row["meta"])) {
                    $results = $row;
                } else {
                    $results["meta"]["ok"] = false;
                }
            }
        } else {
            //check if database provided any meta data if so problem with executing query
            if (isset($comment["meta"])) {
                $results = $comment;
            } else {
                $results["meta"] = noCommentFound($data["commentID"]);
            }
        }
    } else {
        $results["meta"] = dataNotProvided($dataNeeded);
    }
    return $results;
}
Example #18
0
    $alert .= "<div class=\"new_content_license\">";
    $alert .= " <p><convert>#label=482<convert></p>";
    $alert .= " <p><convert>#label=483<convert></p>";
    $alert .= " <p><convert>#label=484<convert></p>";
    $alert .= " <p><convert>#label=509<convert> : " . getLicensePicture(1) . "</p>";
    $alert .= "</div>";
    return $alert;
}
//Get the values to display :
$locations = getLocation($category, $id);
$topographies = getTopography($category, $id);
$descriptions = getDescription($category, $id);
$riggings = getRigging($category, $id);
$histories = getHistory($category, $id);
$bibliographies = getBibliography($category, $id);
$comments = getComment($category, $id);
//Printing options setup :
$disabledOnlyAttribute = "disabled=\\\"disabled\\\" ";
$checkedAttribute = "checked=\\\"checked\\\" ";
$printLocations = $locations['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printDescriptions = $descriptions['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printRiggings = $riggings['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printTopographies = $topographies['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printHistories = $histories['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printBibliographies = $bibliographies['Count'] > 0 ? "" : $disabledOnlyAttribute;
$printComments = $comments['Count'] > 0 ? "" : $disabledOnlyAttribute;
$defaultProperties = "";
$defaultInput_area = "";
$defaultMap = "checked=\\\"checked\\\" ";
$defaultTable_of_content = "";
$defaultLocation = $locations['Count'] > 0 ? $checkedAttribute : "";
<?php
require 'header.php';
$recent = recentVideo();
$cat = catList();
if (isset($_GET['v'])) {
    $data = videoDetail($_GET['v'])->result[0];
    $comment = getComment($_GET['v']);
?>
    <div class="clear"></div>
    <div class="inner shadow"></div>
        
        <div class="container row">
            <div class="two-thirds column left">
                <h1 class="heading"><?= $data->title ?></h1>
                <!-- Album Detail Start -->
                <div class="in-sec">
                    <div class="album-detail">
                        <a href="" class="thumb">
                            <iframe height="300px" width="550px" scrolling="no" src="http://182.18.165.43/multitvfinal/index.php/details?id=<?php echo $data->id ?>&device=3g" frameborder="0"  webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>	                	
                        </a>
                        <div class="clear"></div>
                    </div>
                    <div class="desc">
                        <p class="musicby"><?= $data->title ?></p>
                        <h4>Album Discription</h4>
                        <p class="txt"><?= $data->description ?> </p>
                    </div>

                </div>
                <div class="in-sec">
                    <div class="album-opts">
Example #20
0
function getComment($comment, &$total_comment, &$total_reply, $isReply, &$cur_level, $max_reply)
{
    $comment->normalize();
    $time = $comment->getAttribute("timestamp");
    $author = $comment->getAttribute("author");
    $ip = $comment->getAttribute("ip");
    $id = $comment->getAttribute("id");
    $subject = trim($comment->childNodes->item(0)->nodeValue);
    $msg = trim($comment->childNodes->item(1)->nodeValue);
    $msg = str_replace(array("\r", "\n"), "<br />", $msg);
    $msg = str_replace(array("[[", "]]"), array("<", ">"), $msg);
    $time = ago(time() - $time * 1);
    $html = '<li class="ec-comment" id="' . $id . '">' . '   <div class="avatar"></div>' . '   <span class="user-name author">' . $author . '</span> <br />' . '   <span class="comment-html">' . (empty($subject) ? "" : '      <strong>' . $subject . '</strong><br /><br />') . $msg . '   </span><br>' . '   <span class="comment-time">' . $time . '</span><br />';
    if ($cur_level < $max_reply) {
        $html .= '   <button name="reply" id="reply_' . $id . '">Reply</button>';
    }
    if ($isReply) {
        $total_reply++;
    } else {
        $total_comment++;
    }
    if ($comment->childNodes->length == 3) {
        $cur_level++;
        $root = $comment->childNodes->item(2);
        $last_child = $root->lastChild;
        if ($last_child) {
            //$html .= '<ul class="ec-comment-list">';
            $temp_html = null;
            while ($last_child) {
                $moderate = $last_child->getAttribute("moderate");
                $ip = $last_child->getAttribute("ip");
                if ($moderate === "0" || $moderate === "4" || $moderate === "1" && $ip === $_SERVER["REMOTE_ADDR"]) {
                    if (is_null($temp_html)) {
                        $temp_html = '<ul class="ec-comment-list">';
                    }
                    $temp_html .= getComment($last_child, $total_comment, $total_reply, true, &$cur_level, $max_reply);
                }
                $last_child = $last_child->previousSibling;
            }
            if (!is_null($temp_html)) {
                $temp_html .= '</ul>';
                $html .= $temp_html;
            }
        }
    }
    $html .= '</li>';
    return $html;
}
Example #21
0
         $results[$i]['Members'] = getMember($results[$i]['id']);
         $results[$i]['Hauls'] = getHaul($results[$i]['id']);
         $results[$i]['Comments'] = getComment($results[$i]['id']);
     }
     echo json_encode($results);
     break;
 case 'delOp':
     delOp($_REQUEST['owner_id'], $_REQUEST['op_id']);
     break;
     /////
     /////
 /////
 /////
 case 'sendComment':
     $member_id = sendComment($_REQUEST['op_id'], $_REQUEST['user_id'], $_REQUEST['comment']);
     $results['Comments'] = getComment($_REQUEST['op_id']);
     echo json_encode($results);
     break;
     /////
 /////
 case 'joinMember':
     $member_id = joinMember($_REQUEST['op_id'], $_REQUEST['user_id'], $_REQUEST['displayname'], $_REQUEST['profile_url']);
     $results['Members'] = getMember($_REQUEST['op_id']);
     echo json_encode($results);
     break;
 case 'partMember':
     $member_id = partMember($_REQUEST['op_id'], $_REQUEST['user_id']);
     $results['Members'] = getMember($_REQUEST['op_id']);
     echo json_encode($results);
     break;
 case 'getMember':
Example #22
0
function comments_preview($atts, $thing = '', $me = '')
{
    global $thisarticle, $has_comments_preview;
    if (!ps('preview')) {
        return;
    }
    extract(lAtts(array('id' => @$pretext['id'], 'form' => 'comments', 'wraptag' => '', 'class' => __FUNCTION__), $atts));
    assert_article();
    if (is_array($thisarticle)) {
        extract($thisarticle);
    }
    if (@$thisid) {
        $id = $thisid;
    }
    $Form = fetch_form($form);
    $preview = psas(array('name', 'email', 'web', 'message', 'parentid', 'remember'));
    $preview['time'] = time();
    $preview['discussid'] = 0;
    if ($preview['message'] == '') {
        $in = getComment();
        $preview['message'] = $in['message'];
    }
    $preview['message'] = markup_comment($preview['message']);
    $GLOBALS['thiscomment'] = $preview;
    $comments = parse($Form) . n;
    unset($GLOBALS['thiscomment']);
    $out = doTag($comments, $wraptag, $class);
    # set a flag, to tell the comments_form tag that it doesn't have to show a preview
    $has_comments_preview = true;
    return $out;
}
Example #23
0
/**
 * Replace header
 */
function replace($fileName, $newHeader)
{
    $result = false;
    if (file_exists($fileName)) {
        $content = file_get_contents($fileName);
        $fileType = preg_replace('/^.*\\.(\\w+)$/sSU', '\\1', basename($fileName));
        $headerPattern = getHeaderPattern($fileType);
        if (preg_match($headerPattern, $content, $match)) {
            $year = null;
            if (preg_match('/Copyright \\(c\\) ([\\d\\- ]+) Creative/m', $match[1], $match2)) {
                $year = $match2[1];
            }
            $comment = getComment($fileType, $match[1]);
            if ('tpl' == $fileType) {
                preg_match_all('/^( \\* @(\\w+)\\W.+)$/sSUm', $match[1], $tags);
                if (!empty($tags[2])) {
                    $bottom = '';
                    foreach ($tags[2] as $k => $tag) {
                        if (!in_array($tag, array('author', 'copyright', 'license', 'link', 'since'))) {
                            $bottom .= $tags[1][$k] . PHP_EOL;
                        }
                    }
                    if (!empty($bottom)) {
                        $newHeader = preg_replace('/(^ \\*\\}$)/sSUm', ' *' . PHP_EOL . $bottom . '\\1', $newHeader);
                    }
                }
            }
            if (empty($year)) {
                $year = '2011';
            }
            if (!empty($year)) {
                if (preg_match('/^\\d+$/', $year) && 2012 > intval($year)) {
                    $year = sprintf('%s-2012', $year);
                }
                $replaceHeader = str_replace(array('%yearplaceholder%', '%commentplaceholder%'), array($year, $comment), $newHeader);
                if ($newContent = preg_replace($headerPattern, $replaceHeader, $content, 1)) {
                    file_put_contents($fileName, $newContent);
                    $result = true;
                }
            } else {
                $result = 'ERROR: cannot detect year in ' . $fileName;
            }
        } else {
            $result = 'ERROR: header not found in ' . $fileName;
        }
    } else {
        $result = 'ERROR: File ' . $fileName . ' not found';
    }
    return $result;
}
Example #24
0
            $title_comment = substr($text_comment, 0, 15);
        } else {
            $title_comment = clearData($_POST['commenttitle']);
        }
        $profile = getProfile($_SESSION['name']);
        $id_user_of_comment = $profile[0]['id'];
        $date_of_public = time();
        $user_rating = $_POST['case'];
        setComment($id_articles, $title_comment, $text_comment, $id_user_of_comment, $date_of_public);
    } else {
        echo "<div>" . $lang['comment field is not filled'] . "</div>";
    }
}
//comment
if (isset($_GET['id'])) {
    $articles = getComment($_GET['id']);
    if (!empty($articles)) {
        foreach ($articles as $article) {
            echo "<hr><div><a href='index.php?profile=" . getName($article['id_user_of_comment']) . "'>" . getName($article['id_user_of_comment']) . "</a></div>";
            if (!empty($_SESSION['status']) and $_SESSION['status'] == '3') {
                echo "<div align='right'><a href='comment.php?comment&del=" . $article['id'] . "'>" . $lang['delete'] . "</a></div>";
            }
            echo "<div><b>" . $article['title_comment'] . "</b></div>";
            echo "<div>" . $article['text_comment'] . "</div>";
            echo "<div align='right'>" . date("m.d.y H:i:s", $article['date_of_public']) . "</div>";
        }
    }
}
if (isset($_SESSION['status']) and $_SESSION['status'] >= 1) {
    $formcomment = "\n<hr>\n<form action='comment.php' method='POST'>\n<div>" . $lang['enter title'] . "</div>\n<input type='text' name='commenttitle'>\n<div>" . $lang['enter comment'] . "</div>\n<textarea cols='60' rows='8' name='commenttext'></textarea>\n<input type='hidden' name='id_articles' value=" . $_GET['id'] . ">\n<div><input type='submit' name='rating'></div>\n</form>";
    echo $formcomment;
Example #25
0
function deleteComment($commentId)
{
    $cData = getComment($commentId);
    if ($cData[0]['user'] == getActiveUserID() || isAdmin() || isModerator()) {
        $link = getDBConnection();
        if (mysqli_select_db($link, getDBName())) {
            $commentId = intval($commentId);
            mysqli_query($link, "DELETE FROM newsComments WHERE id = {$commentId}");
        }
    }
}
Example #26
0
        <p>Songs</p>
        <table class="songs">
            <tr><th>ID</th><th>Artis - Title</th><th>Likes</th><th>Action</th></tr>
            <?php 
listSongs();
?>
        </table>

        <p>Songs Comments</p>
        <table class="comments">
            <tr><th>Comment ID</th><th>Comment</th><th>By User</th><th>For Song</th><th>Action</th></tr>
            <?php 
getComment("song");
?>
        </table>

        <p>Playlists Comments</p>
        <table>
            <tr><th>Comment ID</th><th>Comment</th><th>By User</th><th>For Playlist</th><th>Action</th></tr>
            <?php 
getComment("playlists");
?>
        </table>
    </section>
</div>

<script>
    document.getElementById('background').style.height = window.innerHeight;
</script>
</body>
</html>
                        exit;
                    }
                    $stmt->bind_param('si', $_POST['content'], $item_ID);
                    $stmt->execute();
                    $stmt->close();
                    header("Location: ../story.php?id=" . $origin);
                    exit;
                }
            }
        } else {
            if ($target == 's') {
                $story = getStory($item_ID);
                $content = htmlspecialchars($story['commentary']);
            } else {
                if ($target == 'c') {
                    $comment = getComment($item_ID);
                    $content = htmlspecialchars($comment['comment']);
                }
            }
        }
    }
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
Example #28
0
<?php

$current_time = time();
$CommentFile = realpath('.') . '/user_data/comments.xml';
$xml = new DomDocument('1.0', 'utf-8');
if (file_exists($CommentFile)) {
    $xml->load($CommentFile);
    $root = $xml->firstChild;
    $total = $xml->getElementsByTagName("comment")->length;
    $comments = array();
    $last_child = $root->lastChild;
    if ($last_child) {
        $comments[] = getComment($last_child);
        $previous_sibling = $last_child->previousSibling;
        while ($previous_sibling) {
            $comments[] = getComment($previous_sibling);
            $previous_sibling = $previous_sibling->previousSibling;
        }
    }
    echo json_encode(array("total" => $total, "comments" => $comments));
}
function getComment($comment)
{
    $time = $comment->getAttribute("timestamp");
    $author = $comment->getAttribute("author");
    $ip = $comment->getAttribute("ip");
    $subject = $comment->firstChild->nodeValue;
    $msg = $comment->lastChild->nodeValue;
    $msg = str_replace(array("\r", "\n"), "<br />", $msg);
    $msg = str_replace(array("[[", "]]"), array("<", ">"), $msg);
    $time = ago(time() - $time * 1);