function download($idUpload) { $Upload = $this->Upload->find("first", array('conditions' => array('Upload.id' => $idUpload))); $get_url = realpath('../../app/webroot/img/uploads/') . "\\" . $Upload['Upload']['name']; //$get_url=realpath("../../".$Upload['Upload']['path']."/").$Upload['Upload']['name']; if (!File_exists($get_url)) { print $get_url; print "File's not exits"; exit; } $size = Filesize($get_url); header("Content-Type: application/save"); header("Content-Length: {$size}"); header("Content-Disposition: attachment; Filename=\"" . $Upload['Upload']['name'] . "\""); header("Content-Transfer-Encoding: binary"); if ($fh = fopen("{$get_url}", "rb")) { fpassthru($fh); fclose($fh); } else { print "Permission denied: " . $get_url; exit; } $this->Upload->updateAll(array('Upload.dem' => 'Upload.dem+1'), array('Upload.id' => $idUpload)); //$sql="select dem from uploads where name='".$get_name."'"; //$query=mysql_query($sql); //$row=mysql_fetch_array($query); // $dem=$row['dem']; // echo $dem; // $sql1="update uploads set dem='".($dem+1)."' where name='".$get_name."'"; // mysql_query($sql1); $this->render('index'); }
/** * Constructor of the object. * Generates the table for ANSEL to Unicode mapping. * @param String $conversionFile The name of the mapping file made by Heiner Eichmann. * The file can be downloaded FROM this URL: * http://www.heiner-eichmann.de/gedcom/ans2uni.con.zip */ public function __construct($conversion_file = 'ans2uni.con') { $temp_ini_file = 'mappings.ini'; // Name of temporary ini file if (File_exists($conversion_file)) { // Load file contents, convert into well-formed ini file for later parsing. // This is done because the original mapping file cannot be parsed by the // PHP function parse_ini_file. $file_contents = File_get_contents($conversion_file, 'FILE_BINARY'); // Load contents $file_contents = $this->strip_comments($file_contents, '#'); // Strip comments File_put_contents($temp_ini_file, $file_contents); // Save contents // Get ini contents $map = Parse_ini_file($temp_ini_file); // Parse ini file // Go through map to split up the mappings that contain more characters in the key, // so that mappings with one character goes into $this->mapping[1], those with two // characters goes to $this->mapping[2] etc. foreach ($map as $key => $value) { $characters = explode('+', $key); // Split string where '+' occurrs $num_chars = count($characters); // count number of characters $this->_mapping[$num_chars][Strtolower($key)] = $value; // Put mapping in right place } // Delete temporary ini file efterwards if exists if (File_exists($temp_ini_file)) { Unlink($temp_ini_file); } } else { echo '<p>No mapping file with name ' . $conversion_file . ' exists. Download this file ' . 'from <a href="http://www.heiner-eichmann.de/gedcom/ans2uni.con.zip">here</a>.'; } }
/** * 密文解密 * @param $data 要解密的密文 * @param $data 商户号 */ public function decrypt($data, $merId) { $log = new Logger(); //用户租钥证书 $mer_pk = (require 'config.php'); $priv_key_file = privatekey; //如果商户号不为空,则获取商户私钥地址配置信息 if (!is_null($merId)) { if (!is_null($mer_pk[$merId])) { $priv_key_file = $mer_pk[$merId]; } } $log->logInfo("The private key path for:" . $priv_key_file); if (!File_exists($priv_key_file)) { return FALSE; die("The key is not found, please check the configuration!"); } $fp = fopen($priv_key_file, "r"); $private_key = fread($fp, 8192); fclose($fp); $private_key = openssl_get_privatekey($private_key); openssl_private_decrypt(base64_decode($data), $decrypted, $private_key); $decryptDate = iconv("GBK", "UTF-8", $decrypted); $log->logInfo("敏感信息解密后明文:[" . $decryptDate . "]"); return $decryptDate; }