本文整理汇总了PHP中StringHelper::unicode_str_filter方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::unicode_str_filter方法的具体用法?PHP StringHelper::unicode_str_filter怎么用?PHP StringHelper::unicode_str_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::unicode_str_filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
protected function beforeValidate()
{
if (!parent::beforeValidate()) {
return false;
}
if ($this->scenario == "fromAdmin") {
if ($this->teacher_path_file == NULL) {
$this->addError("teacher_avatar", "teacher_avatar is required");
return false;
}
if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) {
return FALSE;
}
$ext = $this->teacher_path_file->getExtension();
$name = StringHelper::unicode_str_filter($this->teacher_path_file->name);
$storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/';
$targetPath = $storeFolder;
//4
$teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name;
if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
$this->teacher_path_file->save($targetPath, $name);
$this->teacher_avatar = $teacher_ava;
}
}
return TRUE;
}
示例2: getUrlUploadSingleImage
public static function getUrlUploadSingleImage($obj, $user_id)
{
$ext_arr = array('png', 'jpg', 'jpeg', 'bmp', 'pdf', 'txt', 'doc', 'docx', 'xls', 'xlsx');
$name = StringHelper::filterString($obj['name']);
//$name = StringHelper::unicode_str_filter($name);
// $name = StringHelper::makeUrlString($name);
$original_name = $name;
$name = StringHelper::unicode_str_filter($name);
// $name = StringHelper::makeUrlString($name);
$storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/' . date('Y-m-d', time()) . '/' . $user_id . '/';
$pathUrl = 'uploads/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
if (!file_exists($storeFolder)) {
mkdir($storeFolder, 0777, true);
}
$tempFile = $obj['tmp_name'];
$targetFile = $storeFolder . time() . $name;
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if (in_array($ext, $ext_arr)) {
if (move_uploaded_file($tempFile, $targetFile)) {
return array('path' => $pathUrl, 'name' => $original_name);
} else {
return NULL;
}
} else {
return NULL;
}
}
示例3: beforeValidate
protected function beforeValidate()
{
if (!parent::beforeValidate()) {
return false;
}
if ($this->scenario == "fromAdmin") {
if ($this->doc_path_file == NULL) {
$this->addError("doc_path", "doc_path is required");
return false;
}
if (!$this->doc_path_file->checkExt(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'jpg', 'jpeg', 'png'))) {
return FALSE;
}
$api_key = "24cxjtv3vw69wu5p7pqd9";
$secret = "sec-b2rlvg8kxwwpkz9fo3i02mo9vo";
$scribd = new Scribd($api_key, $secret);
$ext = $this->doc_path_file->getExtension();
$name = StringHelper::unicode_str_filter($this->doc_path_file->name);
$storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/document/user_id_' . $this->doc_author;
//2
$targetPath = $storeFolder;
//4
$doc_path = Yii::app()->createAbsoluteUrl('uploads') . '/document/user_id_' . $this->doc_author . '/' . $name;
$targetFile = $targetPath . "/" . $name;
//5
// move_uploaded_file($tempFile, $targetFile); //6
if (!file_exists($storeFolder)) {
mkdir($storeFolder, 0777, true);
}
if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
$this->doc_path_file->save($targetPath, $name);
$this->doc_url = $targetFile;
$this->doc_path = $doc_path;
$this->doc_type = 1;
} else {
if ($ext == "doc" || $ext == "docx" || $ext == "ppt" || $ext == "pptx" || $ext == "xls" || $ext == "xlsx" || $ext == 'txt' || $ext == 'pdf') {
$this->doc_path_file->save($targetPath, $name);
$upload_scribd = @$scribd->upload($targetFile);
// var_dump($targetFile);
// die();
$thumbnail_info = array('doc_id' => $upload_scribd["doc_id"], 'method' => NULL, 'session_key' => NULL, 'my_user_id' => NULL, 'width' => '220', 'height' => '250');
$get_thumbnail = @$scribd->postRequest('thumbnail.get', $thumbnail_info);
$this->doc_scribd_id = @$upload_scribd["doc_id"];
$this->doc_url = @$get_thumbnail["thumbnail_url"];
$this->doc_path = $doc_path;
$this->doc_type = 2;
} else {
$this->doc_path_file->save($targetPath, $name);
$url_file_image = Yii::app()->theme->baseUrl . '/assets/img/document.png';
$this->doc_url = $url_file_image;
$this->doc_path = $doc_path;
$this->doc_type = 3;
}
}
}
return TRUE;
}
示例4: actionUpload
public function actionUpload()
{
//$ds = DIRECTORY_SEPARATOR; //1
$subject_id = $_POST['subject_id'];
$size = 100 * 1024 * 1024;
$doc_name = StringHelper::filterString($_POST['doc_name']);
$doc_description = StringHelper::filterString($_POST['doc_description']);
$doc_author = $_POST['user_id'];
$doc_author_name = $_POST['username'];
$api_key = "24cxjtv3vw69wu5p7pqd9";
$secret = "sec-b2rlvg8kxwwpkz9fo3i02mo9vo";
$this->retVal = new stdClass();
if ($_FILES['file']) {
// print_r ($_FILES['file']);
if ($doc_name != "") {
if ($doc_description != "") {
if ($subject_id != "") {
if ($_FILES['file']['size'] <= $size) {
$scribd = new Scribd($api_key, $secret);
$name = StringHelper::unicode_str_filter($_FILES['file']['name']);
$storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/document/user_id_' . $doc_author . '/';
//2
if (!file_exists($storeFolder)) {
mkdir($storeFolder, 0777, true);
}
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = $storeFolder;
$targetFile = $targetPath . $name;
$ourFileName = $storeFolder . ".htaccess";
$myfile = fopen($ourFileName, "w") or die("Unable to open file!");
$txt = 'Options -Indexes
Options -ExecCGI
AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi .js .html';
fwrite($myfile, $txt);
fclose($myfile);
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$ext = strtolower($ext);
$doc_path = Yii::app()->createAbsoluteUrl('uploads') . '/document/user_id_' . $doc_author . '/' . $name;
if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
move_uploaded_file($tempFile, $targetFile);
//6
$this->saveDoc($doc_name, $doc_description, $doc_path, $doc_author, $subject_id, NULL, 1, $doc_path, $doc_author_name);
$this->retVal->url = $targetFile;
$this->retVal->doc_name = $doc_name;
$this->retVal->doc_path = $doc_path;
$this->retVal->user_name = $doc_author_name;
$this->retVal->success = 1;
} else {
if ($ext == "doc" || $ext == "docx" || $ext == "ppt" || $ext == "pptx" || $ext == "xls" || $ext == "xlsx" || $ext == 'txt' || $ext == 'pdf') {
move_uploaded_file($tempFile, $targetFile);
//6
$upload_scribd = @$scribd->upload($targetFile);
$thumbnail_info = array('doc_id' => $upload_scribd["doc_id"], 'method' => NULL, 'session_key' => NULL, 'my_user_id' => NULL, 'width' => '220', 'height' => '250');
$get_thumbnail = @$scribd->postRequest('thumbnail.get', $thumbnail_info);
// var_dump($get_thumbnail);
$this->saveDoc($doc_name . '.' . $ext, $doc_description, @$get_thumbnail["thumbnail_url"], $doc_author, $subject_id, $upload_scribd["doc_id"], 2, $doc_path, $doc_author_name);
$this->retVal->docid = @$upload_scribd["doc_id"];
$this->retVal->thumbnail = @$get_thumbnail["thumbnail_url"];
$this->retVal->doc_name = $doc_name;
$this->retVal->doc_path = $doc_path;
$this->retVal->user_name = $doc_author_name;
$this->retVal->success = 1;
} else {
if ($ext == "rar" || $ext == "zip" || $ext == "iso") {
move_uploaded_file($tempFile, $targetFile);
//6
$url_file_image = Yii::app()->theme->baseUrl . '/assets/img/document.png';
$this->saveDoc($doc_name . "." . $ext, $doc_description, $url_file_image, $doc_author, $subject_id, NULL, 3, $doc_path, $doc_author_name);
$this->retVal->doc_url = $url_file_image;
$this->retVal->doc_name = $doc_name;
$this->retVal->doc_path = $doc_path;
$this->retVal->user_name = $doc_author_name;
$this->retVal->success = 1;
} else {
$this->retVal->message = "File không được hỗ trợ";
$this->retVal->success = 0;
}
}
}
} else {
$this->retVal->message = "Bạn không thể upload file nặng quá 8MB";
$this->retVal->success = 0;
}
} else {
$this->retVal->message = "Bạn phải nhập đầy đủ các thông tin";
$this->retVal->success = 0;
}
} else {
$this->retVal->message = "Bạn phải nhập đầy đủ các thông tin";
$this->retVal->success = 0;
}
} else {
$this->retVal->message = "Bạn phải nhập đầy đủ các thông tin";
$this->retVal->success = 0;
}
} else {
$this->retVal->message = "Bạn phải nhập đầy đủ các thông tin";
$this->retVal->success = 0;
}
echo CJSON::encode($this->retVal);
//.........这里部分代码省略.........