<?php // deal request for fetching the fresh comments which have been pushed onto the wall (ok) session_start(); $activityid = isset($_SESSION["activityid"]) ? $_SESSION["activityid"] : null; $response = array(); if ($activityid != null) { include_once "../model/connect.php"; include_once "../model/usermodel.php"; include_once "../model/commentmodel.php"; include_once "../model/wallmodel.php"; $conn = getConnection(); $list = freshComments($conn, $activityid); $N = count($list); for ($i = 0; $i < $N; $i++) { $pair = searchComment($conn, $list[$i][0]); $data = array(); $data["nickname"] = getNickname($conn, $pair[0]); $data["istop"] = $list[$i][1]; $data["content"] = $pair[1]; $response[] = $data; } mysql_close($conn); } header("Content-Type:application/json;charset=utf-8"); echo json_encode($response);
function searchFolder(&$i_args, &$o_out, $i_path, $i_depth) { global $FileMaxLength; $i_depth++; if ($i_depth > $i_args['depth']) { return; } if (false == is_dir($i_path)) { return; } $dHandle = opendir($i_path); if ($dHandle === false) { return; } while (false !== ($entry = readdir($dHandle))) { if ($entry == '.') { continue; } if ($entry == '..') { continue; } $path = "{$i_path}/{$entry}"; if (false == is_dir($path)) { continue; } $found = false; $rufolder = "{$path}/" . $i_args['rufolder']; if (is_dir($rufolder)) { $found = true; } if ($found && htaccessPath($i_path)) { $found = true; } if ($found && array_key_exists('status', $i_args)) { $found = false; $rufile = "{$rufolder}/status.json"; if (is_file($rufile)) { if ($fHandle = fopen($rufile, 'r')) { $obj = json_decode(fread($fHandle, $FileMaxLength), true); if (searchStatus($i_args['status'], $obj)) { $found = true; } fclose($fHandle); } } } if ($found && array_key_exists('body', $i_args)) { $found = false; $rufile = "{$rufolder}/body.html"; if (is_file($rufile)) { if ($fHandle = fopen($rufile, 'r')) { $data = fread($fHandle, $FileMaxLength); fclose($fHandle); if (mb_stripos($data, $i_args['body'], 0, 'utf-8') !== false) { $found = true; } } } } if ($found && array_key_exists('comment', $i_args)) { $found = false; $rufile = "{$rufolder}/comments.json"; if (is_file($rufile)) { if ($fHandle = fopen($rufile, 'r')) { $obj = json_decode(fread($fHandle, $FileMaxLength), true); if (searchComment($i_args['comment'], $obj)) { $found = true; } fclose($fHandle); } } } if ($found) { array_push($o_out['result'], $path); } if ($i_depth < $i_args['depth']) { searchFolder($i_args, $o_out, $path, $i_depth); } } closedir($dHandle); }