/** * Tests that \Core\str_to_url is functioning properly. */ public function testStrToURL() { // spaces and intl characters get translated. $this->assertEquals('thors-hammer', \Core\str_to_url('Þors hammer')); // and dots $this->assertEquals('awesome-hot-imagejpg', \Core\str_to_url('AWESOME höt Image!!!!!!!.JPG')); // Unless the second parameter is set to true. $this->assertEquals('awesome-hot-image.jpg', \Core\str_to_url('AWESOME höt Image!!!!!!!.JPG', true)); }
/** * Get the directory to upload images to, excluding the public/private component. * * @return mixed */ public function getUploadDirectory() { // Determine the directory to upload to. This is just a nit-picky backend thing. // This will keep the files organized into their own individual directories (for each album) $dir = $this->getLink('Page')->get('title'); // Trim off any invalid characters $dir = \Core\str_to_url($dir); // And the directory character. $dir = str_replace('/', '', $dir); return $dir . '/'; }
public function getTH(){ $out = ''; $atts = []; if($this->sortkey){ $atts['data-sortkey'] = $this->sortkey; $atts['title'] = 'Sort By ' . str_replace('"', '"', $this->title); } $atts['class'] = $this->getClass(); $atts['data-viewkey'] = 'column-name-' . \Core\str_to_url($this->title); $atts['data-viewtitle'] = $this->title; $out .= '<th'; foreach($atts as $k => $v){ $out .= ' ' . $k . '="' . $v . '"'; } $out .= '>' . $this->title . '</th>'; return $out; }
/** * Lookup query * * @param string $query IP or hostname to lookup * @param bool $is_utf Require UTF-8 * * @return WhoisResult */ public static function Lookup($query = '', $is_utf = true) { // See if this query has been cached by Core <3 $cachekey = \Core\str_to_url('whois-' . $query); $cached = \Core\Cache::Get($cachekey); if ($cached) { $result = $cached; } else { $whois = new phpwhois\Whois(); $result = $whois->lookup($query, $is_utf); // Cache the results for 6 hours \Core\Cache::Set($cachekey, $result, 3600 * 6); } if (!is_array($result)) { return new WhoisNotFoundResult($query); } if (!sizeof($result)) { return new WhoisNotFoundResult($query); } return new WhoisResult($result, $query); }
public function getRewriteURL() { $link = $this->getLink('GalleryAlbum')->get('rewriteurl') . '/'; $link .= $this->get('id'); if ($this->get('title')) { $link .= '-' . \Core\str_to_url($this->get('title')); } return $link; }
$meta = new PageMetaModel($page['site'], $page['baseurl'], 'author', $machinevalue); $meta->set('meta_value_title', $value); $meta->save(); } elseif($tag == 'authorid'){ // This field is ignored, it's handled in the author case. continue; } elseif($tag == 'keywords'){ // This field is actually an array of entries, separated by a comma. $values = array_map('trim', explode(',', $value)); foreach($values as $tag){ if(!$tag) continue; $machinevalue = \Core\str_to_url($tag); $meta = new PageMetaModel($page['site'], $page['baseurl'], 'keyword', $machinevalue); $meta->set('meta_value_title', $tag); $meta->save(); } } else{ // Everything else... if(!$value) continue; $meta = new PageMetaModel($page['site'], $page['baseurl'], strtolower($tag), ''); // These don't have values set, just the value title, (which is the human readable version). $meta->set('meta_value_title', $value); $meta->save(); } }
/** * Send a CSV header and setup all necessary options to the View object to provide a download. * * All the data headers will be rendered automatically, (with the exception of the final 'controls' column). * * @param \View $view Page view to manipulate * @param string $title Title of the file, (will get converted to a valid URL) */ public function sendCSVHeader(\View $view, $title = 'csv export'){ $filename = \Core\str_to_url($title) . '-' . date('Y-m-d') . '.csv'; $view->mode = \View::MODE_NOOUTPUT; $view->contenttype = 'text/csv'; $view->addHeader('Content-Disposition', 'attachment; filename=' . $filename); // Set the limits and everything as necessary. $this->setLimit(99999); if(!$this->_applied){ $this->getFilters()->applyToFactory($this->getModelFactory()); $this->_results = $this->getModelFactory()->get(); $this->_applied = true; } // Build the CSV header to send, (the first record). $header = []; foreach($this->_columns as $c){ /** @var Column $c */ $header[] = $c->title; } // Send the headers and start the output. $view->render(); $this->sendCSVRecord($header); }
/** * Generate an ID from the text contents * * @param $text string * * @return string */ public function generateHeaderID($text){ ++$this->_headerCount; $id = 'md' . $this->_headerCount . '_' . \Core\str_to_url($text); return $id; }
/** * Execute the Core str_to_url function and return the result. * * Type: modifier<br> * Name: to_url<br> * * @param string $string input string * @return string URLified string */ function smarty_modifier_to_url($string) { return \Core\str_to_url($string); }
public function setMeta($key, $value){ $metas = $this->getMetas(); // keywords behave slightly differently here. if($key == 'keywords' || $key == 'keywords[]'){ if(!is_array($value)) $value = array($value => $value); // I need to make sure that each value is a key/value pair. foreach($value as $valueidx => $valueval){ if(trim($valueval) == ''){ // Empty value, empty value! unset($value[$valueidx]); } elseif(is_numeric($valueidx)){ // This will replace any numeric based key with the url version of the value. // This may have an odd side effect of transposing numeric values like 2013, // but since the url version of a number is just the number itself, it should be ok. unset($value[$valueidx]); $value[ \Core\str_to_url($valueval) ] = $valueval; } // No else needed, it's acceptable as-is. } foreach($metas as $idx => $meta){ /** @var $meta \FileMetaModel */ // I'm only interested in these! if($meta->get('meta_key') != 'keyword') continue; if(isset($value[ $meta->get('meta_value') ])){ // Yay, update the value title $meta->set('meta_value_title', $value[ $meta->get('meta_value') ]); $meta->save(); unset($value[ $meta->get('meta_value') ]); } else{ // Nope? Delete it! $meta->delete(); unset($this->_metas[$idx]); } } // Any new incoming keywords left? foreach($value as $metavalue => $metavaluetitle){ $meta = new \FileMetaModel($this->_filename, 'keyword', $metavalue); $meta->set('meta_value_title', $metavaluetitle); $meta->save(); $this->_metas[] = $meta; } } elseif($key == 'license'){ // Match this up to the value if it's available. $all = \Core\Licenses\Factory::GetLicenses(); if(isset($all[$value])){ $valuetitle = $all[$value]['title']; } else{ $valuetitle = $value; } foreach($metas as $idx => $meta){ /** @var $meta \FileMetaModel */ // I'm only interested in this one! if($meta->get('meta_key') != $key) continue; // It must be the one I'm looking for. $meta->set('meta_value', $value); $meta->set('meta_value_title', $valuetitle); $meta->save(); return; // :) } // Doesn't exist? $meta = new \FileMetaModel($this->_filename, $key, $value); $meta->set('meta_value_title', $valuetitle); $meta->save(); $this->_metas[] = $meta; } elseif($key == 'authorid'){ // This affects the author tag instead, look for that! foreach($metas as $idx => $meta){ /** @var $meta \FileMetaModel */ // I'm only interested in this one! if($meta->get('meta_key') != 'author') continue; // It must be the one I'm looking for. $meta->set('meta_value', $value); $meta->save(); return; // :) } // Doesn't exist? $meta = new \FileMetaModel($this->_filename, 'author', $value); $meta->save(); $this->_metas[] = $meta; } elseif($key == 'file'){ // Skip this one! } // Default action, one to one! else{ // Look for this key to see if it exists. foreach($metas as $idx => $meta){ /** @var $meta \FileMetaModel */ // I'm only interested in this one! if($meta->get('meta_key') != $key) continue; // It must be the one I'm looking for. if($value){ // Does it have a value? $meta->set('meta_value_title', $value); $meta->save(); } else{ // It's blank but exists... I can fix that :p $meta->delete(); unset($this->_metas[$idx]); } return; // :) } // Doesn't exist? if($value){ $meta = new \FileMetaModel($this->_filename, $key, ''); $meta->set('meta_value_title', $value); $meta->save(); $this->_metas[] = $meta; } } }
* Created by JetBrains PhpStorm. * User: powellc * Date: 1/17/13 * Time: 10:20 PM * This is the upgrade file from 1.2.1 to 1.3.0. * * The blog system in 1.3.0 and later utilizes a dedicated Page entry for each blog entry. This helps to have more * fine grain control over each entry's settings and data, as well as making use of the insertable system. */ // Create a page for each BlogArticle! // Since this runs prior to the blog system being enabled, I need to manually include the model files. require_once ROOT_PDIR . 'components/blog/models/BlogArticleModel.php'; require_once ROOT_PDIR . 'components/blog/models/BlogModel.php'; $articles = BlogArticleModel::Find(); foreach ($articles as $article) { /** @var $article BlogArticleModel */ /** @var $blog BlogModel */ $blog = $article->getLink('Blog'); /** @var $page PageModel */ $page = $article->getLink('Page'); $page->setFromArray(array('title' => $article->get('title'), 'rewriteurl' => $blog->get('rewriteurl') . '/' . $article->get('id') . '-' . \Core\str_to_url($article->get('title')), 'parenturl' => $blog->get('baseurl'), 'fuzzy' => 0, 'admin' => 0)); if ($article->get('authorid')) { $user = UserModel::Construct($article->get('authorid')); $page->setMeta('author', $user->getDisplayName()); $page->setMeta('authorid', $user->get('id')); } $page->setMeta('description', $article->get('description')); $page->setMeta('keywords', $article->get('keywords')); $page->save(); } // return
/** * @param mixed $value * * @return bool */ public function setValue($value) { if ($this->get('required') && !$value) { $this->_error = $this->get('label') . ' is required.'; return false; } // _link_ allows users to paste in a URL for a given file. This is then copied locally as normal. // In order to detect this, I need to look for the presence of a protocol indicator and this element needs // to have allowlink set. if($this->get('allowlink') && strpos($value, '_link_://') === 0){ $n = $this->get('name'); $value = substr($value, 9); // Source $f = new \Core\Filestore\Backends\FileRemote($value); if(!$f->exists()){ $this->_error = 'Remote file does not seem to exist'; return false; } // Destination $nf = \Core\Filestore\Factory::File($this->get('basedir') . '/' . $f->getBaseFilename()); // do NOT copy the contents over until the accept check has been ran! // Now that I have a file object, (in the temp filesystem still), I should validate the filetype // to see if the developer wanted a strict "accept" type to be requested. // If present, I'll have something to run through and see if the file matches. // I need the destination now because I need to full filename if an extension is requested in the accept. if($this->get('accept')){ $acceptcheck = \Core\check_file_mimetype($this->get('accept'), $f->getMimetype(), $nf->getExtension()); // Now that all the mimetypes have run through, I can see if one matched. if($acceptcheck != ''){ $this->_error = $acceptcheck; return false; } } // Now all the checks should be completed and I can safely copy the file away from the temporary filesystem. $f->copyTo($nf); $value = $nf->getFilename(false); } elseif(($this->get('browsable') || $this->get('browseable')) && strpos($value, '_browse_://public') === 0){ $n = $this->get('name'); $value = substr($value, 11); // Source $f = \Core\Filestore\Factory::File($value); if(!$f->exists()){ $this->_error = 'File does not seem to exist'; return false; } // Now that I have a file object, I still need to validate that this file was what the user was supposed to select. // If present, I'll have something to run through and see if the file matches. if($this->get('accept')){ $acceptcheck = \Core\check_file_mimetype($this->get('accept'), $f->getMimetype(), $f->getExtension()); // Now that all the mimetypes have run through, I can see if one matched. if($acceptcheck != ''){ $this->_error = $acceptcheck; return false; } } } elseif ($value == '_upload_') { $n = $this->get('name'); // Because PHP will have different sources depending if the name has [] in it... if (strpos($n, '][') !== false) { // This is a 2+ nested array value. preg_match_all('#\[([^\]]*)\]#', $n, $matches); $p1 = substr($n, 0, strpos($n, '[')); $src =& $_FILES[$p1]; $in = array( 'name' => $src['name'], 'type' => $src['type'], 'tmp_name' => $src['tmp_name'], 'error' => $src['error'], 'size' => $src['size'], ); foreach($matches[1] as $next){ $in['name'] =& $in['name'][$next]; $in['type'] =& $in['type'][$next]; $in['tmp_name'] =& $in['tmp_name'][$next]; $in['error'] =& $in['error'][$next]; $in['size'] =& $in['size'][$next]; } } elseif (strpos($n, '[') !== false) { // This is a single array value. $p1 = substr($n, 0, strpos($n, '[')); $p2 = substr($n, strpos($n, '[') + 1, -1); if (!isset($_FILES[$p1])) { $this->_error = 'No file uploaded for ' . $this->get('label'); return false; } $in = array( 'name' => $_FILES[$p1]['name'][$p2], 'type' => $_FILES[$p1]['type'][$p2], 'tmp_name' => $_FILES[$p1]['tmp_name'][$p2], 'error' => $_FILES[$p1]['error'][$p2], 'size' => $_FILES[$p1]['size'][$p2], ); } else { $in =& $_FILES[$n]; } if (!isset($in)) { $this->_error = 'No file uploaded for ' . $this->get('label'); return false; } else { $error = \Core\translate_upload_error($in['error']); if($error != ''){ $this->_error = $error; return false; } // Source $f = \Core\Filestore\Factory::File($in['tmp_name']); // Destination // Make sure the filename is sanitized. // Also, limit the new filename to 40 characters. $newbasename = substr(\Core\str_to_url($in['name'], true), 0, 40); $nf = \Core\Filestore\Factory::File($this->get('basedir') . '/' . $newbasename); // do NOT copy the contents over until the accept check has been ran! // Now that I have a file object, (in the temp filesystem still), I should validate the filetype // to see if the developer wanted a strict "accept" type to be requested. // If present, I'll have something to run through and see if the file matches. // I need the destination now because I need to full filename if an extension is requested in the accept. if($this->get('accept')){ $acceptcheck = \Core\check_file_mimetype($this->get('accept'), $f->getMimetype(), $nf->getExtension()); // Now that all the mimetypes have run through, I can see if one matched. if($acceptcheck != ''){ $this->_error = $acceptcheck; return false; } } // Now all the checks should be completed and I can safely copy the file away from the temporary filesystem. $f->copyTo($nf); $value = $nf->getFilename(false); } } $this->_attributes['value'] = $value; return true; }
/** * Get the ID for this element, will either return the user-set ID, or an automatically generated one. * * @return string */ public function getID(){ // If the ID is already set, return that. if (!empty($this->_attributes['id'])){ return $this->_attributes['id']; } // I need to generate a javascript and UA friendly version from the name. else{ // Names such as config[/blah/foo] are valid, but throw IDs for a loop when config-/blah/foo is rendered! $n = str_replace(['/', '[', ']'], '-', $this->get('name')); // Convert the rest of the characters to valid URl characters. $n = \Core\str_to_url($n); $c = strtolower(get_class($this)); // Prepend the form type to the name. $id = $c . '-' . $n; // Remove empty parantheses, (there shouldn't be any) $id = str_replace('[]', '', $id); // And replace brackets with dashes appropriatetly $id = preg_replace('/\[([^\]]*)\]/', '-$1', $id); return $id; } }
/** * Test the creation of a blog article based off the newly created blog * * @depends testCreateBlog */ public function testCreateBlogArticle() { // Update the current user so it has admin access. \Core\user()->set('admin', true); // Setup some variables that will be used throughout this method. $title = 'New Test Blog Article'; $randomsnippet = 'Random-Snippet-' . Core::RandomHex(10); $lorem = new BaconIpsumGenerator(); $body = $lorem->getParagraph(1); // Tack on the random snipped I'll be looking for. $body .= $lorem->getParagraphsAsMarkup(8, $randomsnippet); $blog = new BlogModel(self::$TestBlogID); $request = new PageRequest('/blog/article/create/' . self::$TestBlogID); $request->execute(); $view = $request->getView(); $this->assertEquals(200, $view->error, 'Checking that article creation returns a valid page'); // The returned data should have a "form" available. This is the actual creation form. /** @var $form Form */ $form = $view->getVariable('form'); $this->assertInstanceOf('Form', $form, 'Checking that the form is set from the blog article create controller'); // Set some variables on the form $form->getElement('page[title]')->set('value', $title); $form->getElement('page[rewriteurl]')->set('value', $blog->get('rewriteurl') . '/' . \Core\str_to_url($title)); $form->getElement('model[image]')->set('value', 'public/blog/blog-test-image.png'); $form->getElement('model[body]')->set('value', $body); // Copy in the image $src = \Core\Filestore\Factory::File(ROOT_PDIR . 'components/blog/tests/blog-test-image.png'); /** @var $dest \Core\Filestore\File */ $dest = \Core\Filestore\Factory::File('public/blog/blog-test-image.png'); $src->copyTo($dest, true); // make sure that it exists $this->assertTrue($dest->exists(), 'Checking that files can be copied into the public filestore'); // And submit this form to the handler. // On a successful submission, it should be simply the URL of the blog. $formsubmission = call_user_func_array($form->get('callsmethod'), array($form)); if ($formsubmission === false) { throw new Exception(implode("\n", $form->getErrors())); } // Go to the parent listing page and find this entry. $request = new PageRequest($blog->get('rewriteurl')); $request->execute(); $view = $request->getView(); $this->assertEquals(200, $view->error); $html = $view->fetch(); $this->assertContains($title, $html); $this->assertContains('itemtype="http://schema.org/BlogPosting"', $html); preg_match_all('#<div[^>]*itemtype="http://schema.org/BlogPosting"[^>]*>.*<a[^>]*href="(.*)"[^>]*>(.*)</a>#msU', $html, $matches); // Title should now have three keys, with at least one value each. $this->assertNotEmpty($matches[1]); $this->assertNotEmpty($matches[2]); // This node contains the URL. $foundurl = $matches[1][0]; $foundtitle = trim($matches[2][0]); // Make sure the url contains the site url. $this->assertStringStartsWith(ROOT_URL, $foundurl); // And trim it off. This is because PageRequest expects that the url is already trimmed. $foundurl = '/' . substr($foundurl, strlen(ROOT_URL)); $this->assertEquals($title, $foundtitle); //$this->assertStringStartsWith('/blog/article/view/', $formsubmission, 'Checking that blog article creation was successful'); // Go to the page and make sure that it loads up! $request = new PageRequest($foundurl); $request->execute(); $view = $request->getView(); $this->assertEquals(200, $view->error, 'Checking that public blog article exists'); $html = $view->fetch(); $this->assertContains($title, $html, 'Checking that the public blog article page contains the correct title'); $this->assertContains($randomsnippet, $html, 'Checking that the public blog article page contains the correct body'); $this->assertContains('blog-test-image', $html, 'Checking that the public blog article page contains the correct image'); }
public function view() { $view = $this->getView(); $m = NavigationModel::Construct($this->getParameter(0)); $current = PageRequest::GetSystemRequest(); $currenturl = $current->getBaseURL(); // Used to indicate the "active" link. if (!$m->exists()) { return View::ERROR_NOTFOUND; } // Get the entries for this model as well. $entries = $m->getLink('NavigationEntry', 'weight ASC'); // View won't quite just have a flat list of entries, as they need to be checked and sorted // into a nested array. $sortedentries = []; // First level children foreach ($entries as $k => $e) { if (!$e->get('parentid')) { $classes = []; $classes[] = Core\str_to_url($e->get('title')) . '-link'; if ($e->get('baseurl') == $currenturl) { $classes[] = 'active'; } if (\Core\user()->checkAccess($e->getAccessString())) { // There's a weird bug where sometimes the access cache is empty. // In that case, just allow the user to view the page. $sortedentries[] = ['obj' => $e, 'children' => [], 'classes' => $classes]; } unset($entries[$k]); } } // One level deep if (sizeof($entries)) { foreach ($sortedentries as $sk => $se) { foreach ($entries as $k => $e) { if ($e->get('parentid') == $se['obj']->get('id')) { if (\Core\user()->checkAccess($e->getAccessString())) { // There's a weird bug where sometimes the access cache is empty. // In that case, just allow the user to view the page. $classes = []; $classes[] = Core\str_to_url($e->get('title')) . '-link'; if ($e->get('baseurl') == $currenturl) { $classes[] = 'active'; // also set active class on the parent so frontenders don't rage :) $sortedentries[$sk]['classes'][] = 'active'; } // Add the "more" class to the parent. $sortedentries[$sk]['classes'][] = 'more'; $sortedentries[$sk]['children'][] = ['obj' => $e, 'children' => [], 'classes' => $classes]; } unset($entries[$k]); } } } } // Two levels deep // this would be so much simpler if the menu was in DOM format... :/ if (sizeof($entries)) { foreach ($sortedentries as $sk => $se) { foreach ($se['children'] as $subsk => $subse) { foreach ($entries as $k => $e) { if ($e->get('parentid') == $subse['obj']->get('id')) { if (\Core\user()->checkAccess($e->getAccessString())) { $classes = []; $classes[] = Core\str_to_url($e->get('title')) . '-link'; if ($e->get('baseurl') == $currenturl) { $classes[] = 'active'; // also set active class on the top-most nav parent so frontenders don't rage :) $sortedentries[$sk]['children'][$subsk]['class'][] = 'active'; } // Add the "more" class to the parent. $sortedentries[$sk]['children'][$subsk]['class'][] = 'more'; $sortedentries[$sk]['children'][$subsk]['children'][] = ['obj' => $e, 'children' => [], 'classes' => $classes]; } unset($entries[$k]); } } } } } foreach ($sortedentries as $k => $el) { $this->_transposeClass($sortedentries[$k]); } $view->title = $m->get('title'); $view->access = $m->get('access'); $view->templatename = '/widgets/navigation/view.tpl'; $view->assignVariable('model', $m); $view->assignVariable('entries', $sortedentries); /* $view->addControl('New Navigation Menu', '/Navigation/Create', 'add'); $view->addControl('Edit Page', '/Content/Edit/' . $m->get('id'), 'edit'); $view->addControl('Delete Page', '/Content/Delete/' . $m->get('id'), 'delete'); $view->addControl('All Content Pages', '/Content', 'directory'); */ }
/** * Handle the entire upload as a standard multitype POST * @return array */ private function _doPost() { $info = array(); if (sizeof($_FILES) == 1) { // $upload will be the current index of FILES, which should contain all the uploaded files, // in an associative array as typical with FILES. $upload = current($_FILES); } if ($upload && is_array($upload['tmp_name'])) { // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { // Source $f = \Core\Filestore\Factory::File($upload['tmp_name'][$index]); // Destination // Make sure the filename is sanitized. $newbasename = \Core\str_to_url(urldecode($upload['name'][$index]), true); $nf = \Core\Filestore\Factory::File($this->_formelement->get('basedir') . $newbasename); // This is the object that is returned in the json array. // It needs to contain something. $file = array('name' => '', 'size' => $f->getFilesize(), 'type' => $f->getMimetype(), 'url' => '', 'thumbnail_url' => '', 'error' => ''); // do NOT copy the contents over until the accept check has been ran! // Now that I have a file object, (in the temp filesystem still), I should validate the filetype // to see if the developer wanted a strict "accept" type to be requested. // If present, I'll have something to run through and see if the file matches. // I need the destination now because I need to full filename if an extension is requested in the accept. if ($this->_formelement->get('accept')) { $acceptcheck = \Core\check_file_mimetype($this->_formelement->get('accept'), $f->getMimetype(), $nf->getExtension()); // Now that all the mimetypes have run through, I can see if one matched. if ($acceptcheck != '') { $file['error'] = $acceptcheck; $info[] = $file; continue; // skip to the next file upload. } } // Now all the checks should be completed and I can safely copy the file away from the temporary filesystem. $f->copyTo($nf); // And now all the file's attributes will be visible. $file['name'] = $nf->getBaseFilename(); $file['url'] = $nf->getURL(); $file['thumbnail_url'] = $nf->getPreviewURL('50x50'); $info[] = $file; } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: $info[] = $this->handle_file_upload(isset($upload['tmp_name']) ? $upload['tmp_name'] : null, isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), isset($upload['error']) ? $upload['error'] : null); } return $info; }