Ejemplo n.º 1
0
// Handle storing a newly uploaded file.
// ----------------------------------------------------------------------
if (!empty($_FILES) && is_uploaded_file($_FILES["newfile"]["tmp_name"])) {
    // Read in the uploaded file.
    if (!empty($_FILES["newfile"]["size"])) {
        $fp = fopen($_FILES["newfile"]["tmp_name"], "r");
        $file_data = fread($fp, $_FILES["newfile"]["size"]);
        fclose($fp);
    } else {
        $file_data = "";
    }
    // Create the file array for the file storage API.
    $file = array("user_id" => $PHORUM["user"]["user_id"], "filename" => $_FILES["newfile"]["name"], "filesize" => $_FILES["newfile"]["size"], "file_data" => $file_data, "link" => PHORUM_LINK_USER);
    // Store the file.
    if (!phorum_api_file_check_write_access($file) || !phorum_api_file_store($file)) {
        $PHORUM["DATA"]["ERROR"] = phorum_api_error_message();
    } else {
        $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["FileAdded"];
    }
} elseif (!empty($_POST["delete"])) {
    foreach ($_POST["delete"] as $file_id) {
        if (phorum_api_file_check_delete_access($file_id)) {
            phorum_api_file_delete($file_id);
        }
    }
}
// ----------------------------------------------------------------------
// Display the files for the current user.
// ----------------------------------------------------------------------
$files = $PHORUM['DB']->get_user_file_list($PHORUM["user"]["user_id"]);
$total_size = 0;
Ejemplo n.º 2
0
/**
 * @deprecated Replaced by {@link phorum_api_error->message()}.
 */
function phorum_api_strerror()
{
    return phorum_api_error_message();
}
Ejemplo n.º 3
0
<?php

# Store a personal file for a user.
require_once './include/api/file.php';
$file = array("filename" => "myfile.ext", "filesize" => 2048, "file_data" => $file_data, "link" => PHORUM_LINK_USER);
if (!phorum_api_file_check_write_access($file) || !phorum_api_file_store($file)) {
    die("Storing the file failed. The error was: " . phorum_api_error_message());
}
Ejemplo n.º 4
0
" />
            <input type="submit" name="restore" value="Restore deleted field" />
            <input type="submit" name="create" value="Create new field" />
          </form>
        </div>
        <?php 
            return;
        }
    }
    // $_POST could have been emptied in the previous code.
    if (count($_POST)) {
        // Create or update the custom field.
        $field = array('id' => $_POST['curr'] == 'NEW' ? NULL : $_POST['curr'], 'name' => $_POST['name'], 'field_type' => $_POST['field_type'], 'length' => $_POST['length'], 'html_disabled' => $_POST['html_disabled'], 'show_in_admin' => $_POST['show_in_admin']);
        $field = phorum_api_custom_field_configure($field);
        if ($field === FALSE) {
            $error = phorum_api_error_message();
            $action = $_POST['curr'] == 'NEW' ? "create" : "update";
            phorum_admin_error("Failed to {$action} custom field: " . $error);
        } else {
            $action = $_POST['curr'] == 'NEW' ? "created" : "updated";
            phorum_admin_okmsg("Custom field {$action}");
        }
    }
}
// Confirm deleting a profile field.
if (isset($_GET["curr"]) && isset($_GET["delete"])) {
    ?>
  <div class="PhorumInfoMessage">
    Are you sure you want to delete this custom field?
    <br/><br/>
    <form action="<?php