コード例 #1
0
 public function picture_update()
 {
     $validator = Validator::make(Input::all(), file::$rules);
     if ($validator->fails()) {
         Session::flash('error', 'uploaded file is not valid');
         return Redirect::back()->withInput()->withErrors($validator->messages());
     }
     $data = file::where('user_id', '=', Auth::user()->id)->pluck('path');
     $file = Input::file('image');
     $extension = $file->getClientOriginalExtension();
     $filename = Auth::user()->id . '.' . $extension;
     $file->move('uploads', $filename);
     $path = '../uploads/' . $filename;
     $picture = new file();
     $picture->user_id = Auth::user()->id;
     $picture->path = $path;
     if ($data == null) {
         $picture->save();
     } else {
         $picture->update();
     }
     return Redirect::back();
 }
コード例 #2
0
ファイル: cache.php プロジェクト: art-youth/framework
 function save($data)
 {
     //如果缓存目录不存在则创建
     if (!$this->is_exist(false)) {
         file::folder($this->save_dir);
     }
     if ($this->ext == 'php') {
         $data = '<?php' . "\r\n" . 'return ' . var_export($data, true) . ';';
     }
     if ($this->ext == 'js') {
         $data = json_encode($data);
     }
     if ($this->ext == 'ini') {
         $data = fun::arr_ini($data);
     }
     if ($this->ext == 'xml') {
         $data = fun::xml($data);
     }
     if (is_array($data) && $this->ext == 'txt') {
         $data = serialize($data);
     }
     return file::save($this->file_name, $data);
 }
コード例 #3
0
function createNewObject($object_type, $post_vars, $system_data_classes, $object_save = 0)
{
    if (!$object_type) {
        return false;
    }
    if (!in_array($object_type, $system_data_classes)) {
        return false;
    }
    switch ($object_type) {
        case "page":
            $object = new page("new page");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->createContent();
                $object->save();
            }
            break;
        case "process":
            $object = new process("new process");
            $object->update_document_props($post_vars);
            $object->update_design_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        case "section":
            $object = new section("new section");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->createContent();
                $object->save();
            }
            break;
        case "image":
            $object = new image("new image");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        case "file":
            $object = new file("new file");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        default:
            break;
    }
    return $object;
}
コード例 #4
0
 public function change_password($id = null)
 {
     if (!is_null($id) && isset($_POST['new_password'])) {
         $file = new file();
         $file->find($id);
         $file->password = $_POST['new_password'];
         $file->save();
         $this->session->flash($this->l10n->__("La clave de acceso ha sido cambiada"));
         $this->redirect("files");
     }
 }
コード例 #5
0
ファイル: create.php プロジェクト: art-youth/framework
 static function html($url, $file_name, $dir = '')
 {
     $save_dir = self::is_exist('html', $dir);
     $data = file_get_contents($url);
     return file::save($save_dir . $file_name, $data);
 }
コード例 #6
0
 public static function register_upload($tmp_name, $target_name, $parent, $mime = NULL, $move_uploaded_file = false)
 {
     global $website;
     global $user;
     global $DB;
     $file = NULL;
     if ($move_uploaded_file) {
         $uploaded_file_temp = uniqid('upload-');
         move_uploaded_file($tmp_name, NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $uploaded_file_temp);
         $tmp_name = $uploaded_file_temp;
     }
     if (strpos($tmp_name, '/') === 0) {
         $tmp_file_path = $tmp_name;
     } else {
         $tmp_file_path = NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $tmp_name;
     }
     if (file_exists($tmp_file_path)) {
         if (empty($mime)) {
             $mime = file::getMime($target_name, $tmp_file_path);
         }
         $target_name = rawurldecode($target_name);
         // check if the parent folder given is valid in the current website
         if ($parent > 0) {
             $DB->query('SELECT id FROM nv_files WHERE website = ' . $website->id . ' AND id = ' . $parent);
             $rs = $DB->result('id');
             if (empty($rs) || $rs[0] != $parent) {
                 // parent folder invalid, put file in the root folder
                 $parent = 0;
             }
         }
         $file = new file();
         $file->id = 0;
         $file->website = $website->id;
         $file->mime = $mime[0];
         $file->type = $mime[1];
         $file->parent = intval($parent);
         $file->name = $target_name;
         $file->size = filesize($tmp_file_path);
         if ($file->type == 'image') {
             $dimensions = file::image_dimensions($tmp_file_path);
             $file->width = $dimensions['width'];
             $file->height = $dimensions['height'];
         }
         $file->date_added = core_time();
         $file->uploaded_by = empty($user->id) ? '0' : $user->id;
         $file->permission = 0;
         $file->enabled = 1;
         $file->save();
         rename($tmp_file_path, NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $file->id);
         if ($file->type == 'image') {
             $file->resize_uploaded_image();
         }
     }
     return $file;
 }
コード例 #7
0
ファイル: log.php プロジェクト: art-youth/framework
 static function mail($info)
 {
     $file = dc_log_log . 'mail/' . date('y-m') . '.log';
     $info = '[' . date('d H:i:s') . '] ' . $info . "\n";
     file::save($file, $info, 'a+');
 }
コード例 #8
0
 function markAnswered($msg)
 {
     file::save("data/answered", $msg->message_id . "\n", true);
 }
コード例 #9
0
ファイル: FileTest.php プロジェクト: te-koyama/openpne
//------------------------------------------------------------
$t->diag('File');
$t->diag('File::__toString()');
$t->is((string) $file1, 'dummy_file');
//------------------------------------------------------------
$t->diag('File::getImageFormat()');
$t->is($file1->getImageFormat(), 'png');
$t->is($file2->getImageFormat(), 'jpg');
$t->is($file3->getImageFormat(), false);
//------------------------------------------------------------
$t->diag('File::isImage()');
$t->is($file1->isImage(), true);
$t->is($file2->isImage(), true);
$t->is($file3->isImage(), false);
//------------------------------------------------------------
$t->diag('File::setFromValidatedFile()');
// require
new sfValidatorFile();
$validated = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content));
$newFile = new file();
$newFile->setFromValidatedFile($validated);
$t->is((string) $newFile->getOriginalFilename(), 'test.txt');
//------------------------------------------------------------
$t->diag('File::getFilesize()');
$newFile->save();
$t->is($newFile->getFilesize(), 22, 'The "file.file_size" is stored.');
//-----------------------------------------------------------
$t->diag('->delete()');
$file3->delete();
$t->ok(!Doctrine::getTable('File')->find(3), 'The parent "File" record is removed.');
$t->ok(!Doctrine::getTable('FileBin')->find(3), 'The related "FileBin" record is removed.');
コード例 #10
0
 function makeCategory($config, $subcategory)
 {
     print "Make subcategory {$subcategory['id']} page...\n";
     if (!is_dir($outputdir = "{$config->outputdir}/{$subcategory['folder']}")) {
         mkdir($outputdir);
     }
     $item = DB_DataObject::factory("item");
     $categDays = $item->getDays();
     $pager =& Pager::factory(array("mode" => "Jumping", "perPage" => $config->daynum, "delta" => 10, "itemData" => $categDays, "append" => false, "path" => "../", "fileName" => "{$subcategory['folder']}/index%d.html"));
     for ($i = 1; $i <= $pager->numPages(); $i++) {
         $tpl = new template();
         $tpl->load("templates/category.html", true, true);
         $tpl->setv("category_name", $subcategory["name"]);
         PagesGenerator::getCategories($tpl, "../");
         $data = $pager->getPageData($i);
         $links = $pager->getLinks($i);
         $tpl->setBlock("pages");
         $tpl->setv("pages", $links["all"]);
         foreach ($data as $day) {
             $res = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum);
             $res1 = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum, true);
             if (sizeof($res) == 0 && sizeof($res1) == 0) {
                 continue;
             }
             $tpl->setBlock("forday");
             $tpl->setv("date", date("Y-m-d", strtotime($day[0])));
             if (sizeof($res) > 0) {
                 foreach ($res as $row) {
                     $tpl->setBlock("rows");
                     $tpl->setv($row);
                     $tpl->parseBlock();
                 }
             }
             if (sizeof($res1) > 0) {
                 $numthumbs = 0;
                 foreach ($res1 as $row) {
                     $tpl->setBlock("thumb");
                     $tpl->setv($row);
                     $tpl->parseBlock();
                     if (++$numthumbs >= $config->numthumbs) {
                         $tpl->parse("rowthumbs");
                         $numthumbs = 0;
                     }
                 }
             }
             $tpl->parse("forday");
         }
         file::save("{$config->outputdir}/{$subcategory['folder']}/index{$i}.html", $tpl->get());
     }
 }
コード例 #11
0
ファイル: index.php プロジェクト: robinhunan/coolphp
            if ('add' == $v) {
                //添加页
                $tr = $tr == 'tr' ? 'tr2' : 'tr';
                foreach ($_POST[$v] as $key => $val) {
                    $fields .= "<tr class='{$tr} h30'>\n<td  class='ltit'>{$_POST['field'][$key]}</td>\n<td><input name='{$key}' type='text'></td>\n</tr>\n";
                }
                $str = str_replace(array('__table__', '__ds_table__', '__fields__'), array($table, $ds_table, $fields), $str);
            } else {
                if ('edit' == $v) {
                    //编辑页
                    $tr = $tr == 'tr' ? 'tr2' : 'tr';
                    foreach ($_POST[$v] as $key => $val) {
                        $fields .= "<tr class='{$tr} h30'>\n<td  class='ltit'>{$_POST['field'][$key]}</td>\n<td><input name='{$key}' value=\"{\$row['{$key}']}\" type='text'></td>\n</tr>\n";
                    }
                    $str = str_replace(array('__table__', '__ds_table__', '__fields__'), array($table, $ds_table, $fields), $str);
                }
            }
        }
        file::save($mod, $str);
    }
}
/** 显示所有的数据表 **/
foreach ($db->query('show tables') as $row) {
    $tables[] = $row[0];
}
$table = in_array($table, $tables) ? $table : $tables[0];
/** 显示一个表中的所有字段 */
foreach ($db->query('show full COLUMNS from ' . $table) as $row) {
    $rows[] = $row;
}
include template::inc('tools/index.php');
コード例 #12
0
ファイル: files.php プロジェクト: NavigateCMS/Navigate-CMS
function run()
{
    global $user;
    global $layout;
    global $DB;
    global $website;
    $out = '';
    $item = new file();
    switch ($_REQUEST['act']) {
        case 1:
            // json retrieval & operations
        // json retrieval & operations
        case "json":
            if ($_REQUEST['op'] == 'upload') {
                $tmp_name = $_REQUEST['tmp_name'];
                if ($tmp_name == "{{BASE64}}") {
                    $tmp_name = base64_encode($_REQUEST['name']);
                }
                $file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']);
                if (!empty($file)) {
                    echo json_encode(array('id' => $file->id, 'name' => $file->name));
                } else {
                    echo json_encode(false);
                }
            }
            switch ($_REQUEST['op']) {
                case 'create_folder':
                    file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']);
                    echo json_encode(true);
                    break;
                case 'edit_folder':
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->name = $_REQUEST['name'];
                    $f->mime = $_REQUEST['mime'];
                    $ok = $f->save();
                    echo json_encode($ok);
                    break;
                case 'edit_file':
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->name = $_REQUEST['name'];
                    $ok = $f->save();
                    echo json_encode($ok);
                    break;
                case 'duplicate_file':
                    //error_reporting(~0);
                    //ini_set('display_errors', 1);
                    $status = false;
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->id = 0;
                    $f->insert();
                    if (!empty($f->id)) {
                        $done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id);
                        $status = "true";
                        if (!$done) {
                            $f->delete();
                            $status = t(56, "Unexpected error");
                        }
                    }
                    echo $status;
                    break;
                case 'move':
                    if (is_array($_REQUEST['item'])) {
                        $ok = true;
                        for ($i = 0; $i < count($_REQUEST['item']); $i++) {
                            unset($item);
                            $item = new file();
                            $item->load($_REQUEST['item'][$i]);
                            $item->parent = $_REQUEST['folder'];
                            $ok = $ok & $item->update();
                        }
                        echo json_encode($ok ? true : false);
                    } else {
                        $item->load($_REQUEST['item']);
                        $item->parent = $_REQUEST['folder'];
                        echo json_encode($item->update());
                    }
                    break;
                case 'delete':
                    try {
                        $item->load($_REQUEST['id']);
                        $status = $item->delete();
                        echo json_encode($status);
                    } catch (Exception $e) {
                        echo $e->getMessage();
                    }
                    break;
                case 'permissions':
                    $item->load($_REQUEST['id']);
                    if (!empty($_POST)) {
                        $item->access = intval($_POST['access']);
                        $item->permission = intval($_POST['permission']);
                        $item->enabled = intval($_POST['enabled']);
                        $item->groups = $_POST['groups'];
                        if ($item->access < 3) {
                            $item->groups = array();
                        }
                        $status = $item->save();
                        echo json_encode($status);
                    } else {
                        echo json_encode(array('access' => $item->access, 'groups' => $item->groups, 'permission' => $item->permission, 'enabled' => $item->enabled));
                    }
                    break;
                case 'description':
                    $item->load($_REQUEST['id']);
                    if (!empty($_POST)) {
                        $item->title = array();
                        $item->description = array();
                        foreach ($website->languages as $language) {
                            $lcode = $language['code'];
                            if (!isset($_REQUEST['titles'][$lcode])) {
                                break;
                            }
                            $item->title[$lcode] = $_REQUEST['titles'][$lcode];
                            $item->description[$lcode] = $_REQUEST['descriptions'][$lcode];
                        }
                        $status = $item->save();
                        echo json_encode($status);
                    } else {
                        // return file title and description (alt)
                        $data = array('title' => $item->title, 'description' => $item->description);
                        echo json_encode($data);
                    }
                    break;
                case 'focalpoint':
                    $item->load($_REQUEST['id']);
                    if (!empty($_POST)) {
                        $item->focalpoint = $_REQUEST['top'] . '#' . $_REQUEST['left'];
                        $status = $item->save();
                        // remove cached thumbnails
                        file::thumbnails_remove($item->id);
                        echo json_encode($status);
                    } else {
                        if (empty($item->focalpoint)) {
                            $item->focalpoint = '50#50';
                            $item->save();
                            // remove cached thumbnails
                            file::thumbnails_remove($item->id);
                        }
                        echo $item->focalpoint;
                    }
                    break;
                case 'video_info':
                    if ($_REQUEST['provider'] == 'youtube') {
                        $item->load_from_youtube($_REQUEST['reference'], false);
                        // force cache reload
                    } else {
                        if ($_REQUEST['provider'] == 'vimeo') {
                            $item->load_from_vimeo($_REQUEST['reference'], false);
                            // force cache reload
                        } else {
                            if (!empty($_REQUEST['reference']) && is_numeric($_REQUEST['reference'])) {
                                $item->load($_REQUEST['reference']);
                            } else {
                                if (is_numeric($_REQUEST['provider'])) {
                                    $item->load($_REQUEST['provider']);
                                } else {
                                    unset($item);
                                }
                            }
                            if (!empty($item)) {
                                // add some extra data
                                $item->extra = array('reference' => $item->id, 'link' => '', 'thumbnail' => 'img/icons/ricebowl/mimetypes/video.png', 'thumbnail_big' => 'img/icons/ricebowl/mimetypes/video.png', 'thumbnail_url' => 'img/icons/ricebowl/mimetypes/video.png', 'duration' => '', 'embed_code' => '<video src="' . file::file_url($item->id, 'inline') . '></video>');
                            }
                        }
                    }
                    if (!empty($item)) {
                        echo json_encode($item);
                    } else {
                        echo false;
                    }
                    break;
            }
            session_write_close();
            $DB->disconnect();
            exit;
            break;
        case 2:
            // show/edit item properties
        // show/edit item properties
        case "edit":
            $item->load($_REQUEST['id']);
            if (isset($_REQUEST['form-sent'])) {
                $item->load_from_post();
                try {
                    $item->save();
                    unset($item);
                    $item = new file();
                    $item->load($_REQUEST['id']);
                    $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
                } catch (Exception $e) {
                    $layout->navigate_notification($e->getMessage(), true, true);
                }
            }
            $out = files_item_properties($item);
            break;
        case 10:
        case 'media_browser':
            files_media_browser($_GET['limit'], $_GET['offset']);
            break;
        case 92:
            // pixlr (image editor) overlay remover
        // pixlr (image editor) overlay remover
        case 'pixlr_exit':
            ob_clean();
            file::thumbnails_remove(intval($_GET['id']));
            echo '
			<html>
			<head></head>
			<body>
			<script language="javascript" type="text/javascript">
				//window.parent.eval("$(\'#thumbnail-cache\').attr(\'src\', $(\'#thumbnail-cache\').attr(\'src\') + \'&refresh=\' + new Date().getTime());");
				window.parent.eval(\'$("#image-preview").attr("src", $("#image-preview").attr("src") + "&refresh=" + new Date().getTime());\');
				window.parent.eval("pixlr.overlay.hide();");
			</script>
			</body>
			</html>	
			';
            core_terminate();
            break;
            /*	
            case 91: // picnik editing
            	ob_clean();
            	
            	// $strPicnikUrl is the URL that we use to launch Picnik.
            	$strPicnikUrl = "http://www.picnik.com/service";	
            	// $aPicnikParams collects together all the params we'll give Picnik.  Start with an API key
            	$aPicnikParams['_apikey'] = $website->picnik_api_key;
            	// tell Picnik where to send the exported image
            	$aPicnikParams['_export'] = NAVIGATE_URL.'/navigate_upload.php?wid='.$website->id.'&engine=picnik&id='.$_REQUEST['id'].'&engine=picnik&session_id='.session_id();
            	// give the export button a title
            	$aPicnikParams['_export_title'] = t(34, 'Save');
            	// turn on the close button, and tell it to come back here
            	//$aPicnikParams['_close_target'] = $strRoot;
            	// send in the previous "king" image in case the user feels like decorating it
            	$aPicnikParams['_import'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=attachment&sid='.session_id();	
            	// tell Picnik to redirect the user to the following URL after the HTTP POST instead of just redirecting to _export
            	$aPicnikParams['_redirect'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=inline&ts='.core_time(); //'javascript: return false;';
            
            	// tell Picnik our name.  It'll use it in a few places as appropriate
            	$aPicnikParams['_host_name'] = 'Navigate';
            	// turn off the "Save &amp; Share" tab so users don't get confused
            	$aPicnikParams['_exclude'] = "out";
            
            	echo '<html><head></head><body>';
            
            	echo '<form id="picnik_form" method="POST" action="'.$strPicnikUrl.'" style=" visibility: hidden; ">';
            	
            	// put all the API parameters into the form as hidden inputs
            	foreach( $aPicnikParams as $key => $value ) {
            		echo "<input type='hidden' name='$key' value='$value'/>\n";
            	}
            	
            	//echo "<input type='text' name='address' value='Your Majesty'/>\n";
            	echo "<input type='submit' value='Picnik'/>\n";
            	echo "</form>";
            	echo '<script language="javascript" type="text/javascript">
            			document.forms[0].submit();
            		  </script>';
            	echo '</body></html>';
            
            	core_terminate();
            	break;
            */
        /*	
        case 91: // picnik editing
        	ob_clean();
        	
        	// $strPicnikUrl is the URL that we use to launch Picnik.
        	$strPicnikUrl = "http://www.picnik.com/service";	
        	// $aPicnikParams collects together all the params we'll give Picnik.  Start with an API key
        	$aPicnikParams['_apikey'] = $website->picnik_api_key;
        	// tell Picnik where to send the exported image
        	$aPicnikParams['_export'] = NAVIGATE_URL.'/navigate_upload.php?wid='.$website->id.'&engine=picnik&id='.$_REQUEST['id'].'&engine=picnik&session_id='.session_id();
        	// give the export button a title
        	$aPicnikParams['_export_title'] = t(34, 'Save');
        	// turn on the close button, and tell it to come back here
        	//$aPicnikParams['_close_target'] = $strRoot;
        	// send in the previous "king" image in case the user feels like decorating it
        	$aPicnikParams['_import'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=attachment&sid='.session_id();	
        	// tell Picnik to redirect the user to the following URL after the HTTP POST instead of just redirecting to _export
        	$aPicnikParams['_redirect'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=inline&ts='.core_time(); //'javascript: return false;';
        
        	// tell Picnik our name.  It'll use it in a few places as appropriate
        	$aPicnikParams['_host_name'] = 'Navigate';
        	// turn off the "Save &amp; Share" tab so users don't get confused
        	$aPicnikParams['_exclude'] = "out";
        
        	echo '<html><head></head><body>';
        
        	echo '<form id="picnik_form" method="POST" action="'.$strPicnikUrl.'" style=" visibility: hidden; ">';
        	
        	// put all the API parameters into the form as hidden inputs
        	foreach( $aPicnikParams as $key => $value ) {
        		echo "<input type='hidden' name='$key' value='$value'/>\n";
        	}
        	
        	//echo "<input type='text' name='address' value='Your Majesty'/>\n";
        	echo "<input type='submit' value='Picnik'/>\n";
        	echo "</form>";
        	echo '<script language="javascript" type="text/javascript">
        			document.forms[0].submit();
        		  </script>';
        	echo '</body></html>';
        
        	core_terminate();
        	break;
        */
        case 0:
            // list / search result
        // list / search result
        default:
            // show requested folder or search
            $out = files_browser($_REQUEST['parent'], $_REQUEST['navigate-quicksearch']);
            users_log::action($_REQUEST['fid'], intval($_REQUEST['parent']), 'list', '', json_encode($_REQUEST));
            break;
    }
    return $out;
}
コード例 #13
0
 function save($params)
 {
     $json = new Services_JSON();
     file::save("data/config.ini", $json->encode(array("itemnum" => $params["itemnum"], "daynum" => $params["daynum"], "email" => $params["email"], "emailpassword" => $params["emailpassword"], "emailserver" => $params["emailserver"], "outputdir" => $params["outputdir"], "numthumbs" => $params["numthumbs"], "logemail" => $params["logemail"])));
     print $json->encode(array("error" => false));
 }