public function sendResetPasswordMail($userEmail)
 {
     $result = $this->mailPrepare($userId);
     if ($result['status'] == "ok") {
         $userInfo = $result['user_info'];
         $this->setSubject('Quên mật khẩu đăng nhập');
         $resetLink = VC_Config::getInstance()->vcBaseurlsUser() . "/user/reset-password/?code=" . $userInfo->guid;
         $this->assign("reset_password_link", $resetLink);
         $newPassword = VC_Utils_String::generateCode(6);
         $userInfo->password_tmp = $newPassword;
         $userInfo->save();
         $this->assign('new_password', $newPassword);
         unset($result['user_info']);
         unset($userInfo);
         $this->sendMail("password_reset");
     }
     return $result;
 }
 /**
  * Singleton implementation
  * @return VC_Config
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new VC_Config();
     }
     return self::$instance;
 }
<?php

defined('ROOT_PATH') || define('ROOT_PATH', realpath(dirname(__FILE__) . '/../../..'));
defined('APP_PATH') || define('APP_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(ROOT_PATH, ROOT_PATH . '/libs', realpath(APP_PATH . '/../library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'VC/Config.php';
$config = VC_Config::load(array('common', 'urls', 'database', 'storage'));
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, $config);
$application->bootstrap();
 public function indexAction()
 {
     if ($this->userId == 0) {
         throw new VC_Exception("You have not permission");
     }
     $invidualDir = 'u_' . $this->userId;
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $uploadRootDir = ROOT_PATH . '/Sources/store/public/uploads';
     $uploadDir = $uploadRootDir . '/' . $invidualDir;
     if (!is_dir($uploadDir)) {
         mkdir($uploadDir, 0777);
         copy($uploadRootDir . "/index.html", $uploadDir . "/index.html");
     }
     $error = "";
     $msg = "";
     $config = VC_Config::getConfig();
     $maxFileSize = 0;
     $valid = false;
     if (isset($config['file']['upload']['size'])) {
         $maxFileSize = $config['file']['upload']['size'];
     } else {
         $error = "System error, please contact to administrator to resolve this problem, thank you very much";
     }
     $fileElementName = 'fileToUpload';
     $upload = new Zend_File_Transfer_Adapter_Http("http");
     $allowExt = explode(",", str_replace(" ", "", $config['file']['upload']['ext']));
     $upload->addValidator('Extension', true, $allowExt);
     $upload->addValidator('FilesSize', true, array('min' => '10B', 'max' => $maxFileSize));
     $upload->addValidator('Count', true, array('min' => 1, 'max' => 1));
     $messages = array();
     $files = $upload->getFileInfo();
     if ($upload->isValid() && $upload->isUploaded()) {
         reset($files);
         $fileInputName = key($files);
         //Get file extension
         $fileName = $files[$fileInputName]['name'];
         $ext = substr($fileName, strrpos($fileName, "."));
         $fileName = preg_replace("/[^a-z.0-9]/i", "", $_FILES[$fileInputName]['name']);
         $tempPath = $files[$fileInputName]['tmp_name'];
         $baseName = str_replace($ext, "", $fileName);
         //Name no ext
         if ("" == $fileName) {
             $fileName = time() . $ext;
         }
         if (file_exists($uploadDir . "/" . $fileName)) {
             $fileName = $baseName . "_" . time() . $ext;
         }
         if (move_uploaded_file($tempPath, $uploadDir . "/" . $fileName)) {
             $valid = true;
         } else {
             $error = "Could not upload file, please try again.";
         }
     }
     if ($valid) {
         //Save to upload_tmp in DB
         $uploadTmpTbl = new VC_DbTable_Common("upload_tmp", "id");
         $uploadTmpData = array();
         $uploadTmpData['file_name'] = $this->_getParam("file_name", $fileName);
         $uploadTmpData['user_id'] = $this->userId;
         $uploadTmpData['upload_date'] = date("Y-m-d");
         $insertTokenNamespace = new Zend_Session_Namespace("INSERT_TOKEN");
         $uploadTmpData['insert_token'] = $insertTokenNamespace->insertToken;
         $iconPath = VC_Business_File::getFileIcon($ext, '/uploads/' . $invidualDir . '/' . $fileName);
         $filePath = '/uploads/' . $invidualDir . '/' . $fileName;
         $uploadTmpData['icon_path'] = $iconPath;
         $uploadTmpData['file_path'] = $filePath;
         $uploadTmpTbl->insert($uploadTmpData);
         $result = array('error' => '', 'icon' => $iconPath, 'file' => $filePath, 'name' => $uploadTmpData['file_name']);
         echo Zend_Json_Encoder::encode($result, true);
     } else {
         $messages = $upload->getMessages();
         $result = array('error' => implode("\n", $messages) . "\n" . $error, 'file' => '');
         echo Zend_Json_Encoder::encode($result);
     }
 }