Пример #1
0
<?php

global $cgi;
loader_import('cms.Workflow.Lock');
lock_init();
if (lock_exists($cgi->_collection, $cgi->_key)) {
    page_title(intl_get('Item Locked by Another User'));
    echo '<p><a href="javascript: history.go (-1)">' . intl_get('Back') . '</a></p>';
    echo template_simple(LOCK_INFO_TEMPLATE, lock_info($cgi->_collection, $cgi->_key));
    return;
} else {
    lock_add($cgi->_collection, $cgi->_key);
}
class SitestudyEditForm extends MailForm
{
    function SitestudyEditForm()
    {
        parent::MailForm();
        $this->parseSettings('inc/app/sitestudy/forms/edit/settings.php');
        global $page, $cgi;
        page_title(intl_get('Editing Case Study') . ': ' . $cgi->_key);
        loader_import('ext.phpsniff');
        $sniffer = new phpSniff();
        $this->_browser = $sniffer->property('browser');
        // include formhelp, edit panel init, and cancel handler
        page_add_script(site_prefix() . '/js/formhelp.js');
        page_add_script(CMS_JS_FORMHELP_INIT);
        page_onload('cms_init_edit_panels ()');
        page_add_script('
			function cms_cancel_unlock (f, collection, key) {
				if (arguments.length == 0) {
Пример #2
0
 /**
  * LOCK method handler
  *
  * @param  array  general parameter passing array
  * @return bool   true on success
  */
 function LOCK(&$options)
 {
     // get absolute fs path to requested resource
     $options['path'] = strtolower($this->_path());
     $fspath = $this->base . $options["path"];
     loader_import('cms.Workflow.Lock');
     lock_init();
     if ($this->checkLock($options['path'], $options['locktoken'])) {
         $this->_debug(__LINE__, 409, 'Locked: ' . $options['path']);
         return '423 Locked';
     }
     if (@is_dir($fspath)) {
         $info = lock_info('sitellite_filesystem', trim($options['path'], '/'));
         if ($info) {
             if (lock_update('sitellite_filesystem', trim($options['path'], '/'))) {
                 $options['owner'] = $info->user;
                 $options['scope'] = 'exclusive';
                 $options['type'] = 'write';
                 $options['timeout'] = time() + appconf('lock_timeout');
                 $options['locktoken'] = $info->token;
                 return '200 OK';
             }
         } elseif (local_add('sitellite_filesystem', trim($options['path'], '/'), $options['locktoken'])) {
             $info = lock_info('sitellite_filesystem', trim($options['path'], '/'));
             $options['owner'] = $info->user;
             $options['scope'] = 'exclusive';
             $options['type'] = 'write';
             $options['timeout'] = time() + appconf('lock_timeout');
             return '200 OK';
         }
         $this->_debug(__LINE__, 409, 'Locked: ' . $options['path']);
         return '409 Conflict';
     } else {
         $info = lock_info('sitellite_filesystem', trim($options['path'], '/'));
         if ($info) {
             if (lock_update('sitellite_filesystem', trim($options['path'], '/'))) {
                 $options['owner'] = $info->user;
                 $options['scope'] = 'exclusive';
                 $options['type'] = 'write';
                 $options['timeout'] = time() + appconf('lock_timeout');
                 $options['locktoken'] = $info->token;
                 return '200 OK';
             }
         } elseif (lock_add('sitellite_filesystem', trim($options['path'], '/'), $options['locktoken'])) {
             $info = lock_info('sitellite_filesystem', trim($options['path'], '/'));
             $options['owner'] = $info->user;
             $options['scope'] = 'exclusive';
             $options['type'] = 'write';
             $options['timeout'] = time() + appconf('lock_timeout');
             return '200 OK';
         }
         $this->_debug(__LINE__, 409, 'Locked: ' . $options['path']);
         return '409 Conflict';
     }
 }
Пример #3
0
$form = new SitewikiEditForm();
if ($form->editable && !isset($cgi->editing)) {
    if (!session_valid()) {
        global $session;
        $session->username = '';
    }
    if (lock_exists('sitewiki_page', $cgi->page)) {
        if ($cgi->break_lock == 1) {
            lock_remove('sitewiki_page', $cgi->page);
            if (!session_valid()) {
                $session->username = '******';
            }
            lock_add('sitewiki_page', $cgi->page);
        } else {
            $info = lock_info('sitewiki_page', $cgi->page);
            loader_import('saf.Date');
            $now = time();
            $then = Date::toUnix($info->expires) - 3600;
            $diff = $now - $then;
            $info->min = round($diff / 60);
            echo template_simple('locked.spt', $info);
            return;
        }
    } else {
        if (!session_valid()) {
            $session->username = '******';
        }
        lock_add('sitewiki_page', $cgi->page);
    }
}
echo $form->run();
Пример #4
0
     $path = webfiles_request();
     if (!file_exists($prefix . $path)) {
         webfiles_error(404, 'Not found');
     }
     //if (is_dir ($prefix . $path)) {
     //	webfiles_error (500, 'Locks not supported on directories');
     //}
     // it's someone else's lock
     $lock = webfiles_lock($path);
     if ($lock && $lock->owner != session_username()) {
         webfiles_error(409, 'Conflict');
     }
     //if (lock_exists ('sitellite_filesystem', ltrim ($path, '/'))) {
     //	webfiles_error (409, 'Conflict');
     //}
     if (!lock_add('sitellite_filesystem', trim($path, '/'))) {
         webfiles_error(500, 'Internal server error');
     }
     webfiles_response((object) array('owner' => session_username(), 'expires' => date('Y-m-d H:i:s', time() + 3600)));
     break;
 case 'unlock':
     $path = webfiles_request();
     if (!file_exists($prefix . $path)) {
         webfiles_error(404, 'Not found');
     }
     //if (is_dir ($prefix . $path)) {
     //	webfiles_error (500, 'Locks not supported on directories');
     //}
     // it's someone else's lock
     $lock = webfiles_lock($path);
     if ($lock && $lock->owner != session_username()) {