반응형

php/코드이그나이터(CI3) 10

php 8.1 phpexcel 대체

기존 phpexcel 을 사용중이였는데 버전업을 진행하며 이제는 더이상 phpexcel를 사용할 수 없게되었다.파일을 읽는건 문제 없지만 엑셀을 출력하기위해 엑셀을 쓰는 과정에서 오류가 있었다.다음은 오류중 하나이다더보기Message: Return type of PHPExcel_WorksheetIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice그냥 간단하게 타입명시 오류다.일일이 고치기도 힘들기에 이제는 더이상 phpexcel을 가지고 갈 수 없는 환..

php 오라클 date 타입 형식 변경

php에서 오라클 데이터중 date 형식의 데이터를 가져오게되면10-Oct-03 이런식으로 가져오는 경우가 있다.이런경우 형식을 YYYY-MM-DD HH24:MI:SS 형식으로 바꿔주는 방법이다. class Test_model extends CI_Model{ public function __construct() { parent::__construct(); $this->set_nls_date_format(); } /** * 해당 세션에서만 오라클 date 타입 형식을 바꿔주는 쿼리 */ public function set_nls_date_format($format = 'YYYY-MM-DD HH24:MI:SS'){ $query = "ALTER SESSION SET nls_date_format = '..

php/java view생성 후 ajax리턴

웹에서 새로고침 없이 화면을 그릴때 ajax를 써서 화면을 생성한다.html을 모두 그려야되는 경우 활용할만한 알고리즘으로php에서 html을 생성 한 후 return 해주는면 된다.​php코드function get_page(){ $new_view = $this->create_view(); //아래 함수에서 html을 리턴 받는다 $this->load->view("/test/page", array( "json_html" => $new_view ));}//view를 생성하여 리턴해준다. load->view 파라미터에 true를 넣으면 html을 출력하지않고 변수로 return 해줄수있다.function create_view(){ $data1 = "testestt"; $row = "db_data..

php 암호화

양방향 암호화기존 양방향 암호화 알고리즘으로 openssl_encrypt를 사용했었다. //암호화function encrypt($str, $key='') { if (!$key) return ""; return base64_encode(openssl_encrypt($str, "AES-256-CBC", $key, true, str_repeat(chr(0), 16)));}//복호화function decrypt($str, $key='') { if (!$key) return ""; return openssl_decrypt(base64_decode($str), "AES-256-CBC", $key, true, str_repeat(chr(0), 16));} 그런데 패스워..

코드이그나이터3, 세션생성오류

코드이그나이터3(이하 CI3) 과 PHP 7.1 버젼을 사용하면서 세션에서 문제가 생겼다. 분명 컨트롤러에서는 생성이 되는데 view 로 리다이렉션만 해버리면 세팅한 세션이 사라지고 ci_last_regenerate] => 1627888197 이런 것만 남게되는 상황이다. ​ session_start() 를 해봐도 이미 세션은 시작되어있다고 나와있었고 config 파일에서 세션저장을 db로도 file 로도 해보고...참 많은 삽질을 한 결과 CI3 버젼과 PHP 7.1 버젼에서만 세션 오류가 생긴다는걸 확인할수 있었다. 해결은 CI3에 system/libraries/Session.php 파일에 들어가서 대략 130라인에 // Sanitize the cookie, because apparently PHP ..

php sftp로 폴더 업로드

필요한 서버에 sftp로 폴더 업로드 소스 개인적으로 사실 요즘 잘 안쓰긴 하다만... 그래도 예전에 네이버에 작성했던 글을 다시 읽으며 코드를 다시 보는게 재밌긴하다. $strServer = $host; $strServerPort = $port; $strServerUsername = $username; $strServerPassword = $pw; $resConnection = ssh2_connect($strServer, $strServerPort); if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword)) { $sftp = ssh2_sftp($resConnection); $dir = ssh2_exec($resConne..

php 서버내의 폴더, 파일 압축

function dirZip($resource,$dir) { if(filetype($dir) === 'dir') { clearstatcache(); if($fp = @opendir($dir)) { while(false !== ($ftmp = readdir($fp))){ if(($ftmp !== ".") && ($ftmp !== "..") && ($ftmp !== "")) { if(filetype($dir.'/'.$ftmp) === 'dir') { clearstatcache(); // 디렉토리이면 생성하기 $resource->addEmptyDir($dir.'/'.$ftmp); set_time_limit(0); $this->dirZip($resource,$dir.'/'.$ftmp); } else { // 파..

반응형