Ejemplo n.º 1
0
     }
 } else {
     if ($action == 'favs') {
         // add a favourite
         switch ($params['type']) {
             default:
                 Error::generate('suspicious', 'Bad fav type');
                 $params['owner'] = false;
                 break;
             case 'topic':
             case 'course':
         }
         if (!$params['owner'] || !User::IsAuthenticated()) {
             check_perms(false);
         } else {
             if (!User::SetAttrib(User::GetAuthenticatedID(), $params['type'] . 'fav', $params['cid'])) {
                 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                 header("Cache-Control: no-cache, must-revalidate");
                 header("Pragma: no-cache");
                 header("Content-Type: text/html");
                 header("Connection:");
                 header("Content-length:");
                 echo "Could not add to favs.";
             } else {
                 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                 header("Cache-Control: no-cache, must-revalidate");
                 header("Pragma: no-cache");
                 header("Content-Type: text/html");
                 header("Connection:");
Ejemplo n.º 2
0
             $ratio = min($srcw / $dstw, $srch / $dsth);
             $smside = min($srcw, $srch);
             $srcx = ($srcw - $smside) / 2;
             $srcy = ($srch - $smside) / 2;
             imagecopyresampled($imgdst, $imgsrc, 0, 0, $srcx, $srcy, $dstw, $dsth, $smside, $smside);
             imagepng($imgsrc, "{$ROOT}/{$fullname}");
             imagepng($imgdst, $tmpname);
             imagedestroy($imgsrc);
             imagedestroy($imgdst);
         }
         if (!file_exists("{$ROOT}/{$upload_dir}")) {
             mkdir("{$ROOT}/{$upload_dir}");
         }
         $fileCfg = array('name' => $params['name'], 'path' => $upload_path, 'owner' => $id, 'roles' => 'admin', 'type' => $ext, 'context' => $params['type'], 'comment' => $params['comment']);
         $res = File::Create($fileCfg, $tmpname);
         if ($res && User::SetAttrib($id, 'file', $res)) {
             if ($params['type'] == 1) {
                 Error::generate('notice', 'File was successfully uploaded, and is pending approval by an administrator.');
             } else {
                 Error::generate('notice', 'Your avatar has been updated.');
             }
         } else {
             Error::generate('notice', 'Could not upload file.', Error::$FLAGS['single']);
         }
         if (isset($_SESSION) && $_SESSION['last_rendered_page']) {
             redirect_raw($_SESSION['last_rendered_page']);
         } else {
             redirect();
         }
     }
 }