Пример #1
0
function tdomf_create_dummy_user()
{
    $rand_username = "******" . tdomf_random_string(5);
    $rand_password = tdomf_random_string(8);
    tdomf_log_message("Attempting to create dummy user {$rand_username}");
    $user_id = wp_create_user($rand_username, $rand_password);
    $user = new WP_User($user_id);
    if ($user->has_cap("publish_posts")) {
        $user->remove_cap("publish_posts");
    }
    $users = get_option(TDOMF_OPTION_CREATEDUSERS);
    if ($users == false) {
        $users = array($user_id);
        add_option(TDOMF_OPTION_CREATEDUSERS, $users);
    } else {
        $users = array_merge($users, array($user_id));
        update_option(TDOMF_OPTION_CREATEDUSERS, $users);
    }
    update_option(TDOMF_DEFAULT_AUTHOR, $user_id);
    tdomf_log_message("Dummy user created for default author, user id = {$user_id}");
    return $user_id;
}
Пример #2
0
    }
}
// Create new security key
//
unset($form_data['tdomf_upload_key_' . $form_id . '_' . $index]);
tdomf_save_form_data($form_id, $form_data);
$form_data = tdomf_get_form_data($form_id);
//
if ($tdomf_verify == 'wordpress_nonce' && function_exists('wp_create_nonce')) {
    $nonce_string = wp_create_nonce('tdomf-form-upload-' . $form_id . '-' . $index);
    $form_data["tdomf_upload_key_" . $form_id . '_' . $index] = $nonce_string;
} else {
    if ($tdomf_verify == 'none') {
        // do nothing! Bad :(
    } else {
        $upload_key = tdomf_random_string(100);
        $form_data["tdomf_upload_key_" . $form_id . '_' . $index] = $upload_key;
    }
}
//
tdomf_save_form_data($form_id, $form_data);
$form_data = tdomf_get_form_data($form_id);
// Now the fun bit, the actually form!
//
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- <link rel="stylesheet" href="<?php 
bloginfo('stylesheet_url');
?>
 function preview($args, $options, $postfix = '')
 {
     extract($args);
     $form_data = tdomf_get_form_data($tdomf_form_id);
     // preview key
     //
     $tdomf_verify = get_option(TDOMF_OPTION_VERIFICATION_METHOD);
     if ($tdomf_verify == 'wordpress_nonce' && function_exists('wp_create_nonce')) {
         $nonce_string = wp_create_nonce('tdomf-form-upload-preview-' . $tdomf_form_id . '-' . $postfix);
         $form_data["tdomf_upload_preview_key_" . $tdomf_form_id . '_' . $postfix] = $nonce_string;
     } else {
         if ($tdomf_verify == 'none') {
             unset($form_data["tdomf_upload_preview_key_" . $tdomf_form_id . '_' . $postfix]);
         } else {
             $upload_key = tdomf_random_string(100);
             $form_data["tdomf_upload_preview_key_" . $tdomf_form_id . '_' . $postfix] = $upload_key;
         }
     }
     tdomf_save_form_data($tdomf_form_id, $form_data);
     $output = '';
     $theirfiles = $form_data['uploadfiles_' . $tdomf_form_id . '_' . $postfix];
     for ($i = 0; $i < $options['max']; $i++) {
         if (file_exists($theirfiles[$i]['path'])) {
             if (isset($form_data["tdomf_upload_preview_key_" . $tdomf_form_id . '_' . $postfix])) {
                 $uri = get_bloginfo('wpurl') . '/?tdomf_upload_preview=' . $i . "&key=" . $form_data["tdomf_upload_preview_key_" . $tdomf_form_id . '_' . $postfix] . "&form=" . $tdomf_form_id . '&index=' . $postfix;
             } else {
                 $uri = get_bloginfo('wpurl') . '/?tdomf_upload_preview=' . $i . "&form=" . $tdomf_form_id . '&index=' . $postfix;
             }
             if ($options['a']) {
                 $output .= "<p><a href=\"{$uri}\">" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($theirfiles[$i]['path'])) . ")</a></p>";
             }
             if ($options['img']) {
                 $output .= "<p><img src=\"{$uri}\" /></p>";
             }
         }
     }
     return $output;
 }
Пример #4
0
function tdomf_session_start()
{
    tdomf_session_cleanup();
    if (!isset($_COOKIE['tdomf_' . COOKIEHASH])) {
        #$session_key = tdomf_random_string(15);
        $session_key = uniqid(tdomf_random_string(3));
        return setcookie('tdomf_' . COOKIEHASH, $session_key, 0, COOKIEPATH, COOKIE_DOMAIN);
    }
    return true;
}