Changeset 361
- Timestamp:
- 03/20/08 12:39:43 (16 years ago)
- Location:
- plugins/previewpost
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/previewpost/_admin.php
r356 r361 21 21 # 22 22 # ***** END LICENSE BLOCK ***** 23 require dirname(__FILE__).'/_widgets.php'; 23 24 24 25 $core->addBehavior('adminPostHeaders',array('previewBehaviors','postHeaders')); … … 29 30 { 30 31 global $post_url,$core; 31 return '<script type="text/javascript" src="index.php?pf=preview post/js/post.js"></script>'.32 return '<script type="text/javascript" src="index.php?pf=preview/js/post.js"></script>'. 32 33 '<script type="text/javascript">'."\n". 33 34 "//<![CDATA[\n". -
plugins/previewpost/_define.php
r356 r361 23 23 24 24 $this->registerModule( 25 /* Name */ "Preview Post",25 /* Name */ "Preview", 26 26 /* Description*/ "Public part post Preview for Dotclear2", 27 27 /* Author */ "Bruno Hondelatte", 28 /* Version */ ' 0.2',28 /* Version */ 'SVN', 29 29 /* Permissions */ 'usage,contentadmin' 30 30 ); -
plugins/previewpost/_prepend.php
r356 r361 23 23 24 24 $GLOBALS['core']->url->register('preview','preview','^preview/(.+)$',array('urlPreview','post')); 25 $GLOBALS['core']->url->register('public_auth','public_auth','^login$',array('urlPreview','login')); 25 26 26 27 ?> -
plugins/previewpost/_public.php
r356 r361 21 21 # 22 22 # ***** END LICENSE BLOCK ***** 23 24 require dirname(__FILE__).'/_widgets.php'; 25 $core->addBehavior('publicPrepend',array('PreviewBehavior','publicPrepend')); 26 27 $core->tpl->addValue('EntryIfOffline',array('tplPreview','EntryIfOffline')); 23 28 24 29 class urlPreview extends dcUrlHandlers … … 68 73 exit; 69 74 } 75 76 public static function login($args) 77 { 78 global $core; 79 if (!isset($_POST['user_id']) || !isset($_POST['user_pwd'])) { 80 header('Location: '.$core->blog->url); 81 return; 82 } 83 $user_id=$_POST['user_id']; 84 $user_pwd = $_POST['user_pwd']; 85 if ($core->auth->checkUser($user_id,$user_pwd) === true) { 86 $core->session->start(); 87 $_SESSION['sess_user_id'] = $user_id; 88 $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 89 90 if (!empty($_POST['blog'])) { 91 $_SESSION['sess_blog_id'] = $_POST['blog']; 92 } 93 if (!empty($_POST['user_remember'])) 94 { 95 $cookie_admin = 96 http::browserUID(DC_MASTER_KEY.$user_id.crypt::hmac(DC_MASTER_KEY,$user_pwd)). 97 bin2hex(pack('a32',$user_id)); 98 99 setcookie('dc_admin',$cookie_admin,strtotime('+15 days'),'','',DC_ADMIN_SSL); 100 } 101 header('Location: '.$core->blog->url); 102 return; 103 }; 104 105 } 70 106 } 71 107 108 109 class PreviewBehavior { 110 public static function publicPrepend(&$core) { 111 if (isset($_COOKIE[DC_SESSION_NAME])) 112 { 113 $core->session->start(); 114 $core->auth->checkUser($_SESSION['sess_user_id']); 115 } 116 117 } 118 } 119 120 class tplPreview { 121 public static function EntryIfOffline($attr) { 122 $ret = isset($attr['return']) ? $attr['return'] : 'offline'; 123 $ret = html::escapeHTML($ret); 124 125 return '<?php if ($_ctx->posts->post_status != 1) { '. "echo '".addslashes($ret)."'; } ?".">"; 126 } 127 128 public static function authWidget(&$w) { 129 global $core; 130 $title = $w->title ? html::escapeHTML($w->title) : __('Connection'); 131 $is_authenticated=isset($_COOKIE[DC_SESSION_NAME]); 132 133 $res = '<div id="auth">'. 134 '<h2>'.$title.'</h2>'; 135 136 if (!$is_authenticated) { 137 $res .= '<form action="'.$core->blog->url.'login" method="post">'. 138 '<p><label>'.__('Login').' '. 139 form::field("user_id",20,32).'</label></p>'. 140 '<p><label>'.__('Password').' '. 141 form::password("user_pwd",20,255).'</label></p>'. 142 '<p><input type="submit" value="'.__('login').'" tabindex="3" />'. 143 '</form>'; 144 } else { 145 $res .= "You are authenticated"; 146 } 147 $res .= '</div>'; 148 return $res; 149 150 } 151 }
Note: See TracChangeset
for help on using the changeset viewer.