예제 #1
0
function put(&$vars)
{
    extract($vars);
    // save a revision
    $rec = $collection->MoveFirst();
    $Revision =& $db->model('Revision');
    $r = $Revision->base();
    $r->set_value('data', serialize($rec));
    $r->set_value('profile_id', get_profile_id());
    $r->set_value('target_id', $rec->entry_id);
    $r->save();
    if (isset($request->params['identity']['nickname'])) {
        $nick = strtolower($request->params['identity']['nickname']);
        $request->set_param(array('identity', 'nickname'), $nick);
        if ($profile->nickname == $nick) {
            // nickname did not change
        } else {
            global $prefix;
            // if post_notice is set it's a remote user and can share a nickname with a local user
            $sql = "SELECT nickname FROM " . $prefix . "identities WHERE nickname LIKE '" . $db->escape_string($nick) . "' AND (post_notice = '' OR post_notice IS NULL)";
            $result = $db->get_result($sql);
            if ($db->num_rows($result) > 0) {
                trigger_error('Sorry, that nickname is already being used.', E_USER_ERROR);
            }
        }
    } else {
    }
    if (isset($request->params['identity']['url'])) {
        if (strpos($request->params['identity']['url'], 'http') === false) {
            $request->params['identity']['url'] = 'http://' . $request->params['identity']['url'];
        }
    }
    if (isset($request->params['identity']['password'])) {
        $request->params['identity']['password'] = md5($request->params['identity']['password']);
    }
    $resource->update_from_post($request);
    $rec = $Identity->find($request->id);
    if (is_upload('identities', 'photo')) {
        $sql = "SELECT photo FROM " . $prefix . "identities WHERE id = " . $db->escape_string($request->id);
        $result = $db->get_result($sql);
        $upl = $_FILES['identity']['tmp_name']['photo'];
        $ext = '.' . type_of_image($upl);
        if (!$ext) {
            trigger_error("Sorry for the trouble, but your photo must be a JPG, PNG or GIF file.", E_USER_ERROR);
        }
        $content_type = type_of($ext);
        if ($blobval = $db->result_value($result, 0, "photo")) {
            $rec->set_value('avatar', $request->url_for(array('resource' => "_" . $rec->id)) . $ext);
        } elseif (exists_uploads_blob('identities', $rec->id)) {
            $rec->set_value('avatar', $request->url_for(array('resource' => "_" . $rec->id)) . $ext);
        } else {
            $rec->set_value('avatar', '');
        }
        if (empty($rec->profile)) {
            $rec->set_value('profile', $request->url_for(array('resource' => "_" . $rec->id)));
        }
        if (empty($rec->profile_url)) {
            $rec->set_value('profile_url', $request->url_for(array('resource' => "" . $rec->nickname)));
        }
        $rec->save_changes();
        $atomentry = $Identity->set_metadata($rec, $content_type, $rec->table, 'id');
    }
    broadcast_omb_profile_update();
    header_status('200 OK');
    redirect_to(base_url(true));
}
예제 #2
0
                    </tr>
                   <?php 
if (isset($table_list['list']) && is_array($table_list['list'])) {
    foreach ($table_list['list'] as $key => $val) {
        $alone_id = $val[$table . '_id'];
        $alone_field = $table . '_id';
        $extern_id = $filed_list['extern_id'];
        ?>
                   <tr>
						<?php 
        $i = 0;
        foreach ($val as $kk => $vv) {
            if ($i > 8) {
                break;
            }
            if (is_upload($_GET['extern_id'], $kk) && $vv != '') {
                $vv = '<img width="50" height="50" src="' . $vv . '">';
            } elseif ($i == 0) {
                $vv = '<center>' . helper::utf8_substr($vv, 0, 11) . '</center>';
            } elseif ($i == 1) {
                $action = $vv == 0 ? "屏蔽" : "通过";
                $vv = vars::get_field_str('is_check', $vv, 'html');
            } elseif ($i == 2) {
                $vv = date("Y-m-d H:i:s", $vv);
            } else {
                //$vv = helper :: utf8_substr($vv, 0, 10);
            }
            if (date_type($_GET['extern_id'], $kk)) {
                $vv = date("Y-m-d", intval($vv));
            }
            if ($i == 0) {
예제 #3
0
function post(&$vars)
{
    extract($vars);
    global $request;
    $modelvar = classify($request->resource);
    trigger_before('insert_from_post', ${$modelvar}, $request);
    $table = $request->resource;
    $content_type = 'text/html';
    $rec = ${$modelvar}->base();
    if (!${$modelvar}->can_create($table)) {
        trigger_error("Sorry, you do not have permission to " . $request->action . " " . $table, E_USER_ERROR);
    }
    $fields = ${$modelvar}->fields_from_request($request);
    $fieldlist = $fields[$table];
    foreach ($fieldlist as $field => $type) {
        if (${$modelvar}->has_metadata && is_blob($table . '.' . $field)) {
            if (isset($_FILES[strtolower(classify($table))]['name'][$field])) {
                $content_type = type_of($_FILES[strtolower(classify($table))]['name'][$field]);
            }
        }
        $rec->set_value($field, $request->params[strtolower(classify($table))][$field]);
    }
    $rec->set_value('profile_id', get_profile_id());
    $result = $rec->save_changes();
    if (!$result) {
        trigger_error("The record could not be saved into the database.", E_USER_ERROR);
    }
    $atomentry = ${$modelvar}->set_metadata($rec, $content_type, $table, 'id');
    ${$modelvar}->set_categories($rec, $request, $atomentry);
    if (is_upload($table, 'attachment')) {
        $upload_types = environment('upload_types');
        if (!$upload_types) {
            $upload_types = array('jpg', 'jpeg', 'png', 'gif');
        }
        $ext = extension_for(type_of($_FILES[strtolower(classify($table))]['name']['attachment']));
        if (!in_array($ext, $upload_types)) {
            trigger_error('Sorry, this site only allows the following file types: ' . implode(',', $upload_types), E_USER_ERROR);
        }
        $url = $request->url_for(array('resource' => $table, 'id' => $rec->id));
        $title = substr($rec->title, 0, 140);
        $over = strlen($title) + strlen($url) + 1 - 140;
        if ($over > 0) {
            $rec->set_value('title', substr($title, 0, -$over) . " " . $url);
        } else {
            $rec->set_value('title', $title . " " . $url);
        }
        $rec->save_changes();
        $tmp = $_FILES[strtolower(classify($table))]['tmp_name']['attachment'];
        if (is_jpg($tmp)) {
            $thumbsize = environment('max_pixels');
            $Thumbnail =& $db->model('Thumbnail');
            $t = $Thumbnail->base();
            $newthumb = tempnam("/tmp", "new" . $rec->id . ".jpg");
            resize_jpeg($tmp, $newthumb, $thumbsize);
            $t->set_value('target_id', $atomentry->id);
            $t->save_changes();
            update_uploadsfile('thumbnails', $t->id, $newthumb);
            $t->set_etag();
        }
    }
    trigger_after('insert_from_post', ${$modelvar}, $rec);
    header_status('201 Created');
    redirect_to($request->base);
}