public function upload_photo()
 {
     if (!$this->session->userdata('access_token')) {
         redirect('login', 'refresh');
     } else {
         $data = $this->tq_admin_header_info();
         $adminHead_src = $data['admin_info']->adminHead_src;
         $userHeadSrc = $this->input->post('userHeadSrc');
         if (!empty($userHeadSrc) && $userHeadSrc == $adminHead_src) {
             $params['adminHeadSrc'] = $userHeadSrc;
         } else {
             $fileInfo = $_FILES['uploadphoto'];
             $uploadPath = "public/uploads/userHeadsrc";
             $msg_return = uploadFiles($fileInfo, $uploadPath);
             if (isset($msg_return['msg'])) {
                 $this->session->set_flashdata('error', $msg_return['msg']);
                 redirect('setPersonalData', 'refresh');
             } else {
                 $params['adminHeadSrc'] = $msg_return['newName'];
             }
             if (!empty($adminHead_src)) {
                 $file = '/var/www/html/church/church_admin/public/uploads/userHeadsrc/' . $adminHead_src;
                 if (file_exists($file)) {
                     !unlink($file);
                 }
             }
         }
         $params['admin_nick'] = $this->input->post('admin_nick');
         $params['gender'] = $this->input->post('gender');
         $params['admin_id'] = $this->session->userdata('admin_id');
         $url = API_BASE_LINK . 'personal/upload_admin_photo';
         $result = doCurl($url, $params, 'POST');
         if ($result && $result['http_status_code'] == 200) {
             $result = json_decode($result['output']);
             $content = $result->results;
             if ($content) {
                 $affected_id = $content->affected_id;
                 $adminHead_src_id = $content->adminHead_src_id;
                 if (isset($affected_id) && $adminHead_src_id) {
                     $this->session->set_flashdata('success', '资料修改成功!');
                 }
             } else {
                 $this->session->set_flashdata('error', '资料修改失败!');
             }
         } else {
             show_404();
             exit;
         }
         redirect('setPersonalData', 'refresh');
     }
 }
 //If user is logged, check for access level
 if ($_SESSION['access'] == 'S' or $_SESSION['access'] == 'U' or $_SESSION['access'] == 'A') {
     //once user is autheticated, check to see if this form has been submitted
     if (isset($_POST['_submit_check'])) {
         //form has been submitted
         //check for errors
         if (validateNewRefund() == 'valid') {
             //create user in db
             if (!isset($_POST['urgent'])) {
                 $_POST['urgent'] = 0;
             }
             $now = date("Y-m-d H:i:s");
             $query = "INSERT INTO refund (NG_enc_id, created_by, dt_request, urgent, amount, payable, \n\t\t\t\taddr_ln_1,addr_ln_2,city,state,zip,purpose,status,comments,assigned_to) \n\t\t\t\tVALUES ('{$_POST['enc_nbr']}','{$_SESSION['userid']}','{$now}',{$_POST['urgent']},\n\t\t\t\t'{$_POST['amount']}','{$_POST['payable']}','{$_POST['addr_ln_1']}','{$_POST['addr_ln_2']}',\n\t\t\t\t'{$_POST['city']}','{$_POST['state']}','{$_POST['zip']}','{$_POST['purpose']}','NEW','{$_POST['comments']}','{$_SESSION['userid']}')";
             $result = mysqli_query($db, $query);
             //actually upload any attachments that have been added with the refund
             uploadFiles();
             /*
             echo $query;
             var_dump($result);
             die();
             */
             //send notification that a new refund has been created
             $from = "Patient Refund <*****@*****.**>";
             $to = "Jonathan Bowley <*****@*****.**>";
             $subject = "New Patient Refund Request";
             $body = "Hello,\n\nA new patient refund request has been submitted. Please login to the Patient Refund web application to review.";
             $host = "ssl://smtpout.secureserver.net";
             $port = "465";
             $username = "******";
             $password = "******";
             /*
 public function post()
 {
     $upload = uploadFiles($this->options['param_name']);
     $info = array();
     foreach ($upload as $index => $uploadedFile) {
         $info[] = $this->handle_file_upload($uploadedFile, $index);
     }
     /*} elseif ($upload) {
               // param_name is a single object identifier like "file",
               // $_FILES is a one-dimensional array:
               $info[] = $this->handle_file_upload(
                   $upload['tmp_name'],
                   $upload['name'],
                   $upload['size'],
     		$upload['type'],
                   $upload['error'],
     		0
               ); 
           }*/
     header('Vary: Accept');
     $result = array();
     foreach ($info as $file) {
         if ($file["error"] === false) {
             $sessionArray = array();
             $sessionArray["file"] = $file;
             $sessionArray["fromDB"] = false;
             $sessionArray["deleted"] = false;
             $_SESSION["mupload_" . $this->formStamp][$file["usrName"]] = $sessionArray;
         }
         $userFile = $this->buildUserFile($file);
         if (!$userFile["isImg"]) {
             $userFile["isImg"] = true;
             $userFile["thumbnail_url"] = $userFile["url"] . "&icon=1";
         }
         $result[] = $userFile;
     }
     $json = my_json_encode($result);
     if (IsJSONAccepted()) {
         header('Content-type: application/json');
     } else {
         header('Content-type: text/plain');
     }
     echo $json;
 }
     } else {
         //adicionar
         $request->user_cadastro = $user->user_id;
         $request->user_lastupdate = $user->user_id;
         $request->reg_date_cadastro = date('Y-m-d H:i:s');
         $request->reg_date_lastupdate = date('Y-m-d H:i:s');
         $request = setDados((array) $request);
         $Read->setThis($request);
         $insert = $Read->Execute()->insert();
         if ($insert) {
             $regId = $Read->Execute()->MaxFild('reg_id');
             $Upload = new Upload();
             $regFile = new NcRegFile();
             $regImage = new NcRegImage();
             addOrigens($request->origens, $regId);
             uploadFiles($request->files, $regId);
             uploadImages($request->images, $regId);
         }
         $request->reg_id = $Read->Execute()->MaxFild("reg_id");
     }
     echo json_encode($request);
     break;
 case "DELETE":
     //deleta não implementado
     //deleta todos os arquivos deste registro
     $NcRegFile = new NcRegFile();
     $NcRegFile->setReg_id($id);
     $NcRegFile->Execute()->delete();
     //deleta todas as imagens deste registro
     $NcRegImage = new NcRegImage();
     $NcRegImage->setReg_id($id);
Exemple #5
0
         folderMove($_POST['name'], $_POST['path'], $_POST['where']);
     }
     break;
 case "folderDelete":
     if (isset($_POST['folder'])) {
         folderDelete($_POST['folder']);
     }
     break;
 case "newFolder":
     if (isset($_POST['name'], $_POST['path'])) {
         newFolder($_POST['name'], $_POST['path']);
     }
     break;
 case "fileUpload":
     if (isset($_POST['path'])) {
         uploadFiles($_POST['path']);
     }
     break;
 case "upload":
     if (isset($_POST['dir'])) {
         upload($_POST['dir']);
     }
     break;
 case "uploadSmart":
     uploadSmart();
     break;
 case "uploadAuth":
     if (isset($_POST['path'])) {
         uploadAuth($_POST['path']);
     }
     break;
<?php

// var_dump($_FILES);
require_once '../lib/string.func.php';
require_once 'upload.func.php';
header("content-type:text/html;charset=utf8;");
// foreach ($_FILES as $val) {
//     $info = uploadFile($val);
//     echo $info;
// }
$fileInfo = uploadFiles();
var_dump($fileInfo);
/**
 * Main method that parses POST and update details for given record ID
 *
 * @param int $recID
 */
function updateRecord($recID, $rtyID = null)
{
    // Update the given record.
    // This is non-trivial: so that the versioning stuff (achive_*) works properly
    // we need to separate this into updates, inserts and deletes.
    // We get the currect record details and compare them against the post
    // if the details id is in the post[dtyID][dtlID] then compare the values
    $recID = intval($recID);
    // Check that the user has permissions to edit it.
    $res = mysql_query("select * from Records" . " left join sysUsrGrpLinks on ugl_GroupID=rec_OwnerUGrpID" . " left join defRecTypes on rty_ID=rec_RecTypeID" . " where rec_ID={$recID} and (! rec_OwnerUGrpID or rec_OwnerUGrpID=" . get_user_id() . " or ugl_UserID=" . get_user_id() . ")");
    if (mysql_num_rows($res) == 0) {
        $res = mysql_query("select grp.ugr_Name from Records, " . USERS_DATABASE . ".sysUGrps grp where rec_ID={$recID} and grp.ugr_ID=rec_OwnerUGrpID");
        $grpName = mysql_fetch_row($res);
        $grpName = $grpName[0];
        print '({ error: "\\nSorry - you can\'t edit this record.\\nYou aren\'t in the ' . slash($grpName) . ' workgroup" })';
        return;
    }
    $record = mysql_fetch_assoc($res);
    /*****DEBUG****/
    error_log("save record dtls POST " . print_r($_POST, true));
    // Upload any files submitted ... (doesn't have to take place right now, but may as well)
    uploadFiles();
    //Artem: it does not work here - since we uploaded files at once
    // Get the existing records details and compare them to the incoming data
    $recDetails = getRecordDetails($recID);
    // find UPDATES - everything that is in current record and has a post value is treated as an update
    $recDetailUpdates = array();
    /*****DEBUG****/
    //error_log("save record dtls ".print_r($recDetails,true));
    foreach ($recDetails as $dtyID => $dtlIDs) {
        $eltName = "type:" . $dtyID;
        if (!(@$_POST[$eltName] && is_array($_POST[$eltName]))) {
            // element wasn't in POST: ignore it -this could be a non-rectype detail
            unset($recDetails[$dtyID]);
            // remove from details so it's not deleted
            continue;
        }
        if (count($_POST[$eltName]) == 0) {
            // element was in POST but without content: values have been deleted client-side (need to be deleted in DB so leave POST)
            continue;
        }
        $bdInputHandler = getInputHandlerForType($dtyID);
        //returns the particular handler (processor) for given field type
        foreach ($dtlIDs as $dtlID => $val) {
            /*****DEBUG****/
            //error_log(" in saveRecord details loop  $dtyID,  $dtlID, ".print_r($val,true));
            $eltID = "bd:" . $dtlID;
            $val = @$_POST[$eltName][$eltID];
            if (!$bdInputHandler->inputOK($val, $dtyID, $rtyID)) {
                /*****DEBUG****/
                //error_log(" in saveRecord update details value check error  $dtyID,  $dtlID, ".print_r($val,true));
                continue;
                // faulty input ... ignore
            }
            $toadd = $bdInputHandler->convertPostToMysql($val);
            /*****DEBUG****/
            //error_log(" in saveRecord update details value converted from $val to $toadd");
            if ($toadd == null) {
                continue;
            }
            $recDetailUpdates[$dtlID] = $toadd;
            $recDetailUpdates[$dtlID]["dtl_DetailTypeID"] = $dtyID;
            /*
            @TODO Since this function is utilized in (email)import we need to add verification of values according to detail type
            at the first for terms (enumeration field type)
            */
            unset($_POST[$eltName][$eltID]);
            // remove data from post submission
            if (count($_POST[$eltName]) == 0) {
                // if nothing left in post dtyID then remove it also
                unset($_POST[$eltName]);
            }
            unset($recDetails[$dtyID][$dtlID]);
            // remove data from local reflection of the database
        }
    }
    /*****DEBUG****/
    //error_log("save record dtls POST after updates removed ".print_r($_POST,true));
    /*****DEBUG****/
    //error_log("save record dtls after updates removed ".print_r($recDetails,true));
    // find DELETES
    // Anything left in recDetails now represents recDetails rows that need to be deleted
    $bibDetailDeletes = array();
    foreach ($recDetails as $dtyID => $dtlIDs) {
        foreach ($dtlIDs as $dtlID => $val) {
            array_push($bibDetailDeletes, $dtlID);
        }
    }
    // find INSERTS
    // Try to insert anything left in POST as new recDetails rows
    $bibDetailInserts = array();
    /*****DEBUG****/
    error_log(" in saveRecord checking for inserts  _POST =" . print_r($_POST, true));
    foreach ($_POST as $eltName => $bds) {
        // if not properly formatted or empty or an empty array then skip it
        if (!preg_match("/^type:\\d+\$/", $eltName) || !$_POST[$eltName] || count($_POST[$eltName]) == 0) {
            continue;
        }
        $dtyID = substr($eltName, 5);
        $bdInputHandler = getInputHandlerForType($dtyID);
        foreach ($bds as $eltID => $val) {
            if (!$bdInputHandler->inputOK($val, $dtyID, $rtyID)) {
                /*****DEBUG****/
                //error_log(" in saveRecord insert details value check error for $eltName,  $eltID, ".print_r($val,true));
                continue;
                // faulty input ... ignore
            }
            $newBibDetail = $bdInputHandler->convertPostToMysql($val);
            $newBibDetail["dtl_DetailTypeID"] = $dtyID;
            $newBibDetail["dtl_RecID"] = $recID;
            /*****DEBUG****/
            //error_log("new detail ".print_r($newBibDetail,true));
            array_push($bibDetailInserts, $newBibDetail);
            unset($_POST[$eltName][$eltID]);
            // remove data from post submission
        }
    }
    // Anything left in POST now is stuff that we have no intention of inserting ... ignore it
    // We now have:
    //  - $recDetailUpdates: an assoc. array of dtl_ID => column values to be updated in recDetails
    //  - $bibDetailInserts: an array of column values to be inserted into recDetails
    //  - $bibDetailDeletes: an array of dtl_ID values corresponding to rows to be deleted from recDetails
    // Commence versioning ...
    mysql_query("start transaction");
    $recUpdates = array("rec_Modified" => array("now()"), "rec_FlagTemporary" => 0);
    $recUpdates["rec_ScratchPad"] = $_POST["notes"];
    if (intval(@$_POST["rectype"])) {
        $recUpdates["rec_RecTypeID"] = intval($_POST["rectype"]);
    }
    if (array_key_exists("rec_url", $_POST)) {
        $recUpdates["rec_URL"] = $_POST["rec_url"];
    }
    $owner = $record['rec_OwnerUGrpID'];
    if (is_admin() || is_admin('group', $owner) || $owner == get_user_id()) {
        // must be grpAdmin or record owner to changes ownership or visibility
        if (array_key_exists("rec_owner", $_POST)) {
            $recUpdates["rec_OwnerUGrpID"] = $_POST["rec_owner"];
        }
        if (array_key_exists("rec_visibility", $_POST)) {
            $recUpdates["rec_NonOwnerVisibility"] = $_POST["rec_visibility"];
        } else {
            if ($record['rec_NonOwnerVisibility'] == 'public' && HEURIST_PUBLIC_TO_PENDING) {
                $recUpdates["rec_NonOwnerVisibility"] = 'pending';
            }
        }
    }
    /*****DEBUG****/
    error_log(" in saveRecord update recUpdates = " . print_r($recUpdates, true));
    mysql__update("Records", "rec_ID={$recID}", $recUpdates);
    $biblioUpdated = mysql_affected_rows() > 0 ? true : false;
    if (mysql_error()) {
        error_log("error rec update" . mysql_error());
    }
    $updatedRowCount = 0;
    foreach ($recDetailUpdates as $bdID => $vals) {
        /*****DEBUG****/
        error_log(" in saveRecord update details dtl_ID = {$bdID} value =" . print_r($vals, true));
        mysql__update("recDetails", "dtl_ID={$bdID} and dtl_RecID={$recID}", $vals);
        if (mysql_affected_rows() > 0) {
            ++$updatedRowCount;
        }
    }
    if (mysql_error()) {
        error_log("error detail updates" . mysql_error());
    }
    $insertedRowCount = 0;
    foreach ($bibDetailInserts as $vals) {
        /*****DEBUG****/
        error_log(" in saveRecord insert details detail =" . print_r($vals, true));
        mysql__insert("recDetails", $vals);
        if (mysql_affected_rows() > 0) {
            ++$insertedRowCount;
        }
    }
    if (mysql_error()) {
        error_log("error detail inserts" . mysql_error());
    }
    $deletedRowCount = 0;
    if ($bibDetailDeletes) {
        /*****DEBUG****/
        error_log(" in saveRecord delete details " . print_r($bibDetailDeletes, true));
        mysql_query("delete from recDetails where dtl_ID in (" . join($bibDetailDeletes, ",") . ") and dtl_RecID={$recID}");
        if (mysql_affected_rows() > 0) {
            $deletedRowCount = mysql_affected_rows();
        }
    }
    if (mysql_error()) {
        error_log("error detail deletes" . mysql_error());
    }
    // eliminate any duplicated lines
    $notesIn = explode("\n", str_replace("\r", "", $_POST["notes"]));
    $notesOut = "";
    $notesMap = array();
    for ($i = 0; $i < count($notesIn); ++$i) {
        if (!@$notesMap[$notesIn[$i]] || !$notesIn[$i]) {
            // preserve blank lines
            $notesOut .= $notesIn[$i] . "\n";
            $notesMap[$notesIn[$i]] = true;
        }
    }
    $_POST["notes"] = preg_replace("/\n\n+/", "\n", $notesOut);
    if ($updatedRowCount > 0 || $insertedRowCount > 0 || $deletedRowCount > 0 || $biblioUpdated) {
        /* something changed: update the records title and commit all changes */
        $title_check = check_title_mask2($record["rty_TitleMask"], $record["rec_RecTypeID"], true);
        if ($title_check != '') {
            $new_title = "Please go to Designer View > Essentials > Record types/fields and edit the title mask for this record type";
        } else {
            $new_title = fill_title_mask($record["rty_TitleMask"], $record["rec_ID"], $record["rec_RecTypeID"]);
        }
        mysql_query("update Records\n                set rec_Title = '" . addslashes($new_title) . "'\n                where rec_ID = {$recID}");
        mysql_query("commit");
        // Update memcached's copy of record (if it is cached)
        updateCachedRecord($recID);
        return true;
    } else {
        /* nothing changed: rollback the transaction so we don't get false versioning */
        mysql_query("rollback");
        return false;
    }
}
Exemple #8
0
 if (!isset($_POST['urgent'])) {
     $_POST['urgent'] = 0;
 }
 //echo 'ive reached the DB insert <br>';
 //include 'dump_all_page_contents.php';
 //create user in db
 $now = date("Y-m-d H:i:s");
 $query = "INSERT INTO refund (NG_enc_id, created_by, dt_request, urgent, amount, payable, \n\t\t\t\taddr_ln_1,addr_ln_2,city,state,zip,purpose,status,comments,assigned_to,refund_type) \n\t\t\t\tVALUES ('{$_POST['encounters'][0]}','{$_SESSION['userid']}','{$now}',{$_POST['urgent']},\n\t\t\t\t'{$_POST['amount']}','{$_POST['payable']}','{$_POST['addr_ln_1']}','{$_POST['addr_ln_2']}',\n\t\t\t\t'{$_POST['city']}','{$_POST['state']}','{$_POST['zip']}','{$_POST['purpose']}','NEW','{$_POST['comments']}','{$_SESSION['userid']}','{$_POST['refund_type']}')";
 $result = mysqli_query($db, $query);
 $last_id = mysqli_insert_id($db);
 $auto_increment = $last_id++;
 //reset auto increment id in case of errors
 $query_resetAutoIncrement = "ALTER TABLE refund AUTO_INCREMENT = '{$auto_increment}'";
 $result = mysqli_query($db, $query_resetAutoIncrement);
 //upload any attachments that have been added with the refund
 $successfulUpload = uploadFiles($last_id);
 if ($successfulUpload == 1) {
     //echo '<br> do I get here';
     if (sizeof($_POST['encounters']) > 1) {
         foreach ($_POST['encounters'] as $key => $value) {
             if (strlen($value) > 0) {
                 //if there was actually a number entered into the encounter field
                 $queryManyEncounters = "INSERT INTO \n\t\t\t\t\t\t\trefund_manyEncounters \n\t\t\t\t\t\t\t(Encounter_ID, refund_ID) \n\t\t\t\t\t\t\tVALUES ('{$value}','{$last_id}')";
                 $result = mysqli_query($db, $queryManyEncounters);
             }
         }
     }
     //die();
     //send notification that a new refund has been created: call mail_presets
     //RULE: ON Creation:
     //IF urgent status email both creator and Erika, otherwise just email Erika///////////////////////////////////////////
function fileManager()
{
    if ($_SESSION['adminType'] == 'sadmin') {
        $fileManPath = RAZOR_SADMIN_PATH;
    } else {
        $fileManPath = RAZOR_FILEMAN_PATH;
    }
    // set upload limits if server permits //
    @ini_set('upload_max_filesize', '100M');
    @ini_set('post_max_size', '105M');
    @ini_set('memory_limit', '205M');
    @ini_set('max_execution_time', '300');
    // end of set //
    $dirToView = '';
    $dirFound = false;
    $fileFound = false;
    if (isset($_GET['dir']) && $_GET['dir']) {
        // get sub dir from url //
        $subDir = $_GET['dir'];
        // ensure no one has injected url, force to correct format //
        // IMPORTANT - TO PREVENT ACCESS TO OTHER AREAS ON SERVER //
        $subDir = str_replace('/', '>', $subDir);
        $subDir = str_replace('..', '', $subDir);
        // change to path format //
        $subDir = str_replace('>', '/', $subDir);
        if (is_dir(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $subDir)) {
            $dirToView = $subDir . '/';
            $dirFound = true;
        } elseif (file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $subDir)) {
            $dirToView = $subDir;
            $fileFound = true;
        }
        // remove user level ability to do anything with restricted files //
        if ($_SESSION['adminType'] == 'user') {
            $noAccessArray = noReadWriteAccess();
            if (in_array($dirToView, $noAccessArray)) {
                return;
            }
        }
    }
    if (isset($_GET['del']) && $_GET['del']) {
        if ($dirFound) {
            $dirArray = array();
            if (substr($dirToView, -1) == '/') {
                $dirToView = substr($dirToView, 0, -1);
            }
            $dirArray = explode('/', $dirToView);
            array_pop($dirArray);
            $verifyDir = implode('/', $dirArray) . '/';
            if (is_dir(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $verifyDir)) {
                $dirDelRes = deleteDirR($fileManPath . $dirToView);
                if (!$dirDelRes) {
                    MsgBox(lt('Folder and contents deleted') . '...', 'greenbox');
                } else {
                    MsgBox(lt('Error deleting folder and contents') . '...', 'redbox');
                }
                $dirToView = $verifyDir;
            }
        } elseif ($fileFound) {
            $verifyFile = str_replace(basename($dirToView), '', $dirToView);
            if (is_dir(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $verifyFile)) {
                deleteFile($fileManPath . $dirToView);
                $dirToView = $verifyFile;
            }
        }
    }
    if (isset($_POST['upload'])) {
        uploadFiles();
    }
    if (isset($_POST['rename'])) {
        renameFileDir();
    }
    if (isset($_POST['copy'])) {
        copyFileDir();
    }
    if (isset($_POST['move'])) {
        moveFileDir();
    }
    if (isset($_POST['createnewdir'])) {
        createNewDir();
    }
    if (isset($_POST['edit'])) {
        editFile();
    }
    $filesPath = getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $dirToView;
    if (is_dir($filesPath)) {
        if (isset($_GET['up']) && $_GET['up']) {
            displayFileUpload($dirToView);
        } elseif (isset($_GET['ren']) && $_GET['ren']) {
            displayRenameFileDir($dirToView, false);
        } elseif (isset($_GET['cop']) && $_GET['cop']) {
            displayCopyFileDir($dirToView, false);
        } elseif (isset($_GET['mov']) && $_GET['mov']) {
            displayMoveFileDir($dirToView, false);
        } elseif (isset($_GET['newdir']) && $_GET['newdir']) {
            displayCreateNewDir($dirToView);
        } else {
            $readFiles = array();
            $readFiles = readDirContents($filesPath);
            BsocketB('admin-datastore-data', array(&$filesPath, &$readFiles));
            displayDirContents($readFiles, $dirToView);
        }
    } elseif (file_exists($filesPath)) {
        if (isset($_GET['ren']) && $_GET['ren']) {
            displayRenameFileDir($dirToView, true);
        } elseif (isset($_GET['cop']) && $_GET['cop']) {
            displayCopyFileDir($dirToView, true);
        } elseif (isset($_GET['mov']) && $_GET['mov']) {
            displayMoveFileDir($dirToView, true);
        } elseif (isset($_GET['edit']) && $_GET['edit']) {
            displayEditFile($dirToView);
        } else {
            displayFileType($dirToView);
        }
    }
}
Exemple #10
0
 public function post()
 {
     $upload = uploadFiles($this->options['param_name']);
     $info = array();
     if ($upload && is_array($upload['tmp_name'])) {
         // param_name is an array identifier like "files[]",
         // $_FILES is a multi-dimensional array:
         foreach ($upload['tmp_name'] as $index => $value) {
             $info[] = $this->handle_file_upload($upload['tmp_name'][$index], $upload['name'][$index], $upload['size'][$index], $upload['type'][$index], $upload['error'][$index], $index);
         }
     } elseif ($upload) {
         // param_name is a single object identifier like "file",
         // $_FILES is a one-dimensional array:
         $info[] = $this->handle_file_upload($upload['tmp_name'], $upload['name'], $upload['size'], $upload['type'], $upload['error'], 0);
     }
     header('Vary: Accept');
     $result = array();
     foreach ($info as $file) {
         if ($file["error"] === false) {
             //$file["name"] = $this->options['upload_url_nonabsolute'].$file["name"];
             //if($file["thumbnail"] != "")
             //	$file["thumbnail"] = $this->options['upload_url_nonabsolute'].$file["thumbnail"];
             $_SESSION["mupload_" . $this->formStamp][$file["usrName"]] = array();
             $_SESSION["mupload_" . $this->formStamp][$file["usrName"]]["file"] = $file;
             $_SESSION["mupload_" . $this->formStamp][$file["usrName"]]["fromDB"] = false;
             $_SESSION["mupload_" . $this->formStamp][$file["usrName"]]["deleted"] = false;
         }
         $userFile = $this->buildUserFile($file);
         if (!$userFile["isImg"]) {
             $userFile["isImg"] = true;
             $userFile["thumbnail_url"] = $userFile["url"] . "&icon=1";
         }
         $result[] = $userFile;
     }
     $json = my_json_encode($result);
     if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
         header('Content-type: application/json');
     } else {
         header('Content-type: text/plain');
     }
     echo $json;
 }
Exemple #11
0
                $fileName[$i] = "copy-" . $fileName[$i];
            }
            $uploadFile = $uploadDir . basename($fileName[$i]);
            if ($fileTmpName[$i]) {
                if (copy($fileTmpName[$i], $uploadFile)) {
                    echo "<h3>Файл " . $fileName[$i] . " успешно загружен на сервер</h3>";
                } else {
                    echo "<h3>Ошибка! Не удалось загрузить файл на сервер!</h3>";
                }
            } else {
                echo "Файл " . $fileName[$i] . " НЕ загружен на сервер. Файл поврежден. ";
            }
        }
    }
}
uploadFiles($uploadDir);
$col = 5;
echo "<table>";
if (is_dir($uploadDir)) {
    if ($dh = opendir($uploadDir)) {
        while (($file = readdir($dh)) !== false) {
            if (filetype($uploadDir . $file) != "dir") {
                $arr[] = $uploadDir . $file;
            }
        }
    }
    closedir($dh);
}
if ($arr) {
    echo "<pre>";
    //        var_dump($arr);
    changeRuntime($uid, $pid, $notes);
    header("Location: " . URL . "/puzzle.php?pid={$pid}");
    exit(0);
}
if (isset($_POST['changeWikiPage'])) {
    $pid = $_POST['pid'];
    $wikiPage = $_POST['wikiPage'];
    changeWikiPage($uid, $pid, $wikiPage);
    header("Location: " . URL . "/puzzle.php?pid={$pid}");
    exit(0);
}
if (isset($_POST['uploadFile'])) {
    $pid = $_POST['pid'];
    $type = $_POST['filetype'];
    $file = $_FILES['fileupload'];
    uploadFiles($uid, $pid, $type, $file);
    header("Location: " . URL . "/puzzle.php?pid=" . $pid);
    exit(0);
}
if (isset($_POST['addcomment'])) {
    $pid = $_POST['pid'];
    $comment = $_POST['comment'];
    addComment($uid, $pid, $comment, FALSE, FALSE, TRUE);
    header("Location: " . URL . "/puzzle.php?pid=" . $pid);
    exit(0);
}
if (isset($_POST['requestTestsolve'])) {
    $pid = $_POST['pid'];
    $notes = $_POST['notes'];
    requestTestsolve($uid, $pid, $notes);
    header("Location: " . URL . "/puzzle.php?pid=" . $pid);
 // Buffer the upcoming output
 ob_start();
 include '../request_submitted.html';
 // Get the size of the output
 $outputSize = ob_get_length();
 // Send telling the browser to close the connection
 header("Content-Encoding: none\r\n");
 header("Content-Length: {$outputSize}");
 header("Connection: close\r\n");
 // Flush all output
 ob_end_flush();
 ob_flush();
 flush();
 //Creating folders and uploading files in the background
 createFolders($drive_service, $client, $configObj, $UsersAFSObj);
 uploadFiles($drive_service, $client, $configObj, $UsersAFSObj);
 //Get total files and folders for notification script
 $totalFolders = count($UsersAFSObj->folderList);
 $totalFiles = count($UsersAFSObj->fileList);
 $numFolders = $UsersAFSObj->numFoldersUploaded;
 $numFiles = $UsersAFSObj->numFilesUploaded;
 $failedFiles = $UsersAFSObj->failedFiles;
 $choice = 'drive';
 $logline = date('Y-m-d H:i:s') . ": upload complete! \n";
 fwrite($configObj->logFile, $logline);
 //Send user an email with the results of the transfer
 include '../notification_email.php';
 if ($totalFolders == $numFolders && $totalFiles == $numFiles) {
     //Delete log file if upload was successful
     unlink($logfileName);
 }