/**
  * Store a newly created conversation in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('users' => 'required|array', 'body' => 'required');
     $validator = Validator::make(Input::only('users', 'body'), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     // Create Conversation
     $params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
     $conversation = Conversation::create($params);
     $conversation->users()->attach(Input::get('users'));
     $conversation->users()->attach(array(Auth::user()->id));
     // Create Message
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach (Input::get('users') as $user_id) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
         // Publish Data To Redis
         $data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
         Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     return Redirect::route('chat.index', array('conversation', $conversation->name));
 }
Exemplo n.º 2
0
 public static function addEmail($from, $to, $subject, $body, array $attachments = array())
 {
     if (trim($from) === '') {
         $from = SystemSettings::getSettings(SystemSettings::TYPE_EMAIL_DEFAULT_SYSTEM_EMAIL);
     }
     return Message::create($from, $to, $subject, $body, Message::TYPE_EMAIL, $attachments);
 }
Exemplo n.º 3
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Message::create([]);
     }
 }
Exemplo n.º 4
0
 public function run()
 {
     Eloquent::unguard();
     Message::create(array('message_body' => 'This is a sample message that is short and to the point.', 'user_id' => '1'));
     Message::create(array('message_body' => 'Sa takie dni w tygodniu.', 'user_id' => '1'));
     Message::create(array('message_body' => 'Still working on this special project', 'user_id' => '2'));
     Message::create(array('message_body' => 'Everything I build is amazing and exceeds my own expectations.', 'user_id' => '2'));
     Message::create(array('message_body' => 'Still working on this twitter clone application.', 'user_id' => '3'));
 }
Exemplo n.º 5
0
 public function actionCreate()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     $message = new Message($_POST);
     //TODO:add in error exception in case the message cannot be created
     if ($message->create()) {
         Message::updateCount($message->uid_to, 1);
     }
     Page::redirect("/messages");
 }
Exemplo n.º 6
0
 /**
  * @param array $attributes
  */
 public function loadRelated(array $attributes)
 {
     parent::loadRelated($attributes);
     if (isset($attributes['from'])) {
         $this->from = User::create($attributes['from']);
     }
     if (isset($attributes['message'])) {
         $this->message = Message::create($attributes['message']);
     }
 }
Exemplo n.º 7
0
 public function create()
 {
     RoutingEngine::setPage("runnDAILY", "PV__400");
     $message = new Message($_POST);
     if ($message->message) {
         $message->uid_to = null;
         $message->subject = null;
         exit(json_encode($message->create()));
     }
     var_dump($message);
 }
Exemplo n.º 8
0
    public function run()
    {
        DB::table('messages')->delete();
        $now = new DateTime();
        $oneHourLater = new DateTime('+1 hour');
        $tomorrow = new DateTime('tomorrow');
        Message::create(['message' => 'This is a first message.', 'published_at' => $now]);
        Message::create(['message' => 'This is a second message. It has much more text. Lots and lots of text. I need this to test message lengths.', 'published_at' => $oneHourLater]);
        Message::create(['message' => 'This is a message with an embedded tweet. <blockquote class="twitter-tweet" lang="en"><p>The 3 day <a href="https://twitter.com/hashtag/LaraconEU?src=hash">#LaraconEU</a> Schedule can be downloaded here <a href="http://t.co/VIob78wp7S">http://t.co/VIob78wp7S</a></p>&mdash; Laracon EU (@laraconeu) <a href="https://twitter.com/laraconeu/statuses/503119817600413697">August 23, 2014</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>', 'published_at' => $oneHourLater]);
        Message::create(['message' => 'This is a message on the second day.', 'published_at' => $tomorrow]);
    }
 public function actionAdd()
 {
     $this->pageTitle = Yii::t('page-title', 'Add new message dialog');
     $model = new Message();
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['Message'];
         if ($model->validate()) {
             $model->create();
             $this->redirect('/message/list');
         }
     }
     $this->render('add', ['model' => $model]);
 }
Exemplo n.º 10
0
 /**
  * Store a newly created resource in storage.
  * POST /contacts
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::get();
     $this->contactForm->validate($input);
     Message::create($input);
     Flash::message('Бидэнтэй холбогдож байгаад баярлалаа. Таньд удахгүй хариу мэдэгдье!');
     Mail::send('emails.question', $input, function ($message) {
         $message->to('*****@*****.**')->subject('Ask Ganbaatar');
     });
     Mail::send('emails.question', $input, function ($message) {
         $message->to('*****@*****.**')->subject('Ask Ganbaatar');
     });
     return Redirect::back();
 }
Exemplo n.º 11
0
 public static function sendNew($sender, $conversation, $content, $timeOffset = 0)
 {
     $id = Message::generateId(6);
     $timestamp = Utils::tps() + $timeOffset;
     $message = Message::create(array('id' => $id, 'sender_id' => $sender, 'conversation_id' => $conversation, 'content' => $content, 'timestamp' => $timestamp));
     $recep = array();
     $members = explode(';', trim(Conversation::find($conversation)->members_ids, ';'));
     foreach ($members as $id) {
         if ($id != $sender) {
             $recep[] = trim(UserChannel::find($id)->admins_ids, ';');
         }
     }
     $recep = ';' . implode(';', $recep) . ';';
     $recep = ChannelAction::filterReceiver($recep, "pm");
     ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => userChannel::find($sender)->id, 'recipients_ids' => $recep, 'type' => 'pm', 'target' => $conversation, 'timestamp' => $timestamp));
     return $message;
 }
Exemplo n.º 12
0
 public function view($common)
 {
     RoutingEngine::setPage("runnDAILY About", "PV__400");
     $pages = array("admin_elevation", "about_contact", "about_credits", "about_index", "community_index", "community_view_user", "confirmation_index", "goals_index", "goals_create", "home_index", "home_register", "messages_index", "routes_view", "routes_create", "routes_index", "training_create", "training_index");
     if (in_array($common, $pages)) {
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/{$common}.tpl");
     } else {
         $feedback = new Message();
         $feedback->uid_from = User::$current_user->uid;
         $feedback->uid_to = null;
         $feedback->message = "Please create a help page for " . $_SERVER["HTTP_REFERER"];
         $feedback->subject = null;
         $feedback->type = 2;
         $feedback->create();
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/none.tpl");
     }
     echo $output;
     die;
 }
 /**
  * Store a newly created message in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('body' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     $conversation = Conversation::where('name', Input::get('conversation'))->first();
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Input::get('user_id'), 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach ($conversation->users()->get() as $user) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user->id, 'conversation_id' => $conversation->id, 'read' => false)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     // Publish Data To Redis
     $data = array('room' => Input::get('conversation'), 'message' => array('body' => Str::words($message->body, 5), 'user_id' => Input::get('user_id')));
     Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data)));
     return Response::json(['success' => true, 'result' => $message]);
 }
Exemplo n.º 14
0
 public function save(Request $request)
 {
     //1. receive the message
     /*
      * 1. Receive the message
      * 2. based on its applicatino type, If pinyin chat, exec pinyin
      * 3. Use pusher API to send back request.
      */
     $content = $request->get('message');
     $senderId = $request->get('senderId');
     $receiverID = $request->get('receiverId');
     $message = $request->all();
     $message["haveRead"] = false;
     $redis = Redis::connection();
     $senderName = $redis->hget("user" . $senderId, "name");
     //If the message type is not a keystroke track
     if (intval($message["messageType"]) == 0) {
         //This is a bug, we should fetch from database not Redis, for offline users?
         //$receiverName = $redis->hget("user".$receiverID, "name");
         //begin exec node program pinyin and get a string output.
         exec("pinyin -S " . $content, $output);
         $chinese = $this->mb_str_split($content);
         $pinyin = explode(" ", $output[0]);
         $result = "";
         for ($i = 0; $i < count($chinese); $i++) {
             $result .= '<ruby class="message">' . $chinese[$i] . '<rt class="pinyin">' . $pinyin[$i] . "</rt></ruby>";
         }
         $message["message"] = $result;
     }
     $newmessage = Message::create($message);
     //Pusher logic
     $pusher = new Pusher('c9d61998865ce108f88e', 'b1b28a9b6ffc8999bd01', '134726');
     //todo: add messageType;
     $pusher->trigger("user" . $receiverID, 'newmessage', ['senderName' => $senderName, 'message' => $message["message"], 'senderId' => $senderId, 'messageId' => $newmessage->toArray()["id"], 'timestamp' => $newmessage->toArray()["created_at"]]);
     //Create a new message and wrote to the database, set the message to not read.
     return response()->json(['senderName' => $senderName, 'message' => $message["message"], 'timestamp' => $newmessage->toArray()["created_at"]]);
 }
Exemplo n.º 15
0
 public static function addMessage($text, $ticket = false, $ticket_id = null)
 {
     if (!isset($_SESSION['user'])) {
         throw new Exception('You are not logged in');
     }
     if (empty($text)) {
         throw new Exception('You haven\'t entered a message.');
     }
     $msg = new Message(array('user_id' => $_SESSION['user']['id'], 'text' => $text, 'created' => date('Y-m-d G:i:s')));
     if (isset($ticket_id) && is_numeric($ticket_id)) {
         $msg->ticket_id = $ticket_id;
     }
     // The create method returns the new id
     $insertID = $msg->create();
     $tick_no = null;
     if ($ticket) {
         $wlticket = new Ticket(array('message_id' => $insertID, 'title' => 'NIEUW', 'text' => $text, 'status_id' => 1));
         $tick_no = $wlticket->create();
     }
     if (isset($tick_no) && is_numeric($tick_no)) {
         $msg->setTicket($tick_no);
     }
     return array('id' => $insertID, 'ticket_id' => $msg->ticket_id);
 }
Exemplo n.º 16
0
 }
 /*if(isset($_GET['c_id']) && ($c_id == 0 || $group_id == 0)){$c_id = $_GET['c_id'];$object = Group::find_group_for_c_id($c_id);if(is_object($object) && array_key_exists($session->user_id,$object->users)){$c_id = $database->escape_value($_GET['c_id']);$group_id = Group::find_group_for_c_id($c_id);}else{$c_id = 0;$group_id = 0;}}else{$c_id = 0;$group_id = 0;}*/
 if (isset($_POST['send_message'])) {
     $c_id = $database->escape_value($_POST['c_id']);
     if ($c_id != 0) {
         $object = Conversation::find_by_id($c_id);
         $group_id = Group::find_group_id_for_c_id($c_id);
         if ($object->from_id === $group_id) {
             $message_to_send = new Message();
             $message_to_send->c_id = $c_id;
             $message_to_send->message = $database->escape_value($_POST['message']);
             $message_to_send->from_id = $session->user_id;
             $message_to_send->to_id = NULL;
             $message_to_send->timestamp = strftime("%Y-%m-%d %H:%M:%S", time());
             $message_to_send->image = $database->escape_value(NULL);
             if ($message_to_send->create()) {
                 Group::change_timestamp($group_id);
                 redirect_to("index.php?msg=group&group_id={$group_id}&c_id=" . $c_id);
             } else {
                 echo "Message creation failed";
             }
         }
     }
 }
 if (isset($_POST['search'])) {
     $objects = Group::find_by_group_name($_POST['search_item']);
     $search = "";
     if (is_array($objects) && !empty($objects)) {
         foreach ($objects as $key => $object) {
             if (Group::verify_user($session->user_id, $object->id)) {
                 $search .= "<div class=\"group_search conversation\">";
 public function personalReply($id)
 {
     $in = Input::all();
     Message::create(['RecipientID' => $id, 'SenderID' => Auth::user()->StudentID, 'Message' => $in['message']]);
     return '';
 }
Exemplo n.º 18
0
 /**
  * @param array $attributes
  */
 public function loadRelated(array $attributes)
 {
     parent::loadRelated($attributes);
     if (isset($attributes['from'])) {
         $this->from = User::create($attributes['from']);
     }
     if (isset($attributes['chat'])) {
         $this->chat = isset($attributes['chat']->title) ? GroupChat::create($attributes['chat']) : User::create($attributes['chat']);
     }
     if (isset($attributes['forward_from'])) {
         $this->forward_from = User::create($attributes['forward_from']);
     }
     if (isset($attributes['forward_from_chat'])) {
         $this->forward_from_chat = Chat::create($attributes['forward_from_chat']);
     }
     if (isset($attributes['reply_to_message'])) {
         $this->reply_to_message = Message::create($attributes['reply_to_message']);
     }
     if (isset($attributes['entities'])) {
         $this->entities = array_map(function ($entity) {
             return MessageEntity::create($entity);
         }, $attributes['entities']);
     }
     if (isset($attributes['audio'])) {
         $this->audio = Audio::create($attributes['audio']);
     }
     if (isset($attributes['document'])) {
         $this->document = Document::create($attributes['document']);
     }
     if (isset($attributes['photo'])) {
         $this->photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['photo']);
     }
     if (isset($attributes['sticker'])) {
         $this->sticker = Sticker::create($attributes['sticker']);
     }
     if (isset($attributes['video'])) {
         $this->video = Video::create($attributes['video']);
     }
     if (isset($attributes['voice'])) {
         $this->voice = Voice::create($attributes['voice']);
     }
     if (isset($attributes['contact'])) {
         $this->contact = Contact::create($attributes['contact']);
     }
     if (isset($attributes['location'])) {
         $this->location = Location::create($attributes['location']);
     }
     if (isset($attributes['venue'])) {
         $this->venue = Venue::create($attributes['venue']);
     }
     if (isset($attributes['new_chat_member'])) {
         $this->new_chat_member = User::create($attributes['new_chat_member']);
     }
     if (isset($attributes['left_chat_member'])) {
         $this->left_chat_member = new User($attributes['left_chat_member']);
     }
     if (isset($attributes['new_chat_photo'])) {
         $this->new_chat_photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['new_chat_photo']);
     }
 }
Exemplo n.º 19
0
 public function run()
 {
     Message::create(['receiver_id' => 1, 'sender_id' => 2, 'content' => '其实不应该是这样的,你完全不理解戏曲的重要性,我们做的是什么,热爱,对生活的向往,向阳!']);
     Message::create(['receiver_id' => 1, 'sender_id' => 3, 'content' => '其实不应该是这样的,你完全不理解戏曲的重要性,我们做的是什么,热爱,对生活的向往,向阳!']);
     Message::create(['receiver_id' => 1, 'sender_id' => 4, 'content' => '其实不应该是这样的,你完全不理解戏曲的重要性,我们做的是什么,热爱,对生活的向往,向阳!']);
 }
Exemplo n.º 20
0
 /**
  * Send request
  */
 public function postMessages($id)
 {
     //validate the input
     $rules = array('comments' => 'required|min:10', 'status_id' => 'required|numeric', 'attachment' => 'mines:pdf,doc,docx,txt');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //insert request
     $itemData = Input::except('_token');
     $itemData['item_id'] = $id;
     $itemData['user_id'] = $this->user->id;
     $itemData['submit_date'] = new Datetime();
     if (!is_null(Input::file('attachment'))) {
         $fileName = time() . Input::file('attachment')->getClientOriginalName();
         $destinationPath = 'public/upload';
         Input::file('attachment')->move($destinationPath, $fileName);
         $attach_path = $destinationPath . '/' . $fileName;
     }
     if (isset($attach_path)) {
         $itemData['attachment'] = $attach_path;
     }
     $item = Message::create($itemData);
     return Redirect::back()->with('message', 'Your request had been submited!');
 }
Exemplo n.º 21
0
function sec_main()
{
    global $settings, $rules, $coach, $lng, $leagues;
    MTS('Main start');
    list($sel_lid, $HTML_LeagueSelector) = HTMLOUT::simpleLeagueSelector();
    $IS_GLOBAL_ADMIN = is_object($coach) && $coach->ring == Coach::T_RING_GLOBAL_ADMIN;
    /*
     *  Was any main board actions made?
     */
    if (isset($_POST['type']) && is_object($coach) && $coach->isNodeCommish(T_NODE_LEAGUE, $sel_lid)) {
        if (get_magic_quotes_gpc()) {
            if (isset($_POST['title'])) {
                $_POST['title'] = stripslashes($_POST['title']);
            }
            if (isset($_POST['txt'])) {
                $_POST['txt'] = stripslashes($_POST['txt']);
            }
        }
        $msg = isset($_POST['msg_id']) ? new Message((int) $_POST['msg_id']) : null;
        switch ($_POST['type']) {
            case 'msgdel':
                status($msg->delete());
                break;
            case 'msgnew':
                status(Message::create(array('f_coach_id' => $coach->coach_id, 'f_lid' => $IS_GLOBAL_ADMIN && isset($_POST['BC']) && $_POST['BC'] ? Message::T_BROADCAST : $sel_lid, 'title' => $_POST['title'], 'msg' => $_POST['txt'])));
                break;
            case 'msgedit':
                status($msg->edit($_POST['title'], $_POST['txt']));
                break;
            case 'pin':
                status($msg->pin(1));
                break;
            case 'unpin':
                status($msg->pin(0));
                break;
        }
    }
    /*
     *  Now we are ready to generate the HTML code.
     */
    ?>
    <div class="main_head"><?php 
    echo $settings['league_name'];
    ?>
</div>
    <div class='main_leftColumn'>
        <div class="main_leftColumn_head">
            <?php 
    echo "<div class='main_leftColumn_welcome'>\n";
    echo $settings['welcome'];
    echo "</div>\n";
    echo "<div class='main_leftColumn_left'>\n";
    if (count($leagues) > 1) {
        echo $HTML_LeagueSelector;
    }
    echo "</div>\n";
    echo "<div class='main_leftColumn_right'>\n";
    if (is_object($coach) && $coach->isNodeCommish(T_NODE_LEAGUE, $sel_lid)) {
        echo "<a href='javascript:void(0);' onClick=\"slideToggle('msgnew');\">" . $lng->getTrn('main/newmsg') . "</a>&nbsp;\n";
    }
    if (Module::isRegistered('RSSfeed')) {
        echo "<a href='handler.php?type=rss'>RSS</a>\n";
    }
    echo "</div>\n";
    ?>
            <div style="display:none; clear:both;" id="msgnew">
                <br><br>
                <form method="POST">
                    <textarea name="title" rows="1" cols="50"><?php 
    echo $lng->getTrn('common/notitle');
    ?>
</textarea><br><br>
                    <textarea name="txt" rows="15" cols="50"><?php 
    echo $lng->getTrn('common/nobody');
    ?>
</textarea><br><br>
                    <?php 
    if ($IS_GLOBAL_ADMIN) {
        echo $lng->getTrn('main/broadcast');
        ?>
<input type="checkbox" name="BC"><br><br><?php 
    }
    ?>
                    <input type="hidden" name="type" value="msgnew">
                    <input type="submit" value="<?php 
    echo $lng->getTrn('common/submit');
    ?>
">
                </form>
            </div>
        </div>

        <?php 
    /*
        Generate main board.
    
        Left column is the message board, consisting of both commissioner messages and game summaries/results.
        To generate this table we create a general array holding the content of both.
    */
    $j = 1;
    $prevPinned = 0;
    foreach (TextSubSys::getMainBoardMessages($settings['fp_messageboard']['length'], $sel_lid, $settings['fp_messageboard']['show_team_news'], $settings['fp_messageboard']['show_match_summaries']) as $e) {
        if ($prevPinned == 1 && !$e->pinned) {
            echo "<hr>\n";
        }
        $prevPinned = $e->pinned;
        echo "<div class='boxWide'>\n";
        echo "<h3 class='boxTitle{$e->cssidx}'>{$e->title}</h3>\n";
        echo "<div class='boxBody'>\n";
        $fmtMsg = fmtprint($e->message);
        # Basic supported syntax: linebreaks.
        echo "\r\n                    <div id='e{$j}' class='expandable'>{$fmtMsg}</div>\r\n                    <script type='text/javascript'>\r\n                      \$('#e{$j}').expander({\r\n                        slicePoint:       300,\r\n                        expandText:       '" . $lng->getTrn('main/more') . "',\r\n                        collapseTimer:    0,\r\n                        userCollapseText: ''\r\n                      });\r\n                      </script>";
        echo "<br><hr>\n";
        echo "<table class='boxTable'><tr>\n";
        switch ($e->type) {
            case T_TEXT_MATCH_SUMMARY:
                echo "<td align='left' width='100%'>" . $lng->getTrn('main/posted') . " " . textdate($e->date) . " " . (isset($e->date_mod) && $e->date_mod != $e->date ? "(" . $lng->getTrn('main/lastedit') . " " . textdate($e->date_mod) . ") " : '') . $lng->getTrn('main/by') . " {$e->author}</td>\n";
                echo "<td align='right'><a href='index.php?section=matches&amp;type=report&amp;mid={$e->match_id}'>" . $lng->getTrn('common/view') . "</a></td>\n";
                break;
            case T_TEXT_MSG:
                echo "<td align='left' width='100%'>" . $lng->getTrn('main/posted') . " " . textdate($e->date) . " " . $lng->getTrn('main/by') . " {$e->author}</td>\n";
                if (is_object($coach) && ($IS_GLOBAL_ADMIN || $coach->coach_id == $e->author_id)) {
                    // Only admins may delete messages, or if it's a commissioner's own message.
                    echo "<td align='right'><a href='javascript:void(0);' onClick=\"slideToggle('msgedit{$e->msg_id}');\">" . $lng->getTrn('common/edit') . "</a></td>\n";
                    echo "<td align='right'>";
                    $fieldname = 'pin';
                    if ($e->pinned) {
                        $fieldname = 'unpin';
                    }
                    echo inlineform(array('type' => "{$fieldname}", 'msg_id' => $e->msg_id), "{$fieldname}{$e->msg_id}", $lng->getTrn("main/{$fieldname}"));
                    echo "</td>";
                    echo "<td align='right'>";
                    echo inlineform(array('type' => 'msgdel', 'msg_id' => $e->msg_id), "msgdel{$e->msg_id}", $lng->getTrn('common/delete'));
                    echo "</td>";
                }
                break;
            case T_TEXT_TNEWS:
                echo "<td align='left' width='100%'>" . $lng->getTrn('main/posted') . " " . textdate($e->date) . "</td>\n";
                break;
        }
        ?>
                    </tr></table>
                    <?php 
        if ($e->type == T_TEXT_MSG) {
            echo "<div style='display:none;' id='msgedit{$e->msg_id}'>\n";
            echo "<hr><br>\n";
            echo '<form method="POST">
                            <textarea name="title" rows="1" cols="50">' . $e->title . '</textarea><br><br>
                            <textarea name="txt" rows="15" cols="50">' . $e->message . '</textarea><br><br>
                            <input type="hidden" name="type" value="msgedit">
                            <input type="hidden" name="msg_id" value="' . $e->msg_id . '">
                            <input type="submit" value="' . $lng->getTrn('common/submit') . '">
                        </form>';
            echo "</div>";
        }
        ?>
                </div>
            </div>
            <?php 
        $j++;
    }
    ?>

    </div>
    <?php 
    MTS('Board messages generated');
    /*
        The right hand side column optionally (depending on settings) contains standings, latest game results, touchdown and casualties stats.
        We will now generate the stats, so that they are ready to be printed in correct order.
    */
    echo "<div class='main_rightColumn'>\n";
    $boxes_all = array_merge($settings['fp_standings'], $settings['fp_leaders'], $settings['fp_events'], $settings['fp_latestgames']);
    usort($boxes_all, create_function('$a,$b', 'return (($a["box_ID"] > $b["box_ID"]) ? 1 : (($a["box_ID"] < $b["box_ID"]) ? -1 : 0) );'));
    $boxes = array();
    foreach ($boxes_all as $box) {
        # These fields distinguishes the box types.
        if (isset($box['fields'])) {
            $box['dispType'] = 'standings';
        } else {
            if (isset($box['field'])) {
                $box['dispType'] = 'leaders';
            } else {
                if (isset($box['content'])) {
                    $box['dispType'] = 'events';
                } else {
                    $box['dispType'] = 'latestgames';
                }
            }
        }
        switch ($box['type']) {
            case 'league':
                $_type = T_NODE_LEAGUE;
                break;
            case 'division':
                $_type = T_NODE_DIVISION;
                break;
            case 'tournament':
                $_type = T_NODE_TOURNAMENT;
                break;
            default:
                $_type = T_NODE_LEAGUE;
        }
        $box['type'] = $_type;
        $boxes[] = $box;
    }
    // Used in the below standings dispType boxes.
    global $core_tables, $ES_fields;
    $_MV_COLS = array_merge(array_keys($core_tables['mv_teams']), array_keys($ES_fields));
    $_MV_RG_INTERSECT = array_intersect(array_keys($core_tables['teams']), array_keys($core_tables['mv_teams']));
    // Let's print those boxes!
    foreach ($boxes as $box) {
        switch ($box['dispType']) {
            case 'standings':
                $_BAD_COLS = array();
                # Halt on these columns/fields.
                switch ($box['type']) {
                    case T_NODE_TOURNAMENT:
                        if (!get_alt_col('tours', 'tour_id', $box['id'], 'tour_id')) {
                            break 2;
                        }
                        $tour = new Tour($box['id']);
                        $SR = array_map(create_function('$val', 'return $val[0]."mv_".substr($val,1);'), $tour->getRSSortRule());
                        break;
                    case T_NODE_DIVISION:
                        $_BAD_COLS = array('elo', 'swon', 'slost', 'sdraw', 'win_pct');
                        # Divisions do not have pre-calculated, MV, values of these fields.
                        // Fall through!
                    # Divisions do not have pre-calculated, MV, values of these fields.
                    // Fall through!
                    case T_NODE_LEAGUE:
                    default:
                        global $hrs;
                        $SR = $hrs[$box['HRS']]['rule'];
                        foreach ($SR as &$f) {
                            $field = substr($f, 1);
                            if (in_array($field, $_MV_RG_INTERSECT)) {
                                if (in_array($field, $_BAD_COLS)) {
                                    # E.g. divisions have no win_pct record for teams like the mv_teams table (for tours) has.
                                    fatal("Sorry, the element '{$field}' in your specified house sortrule #{$box['HRS']} is not supported for your chosen type (ie. tournament/division/league).");
                                }
                                $f = $f[0] . "rg_" . substr($f, 1);
                            } else {
                                $f = $f[0] . "mv_" . substr($f, 1);
                            }
                        }
                        break;
                }
                list($teams, ) = Stats::getRaw(T_OBJ_TEAM, array($box['type'] => $box['id']), array(1, $box['length']), $SR, false);
                ?>
            <div class='boxWide'>
                <h3 class='boxTitle<?php 
                echo T_HTMLBOX_STATS;
                ?>
'><?php 
                echo $box['title'];
                ?>
</h3>
                <div class='boxBody'>
                    <table class="boxTable">
                        <?php 
                echo "<tr>\n";
                foreach ($box['fields'] as $title => $f) {
                    echo "<td><i>{$title}</i></td>\n";
                }
                echo "</tr>\n";
                foreach ($teams as $t) {
                    if (!$t['retired']) {
                        echo "<tr>\n";
                        foreach ($box['fields'] as $title => $f) {
                            if (in_array($f, $_MV_COLS)) {
                                $f = 'mv_' . $f;
                            }
                            echo "<td>";
                            if ($settings['fp_links'] && $f == 'name') {
                                echo "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $t['team_id'], false, false) . "'>{$t['name']}</a>";
                            } elseif (is_numeric($t[$f]) && !ctype_digit($t[$f][0] == '-' ? substr($t[$f], 1) : $t[$f])) {
                                echo sprintf('%1.2f', $t[$f]);
                            } else {
                                echo in_array($f, array('tv')) ? $t[$f] / 1000 : $t[$f];
                            }
                            echo "</td>\n";
                        }
                        echo "</tr>\n";
                    }
                }
                ?>
                    </table>
                    <?php 
                if (isset($box['infocus']) && $box['infocus']) {
                    echo "<hr>";
                    _infocus($teams);
                }
                ?>
                </div>
            </div>
            <?php 
                MTS('Standings table generated');
                break;
            case 'latestgames':
                if ($box['length'] <= 0) {
                    break;
                }
                ?>
            <div class="boxWide">
                <h3 class='boxTitle<?php 
                echo T_HTMLBOX_MATCH;
                ?>
'><?php 
                echo $box['title'];
                ?>
</h3>
                <div class='boxBody'>
                    <table class="boxTable">
                        <tr>
                            <td style="text-align: right;" width="50%"><i><?php 
                echo $lng->getTrn('common/home');
                ?>
</i></td>
                            <td> </td>
                            <td style="text-align: left;" width="50%"><i><?php 
                echo $lng->getTrn('common/away');
                ?>
</i></td>
                            <td><i><?php 
                echo $lng->getTrn('common/date');
                ?>
</i></td>
                            <td> </td>
                        </tr>
                        <?php 
                list($matches, $pages) = Match::getMatches(array(1, $box['length']), $box['type'], $box['id'], false);
                foreach ($matches as $m) {
                    echo "<tr valign='top'>\n";
                    $t1name = $settings['fp_links'] ? "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team1_id, false, false) . "'>{$m->team1_name}</a>" : $m->team1_name;
                    $t2name = $settings['fp_links'] ? "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team2_id, false, false) . "'>{$m->team2_name}</a>" : $m->team2_name;
                    echo "<td style='text-align: right;'>{$t1name}</td>\n";
                    echo "<td><nobr>{$m->team1_score}&mdash;{$m->team2_score}</nobr></td>\n";
                    echo "<td style='text-align: left;'>{$t2name}</td>\n";
                    echo "<td>" . str_replace(' ', '&nbsp;', textdate($m->date_played, true)) . "</td>";
                    echo "<td><a href='index.php?section=matches&amp;type=report&amp;mid={$m->match_id}'>Show</a></td>";
                    echo "</tr>";
                }
                ?>
                    </table>
                </div>
            </div>
            <?php 
                MTS('Latest matches table generated');
                break;
            case 'leaders':
                $f = 'mv_' . $box['field'];
                list($players, ) = Stats::getRaw(T_OBJ_PLAYER, array($box['type'] => $box['id']), array(1, $box['length']), array('-' . $f), false);
                ?>
            <div class="boxWide">
                <h3 class='boxTitle<?php 
                echo T_HTMLBOX_STATS;
                ?>
'><?php 
                echo $box['title'];
                ?>
</h3>
                <div class='boxBody'>
                    <table class="boxTable">
                        <tr>
                            <td><i><?php 
                echo $lng->getTrn('common/name');
                ?>
</i></td>
                            <?php 
                if ($box['show_team']) {
                    ?>
<td><i><?php 
                    echo $lng->getTrn('common/team');
                    ?>
</i></td><?php 
                }
                ?>
                            <td><i>#</i></td>
                            <td><i><?php 
                echo $lng->getTrn('common/value');
                ?>
</i></td>
                        </tr>
                        <?php 
                foreach ($players as $p) {
                    echo "<tr>\n";
                    echo "<td>" . ($settings['fp_links'] ? "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_PLAYER, $p['player_id'], false, false) . "'>{$p['name']}</a>" : $p['name']) . "</td>\n";
                    if ($box['show_team']) {
                        echo "<td>" . ($settings['fp_links'] ? "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $p['owned_by_team_id'], false, false) . "'>{$p['f_tname']}</a>" : $p['f_tname']) . "</td>\n";
                    }
                    echo "<td>" . $p[$f] . "</td>\n";
                    echo "<td>" . $p['value'] / 1000 . "k</td>\n";
                    echo "</tr>";
                }
                ?>
                    </table>
                </div>
            </div>
            <?php 
                MTS('Leaders standings generated');
                break;
            case 'events':
                $events = _events($box['content'], $box['type'], $box['id'], $box['length']);
                ?>
            <div class="boxWide">
                <h3 class='boxTitle<?php 
                echo T_HTMLBOX_STATS;
                ?>
'><?php 
                echo $box['title'];
                ?>
</h3>
                <div class='boxBody'>
                    <table class="boxTable">
                        <?php 
                $head = array_pop($events);
                echo "<tr>\n";
                foreach ($head as $col => $name) {
                    echo "<td><i>{$name}</i></td>\n";
                }
                echo "</tr>\n";
                foreach ($events as $e) {
                    echo "<tr>\n";
                    foreach ($head as $col => $name) {
                        switch ($col) {
                            case 'date':
                                $e->{$col} = str_replace(' ', '&nbsp;', textdate($e->{$col}, true));
                                break;
                            case 'name':
                                if ($settings['fp_links']) {
                                    $e->{$col} = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_PLAYER, $e->pid, false, false) . "'>" . $e->{$col} . "</a>";
                                }
                                break;
                            case 'tname':
                                if ($settings['fp_links']) {
                                    $e->{$col} = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $e->f_tid, false, false) . "'>" . $e->{$col} . "</a>";
                                }
                                break;
                            case 'rname':
                                if ($settings['fp_links']) {
                                    $e->{$col} = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $e->f_rid, false, false) . "'>" . $e->{$col} . "</a>";
                                }
                                break;
                            case 'f_pos_name':
                                if ($settings['fp_links']) {
                                    $e->{$col} = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $e->f_rid, false, false) . "'>" . $e->{$col} . "</a>";
                                }
                                break;
                            case 'value':
                                $e->{$col} = $e->{$col} / 1000 . 'k';
                                break;
                        }
                        echo "<td>" . $e->{$col} . "</td>\n";
                    }
                    echo "</tr>\n";
                }
                ?>
                    </table>
                </div>
            </div>
            <?php 
                MTS('Events box generated');
                break;
        }
    }
    ?>
    </div>
    <div class="main_foot">
        <?php 
    HTMLOUT::dnt();
    ?>
        <br>
        <a TARGET="_blank" href="http://nicholasmr.dk/index.php?sec=obblm">OBBLM official website</a><br><br>
        This web site is completely unofficial and in no way endorsed by Games Workshop Limited.
        <br>
        Bloodquest, Blood Bowl, the Blood Bowl logo, The Blood Bowl Spike Device, Chaos, the Chaos device, the Chaos logo, Games Workshop, Games Workshop logo, Nurgle, the Nurgle device, Skaven, Tomb Kings, and all associated marks, names, races, race insignia, characters, vehicles, locations, units, illustrations and images from the Blood Bowl game, the Warhammer world are either (R), TM and/or (C) Games Workshop Ltd 2000-2006, variably registered in the UK and other countries around the world. Used without permission. No challenge to their status intended. All Rights Reserved to their respective owners.
    </div>
    <?php 
}
Exemplo n.º 22
0
<?php

session_start();
require_once '../resources/require.php';
// dodoaje nową wiadomość do bazy, uzupełnia komunikat o wysłaniu bądź błędzie
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['verify_post'])) {
    if (trim($_POST['message_text']) != '') {
        $message = new Message($mysqli);
        $message->setReceiverId($_POST['receiver_id']);
        $message->setSenderId($_SESSION['user_id']);
        $message->setText($_POST['message_text']);
        $message->setStatus(0);
        $message->setCreationDate(date("Y-m-d H:i:s"));
        if (!$message->create()) {
            $info = 'Nie udało się wysłać wiadomości. Spróbuj ponownie.';
        } else {
            $info = 'Wiadomość została wysłana.';
        }
    } else {
        $info = 'Uzupełnij treść wiadomości.';
    }
}
?>
<!DOCTYPE html>
<html lang="pl-PL">

<title>Twitter | Wyślij wiadomość </title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
Exemplo n.º 23
0
         $errors["unread"] = $e->getMessage();
     }
 } else {
     if (isset($_POST["sent"])) {
         $form = "sent";
         $to = Tools::prepareUserArgString($_POST["email"]);
         $subject = Tools::prepareUserArgString($_POST["subject"]);
         $texte = Tools::prepareUserArgString($_POST["message"]);
         if (!Tools::verifyEmail($to)) {
             $errors["email"] = "Invalid email format";
         } else {
             if (User::findByEmail($to) == null) {
                 $errors["email"] = "Unknow email address";
             } else {
                 try {
                     $message = Message::create($subject, $texte, Session::getSessionEmail(), $to);
                 } catch (Exception $e) {
                     $errors["other"] = $e->getMessage();
                 }
             }
         }
     } else {
         if (isset($get)) {
             if (Tools::isStringValid($get) && isGetType($type)) {
                 $type = $get;
                 if (!isNew($type)) {
                     $id = Tools::prepareUserArgInteger($_GET["id"]);
                     try {
                         $message = Message::readMessage($get, Session::getSessionEmail(), $id);
                         if (isReceive($type)) {
                             $message->setUnread(false, Session::getSessionEmail())->doUpdate();
Exemplo n.º 24
0
 function addMessage($vars, &$errors)
 {
     $vars['ticketId'] = $this->getTicketId();
     $vars['staffId'] = 0;
     // DELME: When HTML / rich-text is supported
     $vars['title'] = Format::htmlchars($vars['title']);
     $vars['message'] = Format::htmlchars($vars['message']);
     return Message::create($vars, $errors);
 }
Exemplo n.º 25
0
 function addMessage($vars, &$errors)
 {
     $vars['ticketId'] = $this->getTicketId();
     $vars['staffId'] = 0;
     return Message::create($vars, $errors);
 }
Exemplo n.º 26
0
 public static function send($user_fp, $input, $timestamp = false)
 {
     $timestamp = $timestamp ? $timestamp : date('Y-m-d H:i:s');
     Message::create(['user_fp' => $user_fp, 'timestamp' => $timestamp, 'text' => trim($input['message'])]);
 }
<?php

require_once "../includes/initialize.php";
$response = "no response";
if (isset($_POST['message'])) {
    $message = new Message();
    $message->message = $_POST['message'];
    $message->student_id = $session->student_id;
    $message->create();
    $response = "success";
} else {
    $response = "error";
}
echo "success";
Exemplo n.º 28
0
function setup_database()
{
    global $core_tables;
    $conn = mysql_up();
    require_once 'lib/class_sqlcore.php';
    // Create core tables.
    echo "<b>Creating core tables...</b><br>\n";
    foreach ($core_tables as $tblName => $def) {
        echo Table::createTable($tblName, $def) ? "<font color='green'>OK &mdash; {$tblName}</font><br>\n" : "<font color='red'>FAILED &mdash; {$tblName}</font><br>\n";
    }
    // Create tables used by modules.
    echo "<b>Creating module tables...</b><br>\n";
    foreach (Module::createAllRequiredTables() as $module => $tables) {
        foreach ($tables as $name => $tblStat) {
            echo $tblStat ? "<font color='green'>OK &mdash; {$name}</font><br>\n" : "<font color='red'>FAILED &mdash; {$name}</font><br>\n";
        }
    }
    echo "<b>Other tasks...</b><br>\n";
    echo SQLCore::syncGameData() ? "<font color='green'>OK &mdash; Synchronize game data with database</font><br>\n" : "<font color='red'>FAILED &mdash; Error whilst synchronizing game data with database</font><br>\n";
    echo SQLCore::installTableIndexes() ? "<font color='green'>OK &mdash; applied table indexes</font><br>\n" : "<font color='red'>FAILED &mdash; could not apply one more more table indexes</font><br>\n";
    echo SQLCore::installProcsAndFuncs(true) ? "<font color='green'>OK &mdash; created MySQL functions/procedures</font><br>\n" : "<font color='red'>FAILED &mdash; could not create MySQL functions/procedures</font><br>\n";
    // Create root user and leave welcome message on messageboard
    global $rootpass;
    $rootpass = isset($rootpass) ? $rootpass : '******';
    echo Coach::create(array('name' => 'root', 'realname' => 'root', 'passwd' => $rootpass, 'ring' => Coach::T_RING_GLOBAL_ADMIN, 'mail' => '', 'phone' => '', 'settings' => array(), 'def_leagues' => array())) ? "<font color=green>OK &mdash; root user created.</font><br>\n" : "<font color=red>FAILED &mdash; root user was not created.</font><br>\n";
    Message::create(array('f_coach_id' => 1, 'f_lid' => Message::T_BROADCAST, 'title' => 'OBBLM installed!', 'msg' => 'Congratulations! You have successfully installed Online Blood Bowl League Manager. See "about" and "introduction" for more information.'));
    // Done!
    mysql_close($conn);
    return true;
}
Exemplo n.º 29
0
 function media($id = FALSE, $condition = FALSE, $media_id = FALSE)
 {
     $this->load->helper('notification');
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'cprojects', $this->lang->line('application_overview') => 'cprojects/view/' . $id, $this->lang->line('application_media') => 'cprojects/media/' . $id);
     switch ($condition) {
         case 'view':
             if ($_POST) {
                 unset($_POST['send']);
                 unset($_POST['_wysihtml5_mode']);
                 unset($_POST['files']);
                 //$_POST = array_map('htmlspecialchars', $_POST);
                 $_POST['text'] = $_POST['message'];
                 unset($_POST['message']);
                 $_POST['project_id'] = $id;
                 $_POST['media_id'] = $media_id;
                 $_POST['from'] = $this->client->firstname . ' ' . $this->client->lastname;
                 $this->view_data['project'] = Project::find_by_id($id);
                 $this->view_data['media'] = ProjectHasFile::find($media_id);
                 $message = Message::create($_POST);
                 if (!$message) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_message_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_message_success'));
                     foreach ($this->view_data['project']->project_has_workers as $workers) {
                         send_notification($workers->user->email, "[" . $this->view_data['project']->name . "] New comment", 'New comment on meida file: ' . $this->view_data['media']->name . '<br><strong>' . $this->view_data['project']->name . '</strong>');
                     }
                 }
                 redirect('cprojects/media/' . $id . '/view/' . $media_id);
             }
             $this->content_view = 'projects/client_views/view_media';
             $this->view_data['media'] = ProjectHasFile::find($media_id);
             $project = Project::find_by_id($id);
             if ($project->company_id != $this->client->company->id) {
                 redirect('cprojects');
             }
             $this->view_data['form_action'] = 'cprojects/media/' . $id . '/view/' . $media_id;
             $this->view_data['filetype'] = explode('.', $this->view_data['media']->filename);
             $this->view_data['filetype'] = $this->view_data['filetype'][1];
             $this->view_data['backlink'] = 'cprojects/view/' . $id;
             break;
         case 'add':
             $this->content_view = 'projects/_media';
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 $config['upload_path'] = './files/media/';
                 $config['encrypt_name'] = TRUE;
                 $config['allowed_types'] = '*';
                 $this->load->library('upload', $config);
                 if (!$this->upload->do_upload()) {
                     $error = $this->upload->display_errors('', ' ');
                     $this->session->set_flashdata('message', 'error:' . $error);
                     redirect('cprojects/view/' . $id);
                 } else {
                     $data = array('upload_data' => $this->upload->data());
                     $_POST['filename'] = $data['upload_data']['orig_name'];
                     $_POST['savename'] = $data['upload_data']['file_name'];
                     $_POST['type'] = $data['upload_data']['file_type'];
                 }
                 unset($_POST['send']);
                 unset($_POST['userfile']);
                 unset($_POST['file-name']);
                 unset($_POST['files']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $_POST['project_id'] = $id;
                 $_POST['client_id'] = $this->client->id;
                 $media = ProjectHasFile::create($_POST);
                 if (!$media) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_media_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_media_success'));
                     $attributes = array('subject' => $this->lang->line('application_new_media_subject'), 'message' => '<b>' . $this->client->firstname . ' ' . $this->client->lastname . '</b> ' . $this->lang->line('application_uploaded') . ' ' . $_POST['name'], 'datetime' => time(), 'project_id' => $id, 'type' => 'media', 'client_id' => $this->client->id);
                     $activity = ProjectHasActivity::create($attributes);
                     foreach ($this->view_data['project']->project_has_workers as $workers) {
                         send_notification($workers->user->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_media_subject'), $this->lang->line('application_new_media_file_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                     }
                     if (isset($this->view_data['project']->company->client->email)) {
                         send_notification($this->view_data['project']->company->client->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_media_subject'), $this->lang->line('application_new_media_file_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                     }
                 }
                 redirect('cprojects/view/' . $id);
             } else {
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_add_media');
                 $this->view_data['form_action'] = 'cprojects/media/' . $id . '/add';
                 $this->content_view = 'projects/_media';
             }
             break;
         case 'update':
             $this->content_view = 'projects/_media';
             $this->view_data['media'] = ProjectHasFile::find($media_id);
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 unset($_POST['send']);
                 unset($_POST['_wysihtml5_mode']);
                 unset($_POST['files']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $media_id = $_POST['id'];
                 $media = ProjectHasFile::find($media_id);
                 if ($this->view_data['media']->client_id != "0") {
                     $media->update_attributes($_POST);
                 }
                 if (!$media) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_media_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_media_success'));
                 }
                 redirect('cprojects/view/' . $id);
             } else {
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_edit_media');
                 $this->view_data['form_action'] = 'cprojects/media/' . $id . '/update/' . $media_id;
                 $this->content_view = 'projects/_media';
             }
             break;
         case 'delete':
             $media = ProjectHasFile::find($media_id);
             if ($media->client_id != "0") {
                 $media->delete();
                 $this->load->database();
                 $sql = "DELETE FROM messages WHERE media_id = {$media_id}";
                 $this->db->query($sql);
             }
             if (!$media) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_media_error'));
             } else {
                 unlink('./files/media/' . $media->savename);
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_media_success'));
             }
             redirect('cprojects/view/' . $id);
             break;
         default:
             $this->view_data['project'] = Project::find($id);
             $this->content_view = 'projects/client_views/media';
             break;
     }
 }
Exemplo n.º 30
0
<?php

spl_autoload_register(function ($class) {
    require_once str_replace('\\', '/', $class) . '.php';
});
$file = __DIR__ . '/storage/database.sqlite';
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ];
$pdo = new PDO("sqlite:{$file}", null, null, $options);
$pdo->exec("\n    CREATE TABLE IF NOT EXISTS\n      messages (\n      id INTEGER PRIMARY KEY AUTOINCREMENT,\n      content TEXT,\n      published_at DATETIME )\n");
$pdo->exec("\n    CREATE TABLE IF NOT EXISTS\n      histories (\n      id INTEGER PRIMARY KEY AUTOINCREMENT,\n      published_at DATETIME )\n");
// observers
$db = new Observers\DB($pdo, 'histories');
$splFile = new \SplFileObject(__DIR__ . '/storage/data.txt', 'a+');
$file = new Observers\File($splFile);
// subjects
$message = new Message($pdo);
$message->attach($db);
$message->attach($file);
$message->create('Hello world');
var_dump($message->all());
$stmt = $pdo->query('select * from histories');
var_dump($stmt->fetchAll());
var_dump(file_get_contents(__DIR__ . '/storage/data.txt'));