아이 그림 그리기 위한 백라이트

Led strip.
아두이노.
샤오미 보조 베터리.
박스.
0.5mm 두께 아크릴 30cm*40cm.

password 암호화 알고리즘 bcrypt


php script : 

아래 옵셥의 cost 값은 해싱의 속도를 나타낸다.

default : 10이며 값이 커질수록 해싱의 속도가 느려진다. 이는 오토 크래킹으로 부터 보안성을 높여 줄 수 있다.


<?php

/*
if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH)
echo "CRYPT_BLOWFISH is enabled!";
else
echo "CRYPT_BLOWFISH is not available";

*/
#첫번째 매개변수 - $password - 해시할 값(비밀번호)
#두번째 매개변수 - PASSWORD_BCRYPT - 해시에 사용될 알고리즘(PASSWORD_DEFAULT, PASSWORD_BCRYPT, ...)

$password ="tester";
$options15 = [ 'cost' => 15 ] ;
$options12 = [ 'cost' => 12 ] ;

$hashedValue = password_hash($password, PASSWORD_BCRYPT);

$hashedValueWithO12 = password_hash($password, PASSWORD_BCRYPT, $options12);
$hashedValueWithO15 = password_hash($password, PASSWORD_BCRYPT, $options15);

echo "1hashedPassword:".$hashedValue;
echo "<br>2hashedPassword:".$hashedValueWithO12;
echo "<br>3hashedPassword:".$hashedValueWithO15;

/*
if(password_verify($password, $hashedValue))
echo "<br>1true";
else
echo "<br>1false";
if(password_verify($password, $hashedValueWithO12))
echo "<br>2true";
else
echo "<br>2false<br>";

if(password_verify($password, $hashedValueWithO15))
echo "<br>3true";
else
echo "<br>3false<br>";
*/
echo "<br>1.hashedValue:";
print_r( password_get_info( $hashedValue ));

echo "<br>2.hashedValue:";
print_r( password_get_info( $hashedValueWithO12 ));

echo "<br>3.hashedValue:";
print_r( password_get_info( $hashedValueWithO15 ));

?>




cost => 10



cost => 12



cost => 15




reference to : http://dolgo.net/PHP/lecture/18


'프로그래밍 > PHP' 카테고리의 다른 글

php CURL 사용하기  (0) 2018.07.31
Javascript로 Facebook로그인  (0) 2018.05.26
unlink(=delete) 메소드 이용하기  (0) 2018.04.22
directory entry 읽어 파일리스트업  (0) 2018.04.20
파일 업로드(move_uploaded_file)  (3) 2018.04.14

칠레와인 1865 Single Vineyard Cabernet Sauvignon

1865 : SAN PEDRO 창립연도
Alcol : 14.5%
18홀 65타 라는 마케팅, 스토리텔링으로 골프애호가들에게 행운의 숫자 와인으로 기억됨.
떫고 다소 묵직한 느낌, 입안에 머금고 있을 때 과일향 과 맛의 느낌이 참 좋다..
드라이하고 떫은 맛이, 조금전 먹은 음식 맛을 초기화시키는 것 같은데 ^^
개인적인 평가는 Good 이다.

'Food > Wine' 카테고리의 다른 글

PINOT NOIR (피노 누아)  (0) 2018.04.15

 

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

 

자료를 맵핑할 때 특정한 key로 값을 찾을 때 사용되는 함수이다.

난 보통 일적으로 db쿼리를 사용해서 자료를 맞춘다.

 

Select a.key, a.data, b.data2 from

(Select 1 as key, ‘test1’ as data from dual

Union all

Select 2 as key, ‘test2’ as data from dual) a,

(Select 1 as key, ‘test1자료’ as data2 from dual

Union all

Select 2 as key, ‘test2자료’ as data2 from dual) b

Where a.key = b.key

 

위 쿼리의 모습과 같은 내용을 엑셀로도 할 수 있는데 그게 vlookup 이다

 

아래 url을 참고했고.

excel자체의 도움말에서 찾아도 된다.


==> table_array선택후 +F4로 데이터를 고정시켜야 함





reference url : https://support.office.com/en-us/article/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1


업로드된 파일을 삭제하고 싶을 때 , unlink 메소드를 사용한다.


bool unlink ( string $filename [, resource $context ] )


인수

filename : Path to the file.

반환값

성공 시 TRUE를, 실패 시 FALSE를 반환합니다.


 

php초보자로 이벤트(클릭)를 발생시키고 파일을 삭제하는 것도 쉽지 않네.

 

php에서 파일삭제 메소드를 사용하기 위해서 아래 순서대로 호출.

크게 나쁘진 않은 것 같다. 보안관련 이슈는 차후에 학습하면서 추가하면 되겠다.

 

1)    Html a tag 사용한다.

2)    A tag에 삭제파라미터 : 파일명 를 넣고 해당 페이지를 호출

3)    Php get파라미터로 대상을 받아 파일삭제 메소드 호출


>> entries.PNG 삭제 버튼을 클릭함



>>bootstrap css 적용위한 css파일 첨부

bootstrap.min.css

light-bootstrap-dashboard.css



php source : 


<?php
$dir = $_SERVER['DOCUMENT_ROOT']."/admin1/test/img/";


if ( isset ( $_GET['delete']) ) {
echo $_GET['delete'];
echo "<br>";

if ( unlink ( $dir. $_GET['delete'] ) ) {

header("Location: ./fileupload0.php");
exit;
};
}

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>fileupload</title>
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" />
<!-- CSS Files -->
<link href="../../admin3/assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="../../admin3/assets/css/light-bootstrap-dashboard.css?v=2.0.1" rel="stylesheet" />

</head>
<body>
<div class="wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="card card-tasks">
<div class="card-header ">
<h4 class="card-title">Uploaded File's info</h4>
<p class="card-category">files이 있는 directory의 모든 파일을 읽어 리스트업</p>
</div>
<div class="card-body ">
<div class="table-full-width">
<table class="table">
<tbody>
<?php
/**
* Description.
*
* @author: JinMyung <dcan@doitforyou.co.kr>
* @category Filesystem
* @version 1.0
*/

/* files이 있는 directory의 모든 파일을 읽어 리스트업 */
// $dir = $_SERVER['DOCUMENT_ROOT']."/admin1/test/img/";

// 핸들 획득
$handle = opendir($dir);
$files = array();
// 디렉터리에 포함된 파일을 저장한다.
while (false !== ($filename = readdir($handle))) {
if ($filename =="." || $filename =="..") {
continue;
}

// 파일인 경우만 목록에 추가한다.
if (is_file($dir . "/" . $filename)) {
$files[] = $filename;
}
}
// 핸들 해제
closedir($handle);

sort($files);

// 파일명을 출력한다.
foreach ($files as $f) {
//echo $f . "(" . round(filesize($dir . "/" . $f)/1024, 2) . " KB)" ;
$FileFullPathName = "";
$FileFullPathName = $dir . "/" . $f;
echo "<tr>";
echo "<td>".$f . "(" . round(filesize($FileFullPathName)/1024, 2) . " KB)(".date("Y-m-d H:i:s", filemtime($FileFullPathName)) .")</td>";
echo "<td class=\"td-actions text-right\">";
echo " <a href=\"?delete=". $f."\">"."<button type=\"button\" style=\"cursor:hand\" rel=\"tooltip\" title=\"Remove\" class=\"btn btn-danger btn-simple btn-link\">";
echo "<i class=\"fa fa-times\"></i>";
echo "</button></a>";
echo "</td>";
echo "</tr>";

}
?>

</tr>
</tbody>
</table>
</div>
</div>
<div class="card-footer ">
<hr>
<div class="stats">
<i class="now-ui-icons loader_refresh spin"></i>
<?php
echo "refer to : http://blog.devez.net/292 | http://php.net/manual/en/function.readdir.php";
?>
</div>
<form enctype="multipart/form-data" action="fileupload1.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="4000000" />
Send File: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

</div>
</div>
</div>
</div>
</div>
</div>
</div>

</body>
</html>


'프로그래밍 > PHP' 카테고리의 다른 글

Javascript로 Facebook로그인  (0) 2018.05.26
php 패스워드 암호화 bcript  (0) 2018.05.02
directory entry 읽어 파일리스트업  (0) 2018.04.20
파일 업로드(move_uploaded_file)  (3) 2018.04.14
fileupload 에러메시지 설명  (0) 2018.04.14

[영단어] directory entry 

           디스크에 있는 각 파일의 이름·크기·특징 등을 기재한 것

Reference url : http://dic.daum.net/search.do?q=entry



(PHP 4, PHP 5, PHP 7)

readdir — Read entry from directory handle


Description

string readdir ([ resource $dir_handle ] )

Returns the name of the next entry in the directory. The entries are returned in the order in which they are stored by the filesystem.


reference url : http://php.net/manual/en/function.readdir.php



<?php
/**
* Description.
*
* @author: JinMyung <dcan@doitforyou.co.kr>
* @category Filesystem
* @version 1.0
*/

/* files이 있는 directory의 모든 파일을 읽어 리스트업 */
echo "<pre>";
echo "<b>files이 있는 directory의 모든 파일을 읽어 리스트업</b>";
echo "<br>";

$dir = $_SERVER['DOCUMENT_ROOT']."/admin1/test/img/";

// 핸들 획득
$handle = opendir($dir);
$files = array();
// 디렉터리에 포함된 파일을 저장한다.
while (false !== ($filename = readdir($handle))) {
if ($filename =="." || $filename =="..") {
continue;
}

// 파일인 경우만 목록에 추가한다.
if (is_file($dir . "/" . $filename)) {
$files[] = $filename;
}
}
// 핸들 해제
closedir($handle);

sort($files);

// 파일명을 출력한다.
foreach ($files as $f) {
echo $f . "(" . round(filesize($dir . "/" . $f)/1024, 2) . " KB)" ;
echo "<br />";
}

echo "</pre>";
echo "reference url : http://blog.devez.net/292 | http://php.net/manual/en/function.readdir.php";

?>




'프로그래밍 > PHP' 카테고리의 다른 글

php 패스워드 암호화 bcript  (0) 2018.05.02
unlink(=delete) 메소드 이용하기  (0) 2018.04.22
파일 업로드(move_uploaded_file)  (3) 2018.04.14
fileupload 에러메시지 설명  (0) 2018.04.14
angularJS 사용하기  (0) 2018.04.01

Oracle DB를 사용하다보면 항상 찾아보게되는 에러코드


Exception name Oracle Database
error number
SQLCODE Description
ACCESS_INTO_NULL ORA-06530 -6530 Program attempted to assign values to the attributes of an uninitialized object.
CASE_NOT_FOUND ORA-06592 -6592 None of the choices in the WHEN clauses of a CASE statement were selected and there is no ELSE clause.
COLLECTION_IS_NULL ORA-06531 -6531 Program attempted to apply collection methods other than EXISTS to an uninitialized nested table or varray, or program attempted to assign values to the elements of an uninitialized nested table or varray.
CURSOR_ALREADY_OPENED ORA-06511 -6511 Program attempted to open an already opened cursor.
DUP_VAL_ON_INDEX ORA-00001 -1 Program attempted to insert duplicate values in a column that is constrained by a unique index.
INVALID_CURSOR ORA-01001 -1001 There is an illegal cursor operation.
INVALID_NUMBER ORA-01722 -1722 Conversion of character string to number failed.
NO_DATA_FOUND ORA-01403 100 Single row SELECT returned no rows or your program referenced a deleted element in a nested table or an uninitialized element in an associative array (index-by table).
PROGRAM_ERROR ORA-06501 -6501 PL/SQL has an internal problem.
ROWTYPE_MISMATCH ORA-06504 -6504 Host cursor variable and PL/SQL cursor variable involved in an assignment statement have incompatible return types.
STORAGE_ERROR ORA-06500 -6500 PL/SQL ran out of memory or memory was corrupted.
SUBSCRIPT_BEYOND_COUNT ORA-06533 -6533 A program referenced a nested table or varray using an index number larger than the number of elements in the collection.
SUBSCRIPT_OUTSIDE_LIMIT ORA-06532 -6532 A program referenced a nested table or varray element using an index number that is outside the legal range (for example, -1).
SYS_INVALID_ROWID ORA-01410 -1410 The conversion of a character string into a universal rowid failed because the character string does not represent a ROWID value.
TOO_MANY_ROWS ORA-01422 -1422 Single row SELECT returned multiple rows.
VALUE_ERROR ORA-06502 -6502 An arithmetic, conversion, truncation, or size constraint error occurred.
ZERO_DIVIDE ORA-01476 -1476 A program attempted to divide a number by zero.

reference url : https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#TTPLS192


'DataBase > Oracle' 카테고리의 다른 글

ORA-01403 no data found, ORA-01422 TOO_MANY_ROWS  (0) 2018.12.16
select for update wait/nowait  (0) 2018.07.22

Simon & Garfunkel – The Sound Of Silence


Hello, darkness, my old friend

I've come to talk with you again

Because a vision softly creeping

Left it's seeds while I was sleeping

And the vision that was planted in my brain

Still remains

Within the sound of silence

In restless dreams I walked alone

Narrow streets of cobblestone

'Neath the halo of a street lamp

I turned my collar to the cold and damp

When my eyes were stabbed by the flash of a neon light

That split the night

And touched the sound of silence

And in the naked light I saw

Ten thousand people, maybe more

People talking without speaking

People hearing without listening

People writing songs that voices never share

And no-one dared

Disturb the sound of silence

'Fools, ' said I, 'you do not know

Silence like a cancer grows

Hear my words that I might teach you

Take my arms that I might reach you, '

But my words like silent raindrops fell

And echoed

In the wells of silence

And the people bowed and prayed

To the neon god they made

And the sign flashed out it's warning

In the words that it was forming

And the sign said 'The words of the prophets are written on the subway walls

And tenement halls'

And whisper'd

In the sound of silence

Songwriters: PAUL SIMON


reference url : http://www.lyricsfreak.com/a/art+garfunkel/the+sound+of+silence_20271694.html

           https://www.youtube.com/watch?v=HZVkk_aQ0BI

Composer :  PHP 환경에서 사용하는 의존성 관리 도구

설치 => https://getcomposer.org/download/



C:\Users\Administrator>composer


Composer version 1.6.4 2018-04-13 12:04:24

Usage: command [options] [arguments]

Options:

  -h, --help                     Display this help message

  -q, --quiet                    Do not output any message

  -V, --version                  Display this application version

      --ansi                     Force ANSI output

      --no-ansi                  Disable ANSI output

  -n, --no-interaction           Do not ask any interactive question

      --profile                  Display timing and memory usage information

      --no-plugins               Whether to disable plugins.


c:\APMorg\Apache24\htdocs>composer global require squizlabs/php_codesniffer

Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer

Using version ^3.2 for squizlabs/php_codesniffer

./composer.json has been created

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 1 install, 0 updates, 0 removals

  - Installing squizlabs/php_codesniffer (3.2.3): Downloading (100%)

Writing lock file

Generating autoload files


c:\APMorg\Apache24\htdocs>



C:\APMorg\Apache24\htdocs>composer require --dev squizlabs/php_codesniffer

Using version ^3.2 for squizlabs/php_codesniffer

./composer.json has been created

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 1 install, 0 updates, 0 removals

  - Installing squizlabs/php_codesniffer (3.2.3): Loading from cache

Writing lock file

Generating autoload files





vscode-phpcs(composer based)를 적용했더니 
내 코드가 마음에 안드나 보다
30개가 문제있다 나오네...
There must be...
invalid...

phpcs(composer based) 상세 내용은 사용해 보면서 이 글에 업데이트 하는걸로 하겠습니다.




phpcs에서 invalid라 warning하는 건

주석 / 문법오류 / 함수사용시 패턴 / 들여쓰기등을 가이드 해주면서 일괄적인 코딩패턴을 유지할 수 있게 해준다. warning없애려고 하다보니 코드가 깔끔해졌다. => 가독성 좋아짐

참고 ) 주석관련 : https://github.com/squizlabs/PHP_CodeSniffer/issues/258







[fileupload0.php]

html tag enctype="multipart/form-data" 

파일을 업로드 할때 파일속 데이타 모두 encode해서 넘겨야 원본파일을 넘길수 있다. 

그래서 enctype="multipart/form-data" 로 지정해서 넘김.

<form enctype="multipart/form-data" action="fileupload1.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="4000000" />
Send File: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>



[fileupload1.php]

php에서 file upload 시키는 함수는 move_uploaded_file


아래는 업로드시 에러발생했을 경우 에러 메시지를 case별로 적어봤다.

bool move_uploaded_file ( string $Filename , string $Destination )


실제 fileupload0에서 submit되면서 fileupload1으로 넘어올때.

$_FILES 에는 업로드 성공여부(temp폴더에 임시 업로드됨)가 모두 담겨 넘어온다.

그 후 temp폴더에서 "move_uploaded_file" 메소드를 이용 개발자가 정의한 폴더로 move시키는 것이다.


$_FILES info : Array

(

    [userfile] => Array

        (

            [name] => uploaded1.jpg

            [type] => image/jpeg

            [tmp_name] => C:\Windows\Temp\phpFD71.tmp

            [error] => 0

            [size] => 68985

        )

)


<?php

$uploaddir = $_SERVER['DOCUMENT_ROOT']."/admin1/test/img/";

print_r($uploadfile = $uploaddir.basename($_FILES['userfile']['name']));

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File was successfully uploaded.\n";
} else {
echo "FileUpload was failed.\n";
}

echo 'info:';
print_r($_FILES);
echo "<br />";

if(UPLOAD_ERR_OK !=$_FILES['userfile']['error'])
{

switch ($_FILES['userfile']['error']) {
case UPLOAD_ERR_INI_SIZE:
$message = "The uploaded file exceeds the upload_max_filesize directive in php.ini";
break;
case UPLOAD_ERR_FORM_SIZE:
$message = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form";
break;
case UPLOAD_ERR_PARTIAL:
$message = "The uploaded file was only partially uploaded";
break;
case UPLOAD_ERR_NO_FILE:
$message = "No file was uploaded";
break;
case UPLOAD_ERR_NO_TMP_DIR:
$message = "Missing a temporary folder";
break;
case UPLOAD_ERR_CANT_WRITE:
$message = "Failed to write file to disk";
break;
case UPLOAD_ERR_EXTENSION:
$message = "File upload stopped by extension";
break;
default:
$message = "Unknown upload error";
break;
}

echo $message;

}
print "</pre>";
?>


자 이렇게 해서 fileupload0.php => fileupload1.php 순서로 실행되면 

아래의 로그를 받아볼 수 있다.

화일은 temp로 임시 저장된 후 다시 최초 지정한 경로로 옮겨간다. 

'프로그래밍 > PHP' 카테고리의 다른 글

unlink(=delete) 메소드 이용하기  (0) 2018.04.22
directory entry 읽어 파일리스트업  (0) 2018.04.20
fileupload 에러메시지 설명  (0) 2018.04.14
angularJS 사용하기  (0) 2018.04.01
json 데이타 사용하기  (0) 2018.03.28

+ Recent posts