$mtype = $finfo->file($tmpname, FILEINFO_MIME_TYPE); $img = strpos($mtype, 'image/') === 0; } elseif (function_exists('getimagesize')) { $img = getimagesize($tmpname) ? TRUE : FALSE; } elseif (function_exists('exif_imagetype')) { $img = exif_imagetype($tmpname) !== FALSE; } elseif (function_exists('mime_content_type')) { $mtype = mime_content_type($tmpname); $img = strpos($mtype, 'image/') === 0; } if (!$img) { $message = $this->Lang('err_file'); } } if (empty($message)) { $fp = StripeGate\Utils::GetUploadsPath($this); if ($fp) { $fp = cms_join_path($fp, $file_data['name']); if (!chmod($file_data['tmp_name'], 0644) || !cms_move_uploaded_file($file_data['tmp_name'], $fp)) { $message = $this->Lang('err_upload'); } else { //all good $sql = 'UPDATE ' . $pref . 'module_sgt_account SET iconfile=? WHERE account_id=?'; $db->Execute($sql, array($file_data['name'], $params['account_id'])); } } else { $message = $this->Lang('err_upload'); } } if (empty($message)) { $message = FALSE;
/** Export: @mod: reference to current StripeGate module object @account_id: optional account id, or array of such id's, default FALSE @record_id: optional record_id, or array of such id's, default FALSE @sep: optional field-separator for exported content, default ',' At least one of @account_id or @record_id must be provided. Returns: TRUE on success, or lang key for error message upon failure */ public function Export(&$mod, $account_id = FALSE, $record_id = FALSE, $sep = ',') { if (!($account_id || $record_id)) { return 'err_parameter'; } $fname = self::ExportName($mod, $account_id, $record_id); if ($mod->GetPreference('export_file', FALSE)) { $updir = StripeGate\Utils::GetUploadsPath($mod); if ($updir) { $filepath = $updir . DIRECTORY_SEPARATOR . $fname; $fp = fopen($filepath, 'w'); if ($fp) { $success = self::CSV($mod, $account_id, $record_id, $fp, $sep); fclose($fp); if ($success) { $url = StripeGate\Utils::GetUploadsUrl($mod) . '/' . $fname; @ob_clean(); @ob_clean(); header('Location: ' . $url); return TRUE; } } } } else { $csv = self::CSV($mod, $account_id, $record_id, FALSE, $sep); if ($csv) { $config = cmsms()->GetConfig(); if (!empty($config['default_encoding'])) { $defchars = trim($config['default_encoding']); } else { $defchars = 'UTF-8'; } if (ini_get('mbstring.internal_encoding') !== FALSE) { //conversion is possible $expchars = $mod->GetPreference('export_file_encoding', 'ISO-8859-1'); $convert = strcasecmp($expchars, $defchars) != 0; } else { $expchars = $defchars; $convert = FALSE; } @ob_clean(); @ob_clean(); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', FALSE); header('Content-Description: File Transfer'); //note: some older HTTP/1.0 clients did not deal properly with an explicit charset parameter header('Content-Type: text/csv; charset=' . $expchars); header('Content-Length: ' . strlen($csv)); header('Content-Disposition: attachment; filename=' . $fname); if ($convert) { echo mb_convert_encoding($csv, $expchars, $defchars); } else { echo $csv; } return TRUE; } } return 'err_export'; }