!c99Shell v. 1.0 pre-release build #16!

Software: Apache/2.2.3 (CentOS). PHP/5.1.6 

uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44
EDT 2010 i686
 

uid=48(apache) gid=48(apache) groups=48(apache) 

Safe-mode: OFF (not secure)

/var/www/html/mis/application/controllers/ealumni/   drwxr-xr-x
Free 50.41 GB of 127.8 GB (39.44%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     import.php (36.41 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('ea_controller.php');
class 
Import extends Ea_controller {

//    function __construct() {
//        parent::Controller();
//    }

    //----[]--- ฟังก์ชั่น check curl
    
function iscurlinstalled() {
        if  (
in_array('curl'get_loaded_extensions())) {
            return 
true;
        }
        else{
            return 
false;
        }
    }
    
//---[]--- ฟังก์ชั่น check  xml
    
function isxmlinstalled() {
        if  (
in_array('xml'get_loaded_extensions())) {
            return 
true;
        }
        else{
            return 
false;
        }
    }

    
// xml ปีจบการศึกษา
    
function importToEa() {
        
//---[]--- start curl function
        
$url $this->config->item('url_reg2ea')."curl_graduateY";

        
$xmlStr "";
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_POSTtrue);
        
curl_setopt($chCURLOPT_POSTFIELDS$xmlStr);
        
curl_setopt($chCURLOPT_HTTPHEADER, array('Expect:'));
        
$rs curl_exec($ch);
        
$httpcode curl_getinfo($chCURLINFO_HTTP_CODE);
        
curl_close ($ch);
        
//---[]--- end curl function

        
$graduateY simplexml_load_string($rs);

        if(
$this->iscurlinstalled() && $this->isxmlinstalled()) {
            
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
            
$this->load->model($this->config->item("ea_folder").'m_importupdate','imp');

            
// เช็คข้อมูลมาครบหรือไม่
            
$firstNode $this->checkFirstNode($graduateY);
            
$endNode $this->checkEndNode($graduateY);

            
$i 0;
            
$opt = array();
            if(
$firstNode==$endNode) {
                foreach(
$graduateY as $key => $val) {
                    foreach(
$val as $key_v => $val_v) {
                        if(
$key_v!='name' && $key_v!='end') {
                            
$con_rs_am = array('graduateYear'    => (($val_v==0) ? '0' intval($val_v)));
                            
$rs_am $this->am->qryAm($con_rs_am);

                            
$con_qu_imp = array('graduateY'    => (($val_v==0) ? '0' intval($val_v)));
                            
$qu_imp $this->imp->qryImp($con_qu_imp);
                            if(
$qu_imp->num_rows()) {
                                
$tmpDate explode(' ',$qu_imp->row()->importDate);
                            }

                            
$opt[$i]['graduateY'] = intval($val_v);
                            
$opt[$i]['update'] = $rs_am->num_rows();
                            
$opt[$i]['date'] = ($qu_imp->num_rows()) ? abbreDate2($tmpDate[0]) : "-";
                            
$opt[$i]['userupdate'] = ($qu_imp->num_rows() ? $qu_imp->row()->usLogin "-");
                        }

                        
$i++;
                    }
                }
            } else {
                
$msg "อัพเดทข้อมูลนักศึกษาจากระบบทะเบียนไม่สมบูรณ์ <br />กรุณาอัพเดทใหม่อีกครั้ง";

                
$this->session->set_flashdata('msg'$msg);
                
redirect($this->config->item("rg_folder")."msg/err_msg");
            }
        } else {
            
$msg "ไม่สามารถอัพเดทข้อมูลนักศึกษาจากระบบทะเบียนได้ <br />กรุณาตรวจสอบการติดตั้ง cURL และ SimpleXML<br />ติดต่อผู้ดูแลระบบ";

            
$this->session->set_flashdata('msg'$msg);
            
redirect($this->config->item("rg_folder")."msg/err_msg");
        }

        
$this->contents['opt'] = $opt;
        
$this->output($this->config->item("ea_folder")."v_importToEa");
    }

    function 
importStdByGraduateY() {
        
$graduateY $this->input->post('graduateY');

        
//---[]--- start curl function
        
$url $this->config->item('url_reg2ea')."curl_StdByGraduateY";
        
$xmlStr $graduateY;
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_POSTtrue);
        
curl_setopt($chCURLOPT_POSTFIELDS$xmlStr);
        
curl_setopt($chCURLOPT_HTTPHEADER, array('Expect:'));
        
$rs curl_exec($ch);
        
$httpcode curl_getinfo($chCURLINFO_HTTP_CODE);
        
curl_close ($ch);
        
//---[]--- end curl function

        
$rs_std simplexml_load_string($rs);

        if(
$this->iscurlinstalled() && $this->isxmlinstalled()) {
            
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
            
$this->load->model($this->config->item("ea_folder").'m_alumnibio','ab');
            
$this->load->model($this->config->item("ea_folder").'m_importupdate','im');
            
$this->load->model($this->config->item("ea_folder").'m_mapprogram','map');

            
// เช็คข้อมูลมาครบหรือไม่
            
$firstNode $this->checkFirstNode($rs_std);
            
$endNode $this->checkEndNode($rs_std);

            
$i 1;
            if(
$firstNode==$endNode) {
                
$this->db->trans_begin();
                foreach(
$rs_std as $key => $val) {
                    
$con_qu_am = array('studentCode'    => $val->stdCode);
                    
$qu_am $this->am->qryAm($con_qu_am);
                    if(
$val->stdId!='' && $qu_am->num_rows()==0) {
                        
$this->am->alumniId '';
                        
$this->am->studentId intval($val->stdId);
                        
$this->am->studentCode strval($val->stdCode);
                        
$this->am->levelId intval($val->curElvId);
                        
$this->am->programId intval($val->stdCurId);
                        
$this->am->prefixId intval($val->stdPfId);
                        
$this->am->studentName strval($val->stdName);
                        
$this->am->studentSurname strval($val->stdSurname);
                        
$this->am->studentNameEng strval($val->stdNameE);
                        
$this->am->studentSurnameEng strval($val->stdSurnameE);
                        
$this->am->creditAttempt intval($val->stdCreditAttempt);
                        
$this->am->creditSatisfy intval($val->stdCreditSatisfy);
                        
$this->am->GPA floatval($val->stdGPA);
                        
$this->am->admitAcadYear intval($val->stdAdY);
                        
$this->am->admitSemester intval($val->stdTmIdAdmit);
                        
$this->am->admitDate strval($val->stdAdmitDate);
                        
$this->am->finishDate strval($val->stdGraduateDate);
                        
$this->am->studentPassword md5("O]O".$val->stdCode."O[O");
                        
$this->am->studentEmail = ($val->sdtEmail=='') ? 'NULL' strval($val->sdtEmail);
                        
$this->am->studentYear intval($val->stdSyId);
                        
$this->am->studentStatus intval($val->stdSstId);
                        
$this->am->officerId1 'NULL';
                        
$this->am->officerId2 'NULL';
                        
$this->am->financeStatus intval($val->stdFsId);
                        
$this->am->updateUserId $this->session->userdata('UsLogin');
                        
$this->am->updateDateTime date('Y-m-d H:i:s');
                        
$this->am->citizenId strval($val->sdtCitizenId);
                        
$this->am->graduateYear intval($val->stdGraduateY);
                        
$this->am->genStatus strval($val->stdGenStatus);
                        
$this->am->genNo intval($val->stdGenId);
                        
$this->am->entryTypeId intval($val->stdEtId);
                        
$this->am->entryTypeId2 intval($val->stdEt2Id);
                        
$this->am->studentSex strval($val->defaultSex);
                        
$this->am->scholarId intval($val->stdSoId);
                        
$this->am->preAdmitPositionId intval($val->stdPaId);
                        
$this->am->totalPoint intval($val->stdTotalPoint);
                        
$this->am->honor = ($val->stdHonor=='') ? 'NULL' strval($val->stdHonor);
                        
$this->am->medal = ($val->stdMedal=='') ? 'NULL' strval($val->stdMedal);
                        
$this->am->exitExam strval($val->stdExitExam);
                        
$this->am->studentStatusTmp intval($val->stdSstIdTmp);
                        
$this->am->importtoalumni 1;
                        
$this->am->glantId 'Y';
                        
$this->am->glantDate date('Y-m-d H:i:s');
                        
$this->am->glantreqDate date('Y-m-d H:i:s');
                        
$this->am->amAnsQn "N";

                        
// หาหลักสูตรตามระบบทะเบียนศิษย์เก่าก่อน
                        
$con_qu_map = array('mpGraduateY'    => intval($val->stdGraduateY),
                                            
'programId_reg'    => intval($val->stdCurId));
                        
$qu_map $this->map->qryMap($con_qu_map);
                        if(
$qu_map->num_rows()) {
                            
$this->am->amProgramAlumni $qu_map->row()->programId_alumni;
                        } else {
                            
$this->am->amProgramAlumni NULL;
                        }
                        
$this->am->insert();

                        
$this->ab->alumniId $this->am->last_insert_id;
                        
$this->ab->studentId strval($val->sdtStdId);
                        
$this->ab->nationId intval($val->sdtNtId);
                        
$this->ab->religionId intval($val->sdtRlgId);
                        
$this->ab->bloodGroup strtoupper($val->sdtBloodGroup);
                        
$this->ab->birthDate strval($val->sdtBirthDate);
                        
$this->ab->birthCntId intval($val->sdtCntId);
                        
$this->ab->birthProvinceId intval($val->sdtPrvIdBirth);
                        
$this->ab->homeAddress strval($val->sdtHomeAddr);
                        
$this->ab->homeDistrictId intval($val->sdtDtIdHome);
                        
$this->ab->homeAmphurId intval($val->sdtApIdHome);
                        
$this->ab->homeProvinceId intval($val->sdtPrvIdHome);
                        
$this->ab->homeZipcode strval($val->sdtHomePostCode);
                        
$this->ab->homePhoneNo strval($val->sdtHomePhoneNo);
                        
$this->ab->officeName strval($val->sdtWorkName);
                        
$this->ab->workCntId 0;
                        
$this->ab->officeAddress strval($val->sdtWorkAddr);
                        
$this->ab->officeDistrictId intval($val->sdtDtIdWork);
                        
$this->ab->officeAmphurId intval($val->sdtApIdWork);
                        
$this->ab->officeProvinceId intval($val->sdtPrvIdWork);
                        
$this->ab->officeZipcode strval($val->sdtWorkPostCode);
                        
$this->ab->officePhoneNo strval($val->sdtWorkPhoneNo);
                        
$this->ab->workingStatus strval($val->sdtWorkStatus);
                        
$this->ab->workingPosition strval($val->sdtWorkPosition);
                        
$this->ab->workingSalary intval($val->sdtWorkSalary);
                        
$this->ab->fatherName strval($val->sdtFatherName.' '.$val->sdtFatherSurname);
                        
$this->ab->fatherAddress strval($val->sdtFatherAddr);
                        
$this->ab->fatherDistrictId intval($val->sdtDtIdFather);
                        
$this->ab->fatherAmphurId intval($val->sdtApIdFather);
                        
$this->ab->fatherProvinceId intval($val->sdtPrvIdFather);
                        
$this->ab->fatherZipcode strval($val->sdtFatherPostCode);
                        
$this->ab->fatherPhoneNo strval($val->sdtFatherPhoneNo);
                        
$this->ab->fatherOccupation strval($val->sdtFatherOccupation);
                        
$this->ab->fatherStatus strval($val->sdtFatherStatus);
                        
$this->ab->motherName strval($val->sdtMothername.' '.$val->sdtMotherSurname);
                        
$this->ab->motherAddress strval($val->sdtMotherAddr);
                        
$this->ab->motherDistrictId intval($val->sdtDtIdMother);
                        
$this->ab->motherAmphurId intval($val->sdtApIdMother);
                        
$this->ab->motherProvinceId intval($val->sdtPrvIdMother);
                        
$this->ab->motherZipcode strval($val->sdtMotherPostCode);
                        
$this->ab->motherPhoneNo strval($val->sdtMotherPhoneNo);
                        
$this->ab->motherOccupation strval($val->sdtMotherOccupation);
                        
$this->ab->motherStatus strval($val->sdtMotherStatus);
                        
$this->ab->studentSex strval($val->defaultSex);
                        
$this->ab->parentName strval($val->sdtParentName.' '.$val->sdtParentSurname);
                        
$this->ab->parentRelation strval($val->sdtParentRelationship);
                        
$this->ab->parentAddress strval($val->sdtParentAddr);
                        
$this->ab->parentDistrictId intval($val->sdtDtIdParent);
                        
$this->ab->parentAmphurId intval($val->sdtApIdParent);
                        
$this->ab->parentProvinceId intval($val->sdtPrvIdParent);
                        
$this->ab->parentZipcode strval($val->sdtParentPostCode);
                        
$this->ab->parentPhoneNo strval($val->sdtParentPhoneNo);
                        
$this->ab->parentMobile strval($val->sdtParentMobileNo);
                        
$this->ab->parentOcc strval($val->sdtParentOccupation);
                        
$this->ab->parentIncome intval($val->sdtParentIncome);
                        
$this->ab->parentEmail strval($val->sdtParentEmail);
                        
$this->ab->contactPerson strval($val->sdtContactName);
                        
$this->ab->contactAddress strval($val->sdtContactAddr);
                        
$this->ab->contactDistrictId intval($val->sdtDtIdContact);
                        
$this->ab->contactAmphurId intval($val->sdtApIdContact);
                        
$this->ab->contactProvinceId intval($val->sdtPrvIdContact);
                        
$this->ab->contactZipcode strval($val->sdtContactPostCode);
                        
$this->ab->contactPhoneNo strval($val->sdtContactPhoneNo);
                        
$this->ab->cardExpiryDate strval($val->sdtCardExpireDate);
                        
$this->ab->currentCntId 0;
                        
$this->ab->currentAddress strval($val->sdtCurrentAddr);
                        
$this->ab->currentDistrictId intval($val->sdtDtIdCurrent);
                        
$this->ab->currentAmphurId intval($val->sdtApIdCurrent);
                        
$this->ab->currentProvinceId intval($val->sdtPrvIdCurrent);
                        
$this->ab->currentZipcode strval($val->sdtCurrentPostCode);
                        
$this->ab->currentPhoneNo strval($val->sdtCurrentPhoneNo);
                        
$this->ab->graduateAddress strval($val->sdtGraduateAddr);
                        
$this->ab->graduateDistrictId intval($val->sdtDtIdGraduate);
                        
$this->ab->graduateAmphurId intval($val->sdtApIdGraduate);
                        
$this->ab->graduateProvinceId intval($val->sdtPrvIdGraduate);
                        
$this->ab->graduateZipcode strval($val->sdtGraduatePostCode);
                        
$this->ab->graduatePhoneNo strval($val->sdtGraduatePhoneNo);
                        
$this->ab->maritalStatusId intval($val->sdtMsId);
                        
$this->ab->weight floatval($val->sdtWeight);
                        
$this->ab->height floatval($val->sdtHeight);

                        
// ******** copy file รูป จาก eregis/pictureStd => ealumni/pictureStd ******
                        
                        
if(file_exists($this->config->item('ea_rg_upload_pictureStd').strval($val->sdtPicturePath))) {
                            
copy($this->config->item('ea_rg_upload_pictureStd').strval($val->sdtPicturePath), $this->config->item('ea_pictureStd').strval($val->sdtPicturePath));

                            
$this->ab->picturePath strval($val->sdtPicturePath);
                        } else {
                            
$this->ab->picturePath 'photo.jpg';
                        }

                        
$this->ab->recruitmentTypeId intval($val->sdtRtId);
                        
$this->ab->occExamResult strval($val->sdtOccExamResult);
                        
$this->ab->canRefund strval($val->sdtCanRefund);
                        
$this->ab->oldStudentName strval($val->sdtOldName);
                        
$this->ab->entryDegree intval($val->sdtEdgIdPre);
                        
$this->ab->healthPrivId intval($val->sdtHpId);
                        
$this->ab->o1prefixId '';
                        
$this->ab->o1fName '';
                        
$this->ab->o1lName '';
                        
$this->ab->o2prefixId '';
                        
$this->ab->o2fName '';
                        
$this->ab->o2lName '';
                        
                        
// ***** คำนำหน้าชื่อ ชื่อ สกุล จากระบบทะเบียนจากการ import ***** //
                        
$this->ab->regPrefix intval($val->stdPfId);
                        
$this->ab->regStdName strval($val->stdName);
                        
$this->ab->regStdSurname strval($val->stdSurname);
                        
$this->ab->regStdNameE strval($val->stdNameE);
                        
$this->ab->regStdSurnameE strval($val->stdSurnameE);
                        
$this->ab->insert();
                    }

                    
// ***** นำศิษย์เก่าเข้า alumni_ums ***** //
                    
$importToUms $this->importToUms(strval($val->stdCode), strval($val->stdName), strval($val->stdSurname));

                    
$i++;
                }
                if(
$this->db->trans_status() === false) {
                    
$this->db->trans_rollback();
                } else {
                    
$this->db->trans_commit();
                }

                
// insert ImportUpdate
                
$con_rs_im = array('graduateY'    => $this->am->graduateYear);
                
$rs_im $this->im->qryImp($con_rs_im);

                
$this->db->trans_begin();
                
$this->im->importId = ($rs_im->num_rows()) ? $rs_im->row()->importId '';
                
$this->im->graduateY = ($rs_im->num_rows()) ? $rs_im->row()->graduateY $this->am->graduateYear;
                
$this->im->importDate date('Y-m-d H:i:s');
                
$this->im->usLogin $this->session->userdata('UsLogin');
                if(
$rs_im->num_rows()) {
                    
$this->im->update();
                } else {
                    
$this->im->insert();
                }

                if(
$this->db->trans_status() === false) {
                    
$this->db->trans_rollback();
                } else {
                    
$this->db->trans_commit();
                }

                
// copy rg_Generation
                
$copyGen $this->copy_Gen();
                
$res_copyGen = ($copyGen=='1') ? "คัดลอกข้อมูลรุ่นสำเร็จ" "คัดลอกข้อมูลรุ่นไม่สำเร็จ";
                
                
// copy rg_Curriculum+rg_EduLevel
                
$copyCur $this->copy_Cur();
                
$res_copyCur = ($copyCur=='1') ? "คัดลอกข้อมูลหลักสูตรสำเร็จ" "คัดลอกข้อมูลหลักสูตรสำเร็จไม่สำเร็จ";

                
// copy rg_CurriculumConfig
                
$copyCurriculumConfig $this->copy_CurriculumConfig();
                
$res_copyCurriculumConfig = ($copyCurriculumConfig=='1') ? "คัดลอกข้อมูลประเภทบัณฑิตสำเร็จ" "คัดลอกข้อมูลประเภทบัณฑิตสำเร็จไม่สำเร็จ";

                
// copy rg_EduDegree
                
$copyEdg $this->copy_Edg();
                
$res_copyEdg = ($copyEdg=="1") ? "คัดลอกข้อมูลวุฒิการศึกษาสำเร็จ" "คัดลอกข้อมูลวุฒิการศึกษาไม่สำเร็จ";

                
//echo $res_copyGen.'/'.$res_copyCur.'/'.$res_copyCurriculumConfig.'/'.$res_copyEdg;
            
} else {
                
$msg "อัพเดทข้อมูลนักศึกษาจากระบบทะเบียนไม่สมบูรณ์ <br />กรุณาอัพเดทใหม่อีกครั้ง";

                
$this->session->set_flashdata('msg'$msg);
                
redirect($this->config->item("rg_folder")."msg/err_msg");
            }
        } else {
            
$msg "ไม่สามารถอัพเดทข้อมูลนักศึกษาจากระบบทะเบียนได้ <br />กรุณาตรวจสอบการติดตั้ง cURL และ SimpleXML<br />ติดต่อผู้ดูแลระบบ";

            
$this->session->set_flashdata('msg'$msg);
            
redirect($this->config->item("rg_folder")."msg/err_msg");
        }

        
redirect($this->config->item("ea_folder")."import/importToEa");
    }

    function 
copy_Gen() {
        
//---[]--- start curl function
        
$url $this->config->item('url_reg2ea')."curl_generation";
        
$xmlStr "";
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_POSTtrue);
        
curl_setopt($chCURLOPT_POSTFIELDS$xmlStr);
        
curl_setopt($chCURLOPT_HTTPHEADER, array('Expect:'));
        
$rs curl_exec($ch);
        
$httpcode curl_getinfo($chCURLINFO_HTTP_CODE);
        
curl_close ($ch);
        
//---[]--- end curl function

        
$rs_gen simplexml_load_string($rs);

        
$this->load->model($this->config->item("ea_folder").'m_ea_generation','gen');

        
// เช็คข้อมูลมาครบหรือไม่
        
$firstNode $this->checkFirstNode($rs_gen);
        
$endNode $this->checkEndNode($rs_gen);

        if(
$firstNode==$endNode) {
            
$this->db->trans_begin();
            foreach(
$rs_gen as $key => $val) {
                if(
$val->genId!='') {
                    
$this->gen->genId $val->genId;
                    
$qu_gen $this->gen->get_by_key();

                    if(
$qu_gen->num_rows()==0) {
                        
$this->gen->genId $val->genId;
                        
$this->gen->genAcY $val->genAcY;
                        
$this->gen->genNo $val->genNo;
                        
$this->gen->genCurId $val->genCurId;
                        
$this->gen->genTmId $val->genTmId;
                        
$this->gen->insert();
                    }
                }
            }
            if(
$this->db->trans_status() === false) {
                
$this->db->trans_rollback();
                return 
"F";
            } else {
                
$this->db->trans_commit();
                return 
true;
            }
        } else {
            
// fail copy
            
return "F";
        }
    }

    function 
showStdList() {
        
$graduateY $this->input->post('graduateY');

        
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');

        
$con_rs_am = array('graduateYear'    => $graduateY);
        
$ord_rs_am = array('studentCode'    => '');
        
$rs_am $this->am->qryAmJoinAbPf($con_rs_am$ord_rs_am);

        
$this->contents['graduateY'] = $graduateY;
        
$this->contents['rs_am'] = $rs_am;

        
$this->output_detail($this->config->item("ea_folder")."v_showListStd");
    }

    
// นำเข้าแบบ csv
    
function importCSVToEa() {

        
$this->output($this->config->item("ea_folder")."v_importCSVToEa");
    }

    function 
process_importCSVToEa() {
        
$flgShow $this->input->post('flgShow');

        if(
$flgShow==1) {
            
$this->load->library('form_validation');
            
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
            
$this->form_validation->set_rules('uploadfile'' ''trim|xss_clean');

                
$config['upload_path'] = $this->config->item('ea_upload_csv');
                
$config['allowed_types'] = 'csv';
                
$config['max_width'] = '';    //$this->config->item('rg_allowed_width');
                
$config['max_height'] = '';    //$this->config->item('rg_allowed_height');
                
$config['max_size'] = '';    //$this->config->item('rg_upload_size');

                
$this->load->library('upload');

                foreach(
$_FILES as $key => $value) {
                    if(
$_FILES['uploadfile']['name']!="") {
                        
$config['file_name'] = "csv".date('dmY_His');

                        
$this->upload->initialize($config);
                        if (
$this->upload->do_upload($key)){
                            
$data = array('upload_data' => $this->upload->data());
                            
$path $data['upload_data']['file_name'];
                        } else {
                            
$error = array('error' => $this->upload->display_errors());
                            
$this->form_validation->set_rules('uploadfile'trim($error['error']), 'callback_checkupload');
                        }
                    } else {
                        
$this->form_validation->set_rules('uploadfile''กรุณาป้อน''callback_checkupload');
                    }
                }

            if(
$this->form_validation->run() == true) {
                
$this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
                
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
                
$this->load->model($this->config->item("ea_folder").'m_ea_curriculumdetails','curd');
                
$this->load->model($this->config->item("ea_folder").'m_programalumni','pa');

                
$arr = array();
                
$col = array();
                
$str read_file($this->config->item("ea_upload_csv").$path);
                
$lines explode("\r\n"$str);

                for(
$i=0$i count($lines); $i++) {
                    if (
$lines[$i]) {

                        
// ********* check colum **********
                        
$set_col preg_split("/,/"$lines[$i]);
                        
$k 0;
                        foreach(
$set_col as $key => $val) {
                            
$col[$key] = $val;
                            
$k++;
                        }
                        
// set 8 colum
                        
if($k 8) {
                            for(
$k$k<8$k++) {
                                
$col[$k] = "";
                            }
                        }
                        
// ********* check colum **********

                        
list($stdCode$pfName$stdName$stdSurname$admitAcY$graduateY$curName$programAlumni) = $col;

                        if(
$stdCode!="") {
                            
$con_rs_am = array('studentCode'    => iconv('TIS-620''UTF-8'trim($stdCode)));
                            
$rs_am $this->am->qryAm($con_rs_am);

                            if(
$rs_am->num_rows()==0) {
                                
$arr[$i]['stdCode'] = $stdCode;
                            } else {
                                
$arr[$i]['stdCode'] = "<span class='error'>** รหัสนักศึกษาซ้ำ **</span>";
                                
$fail 1;
                            }
                        } else {
                            
$arr[$i]['stdCode'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$pfName!="") {
                            
$con_rs_pf = array('prefixName'    => iconv('TIS-620''UTF-8'trim($pfName)));
                            
$rs_pf $this->pf->qryPf($con_rs_pf);

                            if(
$rs_pf->num_rows()) {
                                
$arr[$i]['pfName'] = iconv('TIS-620''UTF-8'trim($pfName));
                            } else {
                                
$arr[$i]['pfName'] = "<span class='error'>** กรุณาเพิ่ม ".iconv('TIS-620''UTF-8'trim($pfName))." **</span>";
                                
$fail 1;
                            }
                        } else {
                            
$arr[$i]['pfName'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$stdName!="") {
                            
$arr[$i]['stdName'] = iconv('TIS-620''UTF-8'trim($stdName));
                        } else {
                            
$arr[$i]['stdName'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$stdSurname!="") {
                            
$arr[$i]['stdSurname'] = iconv('TIS-620''UTF-8'trim($stdSurname));
                        } else {
                            
$arr[$i]['stdSurname'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$admitAcY!="") {
                            
$arr[$i]['admitAcY'] = iconv('TIS-620''UTF-8'trim($admitAcY));
                        } else {
                            
$arr[$i]['admitAcY'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$graduateY!="") {
                            
$arr[$i]['graduateY'] = iconv('TIS-620''UTF-8'trim($graduateY));
                        } else {
                            
$arr[$i]['graduateY'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        if(
$curName!="") {
                            
$tmpCurName iconv('TIS-620''UTF-8'trim($curName));
                            if(
$tmpCurName=="-") {
                                
$arr[$i]['curName'] = iconv('TIS-620''UTF-8'trim($curName));
                            } else {
                                
$con_rs_curd = array('curName'    => iconv('TIS-620''UTF-8'trim($curName)));
                                
$rs_curd $this->curd->qryCurd($con_rs_curd);

                                if(
$rs_curd->num_rows()) {
                                    
$arr[$i]['curName'] = iconv('TIS-620''UTF-8'trim($curName));
                                } else {
                                    
$arr[$i]['curName'] = "<span class='error'>** กรุณาเพิ่ม ".iconv('TIS-620''UTF-8'trim($curName))." **</span>";
                                    
$fail 1;
                                }
                            }
                        } else {
                            
$arr[$i]['curName'] = "-";
                        }

                        if(
$programAlumni!="") {
                            
$tmpProgramAlumni iconv('TIS-620''UTF-8'trim($programAlumni));
                            if(
$tmpProgramAlumni=="-") {
                                
$arr[$i]['programAlumni'] = iconv('TIS-620''UTF-8'trim($programAlumni));
                            } else {
                                
$con_rs_pa = array('programalumniName'    => iconv('TIS-620''UTF-8'trim($programAlumni)));
                                
$rs_pa $this->pa->qryPa($con_rs_pa);

                                if(
$rs_pa->num_rows()) {
                                    
$arr[$i]['programAlumni'] = iconv('TIS-620''UTF-8'trim($programAlumni));
                                } else {
                                    
$arr[$i]['programAlumni'] = "<span class='error'>** กรุณาเพิ่ม ".iconv('TIS-620''UTF-8'trim($programAlumni))." **</span>";
                                    
$fail 1;
                                }
                            }
                        } else {
                            
$arr[$i]['programAlumni'] = "-";
                        }

                        if(
$curName=="" && $programAlumni=="") {
                            
$arr[$i]['programAlumni'] = "<span class='error'>** กรุณาป้อน **</span>";
                            
$fail 1;
                        }

                        
// check หลักสูตรจากทะเบียน และศิษย์เก่า ห้าม - ทั้ง 2 ช่อง
                        
if($curName!="" && $programAlumni!="") {
                            
//if($tmpCurName==$tmpProgramAlumni) {
                            
if($tmpCurName=="-" && $tmpProgramAlumni=="-") {
                                
$arr[$i]['programAlumni'] = "<span class='error'>** กรุณาป้อน **</span>";
                                
$fail 1;
                            }
                        }
                        
// จบ check หลักสูตรจากทะเบียน และศิษย์เก่า ห้าม - ทั้ง 2 ช่อง

                    
}
                }

                
$this->contents['path'] = $path;
                
$this->contents['arr'] = $arr;
                
                if(isset(
$fail)) {
                    
$this->contents['fail'] = $fail;
                } else if(
count($arr)==0) {
                    
$this->contents['fail'] = 1;
                }

                
$this->output($this->config->item("ea_folder")."v_importCSVToEa");
            } else {
                
$this->importCSVToEa();
            }
        }
    }

    function 
insert_importCSVToEa() {
        
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
        
$this->load->model($this->config->item("ea_folder").'m_alumnibio','ab');
        
$this->load->model($this->config->item("ea_folder").'m_ea_curriculumdetails','curd');
        
$this->load->model($this->config->item("ea_folder").'m_programalumni','pa');
        
$this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');

        
$path $this->input->post('path');

        
$arr = array();
        
$id "";
        
$str read_file($this->config->item("ea_upload_csv").$path);
        
$lines explode("\r\n"$str);

        
$this->db->trans_begin();
        for(
$i=0$i count($lines); $i++) {
            if (
$lines[$i]) {
                
// ********* check colum **********
                
$set_col preg_split("/,/"$lines[$i]);
                
$k 0;
                foreach(
$set_col as $key => $val) {
                    
$col[$key] = $val;
                    
$k++;
                }
                
// set 8 colum
                
if($k 8) {
                    for(
$k$k<8$k++) {
                        
$col[$k] = "";
                    }
                }
                
// ********* check colum **********

                
list($stdCode$pfName$stdName$stdSurname$admitAcY$graduateY$curName$programAlumni) = $col;

                
$con_qu_am = array('studentCode'    => $stdCode);
                
$qu_am $this->am->qryAm($con_qu_am);
                if(
$qu_am->num_rows()==0) {
                    
$con_qu_curd = array('curName'    => iconv('TIS-620''UTF-8'trim($curName)));
                    
$qu_curd $this->curd->qryCurd($con_qu_curd);
                    if(
$qu_curd->num_rows()) {
                        
$row_curd $qu_curd->row();
                    }

                    
$con_qu_pf = array('prefixName'    => iconv('TIS-620''UTF-8'trim($pfName)));
                    
$qu_pf $this->pf->qryPf($con_qu_pf);
                    if(
$qu_pf->num_rows()) {
                        
$row_pf $qu_pf->row();
                    }

                    
$con_qu_pa = array('programalumniName'    => iconv('TIS620''UTF-8'trim($programAlumni)));
                    
$qu_pa $this->pa->qryPa($con_qu_pa);
                    if(
$qu_pa->num_rows()) {
                        
$row_pa $qu_pa->row();
                    }

                    
$this->am->alumniId '';
                    
$this->am->studentId 0;        // not null
                    
$this->am->studentCode iconv('TIS-620''UTF-8'trim($stdCode));
                    
$this->am->levelId = isset($row_curd) ? $row_curd->curElvId NULL;
                    
$this->am->programId = isset($row_curd) ? $row_curd->curId NULL;
                    
$this->am->prefixId $row_pf->prefixId;
                    
$this->am->studentName iconv('TIS-620''UTF-8'trim($stdName));
                    
$this->am->studentSurname iconv('TIS-620''UTF-8'trim($stdSurname));
                    
$this->am->studentNameEng '';
                    
$this->am->studentSurnameEng '';
                    
$this->am->creditAttempt 0;
                    
$this->am->creditSatisfy 0;
                    
$this->am->GPA 0;
                    
$this->am->admitAcadYear iconv('TIS-620''UTF-8'trim($admitAcY));
                    
$this->am->admitSemester 1;
                    
$this->am->admitDate '0000-00-00';
                    
$this->am->finishDate '0000-00-00';
                    
$this->am->studentPassword md5("O]O".iconv('TIS-620''UTF-8'trim($stdCode))."O[O");
                    
$this->am->studentEmail '';
                    
$this->am->studentYear '';
                    
$this->am->studentStatus 4;
                    
$this->am->officerId1 NULL;
                    
$this->am->officerId2 NULL;
                    
$this->am->financeStatus 0;    // not null
                    
$this->am->updateUserId $this->session->userdata('UsLogin');
                    
$this->am->updateDateTime date('Y-m-d H:i:s');
                    
$this->am->citizenId '';
                    
$this->am->graduateYear iconv('TIS-620''UTF-8'trim($graduateY));
                    
$this->am->genStatus 'Y';
                    
$this->am->genNo 0;            // not null
                    
$this->am->entryTypeId 0;        // not null
                    
$this->am->entryTypeId2 0;    // not null
                    
$this->am->studentSex $row_pf->defaultSex;
                    
$this->am->scholarId 0;        // not null
                    
$this->am->preAdmitPositionId NULL;
                    
$this->am->totalPoint 0;
                    
$this->am->honor NULL;
                    
$this->am->medal NULL;
                    
$this->am->exitExam 'Y';
                    
$this->am->studentStatusTmp 1;
                    
$this->am->importtoalumni 2;
                    
$this->am->glantId 'Y';
                    
$this->am->glantDate date('Y-m-d H:i:s');
                    
$this->am->glantreqDate date('Y-m-d H:i:s');
                    
$this->am->amAnsQn "N";
                    
$this->am->amProgramAlumni = isset($row_pa) ? $row_pa->programalumniId "";
                    
$this->am->insert();

                    
$this->ab->alumniId $this->am->last_insert_id;
                    
$this->ab->studentId 0;
                    
$this->ab->nationId NULL;
                    
$this->ab->religionId NULL;
                    
$this->ab->bloodGroup '';
                    
$this->ab->birthDate '0000-00-00';
                    
$this->ab->birthCntId 0;
                    
$this->ab->birthProvinceId NULL;
                    
$this->ab->homeAddress '';
                    
$this->ab->homeDistrictId NULL;
                    
$this->ab->homeAmphurId NULL;
                    
$this->ab->homeProvinceId NULL;
                    
$this->ab->homeZipcode '';
                    
$this->ab->homePhoneNo '';
                    
$this->ab->officeName '';
                    
$this->ab->workCntId 0;
                    
$this->ab->officeAddress '';
                    
$this->ab->officeDistrictId NULL;
                    
$this->ab->officeAmphurId NULL;
                    
$this->ab->officeProvinceId NULL;
                    
$this->ab->officeZipcode '';
                    
$this->ab->officePhoneNo '';
                    
$this->ab->workingStatus '';
                    
$this->ab->workingPosition '';
                    
$this->ab->workingSalary 0;
                    
$this->ab->fatherName '';
                    
$this->ab->fatherAddress '';
                    
$this->ab->fatherDistrictId 0;
                    
$this->ab->fatherAmphurId 0;
                    
$this->ab->fatherProvinceId 0;
                    
$this->ab->fatherZipcode '';
                    
$this->ab->fatherPhoneNo '';
                    
$this->ab->fatherOccupation '';
                    
$this->ab->fatherStatus 0;
                    
$this->ab->motherName '';
                    
$this->ab->motherAddress '';
                    
$this->ab->motherDistrictId NULL;
                    
$this->ab->motherAmphurId NULL;
                    
$this->ab->motherProvinceId NULL;
                    
$this->ab->motherZipcode '';
                    
$this->ab->motherPhoneNo '';
                    
$this->ab->motherOccupation '';
                    
$this->ab->motherStatus 0;
                    
$this->ab->studentSex $row_pf->defaultSex;
                    
$this->ab->parentName '';
                    
$this->ab->parentRelation '';
                    
$this->ab->parentAddress '';
                    
$this->ab->parentDistrictId NULL;
                    
$this->ab->parentAmphurId NULL;
                    
$this->ab->parentProvinceId NULL;
                    
$this->ab->parentZipcode '';
                    
$this->ab->parentPhoneNo '';
                    
$this->ab->parentMobile '';
                    
$this->ab->parentOcc '';
                    
$this->ab->parentIncome 0;
                    
$this->ab->parentEmail '';
                    
$this->ab->contactPerson '';
                    
$this->ab->contactAddress '';
                    
$this->ab->contactDistrictId NULL;
                    
$this->ab->contactAmphurId NULL;
                    
$this->ab->contactProvinceId NULL;
                    
$this->ab->contactZipcode '';
                    
$this->ab->contactPhoneNo '';
                    
$this->ab->cardExpiryDate '0000-00-00';
                    
$this->ab->currentCntId 0;
                    
$this->ab->currentAddress '';
                    
$this->ab->currentDistrictId NULL;
                    
$this->ab->currentAmphurId NULL;
                    
$this->ab->currentProvinceId NULL;
                    
$this->ab->currentZipcode '';
                    
$this->ab->currentPhoneNo '';
                    
$this->ab->graduateAddress '';
                    
$this->ab->graduateDistrictId NULL;
                    
$this->ab->graduateAmphurId NULL;
                    
$this->ab->graduateProvinceId NULL;
                    
$this->ab->graduateZipcode '';
                    
$this->ab->graduatePhoneNo '';
                    
$this->ab->maritalStatusId NULL;
                    
$this->ab->weight 0;
                    
$this->ab->height 0;
                    
$this->ab->picturePath 'photo.jpg';
                    
$this->ab->recruitmentTypeId NULL;
                    
$this->ab->occExamResult '';
                    
$this->ab->canRefund 'N';
                    
$this->ab->oldStudentName '';
                    
$this->ab->entryDegree NULL;
                    
$this->ab->healthPrivId NULL;
                    
$this->ab->o1prefixId '';
                    
$this->ab->o1fName '';
                    
$this->ab->o1lName '';
                    
$this->ab->o2prefixId '';
                    
$this->ab->o2fName '';
                    
$this->ab->o2lName '';
                    
$this->ab->regPrefix '';
                    
$this->ab->regStdName '';
                    
$this->ab->regStdSurname '';
                    
$this->ab->regStdNameE '';
                    
$this->ab->regStdSurnameE '';
                    
$this->ab->insert();

                    
// ***** นำศิษย์เก่าเข้า alumni_ums ***** //
                    
$importToUms $this->importToUms(iconv('TIS-620''UTF-8'trim($stdCode)), iconv('TIS-620''UTF-8'trim($stdName)), iconv('TIS-620''UTF-8'trim($stdSurname)));

                    
$id.= $this->am->last_insert_id.", ";
                }
            }
        }

        if(
$this->db->trans_status() === false) {
            
$this->db->trans_rollback();
            
$this->session->set_flashdata('flgSave'$this->config->item('ea_flgSave_22'));
            
$this->session->set_flashdata('keep'$id);
        } else {
            
$this->db->trans_commit();
            
$this->session->set_flashdata('flgSave'$this->config->item('ea_flgSave_10'));
            
$this->session->set_flashdata('keep'$id);
        }

        
redirect($this->config->item("ea_folder")."import/showCSVToEa");
    }
    function 
showCSVToEa() {
        
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');

        if(
$this->session->flashdata('keep')) {
            
$keep substr($this->session->flashdata('keep'), 0, -2);

            
$this->contents['rs_am'] = $this->am->qryAmByAlumniId($keep);
            
$this->contents['head'] = "รายชื่อนักศึกษาที่นำเข้าข้อมูลจากการอัพโหลดไฟล์";

            
$this->output($this->config->item("ea_folder")."v_showListToEa");
        } else {
            
redirect($this->config->item("ea_folder")."import/importCSVToEa");
        }
    }

    
// ฟังก์ชั่นเฉพาะกิจสำหรับนำเข้า alumni_ums ทำเพียงครั้งเดียวเท่านั้น
    
function updateAlumniUms_onetime() {
        
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');

        
$success false;
        
$rs_am $this->am->qryAmJoinAbPf();

        
$this->db->trans_begin();
        if(
$rs_am->num_rows()) {
            foreach(
$rs_am->result() as $row_am) {

                
$importToUms $this->importToUms(trim($row_am->studentCode), trim($row_am->studentName), trim($row_am->studentSurname));
                
$success $importToUms;
            }
        }
        if(
$this->db->trans_status() === false) {
            
$this->db->trans_rollback();
        } else {
            
$this->db->trans_rollback();
        }
    }
}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Shadow's tricks :D ::

Useful Commands
 
Warning. Kernel may be alerted using higher levels
Kernel Info:

:: Preddy's tricks :D ::

Php Safe-Mode Bypass (Read Files)

File:

eg: /etc/passwd

Php Safe-Mode Bypass (List Directories):

Dir:

eg: /etc/

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0199 ]--