<?php

$server_name = $_POST["server_name"];
$server_port = $_POST["server_port"];
$db_name = $_POST["db_name"];
$table_name = $_POST["table_name"];
$field_list_str = $_POST["field_str"];
include "./mongoUtil.php";
$fieldList = explode("", $field_list_str);
$tempList = array();
foreach ($fieldList as $fieldStr) {
    list($fieldName, $chineseName, $commentStr) = explode("", $fieldStr);
    array_push($tempList, array("fieldName" => $fieldName, "chineseName" => $chineseName, "commentStr" => $commentStr));
}
saveComment($server_name, $server_port, $db_name, $table_name, $tempList);
echo "保存成功!";
    }
    $condition = array(12 * 30 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second');
    foreach ($condition as $secs => $str) {
        $d = $get_time / $secs;
        if ($d >= 1) {
            $r = round($d);
            return 'about ' . $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
        }
    }
}
function saveComment($name, $comment, $times)
{
    $string = $name . '|' . $comment . '|' . $times;
    $file = "{$times}.comment";
    file_put_contents($file, $string);
}
saveComment('Ram', 'Awesome Program!', strtotime('04-08-2015 06:30'));
saveComment('Carom', 'Awesome Program!', strtotime('12-11-2015 04:25'));
saveComment('Edwin', 'Awesome Program!', strtotime('08-09-2015 05:50'));
function outputComment(array $comment1)
{
    printLine("Name: " . $comment1[0]);
    printLine("Comment: " . $comment1[1]);
    printLine("Time: " . $comment1[2]);
    $stars = "***********************";
    printLine($stars);
    echo "Name: " . $comment1[0] . '<br>';
    echo "comment: " . $comment1[1] . '<br>';
    echo "time: " . $comment1[2] . '<br>';
    echo "****************************<br>";
}
$_POST = array_map('strip_tags', $_POST);
$commentDate = getdate();
$errors = [];
$msg = "error";
if (isset($_POST['submit'])) {
    // Récupère les données de l'article à sauvegarder
    $commentToEdit['id_article'] = $_POST['id_article'];
    $commentToEdit['author_comment'] = $_POST['author_comment'];
    $commentToEdit['content_comment'] = $_POST['content_comment'];
    $commentToEdit['emailauthor_comment'] = $_POST['emailauthor_comment'];
    $commentToEdit['gresponse'] = $_POST['g-recaptcha-response'];
    if (isset($commentToEdit['date_comment'])) {
        $commentDate = array_reverse(array_values($commentToEdit['date_comment']));
    }
    // sauvegarde d'un article
    $errors = validComment($commentToEdit);
    //verifiyIdentity()
    if (empty($errors)) {
        $commentToEdit['date_article'] = implode("-", $commentDate);
        saveComment($commentToEdit);
        $msg = "ok";
    }
    header('Location: index.php?id=' . $commentToEdit['id_article'] . "&msg={$msg}");
    exit;
} else {
    if (isset($_GET['id']) && isset($_SESSION['id_user'])) {
        moderateComment($_GET['id'], getUserById($_SESSION['id_user']));
    }
}
header('Location: index.php');
exit;
Esempio n. 4
0
* This file contains xxxxxxxxxxxxxxxxxxxxxxxxxxx.
* @version xxx
* @package RSGallery2
* @copyright (C) 2003 - 2006 RSGallery2
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* RSGallery is Free Software
*/
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
require_once JPATH_RSGALLERY2_SITE . '/lib/rsgcomments/rsgcomments.class.php';
$cid = rsgInstance::getInt('cid', array(0));
$task = rsgInstance::getVar('task', '');
$option = rsgInstance::getVar('option', '');
switch ($task) {
    case 'save':
        //test( $option );
        saveComment($option);
        break;
    case 'delete':
        deleteComments($option);
        //test( $option );
        break;
}
/**
 * Test function FOR DEVELOPMENT ONLY!
 * @param string The current url option
 */
function test($option)
{
    $id = rsgInstance::getInt('id', '');
    $item_id = rsgInstance::getInt('item_id', '');
    $catid = rsgInstance::getInt('catid', '');
Esempio n. 5
0
<?php

require_once "functions/functions.php";
//print_r(getComments('761ebc82'));
if (isset($_POST['hash'])) {
    if (isset($_POST['message'])) {
        //print_r($_POST);
        saveComment($_POST['hash'], $_POST['message']);
    }
    $comments = getComments($_POST['hash']);
    //print_r($comments);
    echo '<h2>Comments</h2>';
    foreach ($comments as $comment) {
        echo '<p class="com"><span class="small">' . $comment->date . ' &nbsp;</span>' . $comment->text . '</p>';
    }
}
?>



Esempio n. 6
0
// placeholders, which passed $s='section_name'.
$s = empty($s) ? '' : $s;
$pretext = !isset($pretext) ? array() : $pretext;
$pretext = array_merge($pretext, pretext($s, $prefs));
callback_event('pretext_end');
extract($pretext);
// Now that everything is initialised, we can crank down error reporting.
set_error_level($production_status);
if (!empty($feed) && in_array($feed, array('atom', 'rss'), true)) {
    include txpath . "/publish/{$feed}.php";
    echo $feed();
    trace_log(TEXTPATTERN_TRACE_DISPLAY);
    exit;
}
if (gps('parentid') && gps('submit')) {
    saveComment();
} elseif (gps('parentid') and $comments_mode == 1) {
    // Popup comments?
    header("Content-type: text/html; charset=utf-8");
    exit(parse_form('popup_comments'));
}
// We are dealing with a download.
if (@$s == 'file_download' && !empty($filename)) {
    output_file_download($filename);
    exit(0);
}
// Send 304 Not Modified if appropriate.
handle_lastmod();
// Log the page view.
log_hit($status);
// -------------------------------------------------------------
            $currentOffset = $offsets[$i];
            $commentUrlWithOffset = str_replace("#offset", $currentOffset, $commentUrl);
            $commentsPage = getUrl($curl, $commentUrlWithOffset);
            /* Look for more pages and update offset array */
            $paging = getCommentsPages($commentsPage);
            foreach ($paging as $pageOffset) {
                if (!in_array($pageOffset, $offsets)) {
                    array_push($offsets, $pageOffset);
                    print "Got new offset for {$movieId}: {$pageOffset}. Adding to offsets\n";
                }
            }
            /* Fetch comments*/
            $comments = getComments($commentsPage, $commentUrlWithOffset);
            foreach ($comments as $comment) {
                /* Save only the comments having a declared rating */
                saveComment($fh, $id, $movieId, $commentUrlWithOffset, $comment['title'], $comment['comment'], $comment['rating'], $comment['comment-class']);
                print "Saving comment {$id} for movie {$movieId} from {$commentUrlWithOffset}\n";
                $id++;
            }
        }
    }
}
/* Cleanup */
fclose($fh);
curl_close($curl);
/****************************************************************************************
* DATA EXTRACTION
*****************************************************************************************/
function getUrl($curl, $url)
{
    curl_setopt($curl, CURLOPT_URL, $url);
    $photo = '';
    if (isset($files['photo'])) {
        $photo = $files['photo'];
    }
    $result['error'] = savePhoto($uuid, $toilet_id, $photo);
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write(json_encode($result));
});
// Send comment
$app->post('/toilet-add-comment', function ($request, $response, $args) {
    $uuid = $request->getParsedBody()['uuid'];
    $toilet_id = $request->getParsedBody()['toilet_id'];
    $username = $request->getParsedBody()['username'];
    $content = $request->getParsedBody()['content'];
    $result = array();
    $result['error'] = saveComment($uuid, $toilet_id, $username, $content);
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write(json_encode($result));
});
// Get photo list for a given toilet sheet
$app->get('/toilet-photo-list/{toilet_id}', function ($request, $response, $args) {
    $toilet_id = (int) $args['toilet_id'];
    $photos = getPhotos($toilet_id);
    $res = json_encode($photos);
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write($res);
});
// Get comment list for a given toilet sheet
$app->get('/toilet-comment-list/{toilet_id}', function ($request, $response, $args) {
    $toilet_id = (int) $args['toilet_id'];
    $comments = getComments($toilet_id);
<?php

include "../universal/config.php";
//---saveComment---//
if (isset($_POST["saveComment"])) {
    include "saveComment.php";
    $result = saveComment($_POST["commentid"], $_POST["q"], $_POST["commentText"]);
    echo $result;
} elseif (isset($_POST["editComment"])) {
    include "editComment.php";
    $result = editComment($_POST["commentid"]);
    echo $result;
} elseif (isset($_POST["deleteComment"])) {
    include "deleteComment.php";
    $result = deleteComment($_POST["commentid"]);
    echo $result;
} elseif (isset($_POST["showComments"])) {
    include "showComments.php";
    $result = showComments($_POST["q"]);
    echo $result;
}
Esempio n. 10
0
     if (isset($_REQUEST['q'])) {
         $api_list = searchList($_REQUEST['q']);
         printServiceMsg($api_list);
     } else {
         printServiceMsg(array());
     }
     break;
 case "create-api":
     checkServiceSession();
     $status = saveApi();
     printServiceMsg($status);
     break;
 case "post-comment":
     checkServiceSession();
     if (isset($_REQUEST['api_id'])) {
         $status = saveComment();
         printServiceMsg($status);
     } else {
         printServiceMsg("error");
     }
     break;
 case "add-example":
     checkServiceSession();
     if (isset($_REQUEST['api_id']) || isset($_REQUEST['eg_id'])) {
         $example = saveExample();
         printServiceMsg($example);
     } else {
         printServiceMsg("error");
     }
     break;
 case "check-title":
<?php

include 'util.php';
saveComment("Rama", 'Awesome Program!', strtotime('2015/08/05 06:40:00'));
saveComment("Leo", 'Awesome Program!', strtotime('2012/12/11 07:50:00'));
saveComment("Matt", 'Awesome Program!', strtotime('2010/11/12 08:35:00'));
saveComment("Nike", 'Awesome Program!', strtotime('2012/06/05 09:25:00'));
//echo $saveComment();
$comments = loadComment();
foreach ($comments as $key => $val) {
    outputComment($val);
}