17 require_once SQ_CORE_PACKAGE_PATH.
'/files/file/file.inc';
36 public $allowed_extensions = Array(
'js');
47 parent::__construct($assetid);
62 public function create(Array &$link, $info=Array())
64 $this->_tmp[
'file_create_data'] =& $info;
68 $info = get_file_upload_info($this->
getPrefix());
71 if ($info === FALSE || empty($info)) {
74 $info = $edit->getChosenFileInfo($this->
getPrefix());
78 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
81 if ($info === FALSE || empty($info)) {
83 $file_title = trim($this->
attr(
'title'));
84 $file_title = preg_replace(
'/\s/',
'_', $file_title);
85 $file_title = preg_replace(
'/[^A-Za-z0-9_\-]/',
'', $file_title);
88 $extension = $this->allowed_extensions[0];
90 $file_name = $file_title .
'.' . $extension;
92 $create_location = SQ_SYSTEM_ROOT.
'/'.
'data/temp';
94 if (!fopen($create_location.
'/'.$file_name,
'w+')) {
95 trigger_localised_error(
'SYS0025', E_USER_WARNING, $file_name.
" from given title ".$file_title);
103 $info[
'name'] = $file_name;
104 $info[
'tmp_name'] = $create_location;
105 $info[
'created_file'] = TRUE;
110 if (!isset($info[
'path'])) {
111 $info[
'path'] = array_get_index($info,
'tmp_name',
'');
113 if (!isset($info[
'filename'])) {
114 $info[
'filename'] = array_get_index($info,
'name',
'');
117 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
118 if (!$this->
validFile($info))
return FALSE;
121 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_DATA_VALIDATION)) {
123 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
124 $valid_names = make_valid_web_paths(Array($info[
'name']));
125 $name = array_shift($valid_names);
128 $bad_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($link[
'asset'], Array($name));
129 if (!empty($bad_paths)) {
130 trigger_localised_error(
'CORE0086', E_USER_WARNING, $name);
137 return parent::create($link, $info);