define('DS', DIRECTORY_SEPARATOR); if (isset($_GET['type'])) { $type = $_GET['type']; } else { $type = ''; } require_once ROOT . DS . 'includes' . DS . 'functions.php'; $dg = new dg(); $lang = $dg->lang(); switch ($type) { case 'upload': require_once ROOT . DS . 'includes' . DS . 'upload.php'; $data = array(); $data['status'] = 0; if (!empty($_FILES['myfile'])) { $root = $dg->folder(); $uploader = new Uploader(); $uploader->setDir(ROOT . DS . $root); $uploader->setExtensions(array('jpg', 'jpeg', 'png', 'gif')); $uploader->setMaxSize(10); $uploader->sameName(false); if ($uploader->uploadFile('myfile')) { $data['status'] = 1; $image = $uploader->getUploadName(); $data['src'] = $root . '/' . $image; $data['src'] = str_replace(DS, '/', $data['src']); $data['item'] = array('title' => $image, 'url' => $data['src'], 'file_name' => $image, 'thumb' => $data['src'], 'file_type' => 'image'); } else { $data['status'] = 0; $data['msg'] = $uploader->getMessage(); //get upload error message