Пример #1
0
 function reply()
 {
     global $CJob;
     $CJob->requireLogin();
     global $params, $MMessage;
     // Params to vars
     // Processes message data
     function viewData($c, $entry = NULL)
     {
         global $MMessage;
         $messages = array_reverse(iterator_to_array($MMessage->findByParticipant($_SESSION['_id']->{'$id'})));
         $replies = array();
         $unread = 0;
         foreach ($messages as $m) {
             $reply = array_pop($m['replies']);
             $reply['_id'] = $m['_id'];
             $from = $reply['from'];
             if (!$reply['read']) {
                 $reply['read'] = strcmp($from, $_SESSION['_id']) == 0;
             }
             if (!$reply['read']) {
                 $unread++;
             }
             $c->setFromNamePic($reply, $from);
             if (strcmp($m['_id'], $entry['_id']) == 0) {
                 $reply['current'] = true;
             } else {
                 $reply['current'] = false;
             }
             $reply['time'] = timeAgo($reply['time']);
             if (strlen($reply['msg']) > 100) {
                 $reply['msg'] = substr($reply['msg'], 0, 97) . '...';
             }
             array_push($replies, $reply);
         }
         // Handle current message
         if (!is_null($entry)) {
             $currentreplies = $entry['replies'];
             $current = array();
             foreach ($currentreplies as $m) {
                 $c->setFromNamePic($m, $m['from']);
                 $m['time'] = timeAgo($m['time']);
                 array_push($current, $m);
             }
             $to = 'Message To: ' . $c->getName($entry['participants'][0]);
             foreach ($entry['participants'] as $p) {
                 if (strcmp($p, $_SESSION['_id']) != 0) {
                     $to = 'Message To: ' . $c->getName($p);
                 }
             }
             $currentid = $entry['_id'];
         } else {
             $current = null;
             $currentid = null;
             $to = '';
         }
         $data = array('messages' => $replies, 'current' => $current, 'currentid' => $currentid, 'unread' => $unread, 'to' => $to);
         if (isset($_GET['msg'])) {
             $data['msg'] = $_GET['msg'];
         }
         return $data;
     }
     if (!isset($_GET['id'])) {
         $this->render('messages', viewData($this));
         return;
     }
     /* ACTUALLY SEND MESSAGES */
     // Validations
     $this->startValidations();
     $this->validate(MongoId::isValid($id = $_GET['id']) and ($entry = $MMessage->get($id)) !== NULL, $err, 'unknown message');
     if ($this->isValid()) {
         $this->validate(in_array($myid = $_SESSION['_id']->{'$id'}, $entry['participants']), $err, 'permission denied');
     }
     if ($this->isValid()) {
         // Set replies to read
         $repliesn = count($entry['replies']);
         for ($i = 0; $i < $repliesn; $i++) {
             if (strcmp($entry['replies'][$i]['from'], $_SESSION['_id']) != 0) {
                 $entry['replies'][$i]['read'] = true;
             }
         }
         $MMessage->save($entry);
         if (!isset($_POST['reply'])) {
             $this->render('messages', viewData($this, $entry));
             return;
         }
         extract($data = $this->data($params));
         // Validations
         $this->validate(strlen($msg) > 0, $err, 'message empty');
         if ($repliesn > 0) {
             $replylast = $entry['replies'][$repliesn - 1];
             $this->validate($msg != $replylast['msg'] or time() - $replylast['time'] > 10, $err, 'message sent');
         }
         if ($this->isValid()) {
             // Send the message
             $msgid = $entry['_id']->{'$id'};
             $from = $myid;
             $fromname = $this->getName($from);
             $tos = array_remove($entry['participants'], $from);
             $entry = $MMessage->reply($msgid, $from, $msg);
             $emails = array();
             foreach ($tos as $to) {
                 $emails[] = $this->getEmail($to);
             }
             // Notify recipients by email
             $link = "http://sublite.net/housing/messages.php?id={$msgid}";
             $message = "\n            {$fromname} has sent you a message on SubLite:\n            <br /><br />\n            View the message on SubLite: <a href='{$link}'>{$link}</a>\n            <br />\n            ---\n            <br /><br />\n            {$msg}\n            <br /><br />\n            ---\n            <br />\n            Reply to this message <a href='{$link}'>on SubLite</a>. DO NOT REPLY DIRECTLY TO THIS EMAIL.\n          ";
             sendgmail($emails, array("*****@*****.**", "SubLite, LLC."), "Message from {$fromname} | SubLite", $message);
             // Notify us of the message
             $toemails = implode(', ', $emails);
             $fromemail = $this->getEmail($from);
             $prevmsgs = '';
             $replies = array_reverse($entry['replies']);
             foreach ($replies as $reply) {
                 $pfromemail = $this->getEmail($reply['from']);
                 $pmsg = $reply['msg'];
                 $prevmsgs .= "<b>{$pfromemail}</b>: <br />{$pmsg}<br />";
             }
             $message = "\n            <b>{$fromemail}</b> has sent a message to <b>{$toemails}</b>:\n            <br /><br />\n            {$msg}\n            <br /><br />\n            msgid: {$msgid}\n            <br /><br />\n            The thread:\n            <br /><br />\n            {$prevmsgs}\n          ";
             sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'Message sent on SubLite!', $message);
             $this->render('messages', viewData($this, $entry));
             return;
         }
         $this->render('messages', viewData($this, $entry));
         return;
     }
     $this->error($err);
     $this->render('notice');
 }
function deleteData()
{
    global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg;
    $pResult = mysql_list_fields($dbname, $tablename);
    $num = mysql_num_fields($pResult);
    $key = "";
    for ($i = 0; $i < $num; $i++) {
        $field = mysql_fetch_field($pResult, $i);
        if ($field->primary_key == 1) {
            if ($field->numeric == 1) {
                $key .= $field->name . "=" . $GLOBALS[$field->name] . " AND ";
            } else {
                $key .= $field->name . "='" . $GLOBALS[$field->name] . "' AND ";
            }
        }
    }
    $key = substr($key, 0, strlen($key) - 4);
    mysql_select_db($dbname, $mysqlHandle);
    $queryStr = "DELETE FROM {$tablename} WHERE {$key}";
    mysql_query($queryStr, $mysqlHandle);
    $errMsg = mysql_error();
    viewData("");
}
Пример #3
0
} else {
    //※データ作成処理
    //-----------------------------------------------------------------------------------
    //  $i=0;
    //  while( $res = $stmt->fetch(PDO::FETCH_ASSOC)){
    //    if($i==0){
    //      //ループ初回のみ、ここを処理
    //      $view .= '"'.$res['img'].','.$res['lat'].','.$res['lon'].','.$res['input_date'].'"';
    //    }else{
    //      //ループ2回めからこちらを処理
    //      $view .=',"'.$res['img'].','.$res['lat'].','.$res['lon'].','.$res['input_date'].'"';
    //    }
    //    $i++;
    //  }
    //-----------------------------------------------------------------------------------
    $view = viewData($stmt);
}
?>


<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CheckInデモ</title>
<style>p{color:white}#map_area{position: relative;height:500px;padding:20px;}#myMap{width:95%;}#myMapimg{width:100%}</style>
<link rel="stylesheet" href="css/range.css">
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>