[923] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | if (! defined ( 'BASEPATH' ))
|
---|
| 4 | exit ( 'No direct script access allowed' );
|
---|
[780] | 5 | /**
|
---|
| 6 | * PrivateContent Class
|
---|
[889] | 7 | *
|
---|
[780] | 8 | * @author dzungnv02
|
---|
| 9 | *
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 |
|
---|
[923] | 13 | class PrivateContent extends MX_Controller {
|
---|
[780] | 14 | public function __construct() {
|
---|
[923] | 15 | parent::__construct ();
|
---|
| 16 | $user = $this->session->userdata ( 'userInfo' );
|
---|
| 17 | $this->vservices->setApiUrl ( $this->config->item ( 'api_url' ) );
|
---|
| 18 | $this->vservices->setConnection ( $this->curl );
|
---|
| 19 | $this->vservices->setUserId ( $user ['us_id'] );
|
---|
[780] | 20 | }
|
---|
[889] | 21 |
|
---|
[923] | 22 | public function getContent() {
|
---|
| 23 | $xmlData = $this->vservices->getPrivateTree ();
|
---|
[889] | 24 |
|
---|
[923] | 25 | $this->xml->parse ( $xmlData );
|
---|
[889] | 26 |
|
---|
[923] | 27 | $aryDirs = array ();
|
---|
| 28 | $aryFiles = array ();
|
---|
| 29 | write_file ( 'log.txt', var_export ( $xmlData, true ) );
|
---|
[889] | 30 |
|
---|
[923] | 31 | if (! isset ( $this->xml->tree )) {
|
---|
| 32 | $aryError = array (
|
---|
| 33 | 'err' => 'KhÃŽng thá» kết ná»i Äến máy chá»§!',
|
---|
| 34 | 'errCode' => '-1'
|
---|
| 35 | );
|
---|
| 36 | $aryData = array (
|
---|
| 37 | 'DIRECTORIES' => array (),
|
---|
| 38 | 'FILES' => array (),
|
---|
| 39 | 'ERROR' => $aryError
|
---|
| 40 | );
|
---|
| 41 | echo json_encode ( $aryData );
|
---|
[780] | 42 | return;
|
---|
| 43 | }
|
---|
[889] | 44 |
|
---|
[923] | 45 | $aryError = array (
|
---|
| 46 | 'err' => $this->xml->tree->_param ['err'],
|
---|
| 47 | 'errCode' => ( int ) $this->xml->tree->_param ['errCode']
|
---|
| 48 | );
|
---|
[889] | 49 |
|
---|
[923] | 50 | if (isset ( $this->xml->tree->folderlist->folder )) {
|
---|
| 51 | if (is_array ( $this->xml->tree->folderlist->folder )) {
|
---|
| 52 | foreach ( $this->xml->tree->folderlist->folder as $key => $value ) {
|
---|
| 53 | $aryDirs [] = array (
|
---|
| 54 | 'id' => $value->_param ['id'],
|
---|
| 55 | 'name' => $value->_value,
|
---|
| 56 | 'parentID' => $value->_param ['parentid'] == - 1 ? 0 : $value->_param ['parentid']
|
---|
| 57 | );
|
---|
[780] | 58 | }
|
---|
[923] | 59 | } else {
|
---|
[780] | 60 | $folder = $this->xml->tree->folderlist->folder;
|
---|
[923] | 61 | $aryDirs [] = array (
|
---|
| 62 | 'id' => $folder->_param ['id'],
|
---|
| 63 | 'name' => $folder->_value,
|
---|
| 64 | 'parentID' => $folder->_param ['parentid'] == - 1 ? 0 : $folder->_param ['parentid']
|
---|
| 65 | );
|
---|
[780] | 66 | }
|
---|
| 67 | }
|
---|
[889] | 68 |
|
---|
[923] | 69 | if (isset ( $this->xml->tree->filelist->file )) {
|
---|
| 70 | if (is_array ( $this->xml->tree->filelist->file )) {
|
---|
| 71 | foreach ( $this->xml->tree->filelist->file as $key => $value ) {
|
---|
| 72 | // $fileUrl = dirname(dirname(dirname($value->_param['fileurl'])));
|
---|
| 73 | $fileUrl = "";
|
---|
| 74 | if ($value->_param ['fileurl'] != "") {
|
---|
| 75 | $fileUrl = $this->config->item ( 'api_url' ) . $value->_param ['fileurl'];
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | $thumbnail = "";
|
---|
| 79 | if ($value->_param ['thumbnail'] != "") {
|
---|
| 80 | $thumbnail = $this->config->item ( 'api_url' ) . $value->_param ['thumbnail'];
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | $aryFiles [] = array (
|
---|
| 84 | 'id' => $value->_param ['id'],
|
---|
| 85 | 'name' => $value->_value,
|
---|
| 86 | 'parentID' => $value->_param ['parentid'] == - 1 ? 0 : $value->_param ['parentid'],
|
---|
| 87 | 'minetype' => $value->_param ['filetype'],
|
---|
| 88 | 'size' => $value->_param ['size'],
|
---|
| 89 | 'thumbnail' => $thumbnail,
|
---|
| 90 | 'fileurl' => $fileUrl
|
---|
| 91 | );
|
---|
[780] | 92 | }
|
---|
[923] | 93 | } else {
|
---|
[780] | 94 | $file = $this->xml->tree->filelist->file;
|
---|
[923] | 95 | $aryFiles [] = array (
|
---|
| 96 | 'id' => $file->_param ['id'],
|
---|
| 97 | 'name' => $file->_value,
|
---|
| 98 | 'parentID' => $file->_param ['parentid'] == - 1 ? 0 : $file->_param ['parentid'],
|
---|
| 99 | 'minetype' => $file->_param ['filetype'],
|
---|
| 100 | 'size' => $file->_param ['size'],
|
---|
| 101 | 'thumbnail' => $value->_param ['thumbnail'],
|
---|
| 102 | 'fileurl' => $value->_param ['fileurl']
|
---|
| 103 | );
|
---|
[780] | 104 | }
|
---|
| 105 | }
|
---|
[923] | 106 |
|
---|
[782] | 107 | $user = $this->session->userdata ( 'userInfo' );
|
---|
[923] | 108 | $aryData = array (
|
---|
| 109 | 'DIRECTORIES' => $aryDirs,
|
---|
| 110 | 'FILES' => $aryFiles,
|
---|
| 111 | 'ERROR' => $aryError,
|
---|
| 112 | 'userinfo' => $user
|
---|
| 113 | );
|
---|
| 114 | echo json_encode ( $aryData );
|
---|
[780] | 115 | }
|
---|
| 116 |
|
---|
[923] | 117 | public function createDir() {
|
---|
| 118 | $parentDir = $this->input->post ( 'fparentid', TRUE );
|
---|
| 119 | $name = $this->input->post ( 'fname', TRUE );
|
---|
[889] | 120 |
|
---|
[923] | 121 | $xmlData = $this->vservices->actionExecute ( 'mkdir', array (
|
---|
| 122 | 'name' => $name,
|
---|
| 123 | 'parent_id' => $parentDir == 0 ? - 1 : $parentDir
|
---|
| 124 | ) );
|
---|
[889] | 125 |
|
---|
[923] | 126 | $this->xml->parse ( $xmlData );
|
---|
[889] | 127 |
|
---|
[923] | 128 | $aryError = array (
|
---|
| 129 | 'err' => $this->xml->status->_param ['err'],
|
---|
| 130 | 'errCode' => ( int ) $this->xml->status->_param ['errCode']
|
---|
| 131 | );
|
---|
| 132 | $aryData = array (
|
---|
| 133 | 'id' => $this->xml->status->_param ['id'],
|
---|
| 134 | 'name' => $this->xml->status->_param ['name'],
|
---|
| 135 | 'parentID' => $parentDir,
|
---|
| 136 | 'ERROR' => $aryError
|
---|
| 137 | );
|
---|
| 138 | echo json_encode ( $aryData );
|
---|
[780] | 139 | }
|
---|
[889] | 140 |
|
---|
[923] | 141 | public function delete() {
|
---|
| 142 | $delobj = $this->input->post ( 'delobj', TRUE );
|
---|
| 143 | $xmlData = $this->vservices->actionExecute ( 'deletemulti', array (
|
---|
| 144 | 'delobj' => $delobj
|
---|
| 145 | ) );
|
---|
| 146 | $this->xml->parse ( $xmlData );
|
---|
| 147 | $aryFolders = array ();
|
---|
[782] | 148 |
|
---|
[923] | 149 | if (isset ( $this->xml->tree->folder )) {
|
---|
| 150 | if (is_array ( $this->xml->tree->folder )) {
|
---|
| 151 | foreach ( $this->xml->tree->folder as $key => $folder ) {
|
---|
| 152 | $aryFolders ['DIRECTORIES'] [] = $folder->_param ['id'];
|
---|
[780] | 153 | }
|
---|
[923] | 154 | } else {
|
---|
| 155 | $aryFolders ['DIRECTORIES'] [] = $this->xml->tree->folder->_param ['id'];
|
---|
[780] | 156 | }
|
---|
| 157 | }
|
---|
[889] | 158 |
|
---|
[923] | 159 | if (isset ( $this->xml->tree->file )) {
|
---|
| 160 | if (is_array ( $this->xml->tree->file )) {
|
---|
| 161 | foreach ( $this->xml->tree->file as $key => $file ) {
|
---|
| 162 | $aryFolders ['FILES'] [] = $file->_param ['id'];
|
---|
[780] | 163 | }
|
---|
[923] | 164 | } else {
|
---|
| 165 | $aryFolders ['FILES'] [] = $this->xml->tree->file->_param ['id'];
|
---|
[780] | 166 | }
|
---|
| 167 | }
|
---|
[889] | 168 |
|
---|
[923] | 169 | $aryError = array (
|
---|
| 170 | 'err' => $this->xml->tree->_param ['err'],
|
---|
| 171 | 'errCode' => ( int ) $this->xml->tree->_param ['errCode']
|
---|
| 172 | );
|
---|
| 173 | $aryData = array (
|
---|
| 174 | 'DIRECTORIES' => isset ( $aryFolders ['DIRECTORIES'] ) ? $aryFolders ['DIRECTORIES'] : array (),
|
---|
| 175 | 'FILES' => isset ( $aryFolders ['FILES'] ) ? $aryFolders ['FILES'] : array (),
|
---|
| 176 | 'ERROR' => $aryError
|
---|
| 177 | );
|
---|
| 178 | echo json_encode ( $aryData );
|
---|
[780] | 179 | }
|
---|
[889] | 180 |
|
---|
[780] | 181 | public function rename() {
|
---|
[923] | 182 | $item = $this->input->post ( 'data', TRUE );
|
---|
| 183 | $objItem = json_decode($item);
|
---|
[933] | 184 |
|
---|
[923] | 185 | $xmlData = $this->vservices->actionExecute ('rename', array ('id' => $objItem->id, 'name' => $objItem->name, 'type' => $objItem->type, 'parentid' => $objItem->parentID == 0 ? -1:$objItem->parentID, 'newName' => $objItem->newName));
|
---|
[933] | 186 | $this->xml->parse ( $xmlData );
|
---|
| 187 | $err = $this->xml->tree->_param ['err'];
|
---|
| 188 | $errCode = ( int ) $this->xml->tree->_param ['errCode'];
|
---|
| 189 | $aryItem = array('id' => (int) $this->xml->tree->item->_param['id'],'name' => $this->xml->tree->item->_param['name'],'parentID' => $this->xml->tree->item->_param['parentId'] == -1 ? 0 : $this->xml->tree->item->_param['parentId']);
|
---|
[889] | 190 |
|
---|
[933] | 191 | $aryData ['DIRECTORIES'] = $objItem->type == 'directory' ? $aryItem :array();
|
---|
| 192 | $aryData ['FILES'] = $objItem->type == 'file' ? $aryItem :array();
|
---|
| 193 | $aryData ['ERROR'] = array ('err' => $err, 'errCode' => $errCode);
|
---|
[923] | 194 |
|
---|
[933] | 195 | echo json_encode ( $aryData );
|
---|
[780] | 196 | }
|
---|
| 197 |
|
---|
[923] | 198 | public function copy() {
|
---|
| 199 | $destination = $this->input->post ( 'destination', TRUE );
|
---|
| 200 | $data = $this->input->post ( 'data', TRUE );
|
---|
| 201 | $act = $this->input->post ( 'act', TRUE );
|
---|
[889] | 202 |
|
---|
[923] | 203 | $xmlData = $this->vservices->actionExecute ( 'copy', array (
|
---|
| 204 | 'act' => $act,
|
---|
| 205 | 'data' => $data,
|
---|
| 206 | 'destination' => $destination == 0 ? - 1 : $destination
|
---|
| 207 | ) );
|
---|
[889] | 208 |
|
---|
[923] | 209 | error_log ( date ( 'YmdHis' ) . ' - $xmlData: ' . var_export ( $xmlData, TRUE ), 3, '/srv/www/sbg/log/file.log' );
|
---|
[889] | 210 |
|
---|
[923] | 211 | $this->xml->parse ( $xmlData );
|
---|
[889] | 212 |
|
---|
[923] | 213 | $aryNewDirs = isset ( $this->xml->data->folderdata ) ? json_decode ( $this->xml->data->folderdata->_value ) : array ();
|
---|
| 214 | $aryNewFiles = isset ( $this->xml->data->filedata ) ? json_decode ( $this->xml->data->filedata->_value ) : array ();
|
---|
[889] | 215 |
|
---|
[923] | 216 | $aryData = array (
|
---|
| 217 | 'DIRECTORIES' => $aryNewDirs,
|
---|
| 218 | 'FILES' => $aryNewFiles
|
---|
| 219 | );
|
---|
| 220 | $aryData ['ERROR'] = array (
|
---|
| 221 | 'err' => $this->xml->data->_param ['err'],
|
---|
| 222 | 'errCode' => ( int ) $this->xml->data->_param ['errCode']
|
---|
| 223 | );
|
---|
| 224 | echo json_encode ( $aryData );
|
---|
[780] | 225 | }
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | /* End of file privatecontent.php */
|
---|
| 229 | /* Location: ./application/modules/ajax/controllers/privatecontent.php */ |
---|