Esempio n. 1
0
 private function view($viewName)
 {
     $data = [];
     $this->load->helper('utils_helper');
     $this->load->model('service_model');
     $this->load->model('server_model', 'server');
     $this->load->model('serverHistory_model', 'serverHistory');
     $data['services'] = $this->service_model->getAll();
     $data['serversConfig'] = $this->server->getConfig();
     $data['serversData'] = $this->serverHistory->getServersHistory();
     $data['percents'] = calculatePercentages($data['serversData'], $data['services']);
     $data['updateTime'] = timeSince($this->serverHistory->getLastUpdate());
     $this->viewRender($data, $viewName);
 }
 /**
  * Get user new messages
  */
 public function actionGetLastNewMessage()
 {
     // Check if we have any messages to show order by urgency level
     $message = PersonalMessageNotification::model()->getLastMessage();
     if (!$message) {
         echoJson(array());
     }
     // Build the text message
     $type = PersonalMessageTopic::model()->messageTypes[$message->notificationTopic->type];
     $text = at("{author} Sent a new reply in PM topic '{title}' on {date}", array('{author}' => $message->notificationAuthor->getUserLink(), '{title}' => $message->notificationTopic->getTopicTitle(false), '{date}' => timeSince($message->created_at)));
     $title = at("You've received a new message");
     // Based on type
     if ($message->notificationTopic->type > 0) {
         $html = $this->renderPartial('_pm_notification', array('message' => $message, 'text' => $text), true);
     } else {
         $html = $this->renderPartial('_pm_normal_notification', array('message' => $message, 'text' => $text), true);
     }
     $footer = $this->renderPartial('_pm_notification_footer', array('message' => $message, 'text' => $text), true);
     // Update the record to show that we showed that notification
     PersonalMessageNotification::model()->updateByPk($message->id, array('was_shown' => 1));
     // Output
     echoJson(array('html' => $html, 'footer' => $footer, 'text' => $text, 'title' => $title, 'type' => $message->notificationTopic->type));
 }
Esempio n. 3
0
 public function index($id)
 {
     $this->load->model('server_model', 'server');
     $this->load->model('serverHistory_model', 'serverHistory');
     $this->load->helper('utils_helper');
     if (!$this->server->isValid($id)) {
         $error = array('heading' => 'Error', 'message' => 'This server couldn\'t be found.');
         $this->load->view('errors/html/error_server', $error);
         return;
     }
     $data['server'] = $this->server->getConfig($id)->row_array();
     $data['serverHistory'] = $this->serverHistory->getServerHistory($id, false);
     $data['lastTimeOnline'] = timeSince($this->serverHistory->getServerLastTimeOnline($id));
     if (!$data['serverHistory']) {
         $error = array('heading' => 'Error', 'message' => 'This server dosen\'t have any history, yet.');
         $this->load->view('errors/html/error_server', $error);
         return;
     }
     $headerData = array('js' => array('dygraph-combined.js'));
     $this->load->view('header', $headerData);
     $this->load->view('server', $data);
     $this->load->view('footer');
 }
Esempio n. 4
0
	</div>
	
	<?php 
foreach ($model->replies as $replyRow) {
    ?>
		
		<div class='grid_12'>
			<div class="box">
				<div class='title'>
					<span class="loatleft">
						<?php 
    echo $replyRow->replyAuthor->getUserLink();
    ?>
					</span>
					<span class="floatright"><?php 
    echo timeSince($replyRow->created_at);
    ?>
</span>	
					<div class="clear"></div>
				</div>		
				<div class="inside">
					<div class="in">
						<?php 
    if ($this->beginCache('pm_reply_id_' . $replyRow->id)) {
        ?>
							<?php 
        echo stripHtmlTags($replyRow->message);
        ?>
						<?php 
        $this->endCache();
    }
Esempio n. 5
0
 /**
  * Output the objects history.
  *
  * We override <code>{@link foowd_object::method_history}</code> so as to add links to the diff method.
  */
 function method_history()
 {
     $this->foowd->track('foowd_text_plain->method_history');
     $this->foowd->template->assign('detailsTitle', $this->getTitle());
     $this->foowd->template->assign('detailsCreated', date(DATETIME_FORMAT, $this->created) . ' (' . timeSince($this->created) . ' ago)');
     $this->foowd->template->assign('detailsAuthor', htmlspecialchars($this->creatorName));
     $this->foowd->template->assign('detailsType', getClassDescription($this->classid));
     if ($this->workspaceid != 0) {
         $this->foowd->template->assign('detailsWorkspace', $this->workspaceid);
     }
     $objArray = $this->foowd->getObjHistory(array('objectid' => $this->objectid, 'classid' => $this->classid));
     $currentVersion = $this->version;
     $latestVersion = $objArray[0]->version;
     unset($objArray[0]);
     $versions = array();
     foreach ($objArray as $object) {
         $version = array();
         $version['updated'] = date(DATETIME_FORMAT, $object->updated) . ' (' . timeSince($object->updated) . ' ago)';
         $version['author'] = htmlspecialchars($object->updatorName);
         $version['version'] = $object->version;
         $version['objectid'] = $object->objectid;
         $version['classid'] = $object->classid;
         if ($object->version != $latestVersion) {
             $version['revert'] = TRUE;
             $version['diff'] = TRUE;
         }
         $this->foowd->template->append('versions', $version);
     }
     $this->foowd->track();
 }
Esempio n. 6
0
/**
 * Get timestamps for a wiki file.
 *
 * @param   string  $file
 *
 * @return  array
 */
function getTimeStamps($file)
{
    return array('created' => date(BD_DATE_FORMAT, filectime($file)), 'timeSinceCreation' => timeSince(filectime($file)), 'modified' => date(BD_DATE_FORMAT, filemtime($file)), 'timeSinceModified' => timeSince(filemtime($file)));
}
Esempio n. 7
0
<?php

$this->widget('zii.widgets.CDetailView', array('data' => $model->attributes, 'attributes' => array(array('name' => 'name', 'label' => 'Name'), array('name' => 'email', 'label' => 'Email'), array('name' => 'role', 'label' => 'Role'), array('name' => 'notes', 'label' => 'Notes'), array('name' => 'created_at', 'header' => 'Created Date', 'value' => timeSince($model->created_at)), array('name' => 'updated_at', 'header' => 'Updated Date', 'value' => timeSince($model->updated_at)))));
Esempio n. 8
0
function random_10_user()
{
    // why not populate my admin page a bit?
    $c = db_init('site_data', 'site_users');
    $users = $c->find()->limit(10)->sort(array('first_login' => -1));
    echo '<div class="col2 rt"><h2>Latest Users</h2><table class="tbpad">';
    echo '<tr><th>userid</th><th>time since they joined</th><th>privilege</th></tr>';
    $qualities = array(1 => 'collector', 10 => 'normal', 20 => 'rarity1', 30 => 'vintage', 69 => 'strange', 100 => 'unusual');
    foreach ($users as $user) {
        echo '<tr class="' . $qualities[$user['privilege']] . '"><td>' . $user['_id'] . '</td><td>' . timeSince($user['first_login']) . '</td><td>' . $user['privilege'] . '</td></tr>';
    }
    echo '</table>';
    $total_users = $c->count();
    $total_donors = $c->count(array('privilege' => (int) 20));
    echo '<h2>Usercount:</h2>There are ' . $total_users . ' users and ' . $total_donors . ' donator accounts in the db.</div>';
}
Esempio n. 9
0
	<li class="row">
		<h3 class="h4">Sent:</h4>
		<p>
		<?php 
echo timeSince(strtotime($match[0]['sent-datetime'])) . ' ago';
?>
 
		</p>

	</li>

	<li class="row">
		<h3 class="h4">Game Played:</h4>
		<p>
		<?php 
echo timeSince(strtotime($match[0]['datetime'])) . ' ago';
?>
 
		</p>
	</li>

	<?php 
if ($matchStatus == 'declined') {
    ?>

			<li class="row is--disputed">

				<h3 class="h4">Disputed by <?php 
    echo $match[0]['loser-name'];
    ?>
.</h4>
Esempio n. 10
0
<?php

function timeSince($time)
{
    $time = time() - $time;
    // to get the time since that moment
    $tokens = array(31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second');
    foreach ($tokens as $unit => $text) {
        if ($time < $unit) {
            continue;
        }
        $numberOfUnits = floor($time / $unit);
        return $numberOfUnits . ' ' . $text . ($numberOfUnits > 1 ? 's ago' : ' ago');
    }
}
$datetime = "2013-12-30 21:39:50";
$new = date("Y-m-d", strtotime($datetime));
echo "NEW: " . timeSince(strtotime($datetime));
Esempio n. 11
0
function formatSnaps($result, $thesnapchat)
{
    if ($result) {
        if (is_object($result)) {
            $result->updates_response->friendsCount = count($result->updates_response->friends);
        }
        if (count($result->updates_response->snaps) > 0) {
            $friendRequests = array();
            $newSnapsArray = array();
            $unopenedSnapsCount = 0;
            // SNAPS
            foreach ($result->updates_response->snaps as $snap) {
                if ($snap->m == SnapChat::MEDIA_FRIEND_REQUEST) {
                    array_push($friendRequests, $snap);
                    continue;
                }
                $snap->media_id = empty($snap->c_id) ? FALSE : $snap->c_id;
                $snap->media_type = $snap->m;
                $snap->time = empty($snap->t) ? FALSE : $snap->t;
                $snap->sender = empty($snap->sn) ? $result->updates_response->username : $snap->sn;
                $snap->recipient = empty($snap->rp) ? $result->updates_response->username : $snap->rp;
                $snap->status = $snap->st;
                $snap->screenshot_count = empty($snap->c) ? 0 : $snap->c;
                $snap->sent = $snap->sts;
                $snap->opened = $snap->ts;
                $snap->loaded = false;
                $snap->loading = false;
                $snap->send = false;
                $snap->beingviewed = false;
                $snap->timeleft = $snap->time;
                $snap->videourl = "";
                $snap->timeago = $snap->status == SnapChat::STATUS_OPENED ? timeSince($snap->opened / 1000) : timeSince($snap->sent / 1000);
                $snap->displayname = "";
                $snap->load = true;
                $snap->zipped = empty($snap->zipped) ? false : $snap->zipped;
                // ZIPPED
                if ($snap->zipped == true && ($snap->media_type == Snapchat::MEDIA_VIDEO || $snap->media_type == Snapchat::MEDIA_VIDEO_NOAUDIO) && $snap->time != false) {
                    $snapBaseName = $thesnapchat->username . "-" . $snap->sender . "-" . $snap->id;
                    $snapfile = "media/snaps/" . $snapBaseName . ".zip";
                    if (!file_exists($snapfile)) {
                        $snapdata = $thesnapchat->getMedia($snap->id);
                        file_put_contents($snapfile, $snapdata);
                    } else {
                        if (filesize($snapfile) == 0) {
                            $snapdata = $thesnapchat->getMedia($snap->id);
                            file_put_contents($snapfile, $snapdata);
                        }
                    }
                    $extractFolder = "media/snaps/" . $snapBaseName;
                    if (!file_exists($extractFolder)) {
                        mkdir($extractFolder, 0777, true);
                    }
                    $zip = new ZipArchive();
                    $res = $zip->open($snapfile);
                    if ($res === TRUE) {
                        $zip->extractTo($extractFolder);
                        $zip->close();
                    }
                    $files = scandir($extractFolder);
                    foreach ($files as $file) {
                        if (strpos($file, 'media') !== false) {
                            $extension = ".mp4";
                            if (strpos($file, $extension) !== FALSE) {
                            } else {
                                if (file_exists($extractFolder . "/" . $file)) {
                                    rename($extractFolder . "/" . $file, $extractFolder . "/" . $file . $extension);
                                }
                            }
                            if (strpos($file, $extension) !== false) {
                                $snapfile = $extractFolder . "/" . $file;
                            } else {
                                $snapfile = $extractFolder . "/" . $file . $extension;
                            }
                            $snap->snapmedia = HOST . "tests/" . $snapfile;
                        } else {
                            if (strpos($file, 'overlay') !== false) {
                                $extension = ".png";
                                if (strpos($file, $extension) !== FALSE) {
                                } else {
                                    if (file_exists($extractFolder . "/" . $file)) {
                                        rename($extractFolder . "/" . $file, $extractFolder . "/" . $file . $extension);
                                    }
                                }
                                $snap->snapoverlay = HOST . "tests/" . $extractFolder . "/" . $file . $extension;
                            }
                        }
                    }
                }
                // ZIPPED
                $theusername = "";
                if ($thesnapchat->username == $snap->sender && $thesnapchat->username == $snap->recipient) {
                    $theusername = $thesnapchat->username;
                } else {
                    if ($thesnapchat->username == $snap->sender) {
                        $theusername = $snap->recipient;
                    } else {
                        if ($thesnapchat->username == $snap->recipient) {
                            $theusername = $snap->sender;
                        }
                    }
                }
                foreach ($result->updates_response->friends as $thefriend) {
                    if ($thefriend->name == $theusername) {
                        $snap->displayname = $thefriend->display;
                        break;
                    }
                }
                if ($snap->status == SnapChat::STATUS_DELIVERED && $snap->recipient == $thesnapchat->username && $snap->time != false) {
                    $unopenedSnapsCount++;
                }
                if (isset($_GET['showonly'])) {
                    $showonly = $_GET['showonly'];
                    if ($showonly == "photo") {
                        if ($snap->media_type == Snapchat::MEDIA_IMAGE) {
                            array_push($newSnapsArray, $snap);
                        }
                    } else {
                        if ($showonly == "video") {
                            if ($snap->media_type == Snapchat::MEDIA_VIDEO || $snap->media_type == Snapchat::MEDIA_VIDEO_NOAUDIO) {
                                array_push($newSnapsArray, $snap);
                            }
                        } else {
                            array_push($newSnapsArray, $snap);
                        }
                    }
                } else {
                    array_push($newSnapsArray, $snap);
                }
            }
            $newFriendRequests = array();
            if (count($friendRequests) > 0) {
                foreach ($friendRequests as $friendRequest) {
                    if (!friendRequestExists($friendRequest, $result->updates_response->friends)) {
                        array_push($newFriendRequests, $friendRequest);
                    }
                }
            }
            $result->updates_response->unopened = $unopenedSnapsCount;
            if (isset($_GET['maxtoshow'])) {
                $maxtoshow = $_GET['maxtoshow'];
            }
            if ($maxtoshow != "unlimited") {
                $newSnapsArray = array_slice($newSnapsArray, 0, $maxtoshow);
            }
            $result->updates_response->snaps = $newSnapsArray;
            $result->updates_response->friend_requests = $newFriendRequests;
        }
        // FRIENDS
        if ($result->updates_response->bests && count($result->updates_response->bests) > 0) {
            $newBestFriendsArray = array();
            $bestFriend = new BestFriend();
            $bestFriend->username = "******";
            $bestFriend->name = "mystory";
            $bestFriend->display = "My Story";
            $bestFriend->type = "mystory";
            array_push($newBestFriendsArray, $bestFriend);
            foreach ($result->updates_response->bests as $best) {
                $bestFriend = new BestFriend();
                $bestFriend->username = $best;
                $bestFriend->name = $best;
                $bestFriend->display = "";
                $bestFriend->type = "bestfriend";
                array_push($newBestFriendsArray, $bestFriend);
            }
            $newRecentFriendsArray = array();
            foreach ($result->updates_response->recents as $recent) {
                $recentFriend = new RecentFriend();
                $recentFriend->username = $recent;
                $recentFriend->name = $recent;
                $recentFriend->display = "";
                $recentFriend->type = "recentfriend";
                array_push($newRecentFriendsArray, $recentFriend);
            }
            $tempFriendsArray = array();
            foreach ($result->updates_response->friends as $friend) {
                if (isset($_GET['hideblockedanddeleted'])) {
                    if ($_GET['hideblockedanddeleted'] == "true") {
                        if ($friend->type == Snapchat::FRIEND_CONFIRMED || $friend->type == Snapchat::FRIEND_UNCONFIRMED) {
                            array_push($tempFriendsArray, $friend);
                        }
                    }
                }
            }
            if (isset($_GET['hideblockedanddeleted'])) {
                if ($_GET['hideblockedanddeleted'] == "false") {
                    $tempFriendsArray = $result->updates_response->friends;
                }
            } else {
                $tempFriendsArray = $result->updates_response->friends;
            }
            $result->updates_response->best_friends = $newBestFriendsArray;
            $result->updates_response->friends = array_merge((array) $newBestFriendsArray, (array) $newRecentFriendsArray, (array) $tempFriendsArray);
        }
        // FRIEND STORES
        //$result->stories_response->orig_stories   = $result->stories_response->friend_stories;
        $friend_stories = array();
        if (count($result->stories_response->friend_stories) > 0) {
            foreach ($result->stories_response->friend_stories as $user) {
                if (count($user->stories) > 0) {
                    foreach ($user->stories as $thestory) {
                        $thestory->story->timeago = timeSince($thestory->story->timestamp / 1000);
                        array_push($friend_stories, $thestory->story);
                    }
                }
            }
        }
        // MY STORES
        $my_stories = array();
        if (count($result->stories_response->my_stories) > 0) {
            foreach ($result->stories_response->my_stories as $thestory) {
                $thestory->story->timeago = timeSince($thestory->story->timestamp / 1000);
                array_push($my_stories, $thestory->story);
            }
        }
        $whole_stories = array_merge((array) $my_stories, (array) $friend_stories);
        if (count($whole_stories) > 0) {
            foreach ($whole_stories as $story) {
                $story->timeago = timeSince($story->timestamp / 1000);
                $story->loaded = false;
                $story->loading = false;
                $story->load = true;
                $storyBaseName = $thesnapchat->username . "-" . $story->username . "-" . $story->media_id;
                $storyfile = "media/stories/" . $storyBaseName;
                $storyfileCopy = $storyfile;
                $extension = "";
                if ($story->media_type == Snapchat::MEDIA_IMAGE) {
                    $extension = ".jpg";
                    $story->storymediathumbnail = HOST . "slir/w50/snapchat/tests/" . $storyfile;
                } else {
                    if ($story->media_type == Snapchat::MEDIA_VIDEO || $story->media_type == Snapchat::MEDIA_VIDEO_NOAUDIO) {
                        $story->storymediathumbnail = "http://imgur.com/YFCeC5M.jpg";
                        if ($story->zipped == true) {
                            $extension = ".zip";
                        } else {
                            $extension = ".mp4";
                        }
                    }
                }
                $storyfile = $storyfile . $extension;
                if (!file_exists($storyfile)) {
                    $storydata = $thesnapchat->getStory($story->media_id, $story->media_key, $story->media_iv);
                    file_put_contents($storyfile, $storydata);
                } else {
                    if (filesize($storyfile) == 0) {
                        $storydata = $thesnapchat->getStory($story->media_id, $story->media_key, $story->media_iv);
                        file_put_contents($storyfile, $storydata);
                    }
                }
                if ($story->zipped == true) {
                    $extractFolder = "media/stories/" . $storyBaseName;
                    if (!file_exists($extractFolder)) {
                        mkdir($extractFolder, 0777, true);
                    }
                    $zip = new ZipArchive();
                    $res = $zip->open($storyfile);
                    if ($res === TRUE) {
                        $zip->extractTo($extractFolder);
                        $zip->close();
                    }
                    $files = scandir($extractFolder);
                    foreach ($files as $file) {
                        if (strpos($file, 'media') !== false) {
                            $extension = ".mp4";
                            if (strpos($file, $extension) !== FALSE) {
                            } else {
                                if (file_exists($extractFolder . "/" . $file)) {
                                    rename($extractFolder . "/" . $file, $extractFolder . "/" . $file . $extension);
                                }
                            }
                            if (strpos($file, $extension) !== false) {
                                $storyfile = $extractFolder . "/" . $file;
                            } else {
                                $storyfile = $extractFolder . "/" . $file . $extension;
                            }
                        } else {
                            if (strpos($file, 'overlay') !== false) {
                                $extension = ".png";
                                if (strpos($file, $extension) !== FALSE) {
                                } else {
                                    if (file_exists($extractFolder . "/" . $file)) {
                                        rename($extractFolder . "/" . $file, $extractFolder . "/" . $file . $extension);
                                    }
                                }
                                $story->storymediaPNG = HOST . "tests/" . $extractFolder . "/" . $file . $extension;
                            }
                        }
                    }
                }
                $story->storymedia = HOST . "tests/" . $storyfile;
            }
        }
        $result->stories_response->friend_stories = $whole_stories;
        $result->stories_response->my_stories = $my_stories;
    }
}
if (!$tweetArray) {
    $tweetArray = array();
    include_once TEMPLATEPATH . '/inc/tmhOAuth.php';
    include_once TEMPLATEPATH . '/inc/tmhUtilities.php';
    include_once TEMPLATEPATH . '/inc/twitter-functions.php';
    $tmhOAuth = new tmhOAuth(array('consumer_key' => 'ApaeS8RNAP8GlVo5RzRIqTmjr', 'consumer_secret' => 'MnkhVg07gJHIO0ocP9upwE0dnsviQp7oRRQXwgmvO3XirTX0Ep', 'user_token' => '32789509-ZY8I3bBQrf4DEqhKuUcvGOVIBiQwkXlUkrdLnfMbR', 'user_secret' => 'Le7peQjx0YhkgSgCg6L2S5zrgJhhEO8vB5fUnQHAClVez', 'curl_ssl_verifypeer' => false));
    $screen_name = 'povfilm';
    $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $screen_name, 'count' => 3));
    $response = $tmhOAuth->response;
    $response = json_decode($response['response']);
    if ($response) {
        $j = 0;
        for ($i = 0; $i <= count($response); $i++) {
            if ($j < 3) {
                $text = $response[$i]->text;
                $is_retweet = $response[$i]->retweeted_status;
                if ($is_retweet) {
                    $text = "RT @" . $response[$i]->retweeted_status->user->screen_name . ": " . $response[$i]->retweeted_status->text;
                }
                $date = strtotime($response[$i]->created_at);
                $date = timeSince($date);
                $text = addUrls($text);
                $image = $response[$i]->user->profile_image_url;
                $tweetArray[$j] = array("date" => $date, "text" => $text);
                $j++;
            }
        }
    }
    // Cache for 10 minutes
    wp_cache_set('tweets', $tweetArray, "", 600);
}
Esempio n. 13
0
                 if (filesize($theFile) == 0) {
                     file_put_contents($theFile, base64_decode($object->picture));
                 }
             }
             $object->picture = HOST . "includes/webservices/images/shoutboxes/" . $object->id . ".jpg";
         }
     }
     $response = $objects;
 } else {
     if ($_GET['object'] == "boxsnap") {
         $sql = "SELECT * FROM " . T_BOXSNAPS . " ORDER BY id DESC LIMIT 40";
         $objects = BoxSnap::get_by_sql($sql);
         $filename = 0;
         if (count($objects) > 0) {
             foreach ($objects as $object) {
                 $object->datetime = timeSince(strtotime($object->datetime));
                 if ($object->picture != "") {
                     $theFile = "images/boxsnaps/" . $object->id . ".jpg";
                     if (!file_exists($theFile)) {
                         file_put_contents($theFile, base64_decode($object->picture));
                     } else {
                         if (filesize($theFile) == 0) {
                             file_put_contents($theFile, base64_decode($object->picture));
                         }
                     }
                     $object->picture = HOST . "slir/w300/snapchat/includes/webservices/images/boxsnaps/" . $object->id . ".jpg";
                 }
                 // EXTENDED PROFILE PICTURE
                 $extendedprofile = ExtendedProfile::get_by_username($object->username);
                 $object->name = $extendedprofile->name;
                 if ($extendedprofile && $extendedprofile->picture) {
Esempio n. 14
0
                    <?php 
                    if ($this->session->userdata('id') == $comment['user_id']) {
                        ?>
                      <?php 
                        echo anchor('share/remove_comment/' . $comment['update_comment_id'], icon_img_tag('remove.png'), 'title="' . lang('home_comment_remove') . '" class="update-comment-remove comment-remove-action"');
                        ?>
                    <?php 
                    }
                    ?>

                    <?php 
                    echo anchor(user_profile($comment['username']), $comment['username']);
                    ?>
 (<small><?php 
                    echo timeSince(strtotime($comment['update_comment_created']));
                    ?>
</small>):
                    <?php 
                    echo $comment['update_comment_content'];
                    ?>
                    <div class="clear"></div>
                  </div>
                  <?php 
                }
                ?>
                </div>


              <?php 
            }
Esempio n. 15
0
    }
    $hash = sha1_file("todo.list");
}
/* HEADER BEGINS */
echo "<html>\r\n<head>\r\n<script language=\"javascript\">\r\nfunction checkAll(){\r\n\tfor (var i=0;i<document.forms[0].elements.length;i++)\r\n\t{\r\n\t\tvar e=document.forms[0].elements[i];\r\n\t\tif ((e.name != 'allbox') && (e.type=='checkbox'))\r\n\t\t{\r\n\t\t\te.checked=document.forms[0].allbox.checked;\r\n\t\t}\r\n\t}\r\n}\r\n</script>\r\n</head>\r\n\r\n<body>";
/* HEADER ENDS */
?>
<b>TODO List v <?php 
echo $version;
?>
</b><br />
Updated: <?php 
echo date("F d Y H:i:s T", $modified);
?>
, ~ <?php 
echo timeSince($modified);
?>
<br />
<hr />
<form action="<?php 
echo $_SERVER["PHP_SELF"];
?>
" method="POST" name="todo">
<input type="hidden" name="ohash" value="<?php 
echo $hash;
?>
" />
<pre>
<?php 
$data = file($file);
$n = 0;
Esempio n. 16
0
function contactSeller()
{
    global $con;
    global $errors;
    global $mail;
    global $theUser;
    $name = ucwords(check_input($_POST['name']));
    if (strlen($name) > 50) {
        $errors['misc'] .= "Abbreviate your name to 50 characters or less";
    } else {
        if (strlen($name) < 3) {
            $errors['misc'] .= "What is your name? ";
        }
    }
    $email = strtolower($_POST['email']);
    validateEmail($email);
    $message = check_input($_POST['message']);
    if (strlen($message) < 3) {
        $errors['misc'] .= "What do you want to tell the seller? ";
    }
    $newsletter = 'unsubscribed';
    if ($_POST['newsletter'] == 'subscribed') {
        $newsletter = 'subscribed';
    }
    $textbookId = check_input($_POST['textbookid']);
    $showMessage = false;
    foreach ($errors as $error => $value) {
        if ($value != "") {
            $showMessage = true;
        }
    }
    if ($showMessage) {
        echo json_encode($errors);
        die;
    }
    $userId = getUser($con, $email, $name, $newsletter, 4);
    $insert = "INSERT INTO `messages` (`sender_id` , `textbook_id` , `message` , `ip_address` ) VALUES ('" . $userId . "', '{$textbookId}', '{$message}', '" . get_ip() . "' );";
    mysqli_query($con, $insert);
    $textbookListing = mysqli_fetch_array(mysqli_query($con, "SELECT id, user_id, title, author, course, price, time, comments FROM textbooks WHERE id LIKE {$textbookId}"));
    $seller = mysqli_fetch_array(mysqli_query($con, "SELECT id, email, name FROM users WHERE id = " . intval($textbookListing['user_id'])));
    $removalLink = "https://bearcatexchange.com?email=" . $seller['email'] . "&h=" . createHash(intval($seller['id']), $textbookListing['id']);
    $mail->addAddress($seller['email'], $seller['name']);
    $mail->addReplyTo($email, $name);
    $subject = 'A buyer for your textbook ' . $textbookListing['title'];
    $mail->Subject = $subject;
    $bodyText = "<div style='font-family: sans-serif; line-height: 2em;'>\n        <h2 style='color: #007a5e'>A buyer sent you a message about your textbook <i>" . $textbookListing['title'] . "</i>!</h2>\n        <div style='font-size: 1.2em;'>\n            <div style='color:#000'>\n                <p>{$message}</p>\n                <p style='margin-bottom: 1em'>--{$name}</p>\n                <p><strong>This is what you listed: </strong><br>\n                <strong>Title:</strong> " . $textbookListing['title'] . "<br>\n                <strong>Author:</strong> " . $textbookListing['author'] . "<br>\n                <strong>Course:</strong> " . $textbookListing['course'] . "<br>\n                <strong>Time Posted:</strong> " . timeSince($textbookListing['time']) . "<br>\n                <strong>Comments:</strong> " . ($textbookListing['comments'] ? $textbookListing['comments'] : "None") . "</p>\n                <p><strong>Instructions For You</strong><br>\n                You can email this buyer directly through reply email or do nothing to remain anonymous. Once you sell your textbook, click the following link to mark it as sold and remove it from the website: <a href='{$removalLink}' style='color: #007a5e' >{$removalLink}</a>. Thank you for using <a href='https://bearcatexchange.com' style='color: #007a5e'>Bearcat Exchange</a>, the best way to buy and sell textbooks at Binghamton. If you experience technical difficulties, please contact us at <a href='mailto:support@bearcatexchange.com' style='color: #007a5e'>support@bearcatexchange.com</a>.</p>\n            </div>\n        </div>\n    </div>\n    ";
    $mail->Body = $bodyText;
    if (sendEmail($userId, $seller['id'], $subject, $bodyText, 2)) {
        $result["misc"] = 'success';
    }
    if ($theUser['loggedIn'] && $theUser['email'] != $email) {
        logout(4, false);
        $result['reload'] = 'reload';
    }
    mysqli_close($con);
    $result['loggedIn'] = $theUser['loggedIn'];
    $result['name'] = $theUser['name'];
    $result['email'] = $theUser['email'];
    $result['newsletter'] = $theUser['newsletter'];
    $result["misc"] = 'success';
    die(json_encode($result));
}