Example #1
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 profile field.
        $field = array('id' => $_POST['curr'] == 'NEW' ? NULL : $_POST['curr'], 'name' => $_POST['name'], 'length' => $_POST['length'], 'html_disabled' => $_POST['html_disabled'], 'show_in_admin' => $_POST['show_in_admin']);
        $field = phorum_api_custom_profile_field_configure($field);
        if ($field === FALSE) {
            $error = phorum_api_strerror();
            $action = $_POST['curr'] == 'NEW' ? "create" : "update";
            phorum_admin_error("Failed to {$action} profile field: " . $error);
        } else {
            $action = $_POST['curr'] == 'NEW' ? "created" : "updated";
            phorum_admin_okmsg("Profile 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 profile field?
    <br/><br/>
    <form action="<?php 
Example #2
0
         // Tweak the file size for a generic upload error.
         $file["size"] = 0;
     }
 }
 // Some problems in uploading result in files which are
 // zero in size. We asume that people who upload zero byte
 // files will almost always have problems uploading. We simply
 // skip 0 byte files here, so after this loop we'll show a
 // generic upload error if no files were uploaded in the end.
 if ($file["size"] == 0) {
     continue;
 }
 // Let the file storage API run some upload access checks
 // (maximum attachment file size and file type).
 if (!phorum_api_file_check_write_access(array("link" => PHORUM_LINK_EDITOR, "filename" => $file["name"], "filesize" => $file["size"]))) {
     $PHORUM["DATA"]["ERROR"] = phorum_api_strerror();
     break;
 }
 // Check if the total cumulative attachment size isn't too large.
 if ($PHORUM["max_totalattachment_size"] > 0 && $file["size"] + $attach_totalsize > $PHORUM["max_totalattachment_size"] * 1024) {
     $PHORUM["DATA"]["ERROR"] = str_replace('%size%', phorum_filesize($PHORUM["max_totalattachment_size"] * 1024), $PHORUM["DATA"]["LANG"]["AttachTotalFileSize"]);
     break;
 }
 // Add the file data and user_id to the file info for the hook call.
 $file["data"] = @file_get_contents($file["tmp_name"]);
 $file["user_id"] = $PHORUM["user"]["user_id"];
 /*
  * [hook]
  *     before_attach
  *
  * [description]
Example #3
0
<?php

# Store a personal file for a user.
if (!defined('PHORUM')) {
    return;
}
require_once "./include/api/base.php";
require_once "./include/api/file_storage.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_strerror());
}