Changeset 557
- Timestamp:
- 05/23/08 16:39:28 (6 months ago)
- Location:
- trunk/app
- Files:
-
- 2 added
- 2 modified
-
controllers/shares_controller.php (modified) (6 diffs)
-
views/shares/display.ctp (modified) (1 diff)
-
views/shares/download.ctp (added)
-
webroot/img/static/shares-icon.png (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/shares_controller.php
r540 r557 23 23 { 24 24 $this->pageTitle = 'Share'; 25 25 $this->layout = 'ajax'; 26 26 $conditions = array("Share.secret"=>$secret, "Share.public"=>1); 27 27 28 28 $file = $this->Share->field('file', $conditions); 29 29 30 if (!$file) 31 { 32 $this->redirect('/'); 33 } 34 else 35 { 36 $this->redirect("/files/userfiles/".$file); 37 } 30 if (!$file): 31 $this->redirect('/'); 32 else: 33 $this->set('file', 'files/userfiles/'.$file); 34 endif; 38 35 } 39 36 … … 106 103 107 104 /** Security: checks to see if file is an image, if not do not allow upload ==*/ 108 if ( $type == "application/x-php") // .php is not a valid file!!! 109 { 110 $ErrMsg = "<h1>ERROR</h1> the file ". $file_name . " is not valid.<br>"; 111 $ErrMsg .= "<p>no se pueden agregar archivos .php, subelo como .txt<br /><br />"; 112 $ErrMsg .= '<a href="upload_1.php"> >> Regresar </a>'; 105 if ( $type == "application/x-php"): // .php is not a valid file!!! 106 $msg = 'Error the file '. $file_name . ' is not valid. No se pueden agregar archivos .php, subelo como .txt'; 113 107 /** delete uploaded file ==*/ 114 108 unlink($file); 115 exit($ErrMsg); 116 } 117 118 if ( $file_size > $maxfilesize) 119 { 120 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>"; 121 $ErrMsg .= "<p>Bigger than 30 MB <br><br>"; 122 $ErrMsg .= "The current size: " . $file_size ."</p>\n"; 109 $this->flash($msg, '/admin/shares/listing'); 110 return false; 111 endif; 112 113 if ( $file_size > $maxfilesize): 114 $msg = 'Error. The image is too big. Bigger than 30 MB. The current size: ' . $file_size ; 123 115 124 /** delete uploaded file*/116 /** delete uploaded file ==*/ 125 117 unlink($file); 126 exit($ErrMsg); 127 } 118 $this->flash($msg, '/admin/shares/listing'); 119 return false; 120 endif; 128 121 129 122 $conditions = array("user_id" => $this->Auth->user('id')); … … 139 132 $allowed = array("pdf", "doc", "xls", "xcf", "ppt", "sxw", "odt", "odc", "ods", "odp", "abw", "html", "zip", "rar", "gz", "png", "jpg", "gif", "svg", "mp3", "ogg", "flac", "txt"); 140 133 141 if ( !in_array($extension, $allowed) ) 142 { 143 die("This does not look like one allowed file ". $extension); 144 } 134 if ( !in_array($extension, $allowed) ): 135 die("This does not look like one allowed file ". $extension); 136 endif; 145 137 146 138 $Name = $this->Auth->user('username') . "_" . $next_id . '.'. $extension; … … 153 145 154 146 /** do extra security check to prevent malicious abuse */ 155 if (is_uploaded_file($file)) 156 { 147 if (is_uploaded_file($file)): 157 148 /** move file to proper directory ==*/ 158 if (!move_uploaded_file($file, $newfile)) 159 { 149 if (!move_uploaded_file($file, $newfile)): 160 150 /** if an error occurs the file could not 161 151 be written, read or possibly does not exist ==*/ 162 152 163 153 exit('Error Uploading File.'); 164 }165 }154 endif; 155 endif; 166 156 167 157 … … 172 162 $this->data['Share']['user_id'] = $this->Auth->user('id'); 173 163 174 if ($this->Share->save($this->data["Share"])) 175 { 176 $this->msgFlash('File saved','/admin/shares/listing'); 177 } 178 } 179 164 if ($this->Share->save($this->data["Share"])): 165 $this->msgFlash('File saved','/admin/shares/listing'); 166 endif; 167 } 180 168 } 181 169 … … 187 175 $this->data['Share']['id'] = $id; 188 176 189 if ($this->Share->save($this->data['Share'])) 190 { 177 if ($this->Share->save($this->data['Share'])): 191 178 $this->msgFlash('Share changed', '/admin/shares/listing'); 192 }179 endif; 193 180 } 194 181 public function admin_delete($id) -
trunk/app/views/shares/display.ctp
r329 r557 1 <div style="font-size:18pt;padding:5px;boder:1px solid #c0c0c0"> <?php echo $blog["User"]["username"]; ?>'s Files</div>2 1 <?php 3 2 //die(print_r($data)); 4 if ( count($data) < 1) 5 { 3 4 echo $html->div(null, $blog['User']['username'] . '\'s Files', array('style'=>'font-size:18pt;padding:5px;boder:1px solid #c0c0c0')); 5 6 if ( count($data) < 1): 6 7 echo $html->para('title', 'Teacher does not have any resource'); 7 } 8 endif; 8 9 9 foreach ($data as $v) 10 { 11 echo '<div style="padding:6px;margin:4px;height:30px;border:1px dotted orange;vertical-align:middle;">';12 echo $html->link($v["Share"]["description"], '/shares/download/'.$v["Share"]["secret"]);13 echo $html->link($html->image('static/button_download.gif', array("alt"=>$v["Share"]["description"], "alt"=>$v["Share"]["description"])), '/shares/show/'.$v["Share"]["secret"], null, null, false); 14 echo '</div>';15 } 10 foreach ($data as $v): 11 $tmp = $html->link($html->image('static/shares-icon.png', array('alt'=>'Download', 'title'=>'Download')),'/shares/download/'.$v["Share"]["secret"], null, null, false).'<br />'; 12 $tmp .= $html->link($v["Share"]["description"], '/shares/download/'.$v["Share"]["secret"]); 13 $tmp .= $html->link($html->image('static/button_download.gif', array("alt"=>$v["Share"]["description"], "alt"=>$v["Share"]["description"])), '/shares/download/'.$v["Share"]["secret"], null, null, false); 14 15 echo $html->div(null,$tmp,array('style'=>'padding:6px;margin:4px;border:1px dotted orange;vertical-align:middle;width:90%;')); 16 endforeach; 16 17 ?>
