function convertdatauris($in) { global $CFG, $userid; $okext = array('jpeg' => '.jpg', 'gif' => '.gif', 'png' => '.png'); if (strpos($in, 'data:image') === false) { return $in; } $in = preg_replace('/<img[^>]*src="data:image[^>]*$/', '', $in); if (!isset($CFG['GEN']['noFileBrowser'])) { preg_match_all('/<img[^>]*src="(data:image\\/(\\w+);base64,([^"]*))"/', $in, $matches); foreach ($matches[3] as $k => $code) { $img = base64_decode($code); $ext = $matches[2][$k]; if (!isset($okext[$ext])) { continue; } $key = "ufiles/{$userid}/pastedimage" . tzdate("ymd-His", time()) . '-' . $k . $okext[$ext]; storecontenttofile($img, $key, "public"); $in = str_replace($matches[1][$k], getuserfileurl($key), $in); } return $in; } else { $in = preg_replace('/<img[^>]*src="data:image[^>]*>/', '', $in); } return $in; }
function relocatefileifneeded($file, $key, $sec = "public") { if ($GLOBALS['filehandertypecfiles'] == 's3') { if ($sec == "public" || $sec == "public-read") { $sec = "public-read"; } else { $sec = "private"; } $s3 = new S3($GLOBALS['AWSkey'], $GLOBALS['AWSsecret']); if ($s3->putObjectFile($file, $GLOBALS['AWSbucket'], $key, $sec)) { return getuserfileurl($key); } else { return false; } } else { return true; } }
$name = "{$line['LastName']}, {$line['FirstName']}"; } echo "<br/>Posted by: {$name}, "; echo tzdate("F j, Y, g:i a", $line['postdate']); echo "</div><div class=blockitems>"; if ($line['files'] != '') { $fl = explode('@@', $line['files']); if (count($fl) > 2) { echo '<p><b>Files:</b> '; //<ul class="nomark">'; } else { echo '<p><b>File:</b> '; } for ($i = 0; $i < count($fl) / 2; $i++) { //if (count($fl)>2) {echo '<li>';} echo '<a href="' . getuserfileurl('ffiles/' . $line['id'] . '/' . $fl[2 * $i + 1]) . '" target="_blank">'; $extension = ltrim(strtolower(strrchr($fl[2 * $i + 1], ".")), '.'); if (isset($itemicons[$extension])) { echo "<img alt=\"{$extension}\" src=\"{$imasroot}/img/{$itemicons[$extension]}\" class=\"mida\"/> "; } else { echo "<img alt=\"doc\" src=\"{$imasroot}/img/doc.png\" class=\"mida\"/> "; } echo $fl[2 * $i] . '</a> '; //if (count($fl)>2) {echo '</li>';} } //if (count($fl)>2) {echo '</ul>';} echo '</p>'; } echo filter($line['message']); echo "<p><a href=\"posts.php?cid={$cid}&forum={$line['forumid']}&thread={$line['threadid']}&page=-4\">Show full thread</a></p>"; echo "</div>\n";
<div class="td_main"> <?php $files = getuserfiles($userid, $type == "img"); if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "upload_file") { echo 'Just uploaded:<br/>'; echo "<a href='#' onClick='delete_file(\"" . basename("ufiles/{$userid}/" . $filename) . "\")'>"; echo "<img border=0 src='" . $delete_image . "'></a> "; echo "<img src='" . $file_small_image . "'> "; echo "<a class='file' href='#' onClick='FileBrowserDialogue.mySubmit(\"" . getuserfileurl("ufiles/{$userid}/" . $filename) . "\");'>" . basename("ufiles/{$userid}/" . $filename) . "</a><br>\n"; echo '<hr/>'; } foreach ($files as $k => $v) { echo "<a href='#' onClick='delete_file(\"" . basename($v['name']) . "\")'>"; echo "<img border=0 src='" . $delete_image . "'></a> "; echo "<img src='" . $file_small_image . "'> "; echo "<a class='file' href='#' onClick='FileBrowserDialogue.mySubmit(\"" . getuserfileurl($v['name']) . "\");'>" . basename($v['name']) . "</a><br>\n"; } ?> </div> <div class="upload"> <div id="upload_div" style="display: block; padding: 0px;"> <form method="post" enctype="multipart/form-data" onSubmit="return switchDivs();"> <?php echo $strings["upload_file"]; ?> <input type="hidden" name="action" value="upload_file"> <input type="hidden" name="MAX_FILE_SIZE" value="10485760" /> <!-- ~10mb --> <input type="file" name="uploaded_file" id="uploaded_file"> <input type="hidden" name="uploaded_file_name" id="uploaded_file_name" /> <input type="submit" value="<?php
echo '<script type="text/javascript"> var filecnt = 1; function addnewfile(t) { var s = document.createElement("span"); s.innerHTML = \'Description: <input type="text" name="newfiledesc-\'+filecnt+\'" /> File: <input type="file" name="newfile-\'+filecnt+\'" /><br/>\'; t.parentNode.insertBefore(s,t); filecnt++; }</script>'; echo "<span class=form>Files:</span>"; echo "<span class=formright>"; if ($line['files'] != '') { require_once '../includes/filehandler.php'; $files = explode('@@', $line['files']); for ($i = 0; $i < count($files) / 2; $i++) { echo '<input type="text" name="filedesc[' . $i . ']" value="' . $files[2 * $i] . '"/>'; echo '<a href="' . getuserfileurl('ffiles/' . $_GET['modify'] . '/' . $files[2 * $i + 1]) . '" target="_blank">View</a> '; echo 'Delete? <input type="checkbox" name="filedel[' . $i . ']" value="1"/><br/>'; } } echo 'Description: <input type="text" name="newfiledesc-0" /> '; echo 'File: <input type="file" name="newfile-0" /><br/>'; echo '<a href="#" onclick="addnewfile(this);return false;">Add another file</a>'; echo "</span><br class=form>\n"; } if ($taglist != '' && ($_GET['modify'] == 'new' || $_GET['modify'] == $threadid)) { $p = strpos($taglist, ':'); echo '<span class="form"><label for="tag">' . substr($taglist, 0, $p) . '</label></span>'; echo '<span class="formright"><select name="tag">'; echo '<option value="">Select...</option>'; $tags = explode(',', substr($taglist, $p + 1)); foreach ($tags as $tag) {
function printchildren($base, $restricttoowner = false) { $curdir = rtrim(dirname(__FILE__), '/\\'); global $children, $date, $subject, $message, $poster, $email, $forumid, $threadid, $isteacher, $cid, $userid, $ownerid, $points; global $feedback, $posttype, $lastview, $bcnt, $icnt, $myrights, $allowreply, $allowmod, $allowdel, $allowlikes, $view, $page, $allowmsg; global $haspoints, $imasroot, $postby, $replyby, $files, $CFG, $rubric, $pointsposs, $hasuserimg, $urlmode, $likes, $mylikes, $section; global $canviewall, $caneditscore, $canviewscore; if (!isset($CFG['CPS']['itemicons'])) { $itemicons = array('web' => 'web.png', 'doc' => 'doc.png', 'wiki' => 'wiki.png', 'html' => 'html.png', 'forum' => 'forum.png', 'pdf' => 'pdf.png', 'ppt' => 'ppt.png', 'zip' => 'zip.png', 'png' => 'image.png', 'xls' => 'xls.png', 'gif' => 'image.png', 'jpg' => 'image.png', 'bmp' => 'image.png', 'mp3' => 'sound.png', 'wav' => 'sound.png', 'wma' => 'sound.png', 'swf' => 'video.png', 'avi' => 'video.png', 'mpg' => 'video.png', 'nb' => 'mathnb.png', 'mws' => 'maple.png', 'mw' => 'maple.png'); } else { $itemicons = $CFG['CPS']['itemicons']; } foreach ($children[$base] as $child) { if ($restricttoowner && $ownerid[$child] != $userid) { continue; } echo "<div class=block> "; echo '<span class="leftbtns">'; if (isset($children[$child])) { if ($view == 1) { $lbl = '+'; $img = "expand"; } else { $lbl = '-'; $img = "collapse"; } //echo "<input type=button id=\"butb$bcnt\" value=\"$lbl\" onClick=\"toggleshow($bcnt)\"> "; echo "<img class=\"pointer\" id=\"butb{$bcnt}\" src=\"{$imasroot}/img/{$img}.gif\" onClick=\"toggleshow({$bcnt})\"/> "; } if ($hasuserimg[$child] == 1) { if (isset($GLOBALS['CFG']['GEN']['AWSforcoursefiles']) && $GLOBALS['CFG']['GEN']['AWSforcoursefiles'] == true) { echo "<img src=\"{$urlmode}s3.amazonaws.com/{$GLOBALS['AWSbucket']}/cfiles/userimg_sm{$ownerid[$child]}.jpg\" onclick=\"togglepic(this)\" />"; } else { echo "<img src=\"{$imasroot}/course/files/userimg_sm{$ownerid[$child]}.jpg\" onclick=\"togglepic(this)\" />"; } } echo '</span>'; echo "<span class=right>"; if ($view == 2) { echo "<input type=button id=\"buti{$icnt}\" value=\"Show\" onClick=\"toggleitem({$icnt})\">\n"; } else { echo "<input type=button id=\"buti{$icnt}\" value=\"Hide\" onClick=\"toggleitem({$icnt})\">\n"; } if ($isteacher) { echo "<a href=\"posts.php?view={$view}&cid={$cid}&forum={$forumid}&thread={$threadid}&page={$page}&move={$child}\">Move</a> \n"; } if ($isteacher || $ownerid[$child] == $userid && $allowmod) { if ($base == 0 && time() < $postby || $base > 0 && time() < $replyby || $isteacher) { echo "<a href=\"posts.php?view={$view}&cid={$cid}&forum={$forumid}&thread={$threadid}&page={$page}&modify={$child}\">Modify</a> \n"; } } if ($isteacher || $allowdel && $ownerid[$child] == $userid && !isset($children[$child])) { echo "<a href=\"posts.php?view={$view}&cid={$cid}&forum={$forumid}&thread={$threadid}&page={$page}&remove={$child}\">Remove</a> \n"; } if ($posttype[$child] != 2 && $myrights > 5 && $allowreply) { echo "<a href=\"posts.php?view={$view}&cid={$cid}&forum={$forumid}&thread={$threadid}&page={$page}&modify=reply&replyto={$child}\">Reply</a>"; } echo "</span>\n"; echo '<span style="float:left">'; echo "<b>{$subject[$child]}</b><br/>Posted by: "; //if ($isteacher && $ownerid[$child]!=0) { // echo "<a href=\"mailto:{$email[$child]}\">"; //} else if ($allowmsg && $ownerid[$child]!=0) { if (($isteacher || $allowmsg) && $ownerid[$child] != 0) { echo "<a href=\"../msgs/msglist.php?cid={$cid}&add=new&to={$ownerid[$child]}\" "; if ($section[$child] != '') { echo 'title="Section: ' . $section[$child] . '"'; } echo ">"; } echo $poster[$child]; if (($isteacher || $allowmsg) && $ownerid[$child] != 0) { echo "</a>"; } if ($isteacher && $ownerid[$child] != 0 && $ownerid[$child] != $userid) { echo " <a class=\"small\" href=\"{$imasroot}/course/gradebook.php?cid={$cid}&stu={$ownerid[$child]}\" target=\"_popoutgradebook\">[GB]</a>"; if ($base == 0 && preg_match('/Question\\s+about\\s+#(\\d+)\\s+in\\s+(.*)\\s*$/', $subject[$child], $matches)) { $query = "SELECT ias.id FROM imas_assessment_sessions AS ias JOIN imas_assessments AS ia ON ia.id=ias.assessmentid "; $aname = addslashes($matches[2]); $query .= "WHERE ia.name='{$aname}' AND ias.userid=" . intval($ownerid[$child]); $result = mysql_query($query) or die("Query failed : {$query} " . mysql_error()); if (mysql_num_rows($result) > 0) { $r = mysql_fetch_row($result); echo " <a class=\"small\" href=\"{$imasroot}/course/gb-viewasid.php?cid={$cid}&uid={$ownerid[$child]}&asid={$r[0]}\" target=\"_popoutgradebook\">[assignment]</a>"; } } } echo ', '; echo tzdate("D, M j, Y, g:i a", $date[$child]); if ($date[$child] > $lastview) { echo " <span style=\"color:red;\">New</span>\n"; } echo '</span>'; if ($allowlikes) { $icon = in_array($child, $mylikes) ? 'liked' : 'likedgray'; $likemsg = 'Liked by '; $likecnt = 0; $likeclass = ''; if ($likes[$child][0] > 0) { $likeclass = ' liked'; $likemsg .= $likes[$child][0] . ' ' . ($likes[$child][0] == 1 ? 'student' : 'students'); $likecnt += $likes[$child][0]; } if ($likes[$child][1] > 0 || $likes[$child][2] > 0) { $likeclass = ' likedt'; $n = $likes[$child][1] + $likes[$child][2]; if ($likes[$child][0] > 0) { $likemsg .= ' and '; } $likemsg .= $n . ' '; if ($likes[$child][2] > 0) { $likemsg .= $n == 1 ? 'teacher' : 'teachers'; if ($likes[$child][1] > 0) { $likemsg .= '/tutors/TAs'; } } else { if ($likes[$child][1] > 0) { $likemsg .= $n == 1 ? 'tutor/TA' : 'tutors/TAs'; } } $likecnt += $n; } if ($likemsg == 'Liked by ') { $likemsg = ''; } else { $likemsg .= '.'; } if ($icon == 'liked') { $likemsg = 'You like this. ' . $likemsg; } else { $likemsg = 'Click to like this post. ' . $likemsg; } echo '<div class="likewrap">'; echo "<img id=\"likeicon{$child}\" class=\"likeicon{$likeclass}\" src=\"{$imasroot}/img/{$icon}.png\" title=\"{$likemsg}\" onclick=\"savelike(this)\">"; echo " <span class=\"pointer\" id=\"likecnt{$child}\" onclick=\"GB_show('" . _('Post Likes') . "','listlikes.php?cid={$cid}&post={$child}',500,500);\">" . ($likecnt > 0 ? $likecnt : '') . ' </span> '; echo '</div>'; } echo '<div class="clear"></div>'; echo "</div>\n"; if ($view == 2) { echo "<div class=hidden id=\"item{$icnt}\">"; } else { echo "<div class=blockitems id=\"item{$icnt}\" style=\"clear:all\">"; } if (isset($files[$child]) && $files[$child] != '') { $fl = explode('@@', $files[$child]); if (count($fl) > 2) { echo '<p><b>Files:</b> '; //<ul class="nomark">'; } else { echo '<p><b>File:</b> '; } for ($i = 0; $i < count($fl) / 2; $i++) { //if (count($fl)>2) {echo '<li>';} echo '<a href="' . getuserfileurl('ffiles/' . $child . '/' . $fl[2 * $i + 1]) . '" target="_blank">'; $extension = ltrim(strtolower(strrchr($fl[2 * $i + 1], ".")), '.'); if (isset($itemicons[$extension])) { echo "<img alt=\"{$extension}\" src=\"{$imasroot}/img/{$itemicons[$extension]}\" class=\"mida\"/> "; } else { echo "<img alt=\"doc\" src=\"{$imasroot}/img/doc.png\" class=\"mida\"/> "; } echo $fl[2 * $i] . '</a> '; //if (count($fl)>2) {echo '</li>';} } //if (count($fl)>2) {echo '</ul>';} echo '</p>'; } echo filter($message[$child]); if ($haspoints) { if ($caneditscore && $ownerid[$child] != $userid) { echo '<hr/>'; echo "Score: <input type=text size=2 name=\"score[{$child}]\" id=\"scorebox{$child}\" value=\""; if ($points[$child] !== null) { echo $points[$child]; } echo "\"/> "; if ($rubric != 0) { echo printrubriclink($rubric, $pointsposs, "scorebox{$child}", "feedback{$child}"); } echo " Private Feedback: <textarea cols=\"50\" rows=\"2\" name=\"feedback[{$child}]\" id=\"feedback{$child}\">"; if ($feedback[$child] !== null) { echo $feedback[$child]; } echo "</textarea>"; } else { if (($ownerid[$child] == $userid || $canviewscore) && $points[$child] !== null) { echo '<div class="signup">Score: '; echo "<span class=red>{$points[$child]} points</span><br/> "; if ($feedback[$child] !== null && $feedback[$child] != '') { echo 'Private Feedback: '; echo $feedback[$child]; } echo '</div>'; } } } echo "<div class=\"clear\"></div></div>\n"; $icnt++; if (isset($children[$child])) { //if has children echo "<div class="; if ($view == 0 || $view == 2) { echo '"forumgrp"'; } else { if ($view == 1) { echo '"hidden"'; } } echo " id=\"block{$bcnt}\">\n"; $bcnt++; printchildren($child, $posttype[$child] == 3 && !$isteacher); echo "</div>\n"; } //} } }