17 require_once SQ_CORE_PACKAGE_PATH.
'/files/file/file.inc';
39 parent::__construct($assetid);
54 public function create(Array &$link, $info=Array())
56 $this->_tmp[
'file_create_data'] =& $info;
60 $info = get_file_upload_info($this->
getPrefix());
63 if ($info === FALSE || empty($info)) {
66 $info = $edit->getChosenFileInfo($this->
getPrefix());
70 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
73 if ($info === FALSE || empty($info)) {
75 $file_title = trim($this->
attr(
'title'));
76 $file_title = preg_replace(
'/\s/',
'_', $file_title);
77 $file_title = preg_replace(
'/[^A-Za-z0-9_\-]/',
'', $file_title);
80 $file_name = $file_title .
'.' . $extension;
82 $create_location = SQ_SYSTEM_ROOT.
'/'.
'data/temp';
84 if (!fopen($create_location.
'/'.$file_name,
'w+')) {
85 trigger_localised_error(
'SYS0025', E_USER_WARNING, $file_name.
" from given title ".$file_title);
93 $info[
'name'] = $file_name;
94 $info[
'tmp_name'] = $create_location;
95 $info[
'created_file'] = TRUE;
100 if (!isset($info[
'path'])) {
101 $info[
'path'] = array_get_index($info,
'tmp_name',
'');
103 if (!isset($info[
'filename'])) {
104 $info[
'filename'] = array_get_index($info,
'name',
'');
107 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
108 if (!$this->
validFile($info))
return FALSE;
111 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
113 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
114 $valid_names = make_valid_web_paths(Array($info[
'name']));
115 $name = array_shift($valid_names);
118 $bad_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($link[
'asset'], Array($name));
119 if (!empty($bad_paths)) {
120 trigger_localised_error(
'CORE0086', E_USER_WARNING, $name);
127 return parent::create($link, $info);
140 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
141 $parse_file = $this->data_path.
'/'.$this->name;
142 $content = file_to_string($parse_file);
144 return trim($content);