public function localupload()
{
$upload = new UploadFile();
$upload->allowExts = array("pem");
$upload->uploadReplace = 1;
$firstLetter = substr($this->token, 0, 1);
$upload->savePath = "./uploads/" . $firstLetter . "/" . $this->token . "/";
if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/uploads") || !is_dir($_SERVER["DOCUMENT_ROOT"] . "/uploads")) {
mkdir($_SERVER["DOCUMENT_ROOT"] . "/uploads", 511);
}
$firstLetterDir = $_SERVER["DOCUMENT_ROOT"] . "/uploads/" . $firstLetter;
if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
mkdir($firstLetterDir, 511);
}
if (!file_exists($firstLetterDir . "/" . $this->token) || !is_dir($firstLetterDir . "/" . $this->token)) {
mkdir($firstLetterDir . "/" . $this->token, 511);
}
if (!file_exists($upload->savePath) || !is_dir($upload->savePath)) {
mkdir($upload->savePath, 511);
}
if (!$upload->upload()) {
$error = 1;
$msg = $upload->getErrorMsg();
$this->error($msg);
exit;
} else {
$error = 0;
$info = $upload->getUploadFileInfo();
$this->siteUrl = $this->siteUrl ? $this->siteUrl : C("site_url");
$msg = $this->siteUrl . substr($upload->savePath, 1) . $info[0]["savename"];
$this->addCert($info[0]["key"], $msg);
}
}