Develop and Download Open Source Software

Browse Subversion Repository

Contents of /iSlideManager.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download) (as text)
Fri Jul 16 05:31:22 2010 UTC (13 years, 8 months ago) by isao-hara
File MIME type: application/x-httpd-php
File size: 1672 byte(s)
Add all files
1 <?php
2 /*
3 iSlideManager.php
4
5 iSlideMaker
6 http://sourceforge.jp/projects/islidemaker/simple/
7
8 Copyright(c) 2010, Isao Hara, isao-hara@users.sourceforge.jp
9
10 All rights reserved. This program is made available under the terms of the
11 Eclipse Public License v1.0 which accompanies this distribution, and is
12 available at http://www.eclipse.org/legal/epl-v10.html
13
14 Contributors: Isao Hara.
15
16 */
17 $name = $_POST['name'];
18 $cmd = $_POST['cmd'];
19 $filetype = $_POST['filetype'];
20 $content = $_POST['datalob'];
21
22 $path = dirname($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
23
24 if(!$name){
25 echo "Filename required";
26 exit;
27 }
28 if($filetype == "svg"){
29 $dirname = $path."/SVG/";
30 $fname = $name.".svg";
31 }else{
32 $dirname = $path."/Slide/";
33 $fname = $name.".txt";
34 }
35
36 if(!$cmd || $cmd=='get'){
37 $res = file_get_contents($dirname.$fname);
38 echo $res;
39 }else if($cmd=='list'){
40 $res = getFileList($dirname);
41 echo implode(',',$res);
42 }else if($cmd=='upload'){
43 $res = save_content($dirname.$fname, $content);
44 if($res){
45 echo "Finish to upload.";
46 }else{
47 echo "Fail to upload.";
48 }
49
50 }else {
51 echo "No such command: $cmd.";
52 }
53
54
55 function save_content($filename, $content){
56 $res = false;
57 $fp = fopen($filename, "w+");
58 if(! $fp){ return $res; }
59 if(flock($fp, LOCK_EX)){
60 $res = fwrite($fp, $content);
61 flock($fp,LOCK_UN);
62 }
63 fclose($fp);
64 return $res;
65 }
66
67 function getFileList($dir){
68 $handle = opendir($dir);
69
70 $filenames=array();
71 while(false !== ($file = readdir($handle))){
72 if( $file != "." && $file != ".." && !is_dir($dir."/".$file)){
73 array_push($filenames, $file);
74 }
75 }
76 closedir($handle);
77 return $filenames;
78 }
79
80
81 ?>

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26