Example #1
0
 /**
  * 发送注册验证短信
  * @param unknown $mobile
  */
 public function sendVirifySms($mobile)
 {
     // 验证该手机号是否已经被注册
     $where = array('mobile' => $mobile);
     $user_info = D('User')->where($where)->find();
     if ($user_info) {
         throw new RadaException('该手机号已经被注册');
     }
     $code = makeRandomString(6, 'number');
     $content = sprintf('你的注册验证码是$d', $code);
     $res = sendSms($mobile, $content);
     if (!$res) {
         throw new RadaException('发送短信失败,请重试');
     }
     // redis记录验证码
     $redis = getRedisEx('USER_CACHE');
     $data = array('mobile' => $mobile, 'code' => $code, 'ctime' => NOW_TIME);
     $redis->setex(self::USER_REGISTER_SMS_PRIFIX . $mobile, 600, json_encode($data));
     return true;
 }
Example #2
0
 $usageArray = $_POST['usage'];
 $formatArray = $_POST['format'];
 $toolsArray = $_POST['tools'];
 $resolutionArray = $_POST['resolution'];
 $sizeArray = $_POST['size'];
 $priceArray = $_POST['price'];
 $sale_priceArray = $_POST['sale_price'];
 $pointArray = $_POST['point'];
 
 for($i=0; $i < sizeof($selectNumArray); $i++)
 {
     $selectNum = intval($selectNumArray[$i]);
     
     $option_file_name = $_FILES['option_file_'.$selectNum];
     
     $optionFileArray['new_name'] = date("YmdHis").makeRandomString(4);                                        
     $optionFileArray['size'] = $option_file_name["size"];
     $optionFileArray['name'] = $option_file_name["name"];
     $optionFileArray['type'] = $option_file_name["type"];
     $optionFileArray['tmp_name'] = $option_file_name["tmp_name"];
     
     if($selectNum < 10000)
     {
         $real_name = $_POST["real_option_file_".$selectNum];
         if($optionFileArray["name"] == "" && $real_name == "")
         {
             $optionFileArray = "delete";
         }
     
         $board_control->updateOptionData($title_en, $number, $selectNum, $usageArray[$i], $formatArray[$i], $toolsArray[$i], $resolutionArray[$i], $sizeArray[$i], $priceArray[$i], $sale_priceArray[$i], $pointArray[$i], $optionFileArray);                            
     }
Example #3
0
function SaveUploadAsFile($dest, $filedata)
{
    if (!is_dir($dest) && !mkdir($dest, 0755, true)) {
        writeErrorLog('Could not create file upload directory \'' . $dest . '\'');
        return false;
    }
    // filename may or may not have an extension that must be preserved
    $pos = strrpos($filedata['name'], '.');
    $basename = $filedata['name'];
    // replace any dots left with a _ for scripts diguised as an image (e.g. exploit-db.php.jpg)
    if ($pos !== false) {
        $tmp = substr($basename, 0, $pos);
        $basename = str_replace('.', '_', $tmp) . substr($basename, $pos);
    }
    // try the org name first, only if it exists add the random string
    $uploadname = $basename;
    while (file_exists($dest . $uploadname)) {
        $rand = makeRandomString();
        if ($pos === false) {
            $uploadname = $basename . '_' . $rand;
        } else {
            $uploadname = substr($basename, 0, $pos) . '_' . $rand . substr($basename, $pos);
        }
    }
    if (empty($filedata['tmp_name'])) {
        writeErrorLog('Could not move uploaded file because the tmp_name is empty.');
        return false;
    }
    $rc = move_uploaded_file($filedata["tmp_name"], $dest . $uploadname);
    if ($rc) {
        return $uploadname;
    }
    writeErrorLog('Moving file ' . $filedata['tmp_name'] . ' to ' . $uploadname . ' failed.');
    return false;
}
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\ListContainersOptions;
use WindowsAzure\Blob\Models\ListBlobsOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
define("DEFAULT_CONTAINER", "dfltcntr");
if (isset($_FILES["s_file"])) {
    $file = $_FILES["s_file"];
} else {
    error("No file found.");
}
$block_name = $file["name"];
//if there is an account id to upload then change the container otherwise use a default
//container name and add the code to a sub folder
$container = isset($_POST["accnt_id"]) ? $_POST["accnt_id"] : DEFAULT_CONTAINER;
//generate the code for this file
$doc_code = makeRandomString();
$remove_action = isset($_POST["remove_action"]) ? $_POST["remove_action"] : "1";
$remove_access_times = isset($_POST["remove_access_times"]) ? $_POST["remove_access_times"] : "1";
$remove_hours = isset($_POST["remove_hours"]) ? $_POST["remove_hours"] : "1";
try {
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
    //createContainerIfNotExists($blobRestProxy);
    $listContainersOptions = new ListContainersOptions();
    $listContainersOptions->setPrefix($container);
    //$listContainersResult = $blobRestProxy->listContainers($listContainersOptions);
    //$containerExists = false;
    // $containers = $listContainersResult->getContainers();
    // for($i = 0; $i < $containers.length; $i++){
    // print_r($containers[$i]);
    // }
    //foreach ($listContainersResult->getContainers() as $container) {
Example #5
0
 private function sendRestore($email)
 {
     $confirm_key = md5(md5(makeRandomString()));
     $this->engine->db->query("UPDATE " . DB_PREF . "users SET `confirm` = '" . $confirm_key . "' WHERE LOWER(email) = '" . strtolower($email) . "' ");
     $message = html_entity_decode($this->params['restore_mail_' . $_SESSION['lang']]);
     $message = str_replace('{restore_link}', $this->engine->url->link('route=account&action=restore', 'confirm_key=') . $confirm_key, $message);
     $this->engine->sendMail($email, 'system@' . $_SERVER['HTTP_HOST'], $_SERVER['HTTP_HOST'] . ' - Notification system', 'Password restore', $message);
 }
Example #6
0
 private function _SaveUploadsAsFiles()
 {
     $dest = Config::GetInstance()->GetStorageFolder(1);
     $tempuploads = array();
     if (!is_dir($dest) && !mkdir($dest, 0755)) {
         $this->errors[] = array("err" => _T('Could not create file upload directory "%s"', $dest));
         return;
     }
     foreach ($_FILES as $fieldname => $filedata) {
         if (empty($filedata['tmp_name'])) {
             continue;
         }
         // it isn't a upload if the file isn't mentioned in the rules
         if (Config::GetInstance()->GetRulePropertyByName($fieldname, 'fieldtype') != 'fileupload') {
             continue;
         }
         // check if the file must be saved on the server
         if (!Config::GetInstance()->GetRulePropertyByName($fieldname, 'files')) {
             // filename may or may not have an extension that must be preserved
             $pos = strrpos($filedata['name'], '.');
             $basename = $filedata['name'];
             $uploadname = $basename;
             if ($pos === false) {
                 $uploadname = $basename . '_' . makeRandomString();
             } else {
                 $uploadname = substr($basename, 0, $pos) . '_' . makeRandomString() . substr($basename, $pos);
             }
             // store the name in post
             $this->post[strtolower($fieldname)] = $uploadname;
             // without payments - emailer looks for the file in its temp storage
             // with payments and JS - emailer is called from the checkout screen, thus we need
             // 		to move the file to our own temp storage.
             if (Config::GetInstance()->UsePayments() && Config::GetInstance()->GetSessionVariable(CC_FB_JSENABLED) && Config::GetInstance()->GetRulePropertyByName($fieldname, 'attach')) {
                 $tempname = SaveUploadAsFile(Config::GetInstance()->GetStorageFolder(5), $filedata);
                 if ($tempname !== false) {
                     $tempuploads[strtolower($fieldname)] = $tempname;
                 }
             }
             continue;
         }
         $storedname = SaveUploadAsFile($dest, $filedata);
         // add it to post, mailer needs it if the file is to be attached
         if ($storedname !== false) {
             $this->post[strtolower($fieldname)] = $storedname;
         }
         // remember which files are stored for which fields, we need that info
         // when reporting data, because in that context we don't have access to the rules
         $this->uploads[] = array('orgname' => $filedata['name'], 'storedname' => $storedname, 'fieldname' => strtolower($fieldname));
     }
     if (count($tempuploads) > 0) {
         Config::GetInstance()->SetSessionVariable(CC_FB_TEMPUPLOADS, $tempuploads);
     }
 }