├── assets ├── css │ └── .gitkeep ├── js │ ├── lazy │ │ └── .gitkeep │ └── autoload │ │ └── .gitkeep └── images │ └── favicon.png ├── lpf-core ├── cache │ └── .gitkeep └── engine │ ├── bbcode │ ├── help │ │ ├── show_help.txt │ │ └── bbcode-help.html │ └── index.php │ ├── htaccess-distr.txt │ ├── start.php │ ├── additions │ ├── compres-css.php │ └── auth-session.php │ ├── autotag │ ├── maxsite.php │ └── simple.php │ └── yaml │ └── Spyc.php ├── lpf-content ├── set │ └── .gitkeep ├── pages │ ├── 404 │ │ ├── functions.php │ │ └── index.php │ ├── lpf-admin │ │ ├── new_page │ │ │ ├── blanks │ │ │ │ ├── my.js.txt │ │ │ │ ├── style.css.txt │ │ │ │ ├── head.php.txt │ │ │ │ ├── footer.php.txt │ │ │ │ ├── header.php.txt │ │ │ │ ├── _post.php.txt │ │ │ │ ├── _post2.php.txt │ │ │ │ ├── _server.php.txt │ │ │ │ ├── init.php.txt │ │ │ │ ├── functions.php.txt │ │ │ │ ├── variables.php.txt │ │ │ │ └── index.php.txt │ │ │ ├── functions.php │ │ │ ├── init.php │ │ │ ├── variables.php │ │ │ ├── js │ │ │ │ └── lazy │ │ │ │ │ └── script.js │ │ │ ├── index.php │ │ │ └── _post2.php │ │ ├── files │ │ │ ├── images │ │ │ │ ├── close.png │ │ │ │ ├── next.png │ │ │ │ ├── prev.png │ │ │ │ └── loading.gif │ │ │ ├── functions.php │ │ │ ├── init.php │ │ │ ├── js │ │ │ │ └── lazy │ │ │ │ │ ├── 1-script.js │ │ │ │ │ ├── 2-filedrag.js │ │ │ │ │ └── 0-lightbox.min.js │ │ │ ├── css │ │ │ │ ├── upload.css │ │ │ │ └── lightbox.min.css │ │ │ ├── variables.php │ │ │ ├── _server.php │ │ │ ├── index.php │ │ │ └── _post2.php │ │ ├── assets │ │ │ ├── fonts │ │ │ │ └── fontawesome │ │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ └── js │ │ │ │ ├── clear_cache.js │ │ │ │ └── lazy │ │ │ │ └── menu.js │ │ ├── editor │ │ │ ├── functions.php │ │ │ ├── init.php │ │ │ ├── variables.php │ │ │ ├── _post2.php │ │ │ ├── js │ │ │ │ └── lazy │ │ │ │ │ └── script.js │ │ │ └── index.php │ │ ├── init.php │ │ ├── auth │ │ │ ├── auth-options.php │ │ │ └── auth-login-form.php │ │ ├── variables.php │ │ ├── _post2.php │ │ ├── snippets │ │ │ └── menu.php │ │ ├── index.php │ │ └── functions.php │ └── home │ │ └── index.php ├── snippets │ ├── _counters.php │ ├── _ga.php │ └── _twitter.php ├── config │ ├── -config.php │ └── -variables.php └── components │ └── demo │ └── demo.php ├── readme.txt ├── license-LPF.txt └── index.php /assets/css/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/js/lazy/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lpf-core/cache/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/js/autoload/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lpf-content/set/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/my.js.txt: -------------------------------------------------------------------------------- 1 | /* my.js */ 2 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/style.css.txt: -------------------------------------------------------------------------------- 1 | /* CSS-style */ 2 | -------------------------------------------------------------------------------- /assets/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/assets/images/favicon.png -------------------------------------------------------------------------------- /lpf-core/engine/bbcode/help/show_help.txt: -------------------------------------------------------------------------------- 1 | Показать/скрыть блок. 2 | 3 | [show Заголовок] 4 | текст 5 | [/show] 6 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/head.php.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/footer.php.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/header.php.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/lpf-content/pages/lpf-admin/files/images/close.png -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/images/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/lpf-content/pages/lpf-admin/files/images/next.png -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/images/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/lpf-content/pages/lpf-admin/files/images/prev.png -------------------------------------------------------------------------------- /lpf-content/pages/404/functions.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /lpf-content/snippets/_ga.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/assets/fonts/fontawesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/lpf-content/pages/lpf-admin/assets/fonts/fontawesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/assets/fonts/fontawesome/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsite/landing/HEAD/lpf-content/pages/lpf-admin/assets/fonts/fontawesome/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/editor/functions.php: -------------------------------------------------------------------------------- 1 | '', // you login 6 | 'password' => '', // you password 7 | 'text_error' => '
Incorect login/password
', // text error 8 | 'login_form' => PAGES_DIR . CURRENT_PAGE_ROOT . '/auth/auth-login-form.php', 9 | ); 10 | 11 | # end of file -------------------------------------------------------------------------------- /lpf-content/components/demo/demo.php: -------------------------------------------------------------------------------- 1 | 'Hello!', 8 | 'class' => 't-red' 9 | ); 10 | 11 | $OPTIONS = array_merge($def_options, $OPTIONS); 12 | 13 | if ($OPTIONS['class']) 14 | echo '' . $OPTIONS['text'] . ''; 15 | else 16 | echo $OPTIONS['text']; 17 | 18 | 19 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/js/lazy/1-script.js: -------------------------------------------------------------------------------- 1 | $("#select_up_dir").change(function() 2 | { 3 | var url = $(this).val(); 4 | if (url) url = '?dir=' + url; 5 | window.location = PHPVAR.current_url + url; 6 | }); 7 | 8 | function update_file_list() 9 | { 10 | // console.log(PHPVAR); 11 | $.post( 12 | PHPVAR.current_url, 13 | { 14 | load_files: "", 15 | dir: PHPVAR.dir 16 | }, 17 | function(data) 18 | { 19 | $("#all_files_result").html(data); 20 | } 21 | ); 22 | } 23 | 24 | update_file_list(); 25 | -------------------------------------------------------------------------------- /lpf-content/pages/404/index.php: -------------------------------------------------------------------------------- 1 | 19 | 20 |

404 — Not found

21 | 22 |

Home

23 | -------------------------------------------------------------------------------- /lpf-content/snippets/_twitter.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/blanks/index.php.txt: -------------------------------------------------------------------------------- 1 | 19 | 20 | h1 Landing Page Framework 21 | 22 | _ Landing Page Framework 23 | 24 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/auth/auth-login-form.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |

7 |

8 |

9 |
10 | 11 |
-------------------------------------------------------------------------------- /lpf-content/pages/home/index.php: -------------------------------------------------------------------------------- 1 | 19 | 20 | h1 Landing Page Framework 21 | 22 | _ Homesite 23 | 24 | _ Admin panel (Put you login/password to pages/lpf-admin/auth/auth-options.php) 25 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/css/upload.css: -------------------------------------------------------------------------------- 1 | #upload_filedrag 2 | { 3 | display: none; 4 | font-weight: bold; 5 | text-align: center; 6 | padding: 20px 0; 7 | margin: 20px 0; 8 | color: #555; 9 | border: 2px dashed #555; 10 | border-radius: 5px; 11 | cursor: default; 12 | } 13 | 14 | #upload_filedrag.hover 15 | { 16 | color: #36D900; 17 | border-color: #36D900; 18 | border-style: solid; 19 | } 20 | 21 | #upload_progress p 22 | { 23 | display: block; 24 | padding: 2px 5px; 25 | margin: 2px 0; 26 | border-radius: 5px; 27 | background: #eee url("progress.png") 100% 0 repeat-y; 28 | font-size: .9rem; 29 | } 30 | 31 | #upload_progress p.success 32 | { 33 | background: #0c0 none 0 0 no-repeat; 34 | } 35 | 36 | #upload_progress p.failure 37 | { 38 | background: #c00 none 0 0 no-repeat; 39 | } 40 | -------------------------------------------------------------------------------- /lpf-core/engine/htaccess-distr.txt: -------------------------------------------------------------------------------- 1 | Options +FollowSymLinks 2 | Options -Indexes 3 | DirectoryIndex index.php 4 | AddDefaultCharset UTF-8 5 | 6 | 7 | RewriteEngine on 8 | RewriteBase / 9 | RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico) 10 | RewriteCond %{REQUEST_FILENAME} !-f 11 | RewriteCond %{REQUEST_FILENAME} !-d 12 | RewriteRule ^(.*)$ /index.php?page=$1 [QSA] 13 | 14 | 15 | 16 | AddOutputFilterByType \ 17 | DEFLATE \ 18 | application/javascript \ 19 | text/css \ 20 | text/html \ 21 | text/javascript \ 22 | text/plain \ 23 | text/xml 24 | 25 | 26 | 27 | 28 | ExpiresActive on 29 | ExpiresDefault "access plus 1 month" 30 | 31 | 32 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/variables.php: -------------------------------------------------------------------------------- 1 | OK: cache cleared'; 12 | 13 | return 'STOP'; 14 | } 15 | 16 | if ($post = mso_check_post('delete_pages', 'page')) 17 | { 18 | if (!_auth()) return 'STOP'; 19 | 20 | if ($post['page']) 21 | { 22 | foreach($post['page'] as $page) 23 | { 24 | // нельзя удалять 25 | if ($page == 'home' or $page == '404' or $page == 'lpf-admin') continue; 26 | 27 | $d = str_replace('\\', '/', PAGES_DIR . $page); 28 | 29 | if (is_dir($d)) 30 | { 31 | _delete_files($d, true); // файлы и подкаталоги 32 | rmdir($d); // основной каталог 33 | } 34 | } 35 | } 36 | 37 | // редиректим сюда же 38 | header('Location: ' . mso_current_url(false, true)); 39 | return 'STOP'; 40 | } 41 | 42 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/_server.php: -------------------------------------------------------------------------------- 1 | 6 |

7 | LPF 8 | 9 | Admin 10 | Editor 11 | Upload files 12 | New page 13 | 14 | 15 | Home 16 | Logout 17 | 18 |

19 | 20 | 21 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | ><?= $TITLE ?>>Login

')) return; 4 | 5 | ?> 6 |
7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 | 15 |
16 | Landing Page Framework v. 17 | Clear cache 18 | 19 |
20 | 21 | 22 |

All pages

23 | 24 |
25 |
    26 | 27 | link'; 47 | } 48 | 49 | ?> 50 |
51 |
52 |
53 | 54 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/editor/_post2.php: -------------------------------------------------------------------------------- 1 | View page'; 28 | } 29 | 30 | file_put_contents($file, $post['content']); 31 | 32 | _clear_cache(); 33 | 34 | echo ' Saved' . $url; 35 | } 36 | else 37 | { 38 | echo ' File not found'; 39 | } 40 | 41 | return 'STOP'; 42 | } 43 | elseif ($post = mso_check_post('load', 'file')) 44 | { 45 | 46 | if (!_auth()) return 'STOP'; 47 | 48 | $file = base64_decode($post['file']); 49 | $file = str_replace('~', '-', $file); 50 | $file = str_replace('\\', '-', $file); 51 | $file = BASE_DIR . $file; 52 | 53 | 54 | if (file_exists($file)) echo file_get_contents($file); 55 | 56 | return 'STOP'; 57 | } 58 | elseif ($post = mso_check_post('delete_file')) 59 | { 60 | if (!_auth()) return 'STOP'; 61 | 62 | $file = base64_decode($post['delete_file']); 63 | $file = str_replace('~', '-', $file); 64 | $file = str_replace('\\', '-', $file); 65 | $file = BASE_DIR . $file; 66 | 67 | if (file_exists($file)) @unlink($file); 68 | 69 | return 'STOP'; 70 | } 71 | 72 | 73 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/css/lightbox.min.css: -------------------------------------------------------------------------------- 1 | .lb-loader,.lightbox{text-align:center;line-height:0}body:after{content:url(../images/close.png) url(../images/loading.gif) url(../images/prev.png) url(../images/next.png);display:none}.lb-dataContainer:after,.lb-outerContainer:after{content:"";clear:both}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{position:absolute;left:0;width:100%;z-index:10000;font-weight:400}.lightbox .lb-image{display:block;height:auto;max-width:inherit;border-radius:3px}.lightbox a img{border:none}.lb-outerContainer{position:relative;background-color:#fff;width:250px;height:250px;margin:0 auto;border-radius:4px}.lb-loader,.lb-nav{position:absolute;left:0}.lb-outerContainer:after{display:table}.lb-container{padding:4px}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(../images/loading.gif) no-repeat}.lb-nav{top:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(../images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(../images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{display:table}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(../images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1} -------------------------------------------------------------------------------- /lpf-content/config/-variables.php: -------------------------------------------------------------------------------- 1 | "apple-touch-icon", "href"=>"apple-touch-icon.png"); 12 | # $META_LINK[] = array("rel"=>"apple-touch-icon", "sizes"=>"72x72", "href"=>"apple-touch-icon-72x72.png"); 13 | 14 | # $VAR['nocache'] = LOCALHOST; 15 | # $VAR['autotag_my'] = false; 16 | # $VAR['bbcode'] = false; 17 | # $VAR['markdown'] = false; 18 | # $VAR['textile'] = false; 19 | # $VAR['simple'] = false; 20 | # $VAR['autopre'] = false; 21 | # $VAR['autoremove'] = false; 22 | # $VAR['compress_text'] = false; 23 | # $VAR['remove_protocol'] = false; 24 | # $VAR['nocss'] = false; 25 | # $VAR['nojs'] = false; 26 | # $VAR['nofavicon'] = false; 27 | # $VAR['nocache'] = false; 28 | # $VAR['html_attr'] = ''; 29 | # $VAR['body_attr'] = ''; 30 | # $VAR['no_output_only_file'] = false; 31 | # $VAR['autoload_css_page'] = true; 32 | # $VAR['autoload_js_page'] = true; 33 | # $VAR['generate_static_page'] = false; 34 | # $VAR['generate_static_page_base_url'] = ''; 35 | # $VAR['head_file'] = true; 36 | # $VAR['start_file'] = true; 37 | # $VAR['end_file'] = true; 38 | # $VAR['start_file_text'] = false; 39 | # $VAR['end_file_text'] = false; 40 | # $VAR['before_file'] = false; 41 | # $VAR['after_file'] = false; 42 | # $VAR['tmpl'] = false; 43 | # $VAR['nd_css'] = 'assets/css'; 44 | # $VAR['nd_images'] = 'assets/images'; 45 | # $VAR['nd_js'] = 'assets/js'; 46 | 47 | 48 | /* 49 | 50 | // sample YAML in index.php 51 | 52 | 53 | / * === 54 | 55 | TITLE: you title 56 | 57 | META: 58 | description: you description 59 | keywords: you keywords 60 | viewport: width=device-width, initial-scale=1.0 61 | generator: Landing Page Framework (lpf.maxsite.com.ua) 62 | 63 | 1: 64 | property: og:title 65 | content: you title 66 | 67 | 2: 68 | property: og:description 69 | content: you description 70 | 71 | 3: 72 | property: og:url 73 | content: http://mysite.com/ 74 | 75 | META_LINK: 76 | 1: 77 | rel: canonical 78 | href: http://mysite.com/ 79 | 80 | VAR: 81 | simple: true 82 | compress_text: true 83 | html_attr: lang="en" prefix="og:http://ogp.me/ns#" 84 | 85 | === * / 86 | 87 | // Result 88 | 89 | 90 | you title 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | */ 101 | 102 | 103 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/editor/js/lazy/script.js: -------------------------------------------------------------------------------- 1 | $('#b-save').fadeOut(0); 2 | 3 | $('#select_file').change(function() 4 | { 5 | var f = $("#select_file :selected").val(); 6 | 7 | if (f) 8 | { 9 | $.post(PHPVAR.current_url, {file:f, load: 1}, function(response) 10 | { 11 | $('#file_path').val(f); 12 | $('#content').val(response); 13 | $('#success').html(' File upload'); 14 | $('#success').show(); 15 | $('#delete_file').hide().removeClass('b-hide-imp').fadeIn(500); 16 | $('#success').fadeOut(2000); 17 | $('#b-save').fadeOut(500); 18 | 19 | }); 20 | } 21 | }) 22 | 23 | $('#edit_form').submit(function() 24 | { 25 | $.post(PHPVAR.current_url, $("#edit_form").serialize(), function(response) 26 | { 27 | $('#success').html(response); 28 | $('#success').fadeIn(300); 29 | $('#b-save').fadeOut(1000); 30 | }); 31 | 32 | return false; 33 | }) 34 | 35 | $('#content').keypress(function() 36 | { 37 | if ($("#select_file :selected").val()) 38 | { 39 | $('#b-save').fadeIn(300); 40 | $('#success').fadeOut(300); 41 | } 42 | }) 43 | 44 | // CTRL+S in textarea —> save file 45 | $("#content").keydown(function(eventObject) 46 | { 47 | if (eventObject.ctrlKey && eventObject.which == 83) // CTRL+S 48 | { 49 | if ($("#select_file :selected").val() && $("#b-save").is(":visible")) 50 | { 51 | $('#edit_form').submit(); 52 | } 53 | 54 | return false; 55 | } 56 | }); 57 | 58 | 59 | function addText(t, t2, elem){ 60 | var editor = document.getElementById(elem); 61 | 62 | if (document.selection) { 63 | editor.focus(); 64 | sel = document.selection.createRange(); 65 | sel.text = t + sel.text + t2; 66 | editor.focus(); 67 | } 68 | else if (editor.selectionStart || editor.selectionStart == '0') { 69 | var startPos = editor.selectionStart; 70 | var endPos = editor.selectionEnd; 71 | var cursorPos = endPos; 72 | var scrollTop = editor.scrollTop; 73 | if (startPos != endPos) { 74 | editor.value = editor.value.substring(0, startPos) 75 | + t 76 | + editor.value.substring(startPos, endPos) 77 | + t2 78 | + editor.value.substring(endPos, editor.value.length); 79 | cursorPos = startPos + t.length 80 | } 81 | else { 82 | editor.value = editor.value.substring(0, startPos) 83 | + t 84 | + t2 85 | + editor.value.substring(endPos, editor.value.length); 86 | cursorPos = startPos + t.length; 87 | } 88 | editor.focus(); 89 | editor.selectionStart = cursorPos; 90 | editor.selectionEnd = cursorPos; 91 | editor.scrollTop = scrollTop; 92 | } 93 | else { 94 | editor.value += t + t2; 95 | } 96 | } 97 | 98 | $('#panel-select').change(function() 99 | { 100 | if ($(this).prop("checked")) 101 | { 102 | $('#panel-html').hide(); 103 | $('#panel-simple').show(); 104 | } 105 | else 106 | { 107 | $('#panel-html').show(); 108 | $('#panel-simple').hide(); 109 | } 110 | }) 111 | 112 | $('#delete_file').click(function(){ 113 | var f = $("#select_file :selected").val(); 114 | 115 | if (f) 116 | { 117 | if (confirm('Delete this file?')) 118 | { 119 | $.post(PHPVAR.current_url, {delete_file:f}, function(response) 120 | { 121 | location.reload(); 122 | }); 123 | } 124 | } 125 | }); 126 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/index.php: -------------------------------------------------------------------------------- 1 | Login

')) return; 4 | 5 | ?> 6 | 7 |
8 | 9 |
10 | 11 |

Create a new page (or add new file)

12 | 13 |
14 | 15 | 16 | 17 |

18 | 19 |

Add files:

20 | 21 |
    22 | 23 |
  • 24 | 25 |
  • Optional files:
  • 26 | 27 |
  • 28 | 29 |
  • 30 | 31 |
  • 32 | 33 |
  • 34 | 35 |
  • 36 | 37 |
  • 38 | 39 |
  • 40 | 41 |
  • 42 | 43 |
  • 44 | 45 |
46 | 47 |

Add folders:

48 | 49 |
    50 |
  • 51 | 52 |
  • 53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 | 64 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/index.php: -------------------------------------------------------------------------------- 1 | Login

')) return; 4 | 5 | // адрес загрузки относительно корня сайта 6 | $upload_dir = 'uploads/'; 7 | 8 | // разрешенные для зугрузки типы файлов 9 | $upload_ext = 'txt|gif|jpg|jpeg|png|svg|html|htm|css|js|zip'; 10 | 11 | // $upload_ext = 'mp3|gif|jpg|jpeg|png|svg|zip|txt|rar|doc|rtf|pdf|html|htm|css|xml|odt|avi|wmv|flv|swf|wav|xls|7z|gz|bz2|tgz'; 12 | 13 | // создадим каталог загрузки если его нет 14 | if (!is_dir(BASEPATH . $upload_dir)) @mkdir(BASEPATH . $upload_dir, 0777); 15 | 16 | // строим список подкаталогов 17 | $directory = BASE_DIR . $upload_dir; 18 | $directory = str_replace('\\', '/', $directory); 19 | 20 | // все подкаталоги 21 | $dirs = _getSubDirs($directory); 22 | // pr($dirs); 23 | 24 | // текущий подкаталог в URL указывается относительно /BASE_DIR/$upload_dir/ в base64 25 | // lpf-admin/files?dir=dHdv -> dHdv 26 | $req_dir = mso_url_request(false, 'dir', true); 27 | $sub_dir = @base64_decode($req_dir); 28 | 29 | // нет такого подкаталога — обнуляем get-запрос 30 | if (!in_array($sub_dir, $dirs)) $req_dir = $sub_dir = ''; 31 | 32 | // $current_url = PAGES_URL . CURRENT_PAGE_ROOT; 33 | 34 | // для передачи в аякс-запрос каталог должен завершаться / 35 | if ($sub_dir) $sub_dir .= '/'; 36 | 37 | // pr($sub_dir); 38 | // pr($req_dir); 39 | 40 | // корневой upload_dir 41 | $select = ''; 42 | 43 | foreach ($dirs as $dir) 44 | { 45 | $val = base64_encode($dir); 46 | $sel = ($val == $req_dir) ? ' selected' : ''; 47 | $select .= ''; 48 | } 49 | 50 | ?> 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
Select dir:
59 | 60 |
61 |
62 | 63 | 64 | Create subdir 65 |
66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | 74 |
75 | 76 |

File Upload

77 | 78 |
79 | 80 | 81 | 82 | 83 |
84 |
or drop files here
85 | 86 |
87 |
88 | 89 |
90 |
91 | 92 |
93 | 94 | 95 | 96 |
97 |

Files

98 |
Loading...
99 |
100 | 101 | 102 | 103 | 108 | -------------------------------------------------------------------------------- /lpf-core/engine/additions/compres-css.php: -------------------------------------------------------------------------------- 1 | ', '>', $out); 36 | $out = str_replace('} ', '}', $out); 37 | $out = str_replace(' (', '(', $out); 38 | 39 | $out = str_replace('0.1em', '.1em', $out); 40 | $out = str_replace('0.2em', '.2em', $out); 41 | $out = str_replace('0.3em', '.3em', $out); 42 | $out = str_replace('0.4em', '.4em', $out); 43 | $out = str_replace('0.5em', '.5em', $out); 44 | $out = str_replace('0.6em', '.6em', $out); 45 | $out = str_replace('0.7em', '.7em', $out); 46 | $out = str_replace('0.8em', '.8em', $out); 47 | $out = str_replace('0.9em', '.9em', $out); 48 | $out = str_replace('1.0em', '1em', $out); 49 | 50 | $out = str_replace(' 0%', ' 0', $out); 51 | 52 | $out = str_replace('#000000', '#000', $out); 53 | $out = str_replace('#111111', '#111', $out); 54 | $out = str_replace('#222222', '#222', $out); 55 | $out = str_replace('#333333', '#333', $out); 56 | $out = str_replace('#444444', '#444', $out); 57 | $out = str_replace('#555555', '#555', $out); 58 | $out = str_replace('#666666', '#666', $out); 59 | $out = str_replace('#777777', '#777', $out); 60 | $out = str_replace('#888888', '#888', $out); 61 | $out = str_replace('#999999', '#999', $out); 62 | $out = str_replace('#aaaaaa', '#aaa', $out); 63 | $out = str_replace('#bbbbbb', '#bbb', $out); 64 | $out = str_replace('#cccccc', '#ccc', $out); 65 | $out = str_replace('#dddddd', '#ddd', $out); 66 | $out = str_replace('#eeeeee', '#eee', $out); 67 | $out = str_replace('#ffffff', '#fff', $out); 68 | $out = str_replace('#AAAAAA', '#aaa', $out); 69 | $out = str_replace('#BBBBBB', '#bbb', $out); 70 | $out = str_replace('#CCCCCC', '#ccc', $out); 71 | $out = str_replace('#DDDDDD', '#ddd', $out); 72 | $out = str_replace('#EEEEEE', '#eee', $out); 73 | $out = str_replace('#FFFFFF', '#fff', $out); 74 | 75 | $out = str_replace('#ff0000', '#f00', $out); 76 | $out = str_replace('#ffff00', '#ff0', $out); 77 | 78 | $out = str_replace(' !important', '!important', $out); 79 | $out = str_replace(' + ', '+', $out); 80 | 81 | $out = str_replace('0.1', '.1', $out); 82 | $out = str_replace('0.2', '.2', $out); 83 | $out = str_replace('0.3', '.3', $out); 84 | $out = str_replace('0.4', '.4', $out); 85 | $out = str_replace('0.5', '.5', $out); 86 | $out = str_replace('0.6', '.6', $out); 87 | $out = str_replace('0.7', '.7', $out); 88 | $out = str_replace('0.8', '.8', $out); 89 | $out = str_replace('0.9', '.9', $out); 90 | 91 | $out = str_replace('font-weight:normal', 'font-weight:400', $out); 92 | $out = str_replace('font-weight:bold', 'font-weight:700', $out); 93 | 94 | $length2 = strlen($out); 95 | 96 | // если размер уменьшился, то обновляем файл 97 | if ($length1 > $length2) 98 | { 99 | $tf = filemtime($fn); // время создания файла 100 | 101 | $fp = fopen($fn, "w"); 102 | fwrite($fp, $out); 103 | fclose($fp); 104 | 105 | @touch($fn, $tf); // поменяем время создания файла назад 106 | } 107 | } 108 | } 109 | 110 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/new_page/_post2.php: -------------------------------------------------------------------------------- 1 | OK: page «' . $in['new_page'] . '»'; 139 | 140 | 141 | return 'STOP'; 142 | } 143 | 144 | /** 145 | * создание каталога, если его нет 146 | **/ 147 | function my_mkdir($d) 148 | { 149 | if (!is_dir($d)) @mkdir($d, 0777); 150 | } 151 | 152 | /** 153 | * создание файла, если его нет 154 | **/ 155 | function my_copy($f1, $f2) 156 | { 157 | if (!file_exists($f2)) @copy($f1, $f2); 158 | } 159 | 160 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/_post2.php: -------------------------------------------------------------------------------- 1 | '; 73 | } 74 | 75 | 76 | return 'STOP'; 77 | } 78 | 79 | // удаление выбранных файлов 80 | if ($post = mso_check_post('delete_files', 'files', 'dir')) 81 | { 82 | if (!_auth()) return 'STOP'; 83 | 84 | $_dr = $post['dir']; 85 | if (!is_dir(BASEPATH . $_dr)) die('no exist dir'); 86 | 87 | $d = BASEPATH . $_dr; 88 | 89 | if ($post['files']) 90 | { 91 | foreach($post['files'] as $file) 92 | { 93 | if (file_exists($d . $file)) @unlink($d . $file); 94 | } 95 | } 96 | 97 | // редиректим сюда же 98 | header('Location: ' . mso_current_url(false, true)); 99 | return 'STOP'; 100 | } 101 | 102 | if ($post = mso_check_post('create_subdir', 'subdir', 'dir', 'upload_dir')) 103 | { 104 | if (!_auth()) return 'STOP'; 105 | 106 | // в $post['dir'] каталог относительно BASEPATH 107 | // а upload_dir нужен только для нового редиректа 108 | 109 | $_dr = $post['dir']; 110 | if (!is_dir(BASEPATH . $_dr)) die('no exist dir'); 111 | 112 | $d = BASEPATH . $_dr; 113 | 114 | // вичищаем введенный каталог 115 | $subdir = _slug($post['subdir']); 116 | $subdir = str_replace('.', '', $subdir); 117 | 118 | $new_redirect = false; 119 | 120 | if ($subdir) 121 | { 122 | // новый каталог только если его уже нет 123 | if (!is_dir(BASEPATH . $_dr . $subdir)) @mkdir(BASEPATH . $_dr . $subdir, 0777); 124 | 125 | // и тут же проверяем и ставим новый адрес для редиректа 126 | if (is_dir(BASEPATH . $_dr . $subdir)) 127 | { 128 | $new_redirect = mso_current_url(false, true, true) . '?dir=' . base64_encode(str_replace($post['upload_dir'], '', $_dr . $subdir)); 129 | } 130 | } 131 | 132 | if ($new_redirect) 133 | header('Location: ' .$new_redirect); 134 | else 135 | header('Location: ' . mso_current_url(false, true)); 136 | 137 | return 'STOP'; 138 | } 139 | 140 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/js/lazy/2-filedrag.js: -------------------------------------------------------------------------------- 1 | /* 2 | filedrag.js - HTML5 File Drag & Drop demonstration 3 | Featured on SitePoint.com 4 | Developed by Craig Buckler (@craigbuckler) of OptimalWorks.net 5 | */ 6 | $(document).ready(function() { 7 | 8 | // getElementById 9 | function $id(id) { 10 | return document.getElementById(id); 11 | } 12 | 13 | // output information 14 | function Output(msg) { 15 | var m = $id("upload_messages"); 16 | m.innerHTML = msg + m.innerHTML; 17 | } 18 | 19 | // file drag hover 20 | function FileDragHover(e) { 21 | e.stopPropagation(); 22 | e.preventDefault(); 23 | e.target.className = (e.type == "dragover" ? "hover" : ""); 24 | } 25 | 26 | // file selection 27 | function FileSelectHandler(e) { 28 | 29 | // cancel event and hover styling 30 | FileDragHover(e); 31 | 32 | // fetch FileList object 33 | var files = e.target.files || e.dataTransfer.files; 34 | 35 | // process all File objects 36 | for (var i = 0, f; f = files[i]; i++) { 37 | 38 | // console.log(f); 39 | 40 | if (f.size > $id("upload_max_file_size").value) { 41 | Output("

Large file - " + f.name + " (" + f.size + " byte)

"); 42 | continue; 43 | } 44 | 45 | var ext = '|' + f.name.substr(f.name.lastIndexOf(".") + 1) + '|'; 46 | var upload_ext = '|' + $id("upload_ext").value + '|'; 47 | 48 | // console.log(upload_ext); 49 | // console.log(ext); 50 | 51 | if (upload_ext.indexOf(ext) == -1) { 52 | Output("

Forbidden type file - " + f.name + " (" + f.type + ")

"); 53 | continue; 54 | } 55 | 56 | // ParseFile(f); 57 | UploadFile(f); 58 | } 59 | } 60 | 61 | // output file information 62 | function ParseFile(file) { 63 | 64 | Output( 65 | "

File information: " + file.name + 66 | " type: " + file.type + 67 | " size: " + file.size + 68 | " bytes

" 69 | ); 70 | 71 | 72 | // !!! если не нужна превьюшка данных 73 | // return; 74 | 75 | 76 | // display an image 77 | if (file.type.indexOf("image") == 0) { 78 | var reader = new FileReader(); 79 | reader.onload = function(e) { 80 | Output( 81 | "

" + file.name + ":
" + 82 | '

' 83 | ); 84 | } 85 | reader.readAsDataURL(file); 86 | } 87 | 88 | // display text 89 | if (file.type.indexOf("text") == 0) { 90 | var reader = new FileReader(); 91 | reader.onload = function(e) { 92 | Output( 93 | "

" + file.name + ":

" +
 94 | 					e.target.result.replace(//g, ">") +
 95 | 					"
" 96 | ); 97 | } 98 | reader.readAsText(file); 99 | } 100 | 101 | } 102 | 103 | // upload files 104 | function UploadFile(file) { 105 | 106 | // following line is not necessary: prevents running on SitePoint servers 107 | if (location.host.indexOf("sitepointstatic") >= 0) return 108 | 109 | var xhr = new XMLHttpRequest(); 110 | 111 | if (xhr.upload && (file.size > $id("upload_max_file_size").value)) { 112 | return; 113 | } 114 | 115 | var ext = '|' + file.name.substr(file.name.lastIndexOf(".") + 1) + '|'; 116 | var upload_ext = '|' + $id("upload_ext").value + '|'; 117 | 118 | if ( xhr.upload && (upload_ext.indexOf(ext) > -1) ) { 119 | 120 | // create progress bar 121 | var o = $id("upload_progress"); 122 | var progress = o.appendChild(document.createElement("p")); 123 | progress.appendChild(document.createTextNode("upload " + file.name)); 124 | 125 | // progress bar 126 | xhr.upload.addEventListener("progress", function(e) { 127 | var pc = parseInt(100 - (e.loaded / e.total * 100)); 128 | progress.style.backgroundPosition = pc + "% 0"; 129 | }, false); 130 | 131 | // file received/failed 132 | xhr.onreadystatechange = function(e) { 133 | if (xhr.readyState == 4) { 134 | progress.className = (xhr.status == 200 ? "success" : "failure"); 135 | Output('

' + xhr.responseText + '

'); 136 | 137 | update_file_list(); 138 | } 139 | }; 140 | 141 | // start upload 142 | // xhr.open("POST", $id("upload").action, true); 143 | xhr.open("POST", $id("upload_action").value, true); 144 | // xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 145 | 146 | // дублируем заголовки если сервер режет X_FILENAME и X_FILENAME_UP_DIR 147 | xhr.setRequestHeader("X-Requested-FileName", unescape(encodeURIComponent(file.name))); 148 | xhr.setRequestHeader("X-Requested-FileUpDir", unescape(encodeURIComponent($id("upload_dir").value))); 149 | 150 | xhr.setRequestHeader("X_FILENAME", unescape(encodeURIComponent(file.name))); 151 | xhr.setRequestHeader("X_FILENAME_UP_DIR", unescape(encodeURIComponent($id("upload_dir").value))); 152 | 153 | xhr.send(file); 154 | } 155 | } 156 | 157 | // initialize 158 | function Init() { 159 | 160 | var fileselect = $id("upload_fileselect"), 161 | filedrag = $id("upload_filedrag"); 162 | // submitbutton = $id("upload_submitbutton"); 163 | 164 | // console.log($id("upload_action").value); 165 | 166 | // file select 167 | fileselect.addEventListener("change", FileSelectHandler, false); 168 | 169 | // is XHR2 available? 170 | var xhr = new XMLHttpRequest(); 171 | if (xhr.upload) { 172 | 173 | // file drop 174 | filedrag.addEventListener("dragover", FileDragHover, false); 175 | filedrag.addEventListener("dragleave", FileDragHover, false); 176 | filedrag.addEventListener("drop", FileSelectHandler, false); 177 | filedrag.style.display = "block"; 178 | 179 | // remove submit button 180 | // submitbutton.style.display = "none"; 181 | } 182 | } 183 | 184 | // call initialization file 185 | if (window.File && window.FileList && window.FileReader) { 186 | Init(); 187 | } 188 | 189 | }); -------------------------------------------------------------------------------- /lpf-core/engine/autotag/maxsite.php: -------------------------------------------------------------------------------- 1 | [html_r]

', '[html_r]', $pee); 22 | $pee = str_replace('

[/html_r]

', '[/html_r]', $pee); 23 | $pee = preg_replace_callback('!\[html_r\](.*?)\[\/html_r\]!is', '_clean_html_r_do', $pee ); 24 | 25 | # если html в [html] код [/html] 26 | $pee = str_replace('

[html]

', '[html]', $pee); 27 | $pee = str_replace('

[/html]

', '[/html]', $pee); 28 | $pee = preg_replace_callback('!\[html\](.*?)\[\/html\]!is', '_clean_html_do', $pee ); 29 | 30 | # преформатированный текст 31 | $pee = preg_replace_callback('!()(.*?)()!is', 'mso_clean_pre_do', $pee ); 32 | 33 | $pee = str_replace('
', '
', $pee); 34 | $pee = str_replace('
', '
', $pee); 35 | 36 | $pee = str_replace("\n\t", "\n", $pee); 37 | 38 | # ставим абзацы 39 | $pee = preg_replace('!(.*)\n!', "\n

$1

", $pee); 40 | 41 | # исправим абзацы ошибочные 42 | $pee = str_replace("

", "", $pee); 43 | $pee = str_replace("

", "", $pee); 44 | $pee = str_replace("

", "

", $pee); 45 | $pee = str_replace("

", "

", $pee); 46 | $pee = str_replace("

", "", $pee); 47 | $pee = str_replace("

(\s)+<", $pee); #

  • и

    54 | $pee = preg_replace('!

    (<' . $allblocks . '[^>]*>)

    !', "\n$1", $pee); #

    55 | $pee = preg_replace('!

    (<' . $allblocks . '[^>]*>)!', "\n$1", $pee); #

    56 | $pee = preg_replace('!

    (]*>)!', "\n$1", $pee); #

    57 | $pee = preg_replace('!(<' . $allblocks . '[^>]*>)

    !', "\n$1", $pee); #

    58 | $pee = preg_replace('!()

    !', "$1", $pee); #

    59 | $pee = preg_replace('!()

    !', "$1", $pee); #

    60 | 61 | $pee = preg_replace('!

      (<' . $allblocks . '[^>]*>)!', "\n$1", $pee); #

       62 | $pee = preg_replace('!

     (<' . $allblocks . '[^>]*>)!', "\n$1", $pee); #

      63 | 64 | # специфичные ошибки 65 | $pee = str_replace("

    \n

    ", "

    ", $pee); 66 | $pee = preg_replace('!
  • (.*)

    \n!', "
  • $1
  • \n", $pee); #
  • ...

    67 | $pee = str_replace("
  • \n\n
  • ", "
  • \n
  • ", $pee); 68 | $pee = str_replace("

    ", "", $pee); 70 | 71 | $pee = preg_replace('!

    \n!', "\n", $pee); 72 | $pee = preg_replace('!

    \n!', "\n", $pee); 73 | 74 | # еще раз подчистка 75 | $pee = preg_replace('!

    !', "", $pee); 76 | $pee = preg_replace('!


    !', "
    ", $pee); 77 | $pee = str_replace("-->

    ", "-->", $pee); 78 | 79 | $pee = str_replace("\n\n\n", "\n", $pee); 80 | $pee = str_replace("\n\n", "\n", $pee); 81 | 82 | # завершим [html] 83 | $pee = str_replace('

    [html_base64]', '[html_base64]', $pee); 84 | $pee = str_replace('[/html_base64]

    ', '[/html_base64]', $pee); 85 | $pee = str_replace('[/html_base64]

    ', '[/html_base64]', $pee); 86 | 87 | $pee = preg_replace_callback('!\[html_base64\](.*?)\[\/html_base64\]!is', '_clean_html_posle', $pee ); 88 | 89 | # [br] 90 | $pee = str_replace('[br]', '
    ', $pee); 91 | $pee = str_replace('[br none]', '
    ', $pee); 92 | $pee = str_replace('[br left]', '
    ', $pee); 93 | $pee = str_replace('[br right]', '
    ', $pee); 94 | 95 | $pee = str_replace('


    ', '
    ', $pee); 96 | $pee = preg_replace('!

    !', "", $pee); 97 | 98 | # принудительный пробел 99 | $pee = str_replace('[nbsp]', ' ', $pee); 100 | 101 | # спецзамены 102 | $pee = str_replace('[BASEURL]', BASE_URL , $pee); // адрес сайта 103 | $pee = str_replace('[BASE_URL]', BASE_URL , $pee); // адрес сайта 104 | 105 | // pr($pee,0); 106 | 107 | return trim($pee); 108 | } 109 | 110 | /** 111 | * предподготовка html в тексте между [html] ... [/html] 112 | * конвертируем все символы в реальный html 113 | * после этого кодируем его в одну строчку base64 [html_base64] 114 | * 115 | * @param $matches 116 | * 117 | * @return string 118 | */ 119 | function _clean_html_do($matches) 120 | { 121 | $arr1 = array('&', '<', '>', '
    ', '
    ', ' '); 122 | $arr2 = array('&', '<', '>', "\n", "\n", ' '); 123 | 124 | $m = trim( str_replace($arr1, $arr2, $matches[1]) ); 125 | $m = '[html_base64]' . base64_encode($m) . '[/html_base64]'; 126 | 127 | return $m; 128 | } 129 | 130 | /** 131 | * аналогично _clean_html_do, только без замен — [html_r] ... [/html_r] 132 | * 133 | * @param $matches 134 | * 135 | * @return string 136 | */ 137 | function _clean_html_r_do($matches) 138 | { 139 | return '[html_base64]' . base64_encode($matches[1]) . '[/html_base64]'; 140 | } 141 | 142 | /** 143 | * декодирование из [html_base64] 144 | * 145 | * @param $matches 146 | * 147 | * @return string 148 | */ 149 | function _clean_html_posle($matches) 150 | { 151 | return base64_decode($matches[1]); 152 | } 153 | 154 | # end of file -------------------------------------------------------------------------------- /lpf-core/engine/autotag/simple.php: -------------------------------------------------------------------------------- 1 | текст без обработки 104 | 105 | */ 106 | 107 | function autotag_simple($text) 108 | { 109 | $text = str_replace(array("\r\n", "\r"), "\n", $text); // win-dos 110 | 111 | $text = "\n" . $text . "\n"; 112 | 113 | // текст без обработки 114 | $text = preg_replace_callback('!(<\!-- nosimple -->)(.*?)(<\!-- \/nosimple -->)!is', 'autotag_simple_no', $text); 115 | 116 | 117 | # _ P 118 | $text = preg_replace('!^\s*_\s(.*?)\n!m', "\n\n

    $1

    \n", $text); 119 | $text = preg_replace('!^\s*_\s(.*?)\n!m', "\n\n

    $1

    \n", $text); 120 | $text = preg_replace('!^\s*_\((.*?)\)\((.*?)\)\s(.*?)\n!m', "\n\n

    $3

    \n", $text); 121 | $text = preg_replace('!^\s*_\((.*?)\)\s(.*?)\n!m', "\n\n

    $2

    \n", $text); 122 | 123 | # __ DIV в одной строке 124 | $text = preg_replace('!^\s*__\s(.*?)\n!m', "\n\n
    $1
    \n", $text); 125 | $text = preg_replace('!^\s*__\s(.*?)\n!m', "\n\n
    $1
    \n", $text); 126 | $text = preg_replace('!^\s*__\((.*?)\)\((.*?)\)\s(.*?)\n!m', "\n\n
    $3
    \n", $text); 127 | $text = preg_replace('!^\s*__\((.*?)\)\s(.*?)\n!m', "\n\n
    $2
    \n", $text); 128 | 129 | # __ I __ _ EM _ 130 | $text = preg_replace('! __(.*?)__!', " $1", $text); 131 | $text = preg_replace('! _(.*?)_!', " $1", $text); 132 | 133 | # ** B ** * STRONG * 134 | $text = preg_replace('! \*\*(.*?)\*\*!', " $1", $text); 135 | $text = preg_replace('! \*(.*?)\*!', " $1", $text); 136 | 137 | # @ CODE @ 138 | $text = preg_replace('! \@(.*?)\@!', " $1", $text); 139 | 140 | # * LI 141 | $text = preg_replace('!^\s*\*\s(.*?)\n!m', "\n
  • $1
  • \n", $text); 142 | 143 | # hr 144 | $text = preg_replace('!^\s*[^<]hr\s*\n!m', "\n
    \n", $text); 145 | $text = preg_replace('!^\s*[^<]hr\((.*?)\)\s*\n!m', "\n
    \n", $text); 146 | $text = preg_replace('!^\s*[^<]hr\((.*?)\)\((.*?)\)\s*\n!m', "\n
    \n", $text); 147 | 148 | // тэги одной строкой 149 | $tags1 = '(h1|h2|h3|h4|h5|h6|dt|dd|li)'; 150 | 151 | # h1(bold)(color: red) Заголовок 152 | $text = preg_replace('!^\s*' . $tags1 . '\((.*?)\)\((.*?)\)\s+(.*?)\n!m', "\n<$1 class=\"$2\" style=\"$3\">$4\n", $text); 153 | 154 | # h1(bold) Заголовок 155 | $text = preg_replace('!^\s*' . $tags1 . '\((.*?)\)\s+(.*?)\n!m', "\n<$1 class=\"$2\">$3\n", $text); 156 | 157 | # h1 Заголовок 158 | $text = preg_replace('!^\s*' . $tags1 . '\s+(.*?)\n!m', "\n<$1>$2\n", $text); 159 | 160 | 161 | // открывающие и отдельно закрывающие тэги div ... /div 162 | $tags2 = '(div|section|article|main|footer|hgroup|header|aside|nav|form|fieldset|label|select|pre|blockquote|bq|ol|ul|table|tr|td|th|caption|tbody|thead|tfoot|dl)'; 163 | 164 | # /div 165 | $text = preg_replace('!\|\|\s*\/' . $tags2 . '\s*(\n|\|\|)!m', "\n\n", $text); 166 | $text = preg_replace('!\s*\/' . $tags2 . '\s*(\n|\|\|)!m', "\n\n", $text); 167 | 168 | # div(t-red)(font-weight: bold) 169 | $text = preg_replace('!\|\|\s*' . $tags2 . '\((.*?)\)\((.*?)\)\s*(\n|\|\|)!m', "\n<$1 class=\"$2\" style=\"$3\">\n", $text); 170 | $text = preg_replace('!\s*' . $tags2 . '\((.*?)\)\((.*?)\)\s*(\n|\|\|)!m', "\n<$1 class=\"$2\" style=\"$3\">\n", $text); 171 | 172 | # div(t-red) 173 | $text = preg_replace('!\|\|\s*' . $tags2 . '\((.*?)\)\s*(\n|\|\|)!m', "\n<$1 class=\"$2\">\n", $text); 174 | $text = preg_replace('!\s*' . $tags2 . '\((.*?)\)\s*(\n|\|\|)!m', "\n<$1 class=\"$2\">\n", $text); 175 | 176 | # div 177 | $text = preg_replace('!\|\|\s*' . $tags2 . '\s*(\n|\|\|)!m', "\n<$1>\n", $text); 178 | $text = preg_replace('!^\s*' . $tags2 . '\s*(\n|\|\|)!m', "\n<$1>\n", $text); 179 | 180 | # замена несуществующего тэга 181 | $text = str_replace('', '
    ', $text); 183 | 184 | return trim($text); 185 | } 186 | 187 | 188 | function autotag_simple_no($matches) 189 | { 190 | return '[html_base64]' . base64_encode($matches[2]) . '[/html_base64]'; 191 | } 192 | 193 | 194 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/functions.php: -------------------------------------------------------------------------------- 1 | 25 | * $r = new RecursiveDirectoryIterator($directory); 26 | * $files = _getFiles($r, 0, $directory); 27 | */ 28 | function _getFiles($rdi, $depth=0, $dir, $allow_ext = array('php', 'txt', 'css', 'less', 'js', 'html', 'htm', 'ini', 'sass', 'scss')) 29 | { 30 | $out = array(); 31 | 32 | if (!is_object($rdi)) return $out; 33 | 34 | for ($rdi->rewind(); $rdi->valid(); $rdi->next()) 35 | { 36 | if ($rdi->isDot()) continue; 37 | 38 | if ($rdi->isDir() || $rdi->isFile()) 39 | { 40 | $cur = $rdi->current(); 41 | $cur = str_replace('\\', '/', $cur); 42 | $cur = str_replace(str_replace('\\', '/', BASE_DIR), '', $cur); 43 | 44 | // pr($cur); 45 | // $cur = str_replace(BASE_DIR, '', $cur); 46 | // $cur = str_replace($dir, '', $cur); 47 | 48 | if ($rdi->isDir()) 49 | { 50 | if ($depth == 0) 51 | { 52 | $out[] = ''; 53 | } 54 | } 55 | 56 | if ($rdi->isFile()) 57 | { 58 | $file_ext = strtolower(str_replace('.', '', strrchr($cur, '.'))); 59 | 60 | if (in_array($file_ext, $allow_ext)) 61 | { 62 | if (is_writable($rdi->getPathname())) $out[] = $cur; 63 | } 64 | } 65 | 66 | if ($rdi->hasChildren()) 67 | { 68 | $out1 = _getFiles($rdi->getChildren(), 1 + $depth, $dir, $allow_ext); 69 | $out = array_merge($out, $out1); 70 | } 71 | } 72 | } 73 | 74 | return $out; 75 | } 76 | 77 | /** 78 | * замена на английские буквы транслитерацией 79 | */ 80 | function _slug($slug, $slash_del = true) 81 | { 82 | $repl = array( 83 | "А"=>"a", "Б"=>"b", "В"=>"v", "Г"=>"g", "Д"=>"d", 84 | "Е"=>"e", "Ё"=>"jo", "Ж"=>"zh", 85 | "З"=>"z", "И"=>"i", "Й"=>"j", "К"=>"k", "Л"=>"l", 86 | "М"=>"m", "Н"=>"n", "О"=>"o", "П"=>"p", "Р"=>"r", 87 | "С"=>"s", "Т"=>"t", "У"=>"u", "Ф"=>"f", "Х"=>"h", 88 | "Ц"=>"c", "Ч"=>"ch", "Ш"=>"sh", "Щ"=>"shh", "Ъ"=>"", 89 | "Ы"=>"y", "Ь"=>"", "Э"=>"e", "Ю"=>"ju", "Я"=>"ja", 90 | 91 | "а"=>"a", "б"=>"b", "в"=>"v", "г"=>"g", "д"=>"d", 92 | "е"=>"e", "ё"=>"jo", "ж"=>"zh", 93 | "з"=>"z", "и"=>"i", "й"=>"j", "к"=>"k", "л"=>"l", 94 | "м"=>"m", "н"=>"n", "о"=>"o", "п"=>"p", "р"=>"r", 95 | "с"=>"s", "т"=>"t", "у"=>"u", "ф"=>"f", "х"=>"h", 96 | "ц"=>"c", "ч"=>"ch", "ш"=>"sh", "щ"=>"shh", "ъ"=>"", 97 | "ы"=>"y", "ь"=>"", "э"=>"e", "ю"=>"ju", "я"=>"ja", 98 | 99 | # украина 100 | "Є" => "ye", "є" => "ye", "І" => "i", "і" => "i", 101 | "Ї" => "yi", "ї" => "yi", "Ґ" => "g", "ґ" => "g", 102 | 103 | # беларусь 104 | "Ў"=>"u", "ў"=>"u", "'"=>"", 105 | 106 | # румынский 107 | "ă"=>'a', "î"=>'i', "ş"=>'sh', "ţ"=>'ts', "â"=>'a', 108 | 109 | "«"=>"", "»"=>"", "—"=>"-", "`"=>"", " "=>"-", 110 | "["=>"", "]"=>"", "{"=>"", "}"=>"", "<"=>"", ">"=>"", 111 | 112 | "?"=>"", ","=>"", "*"=>"", "%"=>"", "$"=>"", 113 | 114 | "@"=>"", "!"=>"", ";"=>"", ":"=>"", "^"=>"", "\""=>"", 115 | "&"=>"", "="=>"", "№"=>"", "\\"=>"", "#"=>"", 116 | "("=>"", ")"=>"", "~"=>"", "|"=>"", "+"=>"", "”"=>"", "“"=>"", 117 | "'"=>"", 118 | 119 | "’"=>"", 120 | "—"=>"-", // mdash (длинное тире) 121 | "–"=>"-", // ndash (короткое тире) 122 | "™"=>"tm", // tm (торговая марка) 123 | "©"=>"c", // (c) (копирайт) 124 | "®"=>"r", // (R) (зарегистрированная марка) 125 | "…"=>"", // (многоточие) 126 | "“"=>"", 127 | "”"=>"", 128 | "„"=>"", 129 | 130 | " "=>"-", 131 | ); 132 | 133 | if ($slash_del) $slug = str_replace('/', '', $slug); 134 | $slug = strtr(trim($slug), $repl); 135 | $slug = htmlentities($slug); // если есть что-то из юникода 136 | $slug = strtr(trim($slug), $repl); 137 | $slug = strtolower($slug); 138 | 139 | return $slug; 140 | } 141 | 142 | /** 143 | * возвращает одномерный массив подкаталогов $dir 144 | */ 145 | function _getSubDirs($dir) 146 | { 147 | $r = new RecursiveDirectoryIterator($dir); 148 | return _RgetSubDirs($r, $dir); 149 | } 150 | 151 | /** 152 | * Рекурсивная к _getSubDirs() 153 | */ 154 | function _RgetSubDirs($rdi, $dir, $depth=0, $all = array()) { 155 | 156 | if (!is_object($rdi)) return; 157 | 158 | for ($rdi->rewind(); $rdi->valid(); $rdi->next()) 159 | { 160 | if ($rdi->isDot()) continue; 161 | 162 | if ($rdi->isDir()) 163 | { 164 | $cur = $rdi->current(); 165 | $cur = _ss($cur); 166 | $cur = str_replace($dir, '', $cur); 167 | 168 | // echo $cur . '
    '; 169 | 170 | $all[] = $cur; 171 | 172 | if ($rdi->hasChildren()) 173 | $all = _RgetSubDirs($rdi->getChildren(), $dir, 1 + $depth, $all); 174 | } 175 | } 176 | 177 | return $all; 178 | } 179 | 180 | // удаляет все файлы и полдкаталоги в каталоге 181 | function _delete_files($path, $del_dir = FALSE, $level = 0) 182 | { 183 | $path = rtrim($path, DIRECTORY_SEPARATOR); 184 | 185 | if (!$current_dir = @opendir($path)) 186 | { 187 | return FALSE; 188 | } 189 | 190 | while (FALSE !== ($filename = @readdir($current_dir))) 191 | { 192 | if ($filename != "." and $filename != "..") 193 | { 194 | if (is_dir($path.DIRECTORY_SEPARATOR.$filename)) 195 | { 196 | // Ignore empty folders 197 | if (substr($filename, 0, 1) != '.') 198 | { 199 | _delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1); 200 | } 201 | } 202 | else 203 | { 204 | @unlink($path.DIRECTORY_SEPARATOR.$filename); 205 | } 206 | } 207 | } 208 | @closedir($current_dir); 209 | 210 | if ($del_dir == TRUE AND $level > 0) 211 | { 212 | return @rmdir($path); 213 | } 214 | 215 | return TRUE; 216 | } 217 | 218 | // очистим кэш 219 | function _clear_cache() 220 | { 221 | _delete_files(CACHE_DIR, FALSE, 0); 222 | } 223 | 224 | 225 | // замена win-слэшей на / 226 | function _ss($t) 227 | { 228 | return str_replace('\\', '/', $t); 229 | } 230 | 231 | 232 | # end of file -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/editor/index.php: -------------------------------------------------------------------------------- 1 |
    Login

    ')) return; 4 | 5 | ?> 6 |
    7 | 8 | 9 | 10 | -'; 31 | foreach ($files as $file) 32 | { 33 | if (strpos($file, '/' . CURRENT_PAGE_ROOT . '/') !== false) continue; // не выводим админку 34 | 35 | $class = 't-gray500'; 36 | 37 | if (strpos($file, '.css') !== false) $class = 't-green'; 38 | if (strpos($file, '.less') !== false) $class = 't-green'; 39 | if (strpos($file, '.js') !== false) $class = 't-orange'; 40 | if (strpos($file, '/index.php') !== false) $class = 'bold'; 41 | 42 | if (strpos($file, 'optgroup') === false) 43 | { 44 | $select .= ''; 45 | } 46 | else 47 | $select .= $file; 48 | } 49 | 50 | ?> 51 | 52 |

    Select file

    53 | 54 |
    55 | 56 | 57 | 58 | 59 | B  60 | I  61 |   62 |   63 | H1  64 | H2  65 | H3  66 | H4  67 | H5  68 | H6  69 |   70 |   71 |   72 | 73 | 74 | P  75 | H1  76 | H2  77 | H3  78 | H4  79 | H5  80 | H6  81 | 82 |   83 |   84 | 85 |   86 | 87 | I  88 | 89 | B  90 | 91 | @  92 | 93 | 94 | 95 | 96 | 97 |

    98 |
    99 | 100 | 104 | 105 | 106 |
    107 | -------------------------------------------------------------------------------- /lpf-content/pages/lpf-admin/files/js/lazy/0-lightbox.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Lightbox v2.8.2 3 | * by Lokesh Dhakar 4 | * 5 | * More info: 6 | * http://lokeshdhakar.com/projects/lightbox2/ 7 | * 8 | * Copyright 2007, 2015 Lokesh Dhakar 9 | * Released under the MIT license 10 | * https://github.com/lokesh/lightbox2/blob/master/LICENSE 11 | */ 12 | !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):a.lightbox=b(a.jQuery)}(this,function(a){function b(b){this.album=[],this.currentImageIndex=void 0,this.init(),this.options=a.extend({},this.constructor.defaults),this.option(b)}return b.defaults={albumLabel:"Image %1 of %2",alwaysShowNavOnTouchDevices:!1,fadeDuration:500,fitImagesInViewport:!0,positionFromTop:50,resizeDuration:700,showImageNumberLabel:!0,wrapAround:!1,disableScrolling:!1},b.prototype.option=function(b){a.extend(this.options,b)},b.prototype.imageCountLabel=function(a,b){return this.options.albumLabel.replace(/%1/g,a).replace(/%2/g,b)},b.prototype.init=function(){this.enable(),this.build()},b.prototype.enable=function(){var b=this;a("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(c){return b.start(a(c.currentTarget)),!1})},b.prototype.build=function(){var b=this;a('
    ').appendTo(a("body")),this.$lightbox=a("#lightbox"),this.$overlay=a("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return b.end(),!1}),this.$lightbox.hide().on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$outerContainer.on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return 0===b.currentImageIndex?b.changeImage(b.album.length-1):b.changeImage(b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.currentImageIndex===b.album.length-1?b.changeImage(0):b.changeImage(b.currentImageIndex+1),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return b.end(),!1})},b.prototype.start=function(b){function c(a){d.album.push({link:a.attr("href"),title:a.attr("data-title")||a.attr("title")})}var d=this,e=a(window);e.on("resize",a.proxy(this.sizeOverlay,this)),a("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var f,g=0,h=b.attr("data-lightbox");if(h){f=a(b.prop("tagName")+'[data-lightbox="'+h+'"]');for(var i=0;ij||e.height>i)&&(e.width/j>e.height/i?(h=j,g=parseInt(e.height/(e.width/h),10),d.width(h),d.height(g)):(g=i,h=parseInt(e.width/(e.height/g),10),d.width(h),d.height(g)))),c.sizeContainer(d.width(),d.height())},e.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){this.$overlay.width(a(document).width()).height(a(document).height())},b.prototype.sizeContainer=function(a,b){function c(){d.$lightbox.find(".lb-dataContainer").width(g),d.$lightbox.find(".lb-prevLink").height(h),d.$lightbox.find(".lb-nextLink").height(h),d.showImage()}var d=this,e=this.$outerContainer.outerWidth(),f=this.$outerContainer.outerHeight(),g=a+this.containerLeftPadding+this.containerRightPadding,h=b+this.containerTopPadding+this.containerBottomPadding;e!==g||f!==h?this.$outerContainer.animate({width:g,height:h},this.options.resizeDuration,"swing",function(){c()}):c()},b.prototype.showImage=function(){this.$lightbox.find(".lb-loader").stop(!0).hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(b){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(a&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),a&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel){var c=this.imageCountLabel(this.currentImageIndex+1,this.album.length);this.$lightbox.find(".lb-number").text(c).fadeIn("fast")}else this.$lightbox.find(".lb-number").hide();this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return b.sizeOverlay()})},b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var a=new Image;a.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var b=new Image;b.src=this.album[this.currentImageIndex-1].link}},b.prototype.enableKeyboardNav=function(){a(document).on("keyup.keyboard",a.proxy(this.keyboardAction,this))},b.prototype.disableKeyboardNav=function(){a(document).off(".keyboard")},b.prototype.keyboardAction=function(a){var b=27,c=37,d=39,e=a.keyCode,f=String.fromCharCode(e).toLowerCase();e===b||f.match(/x|o|c/)?this.end():"p"===f||e===c?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):("n"===f||e===d)&&(this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0))},b.prototype.end=function(){this.disableKeyboardNav(),a(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),a("select, object, embed").css({visibility:"visible"}),this.options.disableScrolling&&a("body").removeClass("lb-disable-scrolling")},new b}); 13 | //# sourceMappingURL=lightbox.min.map -------------------------------------------------------------------------------- /lpf-core/engine/additions/auth-session.php: -------------------------------------------------------------------------------- 1 | 'login', // логин 16 | 'password' => 'password', // пароль 17 | ); 18 | 19 | или, если пользователей несколько 20 | 21 | $OPTIONS = array( 22 | 'users' => array( 23 | 'username1' => 'password1', // логин и пароль 24 | 'username2' => 'password2', // логин и пароль 25 | 'username3' => 'password3', // логин и пароль 26 | ), 27 | 28 | ); 29 | 30 | 31 | 2. Файл functions.php код: 32 | 33 | require_once(ENGINE_DIR . 'additions/auth-session.php'); 34 | $auth_options = mso_load_options(CURRENT_PAGE_DIR . '/auth/auth-options.php'); 35 | mso_auth_init($auth_options); // инициализация авторизации 36 | 37 | 38 | 3. В index.php страницы в начале (в параметре ссылка на логин) 39 | 40 | if (!mso_check_auth()) return; 41 | 42 | ... текст доступный только после авторизации ... 43 | 44 | Ссылка на ВЫХОД 45 | 46 | 47 | * Дополнительно в файле auth/auth-login-form.php можно разместить свою форму логина (см. mso_auth_form). 48 | 49 | 50 | * В файле auth/auth-login-text.php можно разместить текст входа 51 | 52 |

    Login

    53 | 54 | * Или в опции login_text_out 55 | 56 | 'login_text_out' => 'Вход' 57 | 58 | * Или указать при вызове mso_check_auth(); 59 | 60 | if (!mso_check_auth('Вход')) return; 61 | 62 | * В опциях можно указать текст ошибки 63 | 64 | 'text_error' => 'Ошибка!', 65 | 66 | * Можно указать текст ошибки в файле auth/auth-login-text-error.php 67 | Он имеет приоритет перед опцией text_error 68 | 69 | */ 70 | 71 | # инициализация 72 | function mso_auth_init($OPTIONS = true) 73 | { 74 | global $MSO; 75 | 76 | // дефолтные опции 77 | $def_options = array( 78 | 'username' => '', // логин 79 | 'password' => '', // пароль 80 | 81 | 'users' => false, // можно указать массивом array('user1'=>'pas1', 'user2'=>'pas2') 82 | 83 | 'login_link' => 'login', // ссылка для залогирования http://сайт/page?login 84 | 'logout_link' => 'logout', // ссылка для разлогирования http://сайт/page?logout 85 | 86 | 'login_text' => CURRENT_PAGE_DIR . 'auth/auth-login-text.php', // файл текста логина 87 | 'login_form' => CURRENT_PAGE_DIR . 'auth/auth-login-form.php', // файл формы 88 | 89 | 'text_error' => 'Неверный логин/пароль', // текст при ошибке 90 | 'login_text_out' => 'Вход', // текст входа, если не указано иное 91 | 92 | // файл ошибки - имеет приоритет перед text_error 93 | 'login_text_error' => CURRENT_PAGE_DIR . 'auth/auth-login-text-error.php', 94 | 95 | // файлы просто подключаются при разных событиях 96 | 'file_post' => CURRENT_PAGE_DIR . 'auth/auth-r-post.php', // POST 97 | 'file_login_ok' => CURRENT_PAGE_DIR . 'auth/auth-r-login.php', //удачный вход 98 | 'file_logout' => CURRENT_PAGE_DIR . 'auth/auth-r-logout.php', // выход 99 | ); 100 | 101 | // если $OPTIONS === true, то загружаем из auth/auth-options.php текущей page 102 | if ($OPTIONS === true) 103 | { 104 | $OPTIONS = mso_load_options(CURRENT_PAGE_DIR . 'auth/auth-options.php'); 105 | } 106 | 107 | // объединяем с переданными 108 | $OPTIONS = array_merge($def_options, $OPTIONS); 109 | 110 | // если не заданы логин/пароль, то всё рубим 111 | if (!$OPTIONS['username'] or !$OPTIONS['password']) 112 | { 113 | if (!is_array($OPTIONS['users']) and !$OPTIONS['users']) 114 | die('Not specified username and password to login (mso_auth)'); 115 | } 116 | 117 | $MSO['auth_login'] = ''; // результат функиции (что делать дальше) 118 | $MSO['auth_login_options'] = $OPTIONS; // все опции 119 | 120 | // все редиректы на эту же страницу без ?-get 121 | $url_redirect = mso_current_url(false, true, true); 122 | 123 | // вход 124 | if (mso_url_request(false, $OPTIONS['login_link'])) 125 | { 126 | // если есть post, то проверяем данные 127 | if ($_POST 128 | and isset($_POST['flogin_user']) 129 | and isset($_POST['flogin_password']) 130 | and isset($_POST['flogin_submit']) 131 | ) 132 | { 133 | if (file_exists($OPTIONS['file_post'])) require($OPTIONS['file_post']); 134 | 135 | $u = $p = ''; 136 | 137 | // если есть $OPTIONS['users'], то смотрим только его 138 | if (is_array($OPTIONS['users']) and $OPTIONS['users']) 139 | { 140 | // смотрим массив $OPTIONS['users'] 141 | if (isset($OPTIONS['users'][$_POST['flogin_user']])) 142 | { 143 | // есть такой юзер в массиве 144 | $u = $_POST['flogin_user']; // юзер 145 | $p = $OPTIONS['users'][$_POST['flogin_user']]; // его пароль 146 | } 147 | } 148 | else 149 | { 150 | // смотрим $OPTIONS['username'] и $OPTIONS['password' 151 | $u = $OPTIONS['username']; 152 | $p = $OPTIONS['password']; 153 | } 154 | 155 | if (!$u or !$p) 156 | { 157 | $MSO['auth_login'] = 'error_login_show_form'; 158 | } 159 | else 160 | { 161 | // сравниваем логин и пароль 162 | if ( strcmp($_POST['flogin_user'], $u) == 0 163 | and strcmp($_POST['flogin_password'], $p) == 0 ) 164 | { 165 | // равно 166 | if (!isset($_SESSION)) session_start(); 167 | 168 | $_SESSION['username'] = $u; 169 | $_SESSION['password'] = $p; 170 | 171 | if (file_exists($OPTIONS['file_login_ok'])) require($OPTIONS['file_login_ok']); 172 | 173 | // все ок! 174 | header('Location:' . $url_redirect); 175 | } 176 | else 177 | { 178 | // не равно 179 | $MSO['auth_login'] = 'error_login_show_form'; 180 | } 181 | } 182 | } 183 | else 184 | { 185 | // нет post 186 | // если уже есть залогиненость, то редиректим 187 | if (mso_is_auth($OPTIONS)) header('Location:' . $url_redirect); 188 | 189 | $MSO['auth_login'] = 'show_form'; 190 | } 191 | } 192 | elseif (mso_url_request(false, $OPTIONS['logout_link'])) // ссылка на выход 193 | { 194 | if (!isset($_SESSION)) session_start(); 195 | 196 | if (file_exists($OPTIONS['file_logout'])) require($OPTIONS['file_logout']); 197 | 198 | if (isset($_SESSION['username'])) unset($_SESSION['username']); 199 | if (isset($_SESSION['password'])) unset($_SESSION['password']); 200 | 201 | header('Location:' . $url_redirect); 202 | } 203 | 204 | // если нет авторизации, то выводим сслыку на ВХОД 205 | if (strpos($_SERVER['REQUEST_URI'], '?') === FALSE) 206 | { 207 | if (!mso_is_auth($OPTIONS)) $MSO['auth_login'] = 'text_login'; 208 | } 209 | 210 | if (mso_is_auth($OPTIONS)) 211 | return $OPTIONS; 212 | else 213 | return false; 214 | } 215 | 216 | 217 | # обработка результата mso_auth_init() 218 | function mso_check_auth($text_login = false) 219 | { 220 | global $MSO; 221 | 222 | $OPTIONS = $MSO['auth_login_options']; 223 | 224 | if (mso_is_auth($OPTIONS)) return true; 225 | 226 | if ($MSO['auth_login'] == 'text_login') 227 | { 228 | if ($text_login === false) 229 | { 230 | if ($OPTIONS['login_text'] and file_exists($OPTIONS['login_text'])) 231 | require($OPTIONS['login_text']); 232 | else 233 | { 234 | if ($OPTIONS['login_text_out']) 235 | echo $OPTIONS['login_text_out']; 236 | else 237 | echo 'Вход'; 238 | } 239 | } 240 | else 241 | if ($text_login) 242 | echo $text_login; 243 | else 244 | echo $OPTIONS['login_text_out']; 245 | 246 | return false; 247 | } 248 | elseif ($MSO['auth_login'] == 'show_form') 249 | { 250 | if (file_exists($OPTIONS['login_form'])) 251 | require($OPTIONS['login_form']); 252 | else 253 | mso_auth_form(); 254 | 255 | return false; 256 | } 257 | elseif ($MSO['auth_login'] == 'error_login_show_form') 258 | { 259 | if (file_exists($OPTIONS['login_text_error'])) 260 | require($OPTIONS['login_text_error']); 261 | else 262 | echo $OPTIONS['text_error']; 263 | 264 | if (file_exists($OPTIONS['login_form'])) 265 | require($OPTIONS['login_form']); 266 | else 267 | mso_auth_form(); 268 | 269 | return false; 270 | } 271 | 272 | return false; 273 | } 274 | 275 | 276 | # проверка залогированности 277 | # возвращает true — если логин и пароль верный 278 | function mso_is_auth($OPTIONS = true) 279 | { 280 | // если $OPTIONS === true, то загружаем из auth/auth-options.php текущей page 281 | if ($OPTIONS === true) 282 | { 283 | $OPTIONS = mso_load_options(CURRENT_PAGE_DIR . 'auth/auth-options.php'); 284 | } 285 | 286 | if (!isset($_SESSION)) session_start(); 287 | 288 | 289 | if (isset($_SESSION['username']) and isset($_SESSION['password'])) 290 | { 291 | $u = $p = ''; 292 | 293 | if (is_array($OPTIONS['users']) and $OPTIONS['users']) 294 | { 295 | if (isset($OPTIONS['users'][$_SESSION['username']])) 296 | { 297 | $u = $_SESSION['username']; // юзер 298 | $p = $OPTIONS['users'][$_SESSION['username']]; // его пароль 299 | } 300 | } 301 | else 302 | { 303 | $u = $OPTIONS['username']; 304 | $p = $OPTIONS['password']; 305 | } 306 | 307 | if (!$u or !$p) return false; 308 | 309 | if (strcmp($_SESSION['username'], $u) === 0 310 | and strcmp($_SESSION['password'], $p) === 0 311 | ) 312 | { 313 | return true; 314 | } 315 | else 316 | { 317 | return false; 318 | } 319 | } 320 | else 321 | { 322 | return false; 323 | } 324 | } 325 | 326 | # Стандартная форма если нет файла формы 327 | function mso_auth_form() 328 | { 329 | echo ' 330 |
    331 |

    332 |

    333 |

    334 |
    335 | '; 336 | } 337 | 338 | # end of file -------------------------------------------------------------------------------- /lpf-core/engine/bbcode/index.php: -------------------------------------------------------------------------------- 1 | ' . $m . ''; 16 | 17 | return $m; 18 | } 19 | 20 | # функции плагина 21 | function bbcode_custom($text = '') 22 | { 23 | $text = preg_replace_callback('~\[pre(.*?)\](.*?)\[\/pre\]~si', 'bbcode_pre_callback', $text ); 24 | 25 | $preg = array( 26 | 27 | # Text 28 | 29 | // b - важное выделение в тексте 30 | '~\[b (.*?)\](.*?)\[\/b\]~si' => '$2', 31 | '~\[b\](.*?)\[\/b\]~si' => '$1', 32 | 33 | // просто полужирное начертание 34 | '~\[bold (.*?)\](.*?)\[\/bold\]~si' => '$2', 35 | '~\[bold\](.*?)\[\/bold\]~si' => '$1', 36 | 37 | // выжное выделение в тексте - акцент 38 | '~\[i (.*?)\](.*?)\[\/i\]~si' => '$2', 39 | '~\[i\](.*?)\[\/i\]~si' => '$1', 40 | 41 | // просто выделение курсивом 42 | '~\[italic (.*?)\](.*?)\[\/italic\]~si' => '$2', 43 | '~\[italic\](.*?)\[\/italic\]~si' => '$1', 44 | 45 | // удаленный элемент текста 46 | '~\[del (.*?)\](.*?)\[\/del\]~si' => '$2', 47 | '~\[del\](.*?)\[\/del\]~si' => '$1', 48 | 49 | // просто выделение зачеркиванием 50 | '~\[s (.*?)\](.*?)\[\/s\]~si' => '$2', 51 | '~\[s\](.*?)\[\/s\]~si' => '$1', 52 | 53 | '~\[u (.*?)\](.*?)\[\/u\]~si' => '$2', 54 | '~\[u\](.*?)\[\/u\]~si' => '$1', 55 | 56 | '~\[sub\](.*?)\[\/sub\]~si' => '$1', 57 | '~\[sup\](.*?)\[\/sup\]~si' => '$1', 58 | 59 | '~\[small\](.*?)\[\/small\]~si' => '$1', 60 | 61 | 62 | '~\[color=(.*?)\](.*?)\[\/color\]~si' => '$2', 63 | '~\[size=(.*?)\](.*?)\[\/size\]~si' => '$2', 64 | 65 | # стиль для блока [div=color: red]текст[/div] 66 | '~\[div=(.*?)\](.*?)\[\/div\]~si' => '
    $2
    ', 67 | '~\[span=(.*?)\](.*?)\[\/span\]~si' => '$2', 68 | 69 | # div 70 | '~\[left (.*?)\](.*?)\[\/left\]~si' => '
    $2
    ', 71 | '~\[left\](.*?)\[\/left\]~si' => '
    $1
    ', 72 | 73 | '~\[right (.*?)\](.*?)\[\/right\]~si' => '
    $2
    ', 74 | '~\[right\](.*?)\[\/right\]~si' => '
    $1
    ', 75 | 76 | '~\[center (.*?)\](.*?)\[\/center\]~si' => '
    $2
    ', 77 | '~\[center\](.*?)\[\/center\]~si' => '
    $1
    ', 78 | 79 | '~\[justify (.*?)\](.*?)\[\/justify\]~si' => '
    $2
    ', 80 | '~\[justify\](.*?)\[\/justify\]~si' => '
    $1
    ', 81 | 82 | # p 83 | '~\[p\](.*?)\[\/p\]~si' => '

    $1

    ', // абзац 84 | '~\[p=(.*?)\](.*?)\[\/p\]~si' => '

    $2

    ', 85 | '~\[p (.*?)\](.*?)\[\/p\]~si' => '

    $2

    ', 86 | 87 | '~\[p\((.*?)\)\](.*?)\[\/p\]~si' => '

    $2

    ', // [p(класс)] [/p] 88 | 89 | '~\[pleft\](.*?)\[\/pleft\]~si' => '

    $1

    ', 90 | '~\[pright\](.*?)\[\/pright\]~si' => '

    $1

    ', 91 | '~\[pcenter\](.*?)\[\/pcenter\]~si' => '

    $1

    ', 92 | '~\[pjustify\](.*?)\[\/pjustify\]~si' => '

    $1

    ', 93 | 94 | 95 | # 96 | '~\[abbr\](.*?)\[\/abbr\]~si' => '$1', 97 | '~\[abbr (.*?)\](.*?)\[\/abbr\]~si' => '$2', 98 | 99 | '~\[q\](.*?)\[\/q\]~si' => '$1', 100 | '~\[q (.*?)\](.*?)\[\/q\]~si' => '$2', 101 | 102 | '~\[cite\](.*?)\[\/cite\]~si' => '$1', 103 | '~\[cite (.*?)\](.*?)\[\/cite\]~si' => '$2', 104 | 105 | '~\[address\](.*?)\[\/address\]~si' => '
    $1
    ', 106 | '~\[address (.*?)\](.*?)\[\/address\]~si' => '
    $2
    ', 107 | 108 | '~\[dfn\](.*?)\[\/dfn\]~si' => '$1', 109 | '~\[dfn (.*?)\](.*?)\[\/dfn\]~si' => '$2', 110 | 111 | '~\[dl\](.*?)\[\/dl\]~si' => '
    $1
    ', 112 | '~\[dl (.*?)\](.*?)\[\/dl\]~si' => '
    $2
    ', 113 | 114 | '~\[dt\](.*?)\[\/dt\]~si' => '
    $1
    ', 115 | '~\[dt (.*?)\](.*?)\[\/dt\]~si' => '
    $2
    ', 116 | 117 | '~\[dd\](.*?)\[\/dd\]~si' => '
    $1
    ', 118 | '~\[dd (.*?)\](.*?)\[\/dd\]~si' => '
    $2
    ', 119 | 120 | '~\[ins\](.*?)\[\/ins\]~si' => '$1', 121 | '~\[ins (.*?)\](.*?)\[\/ins\]~si' => '$2', 122 | 123 | '~\[hr\]~si' => '
    ', 124 | '~\[line\]~si' => '
    ', 125 | 126 | 127 | # table 128 | '~\[table\]~si' => '', 129 | '~\[table (.*?)\]~si' => '
    ', 130 | '~\[\/table\]~si' => '
    ', 131 | 132 | '~\[tr\]~si' => '', 133 | '~\[tr (.*?)\]~si' => '', 134 | '~\[\/tr\]~si' => '', 135 | 136 | '~\[td\]~si' => '', 137 | '~\[td (.*?)\]~si' => '', 138 | '~\[\/td\]~si' => '', 139 | 140 | '~\[th\]~si' => '', 141 | '~\[th (.*?)\]~si' => '', 142 | '~\[\/th\]~si' => '', 143 | 144 | 145 | # [*] [list] [ul] [ol] 146 | '~\[\*\](.*?)\[\/\*\]~si' => '
  • $1
  • ', 147 | '~\[\*\]~si' => '
  • ', 148 | '~\[ul\](.*?)\[\/ul\]~si' => "
      $1
    ", 149 | '~\[list\](.*?)\[\/list\]~si' => "
      $1
    ", 150 | '~\[ol\](.*?)\[\/ol\]~si' => '
      $1
    ', 151 | 152 | # [li] 153 | '~\[li\]~si' => '
  • ', 154 | '~\[li (.*?)\]~si' => '
  • ', 155 | '~\[\/li\]~si' => '
  • ', 156 | 157 | 158 | # headers 159 | '~\[h1\](.*?)\[\/h1\]~si' => '

    $1

    ', 160 | '~\[h1\((.[^ ]*?)\)\](.*?)\[\/h1\]~si' => '

    $2

    ', 161 | '~\[h1 (.*?)\](.*?)\[\/h1\]~si' => '

    $2

    ', 162 | 163 | '~\[h2\](.*?)\[\/h2\]~si' => '

    $1

    ', 164 | '~\[h2\((.[^ ]*?)\)\](.*?)\[\/h2\]~si' => '

    $2

    ', 165 | '~\[h2 (.*?)\](.*?)\[\/h2\]~si' => '

    $2

    ', 166 | 167 | '~\[h3\](.*?)\[\/h3\]~si' => '

    $1

    ', 168 | '~\[h3\((.[^ ]*?)\)\](.*?)\[\/h3\]~si' => '

    $2

    ', 169 | '~\[h3 (.*?)\](.*?)\[\/h3\]~si' => '

    $2

    ', 170 | 171 | '~\[h4\](.*?)\[\/h4\]~si' => '

    $1

    ', 172 | '~\[h4\((.[^ ]*?)\)\](.*?)\[\/h4\]~si' => '

    $2

    ', 173 | '~\[h4 (.*?)\](.*?)\[\/h4\]~si' => '

    $2

    ', 174 | 175 | '~\[h5\](.*?)\[\/h5\]~si' => '
    $1
    ', 176 | '~\[h5\((.[^ ]*?)\)\](.*?)\[\/h5\]~si' => '
    $2
    ', 177 | '~\[h5 (.*?)\](.*?)\[\/h5\]~si' => '
    $2
    ', 178 | 179 | '~\[h6\](.*?)\[\/h6\]~si' => '
    $1
    ', 180 | '~\[h6\((.[^ ]*?)\)\](.*?)\[\/h6\]~si' => '
    $2
    ', 181 | '~\[h6 (.*?)\](.*?)\[\/h6\]~si' => '
    $2
    ', 182 | 183 | # [code=language][/code] 184 | '~\[code\](.*?)\[\/code\]~si' => '$1', 185 | 186 | 187 | # links 188 | # [url]http://maxsite.org/[/url] 189 | # [url=http://maxsite.org/]Блог Макса[/url] 190 | # [url=http://maxsite.org/ rel="nofollow"]Блог Макса[/url] 191 | # [url rel="nofollow"]http://maxsite.org/[/url] 192 | 193 | '~\[url\](.*?)\[\/url\]~si' => '$1', 194 | '~\[url=(.[^ ]*?)\](.*?)\[\/url\]~si' => '$2', 195 | '~\[url=(.[^\s]*?) (.*?)\](.*?)\[\/url\]~si' => '$3', 196 | '~\[url (.*?)\](.*?)\[\/url\]~si' => '$2', 197 | 198 | 199 | # images 200 | 201 | '~\[imgleft=(.*?)x(.*?)\](.*?)\[\/imgleft\]~si' => '', 202 | '~\[imgleft\](.*?)\[\/imgleft\]~si' => '', 203 | '~\[imgleft (.*?)\](.*?)\[\/imgleft\]~si' => '$1', 204 | 205 | '~\[imgright=(.*?)x(.*?)\](.*?)\[\/imgright\]~si' => '', 206 | '~\[imgright\](.*?)\[\/imgright\]~si' => '', 207 | '~\[imgright (.*?)\](.*?)\[\/imgright\]~si' => '$1', 208 | 209 | '~\[imgcenter\](.*?)\[\/imgcenter\]~si' => '
    ', 210 | '~\[imgcenter (.*?)\](.*?)\[\/imgcenter\]~si' => '
    $1
    ', 211 | 212 | # [imgmini=http://site/uploads/sborka-mini.jpg]http://site/uploads/sborka.jpg[/imgmini] 213 | '~\[imgmini=_(.*?)\](.*?)\[\/imgmini\]~si' => '', 214 | '~\[imgmini=(.*?)\](.*?)\[\/imgmini\]~si' => '', 215 | 216 | '~\[img=(.*?)x(.*?)\](.*?)\[\/img\]~si' => '', 217 | 218 | '~\[img (.*?)\](.*?)\[\/img\]~si' => '$1', 219 | '~\[img\](.*?)\[\/img\]~si' => '', 220 | 221 | # [img(right)]http://localhost/uploads/2008-07-11-19-50-56.jpg[/img] 222 | '~\[img\((.[^ ]*?)\)\](.*?)\[\/img\]~si' => '', 223 | 224 | # [img(right) Описание файла]http://localhost/uploads/2008-07-11-19-50-56.jpg[/img] 225 | '~\[img\((.[^ ]*?)\) (.*?)\](.*?)\[\/img\]~si' => '$2', 226 | 227 | 228 | 229 | # quoting 230 | '~\[quote\](.*?)\[\/quote\]~si' => '
    $1
    ', 231 | '~\[quote=(?:"|"|\')?(.*?)["\']?(?:"|"|\')?\](.*?)\[\/quote\]~si' => '
    $1:$2
    ', 232 | 233 | 234 | # [div(class)]текст[/div] 235 | '~\[div\((.*?)\)\](.*?)\[\/div\]~si' => '
    $2
    ', 236 | 237 | # [div style="color: red"]текст[/div] - произвольные атрибуты 238 | '~\[div (.*?)\](.*?)\[\/div\]~si' => '
    $2
    ', 239 | 240 | # [div(class) атрибуты]текст[/div] 241 | '~\[div\((.*?)\) (.*?)\](.*?)\[\/div\]~si' => '
    $3
    ', 242 | 243 | # [span(class)]текст[/span] 244 | '~\[span\((.*?)\)\](.*?)\[\/span\]~si' => '$2', 245 | 246 | # [span style="color: red"]текст[/span] - произвольные атрибуты 247 | '~\[span (.*?)\](.*?)\[\/span\]~si' => '$2', 248 | 249 | # [span(class) атрибуты]текст[/span] 250 | '~\[span\((.*?)\) (.*?)\](.*?)\[\/span\]~si' => '$3', 251 | 252 | ); 253 | 254 | $text = preg_replace(array_keys($preg), array_values($preg), $text); 255 | 256 | 257 | return $text; 258 | } 259 | 260 | 261 | function bbcode_editor_content_callback($matches) 262 | { 263 | $m = $matches[2]; 264 | 265 | $m = htmlspecialchars($m); 266 | 267 | $m = str_replace("&lt;br&gt;", "
    ", $m); 268 | $m = str_replace("&", "&", $m); 269 | 270 | $m = '[pre' . $matches[1] . ']' . $m . '[/pre]'; 271 | 272 | return $m; 273 | } 274 | 275 | # end file -------------------------------------------------------------------------------- /lpf-core/engine/bbcode/help/bbcode-help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Справка по использованию BB-code 5 | 19 |
    20 | 21 |

    Справочник BB-code

    22 | 23 |

    Работа с текстом:

    24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
    BB-кодОписаниеПримерПредставление в HTML
    [b]текст[/b]Важный текст, полужирныйтекст<strong>текст</strong>
    [i]текст[/i]Важный текст, курсивтекст<em>текст</em>
    [bold]текст[/bold]Просто полужирныйтекст<b>текст</b>
    [italic]текст[/italic]Просто курсивтекст<i>текст</i>
    [u]текст[/u]Подчёркнутый тексттекст<u>текст</u>
    [s]текст[/s]Зачеркнутыйтекст<s>текст</s>
    [sup]текст[/sup]Верхний индекстекст<sup>текст</sup>
    [sub]текст[/sub]Нижний индекстекст<sub>текст</sub>
    [small]текст[/small]Уменьшенный шрифттекст<small>текст</small>
    [p]текст[/p]Абзац<p>текст</p>
    [color=цвет]текст[/color]Цвет текста<span style="color:цвет">текст</span>
    [size=10pt]текст[/size]Размер шрифта<span style="font-size:10pt">текст</span>
    [div=стиль]текст[/div]style для блока<div style="стиль">текст</div>
    [p=стиль]текст[/p]style для абзаца<p style="стиль">текст</p>
    [span=стиль]текст[/span]style для текста<span style="стиль">текст</span>
    42 | 43 |

    Выравнивание:

    44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
    BB-кодОписаниеПредставление в HTML
    [left]текст[/left]Выравнивание в блоке влево<div style="text-align: left;">текст</div>
    [right]текст[/right]Выравнивание в блоке вправо<div style="text-align: right;">текст</div>
    [center]текст[/center]Выравнивание в блоке по центру<div style="text-align: center;">текст</div>
    [justify]текст[/justify]Выравнивание в блоке по ширине<div style="text-align: justify;">текст</div>
    [left стиль]текст[/left] Выравнивание в блоке влево<div style="text-align: left; стиль">текст</div>
    [right стиль]текст[/right]Выравнивание в блоке вправо<div style="text-align: right; стиль">текст</div>
    [center стиль]текст[/center]Выравнивание в блоке по центру<div style="text-align: center; стиль">текст</div>
    [justify стиль]текст[/justify]Выравнивание в блоке по ширине<div style="text-align: justify; стиль">текст</div>
    [pleft]текст[/pleft]Выравнивание в абзаце влево<p style="text-align: left;">текст</p>
    [pright]текст[/pright]Выравнивание в абзаце вправо<p style="text-align: right;">текст</p>
    [pcenter]текст[/pcenter]Выравнивание в абзаце по центру<p style="text-align: center;">текст</p>
    [pjustify]текст[/pjustify]Выравнивание в абзаце по ширине<p style="text-align: justify;">текст</p>
    59 | 60 |

    Заголовки:

    61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
    BB-кодОписаниеПримерПредставление в HTML
    [h1]текст[/h1]Заголовок 1-го уровня

    текст

    <h1>текст</h1>
    [h2]текст[/h2]Заголовок 2-го уровня

    текст

    <h2>текст</h2>
    [h3]текст[/h3]Заголовок 3-го уровня

    текст

    <h3>текст</h3>
    [h4]текст[/h4]Заголовок 4-го уровня

    текст

    <h4>текст</h4>
    [h5]текст[/h5]Заголовок 5-го уровня
    текст
    <h5>текст</h5>
    [h6]текст[/h6]Заголовок 6-го уровня
    текст
    <h6>текст</h6>
    [h1(класс)]текст[/h1]Заголовок 1-го уровня с классом. Аналогично для h2-h6.<h1 class="класс">текст</h1>
    71 | 72 |

    Списки:

    73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
    BB-кодОписаниеПредставление в HTML
    [list]список[/list]Маркированный список<ul>список</ul>
    [ul]список[/ul]Маркированный список<ul>список</ul>
    [ol]список[/ol]Нумерованный список<ol>список</ol>
    [*]текстЭлемент списка<li>текст
    [*]текст[/*]Элемент списка<li>текст</li>
    81 |

    ПРИМЕР СПИСКА:

    82 |

        [list]

    83 |

           [*]первый

    84 |

           [*]второй

    85 |

           [*]третий

    86 |

        [/list]

    87 |
    88 | 89 |

    Разное:

    90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
    BB-кодОписаниеПримерПредставление в HTML
    [br]Принудительный перенос строки<br clear="all">
    [code]текст[/code]Кодтекст<code>текст</code>
    [pre]текст[/pre]Преформатированный текст
    текст
    <pre>текст</pre>
    [abbr]абревиатура[/abbr]Абревиатураабревиатура<abbr>абревиатура</abbr>
    [abbr описание]...[/abbr]Абревиатура с описаниемабревиатура<abbr title="описание">абревиатура</abbr>
    [q]цитата в строке[/q]Цитатацитата<q>цитата в строке</q>
    [q свойства]цитата в строке[/q]Цитата со свойствами<q свойства>цитата в строке</q>
    [cite]Сноска[/cite]Сноскасноска<cite>Сноска</cite>
    [cite свойства]Сноска[/cite]Сноска со свойствами<cite свойства>Сноска</cite>
    [address]адрес[/address]Адрес
    адрес
    <address>адрес</address>
    [address свойства]адрес[/address]Адрес со свойствами<address свойства>адрес</address>
    [dfn]Новый термин[/dfn]<dfn>Новый термин</dfn>
    [dfn свойства]Новый термин[/dfn]<dfn свойства>Новый термин</dfn>
    [del]удаленный текст[/del]<del>удаленный текст</del>
    [del свойства]удаленный текст[/del]<del свойства>удаленный текст</del>
    [ins]Добавленный текст[/ins]<ins>Добавленный текст</ins>
    [ins свойства]Добавленный текст[/ins]<ins свойства>Добавленный текст</ins>
    [dl]Список определений[/dl]<dl>Список определений</dl>
    [dl свойства]Список определений[/dl]<dl свойства>Список определений</dl>
    [dt]Определение[/dt]<dt>Определение</dt>
    [dt свойства]Определение[/dt]<dt свойства>Определение</dt>
    [dd]Описание[/dd]<dd>Описание</dd>
    [dd свойства]Описание[/dd]<dd свойства>Описание</dd>
    [quote]текст[/quote]Цитата<blockquote>текст</blockquote>
    [div(class)]текст[/div]<div class="class">текст</div>
    [div атрибуты]текст[/div]<div атрибуты>текст</div>
    [span(class)]текст[/span]<span class="class">текст</span>
    [span атрибуты]текст[/span]<span атрибуты>текст</span>
    [text-demo]Подключает файл text-demo.txt (можно использовать для проверки стилей шаблона)
    122 | 123 |

    Работа с картинками:

    124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
    BB-кодОписаниеПредставление в HTML
    [img]адрес[/img]Картинка<img src="адрес">
    [img=300x500]адрес[/img]Картинка с размерами<img src="адрес" style="width: 300px; height: 500px">
    [imgleft]адрес[/imgleft]Картинка влево<img src="адрес" style="float: left; margin: 0 10px 0 0;">
    [imgright]адрес[/imgright]Картинка вправо<img src="адрес" style="float: right; margin: 0 0 0 10px;">
    [imgcenter]адрес[/imgcenter]Картинка по центру<div style="text-align: center"><img src="адрес"></div>
    Аналогичные, только с названиями/всплывающими подсказками. В названии нельзя использовать кавычки!
    [img Название]адрес[/img]
    [imgleft Название]адрес[/imgleft]
    [imgright Название]адрес[/imgright]
    [imgcenter Название]адрес[/imgcenter]
    [imgleft=300x500]адрес[/imgleft]Картинка с размерами влево
    [imgright=300x500]адрес[/imgright]Картинка с размерами вправо
    [img(cssClass)]адрес[/img]Картинка с указанным css-классом
    [img(cssClass) Описание]адрес[/img]Картинка с указанным css-классом и описанием
    Миниатюра (адрес-mini) со ссылкой на оригинал
    [imgmini=_адрес-mini]адрес[/imgmini]Открыть в новом окне<a href="адрес" target="_blank"><img src="адрес-mini"></a>
    [imgmini=адрес-mini]адрес[/imgmini]Открыть в том же окне<a href="адрес"><img src="адрес-mini"></a>
    144 | 145 | 146 | 147 |

    Работа с ссылками:

    148 | 149 | 150 | 151 | 152 | 153 | 154 |
    BB-кодПредставление в HTML
    [url]http://maxsite.org/[/url]<a href="http://maxsite.org/">http://maxsite.org/</a>
    [url=http://maxsite.org/]Блог Макса[/url]<a href="http://maxsite.org/">Блог Макса</a>
    [url=http://maxsite.org/ rel="nofollow"]Блог Макса[/url]<a href="http://maxsite.org/" rel="nofollow">Блог Макса</a>
    [url rel="nofollow"]http://maxsite.org/[/url]<a href="http://maxsite.org/" rel="nofollow">http://maxsite.org/</a>
    155 | 156 |

    Работа с таблицей:

    157 |
    158 |
    159 |

    ПРИМЕР ТАБЛИЦЫ:

    160 |

       [table]

    161 |

          [tr]

    162 |

             [td]1-я ячейка 1-й строки[/td]

    163 |

             [td]2-я ячейка 1-й строки[/td]

    164 |

             [td]3-я ячейка 1-й строки[/td]

    165 |

          [/tr]

    166 |

          [tr]

    167 |

             [td]1-я ячейка 2-й строки[/td]

    168 |

             [td]2-я ячейка 2-й строки[/td]

    169 |

             [td]3-я ячейка 2-й строки[/td]

    170 |

          [/tr]

    171 |

          [tr]

    172 |

             [td]1-я ячейка 3-й строки[/td]

    173 |

             [td]2-я ячейка 3-й строки[/td]

    174 |

             [td]3-я ячейка 3-й строки[/td]

    175 |

          [/tr]

    176 |

       [/table]

    177 |

    178 |

    В таблице можно указывать произвольные стили, классы и т.п.:

    179 |

    [table class="red" style="border: 1px solid red"]

    180 |

    ...

    181 |

    [tr rowspan="2"]

    182 |

    [td style="font-size: 18pt"]

    183 |
    184 | 185 |
    186 | -------------------------------------------------------------------------------- /lpf-core/engine/yaml/Spyc.php: -------------------------------------------------------------------------------- 1 | 6 | * @author Chris Wanstrath 7 | * @link https://github.com/mustangostang/spyc/ 8 | * @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2011 Vlad Andersen 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 10 | * @package Spyc 11 | */ 12 | 13 | if (!function_exists('spyc_load')) { 14 | /** 15 | * Parses YAML to array. 16 | * @param string $string YAML string. 17 | * @return array 18 | */ 19 | function spyc_load ($string) { 20 | return Spyc::YAMLLoadString($string); 21 | } 22 | } 23 | 24 | if (!function_exists('spyc_load_file')) { 25 | /** 26 | * Parses YAML to array. 27 | * @param string $file Path to YAML file. 28 | * @return array 29 | */ 30 | function spyc_load_file ($file) { 31 | return Spyc::YAMLLoad($file); 32 | } 33 | } 34 | 35 | if (!function_exists('spyc_dump')) { 36 | /** 37 | * Dumps array to YAML. 38 | * @param array $data Array. 39 | * @return string 40 | */ 41 | function spyc_dump ($data) { 42 | return Spyc::YAMLDump($data, false, false, true); 43 | } 44 | } 45 | 46 | if (!class_exists('Spyc')) { 47 | 48 | /** 49 | * The Simple PHP YAML Class. 50 | * 51 | * This class can be used to read a YAML file and convert its contents 52 | * into a PHP array. It currently supports a very limited subsection of 53 | * the YAML spec. 54 | * 55 | * Usage: 56 | * 57 | * $Spyc = new Spyc; 58 | * $array = $Spyc->load($file); 59 | * 60 | * or: 61 | * 62 | * $array = Spyc::YAMLLoad($file); 63 | * 64 | * or: 65 | * 66 | * $array = spyc_load_file($file); 67 | * 68 | * @package Spyc 69 | */ 70 | class Spyc { 71 | 72 | // SETTINGS 73 | 74 | const REMPTY = "\0\0\0\0\0"; 75 | 76 | /** 77 | * Setting this to true will force YAMLDump to enclose any string value in 78 | * quotes. False by default. 79 | * 80 | * @var bool 81 | */ 82 | public $setting_dump_force_quotes = false; 83 | 84 | /** 85 | * Setting this to true will forse YAMLLoad to use syck_load function when 86 | * possible. False by default. 87 | * @var bool 88 | */ 89 | public $setting_use_syck_is_possible = false; 90 | 91 | 92 | 93 | /**#@+ 94 | * @access private 95 | * @var mixed 96 | */ 97 | private $_dumpIndent; 98 | private $_dumpWordWrap; 99 | private $_containsGroupAnchor = false; 100 | private $_containsGroupAlias = false; 101 | private $path; 102 | private $result; 103 | private $LiteralPlaceHolder = '___YAML_Literal_Block___'; 104 | private $SavedGroups = array(); 105 | private $indent; 106 | /** 107 | * Path modifier that should be applied after adding current element. 108 | * @var array 109 | */ 110 | private $delayedPath = array(); 111 | 112 | /**#@+ 113 | * @access public 114 | * @var mixed 115 | */ 116 | public $_nodeId; 117 | 118 | /** 119 | * Load a valid YAML string to Spyc. 120 | * @param string $input 121 | * @return array 122 | */ 123 | public function load ($input) { 124 | return $this->_loadString($input); 125 | } 126 | 127 | /** 128 | * Load a valid YAML file to Spyc. 129 | * @param string $file 130 | * @return array 131 | */ 132 | public function loadFile ($file) { 133 | return $this->_load($file); 134 | } 135 | 136 | /** 137 | * Load YAML into a PHP array statically 138 | * 139 | * The load method, when supplied with a YAML stream (string or file), 140 | * will do its best to convert YAML in a file into a PHP array. Pretty 141 | * simple. 142 | * Usage: 143 | * 144 | * $array = Spyc::YAMLLoad('lucky.yaml'); 145 | * print_r($array); 146 | * 147 | * @access public 148 | * @return array 149 | * @param string $input Path of YAML file or string containing YAML 150 | */ 151 | public static function YAMLLoad($input) { 152 | $Spyc = new Spyc; 153 | return $Spyc->_load($input); 154 | } 155 | 156 | /** 157 | * Load a string of YAML into a PHP array statically 158 | * 159 | * The load method, when supplied with a YAML string, will do its best 160 | * to convert YAML in a string into a PHP array. Pretty simple. 161 | * 162 | * Note: use this function if you don't want files from the file system 163 | * loaded and processed as YAML. This is of interest to people concerned 164 | * about security whose input is from a string. 165 | * 166 | * Usage: 167 | * 168 | * $array = Spyc::YAMLLoadString("---\n0: hello world\n"); 169 | * print_r($array); 170 | * 171 | * @access public 172 | * @return array 173 | * @param string $input String containing YAML 174 | */ 175 | public static function YAMLLoadString($input) { 176 | $Spyc = new Spyc; 177 | return $Spyc->_loadString($input); 178 | } 179 | 180 | /** 181 | * Dump YAML from PHP array statically 182 | * 183 | * The dump method, when supplied with an array, will do its best 184 | * to convert the array into friendly YAML. Pretty simple. Feel free to 185 | * save the returned string as nothing.yaml and pass it around. 186 | * 187 | * Oh, and you can decide how big the indent is and what the wordwrap 188 | * for folding is. Pretty cool -- just pass in 'false' for either if 189 | * you want to use the default. 190 | * 191 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And 192 | * you can turn off wordwrap by passing in 0. 193 | * 194 | * @access public 195 | * @return string 196 | * @param array|\stdClass $array PHP array 197 | * @param int $indent Pass in false to use the default, which is 2 198 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 199 | * @param bool $no_opening_dashes Do not start YAML file with "---\n" 200 | */ 201 | public static function YAMLDump($array, $indent = false, $wordwrap = false, $no_opening_dashes = false) { 202 | $spyc = new Spyc; 203 | return $spyc->dump($array, $indent, $wordwrap, $no_opening_dashes); 204 | } 205 | 206 | 207 | /** 208 | * Dump PHP array to YAML 209 | * 210 | * The dump method, when supplied with an array, will do its best 211 | * to convert the array into friendly YAML. Pretty simple. Feel free to 212 | * save the returned string as tasteful.yaml and pass it around. 213 | * 214 | * Oh, and you can decide how big the indent is and what the wordwrap 215 | * for folding is. Pretty cool -- just pass in 'false' for either if 216 | * you want to use the default. 217 | * 218 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And 219 | * you can turn off wordwrap by passing in 0. 220 | * 221 | * @access public 222 | * @return string 223 | * @param array $array PHP array 224 | * @param int $indent Pass in false to use the default, which is 2 225 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 226 | */ 227 | public function dump($array,$indent = false,$wordwrap = false, $no_opening_dashes = false) { 228 | // Dumps to some very clean YAML. We'll have to add some more features 229 | // and options soon. And better support for folding. 230 | 231 | // New features and options. 232 | if ($indent === false or !is_numeric($indent)) { 233 | $this->_dumpIndent = 2; 234 | } else { 235 | $this->_dumpIndent = $indent; 236 | } 237 | 238 | if ($wordwrap === false or !is_numeric($wordwrap)) { 239 | $this->_dumpWordWrap = 40; 240 | } else { 241 | $this->_dumpWordWrap = $wordwrap; 242 | } 243 | 244 | // New YAML document 245 | $string = ""; 246 | if (!$no_opening_dashes) $string = "---\n"; 247 | 248 | // Start at the base of the array and move through it. 249 | if ($array) { 250 | $array = (array)$array; 251 | $previous_key = -1; 252 | foreach ($array as $key => $value) { 253 | if (!isset($first_key)) $first_key = $key; 254 | $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key, $array); 255 | $previous_key = $key; 256 | } 257 | } 258 | return $string; 259 | } 260 | 261 | /** 262 | * Attempts to convert a key / value array item to YAML 263 | * @access private 264 | * @return string 265 | * @param $key The name of the key 266 | * @param $value The value of the item 267 | * @param $indent The indent of the current node 268 | */ 269 | private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0, $source_array = null) { 270 | if(is_object($value)) $value = (array)$value; 271 | if (is_array($value)) { 272 | if (empty ($value)) 273 | return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key, $source_array); 274 | // It has children. What to do? 275 | // Make it the right kind of item 276 | $string = $this->_dumpNode($key, self::REMPTY, $indent, $previous_key, $first_key, $source_array); 277 | // Add the indent 278 | $indent += $this->_dumpIndent; 279 | // Yamlize the array 280 | $string .= $this->_yamlizeArray($value,$indent); 281 | } elseif (!is_array($value)) { 282 | // It doesn't have children. Yip. 283 | $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array); 284 | } 285 | return $string; 286 | } 287 | 288 | /** 289 | * Attempts to convert an array to YAML 290 | * @access private 291 | * @return string 292 | * @param $array The array you want to convert 293 | * @param $indent The indent of the current level 294 | */ 295 | private function _yamlizeArray($array,$indent) { 296 | if (is_array($array)) { 297 | $string = ''; 298 | $previous_key = -1; 299 | foreach ($array as $key => $value) { 300 | if (!isset($first_key)) $first_key = $key; 301 | $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array); 302 | $previous_key = $key; 303 | } 304 | return $string; 305 | } else { 306 | return false; 307 | } 308 | } 309 | 310 | /** 311 | * Returns YAML from a key and a value 312 | * @access private 313 | * @return string 314 | * @param $key The name of the key 315 | * @param $value The value of the item 316 | * @param $indent The indent of the current node 317 | */ 318 | private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null) { 319 | // do some folding here, for blocks 320 | if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false || 321 | strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, '%') !== false || strpos ($value, ' ') !== false || 322 | strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "'") !== false || strpos($value, "!") === 0 || 323 | substr ($value, -1, 1) == ':') 324 | ) { 325 | $value = $this->_doLiteralBlock($value,$indent); 326 | } else { 327 | $value = $this->_doFolding($value,$indent); 328 | } 329 | 330 | if ($value === array()) $value = '[ ]'; 331 | if ($value === "") $value = '""'; 332 | if (self::isTranslationWord($value)) { 333 | $value = $this->_doLiteralBlock($value, $indent); 334 | } 335 | if (trim ($value) != $value) 336 | $value = $this->_doLiteralBlock($value,$indent); 337 | 338 | if (is_bool($value)) { 339 | $value = $value ? "true" : "false"; 340 | } 341 | 342 | if ($value === null) $value = 'null'; 343 | if ($value === "'" . self::REMPTY . "'") $value = null; 344 | 345 | $spaces = str_repeat(' ',$indent); 346 | 347 | //if (is_int($key) && $key - 1 == $previous_key && $first_key===0) { 348 | if (is_array ($source_array) && array_keys($source_array) === range(0, count($source_array) - 1)) { 349 | // It's a sequence 350 | $string = $spaces.'- '.$value."\n"; 351 | } else { 352 | // if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"'); 353 | // It's mapped 354 | if (strpos($key, ":") !== false || strpos($key, "#") !== false) { $key = '"' . $key . '"'; } 355 | $string = rtrim ($spaces.$key.': '.$value)."\n"; 356 | } 357 | return $string; 358 | } 359 | 360 | /** 361 | * Creates a literal block for dumping 362 | * @access private 363 | * @return string 364 | * @param $value 365 | * @param $indent int The value of the indent 366 | */ 367 | private function _doLiteralBlock($value,$indent) { 368 | if ($value === "\n") return '\n'; 369 | if (strpos($value, "\n") === false && strpos($value, "'") === false) { 370 | return sprintf ("'%s'", $value); 371 | } 372 | if (strpos($value, "\n") === false && strpos($value, '"') === false) { 373 | return sprintf ('"%s"', $value); 374 | } 375 | $exploded = explode("\n",$value); 376 | $newValue = '|'; 377 | if (isset($exploded[0]) && ($exploded[0] == "|" || $exploded[0] == "|-" || $exploded[0] == ">")) { 378 | $newValue = $exploded[0]; 379 | unset($exploded[0]); 380 | } 381 | $indent += $this->_dumpIndent; 382 | $spaces = str_repeat(' ',$indent); 383 | foreach ($exploded as $line) { 384 | $line = trim($line); 385 | if (strpos($line, '"') === 0 && strrpos($line, '"') == (strlen($line)-1) || strpos($line, "'") === 0 && strrpos($line, "'") == (strlen($line)-1)) { 386 | $line = substr($line, 1, -1); 387 | } 388 | $newValue .= "\n" . $spaces . ($line); 389 | } 390 | return $newValue; 391 | } 392 | 393 | /** 394 | * Folds a string of text, if necessary 395 | * @access private 396 | * @return string 397 | * @param $value The string you wish to fold 398 | */ 399 | private function _doFolding($value,$indent) { 400 | // Don't do anything if wordwrap is set to 0 401 | 402 | if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) { 403 | $indent += $this->_dumpIndent; 404 | $indent = str_repeat(' ',$indent); 405 | $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent"); 406 | $value = ">\n".$indent.$wrapped; 407 | } else { 408 | if ($this->setting_dump_force_quotes && is_string ($value) && $value !== self::REMPTY) 409 | $value = '"' . $value . '"'; 410 | if (is_numeric($value) && is_string($value)) 411 | $value = '"' . $value . '"'; 412 | } 413 | 414 | 415 | return $value; 416 | } 417 | 418 | private function isTrueWord($value) { 419 | $words = self::getTranslations(array('true', 'on', 'yes', 'y')); 420 | return in_array($value, $words, true); 421 | } 422 | 423 | private function isFalseWord($value) { 424 | $words = self::getTranslations(array('false', 'off', 'no', 'n')); 425 | return in_array($value, $words, true); 426 | } 427 | 428 | private function isNullWord($value) { 429 | $words = self::getTranslations(array('null', '~')); 430 | return in_array($value, $words, true); 431 | } 432 | 433 | private function isTranslationWord($value) { 434 | return ( 435 | self::isTrueWord($value) || 436 | self::isFalseWord($value) || 437 | self::isNullWord($value) 438 | ); 439 | } 440 | 441 | /** 442 | * Coerce a string into a native type 443 | * Reference: http://yaml.org/type/bool.html 444 | * TODO: Use only words from the YAML spec. 445 | * @access private 446 | * @param $value The value to coerce 447 | */ 448 | private function coerceValue(&$value) { 449 | if (self::isTrueWord($value)) { 450 | $value = true; 451 | } else if (self::isFalseWord($value)) { 452 | $value = false; 453 | } else if (self::isNullWord($value)) { 454 | $value = null; 455 | } 456 | } 457 | 458 | /** 459 | * Given a set of words, perform the appropriate translations on them to 460 | * match the YAML 1.1 specification for type coercing. 461 | * @param $words The words to translate 462 | * @access private 463 | */ 464 | private static function getTranslations(array $words) { 465 | $result = array(); 466 | foreach ($words as $i) { 467 | $result = array_merge($result, array(ucfirst($i), strtoupper($i), strtolower($i))); 468 | } 469 | return $result; 470 | } 471 | 472 | // LOADING FUNCTIONS 473 | 474 | private function _load($input) { 475 | $Source = $this->loadFromSource($input); 476 | return $this->loadWithSource($Source); 477 | } 478 | 479 | private function _loadString($input) { 480 | $Source = $this->loadFromString($input); 481 | return $this->loadWithSource($Source); 482 | } 483 | 484 | private function loadWithSource($Source) { 485 | if (empty ($Source)) return array(); 486 | if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) { 487 | $array = syck_load (implode ("\n", $Source)); 488 | return is_array($array) ? $array : array(); 489 | } 490 | 491 | $this->path = array(); 492 | $this->result = array(); 493 | 494 | $cnt = count($Source); 495 | for ($i = 0; $i < $cnt; $i++) { 496 | $line = $Source[$i]; 497 | 498 | $this->indent = strlen($line) - strlen(ltrim($line)); 499 | $tempPath = $this->getParentPathByIndent($this->indent); 500 | $line = self::stripIndent($line, $this->indent); 501 | if (self::isComment($line)) continue; 502 | if (self::isEmpty($line)) continue; 503 | $this->path = $tempPath; 504 | 505 | $literalBlockStyle = self::startsLiteralBlock($line); 506 | if ($literalBlockStyle) { 507 | $line = rtrim ($line, $literalBlockStyle . " \n"); 508 | $literalBlock = ''; 509 | $line .= ' '.$this->LiteralPlaceHolder; 510 | $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1])); 511 | while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) { 512 | $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent); 513 | } 514 | $i--; 515 | } 516 | 517 | // Strip out comments 518 | if (strpos ($line, '#')) { 519 | $line = preg_replace('/\s*#([^"\']+)$/','',$line); 520 | } 521 | 522 | while (++$i < $cnt && self::greedilyNeedNextLine($line)) { 523 | $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); 524 | } 525 | $i--; 526 | 527 | $lineArray = $this->_parseLine($line); 528 | 529 | if ($literalBlockStyle) 530 | $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock); 531 | 532 | $this->addArray($lineArray, $this->indent); 533 | 534 | foreach ($this->delayedPath as $indent => $delayedPath) 535 | $this->path[$indent] = $delayedPath; 536 | 537 | $this->delayedPath = array(); 538 | 539 | } 540 | return $this->result; 541 | } 542 | 543 | private function loadFromSource ($input) { 544 | if (!empty($input) && strpos($input, "\n") === false && file_exists($input)) 545 | $input = file_get_contents($input); 546 | 547 | return $this->loadFromString($input); 548 | } 549 | 550 | private function loadFromString ($input) { 551 | $lines = explode("\n",$input); 552 | foreach ($lines as $k => $_) { 553 | $lines[$k] = rtrim ($_, "\r"); 554 | } 555 | return $lines; 556 | } 557 | 558 | /** 559 | * Parses YAML code and returns an array for a node 560 | * @access private 561 | * @return array 562 | * @param string $line A line from the YAML file 563 | */ 564 | private function _parseLine($line) { 565 | if (!$line) return array(); 566 | $line = trim($line); 567 | if (!$line) return array(); 568 | 569 | $array = array(); 570 | 571 | $group = $this->nodeContainsGroup($line); 572 | if ($group) { 573 | $this->addGroup($line, $group); 574 | $line = $this->stripGroup ($line, $group); 575 | } 576 | 577 | if ($this->startsMappedSequence($line)) 578 | return $this->returnMappedSequence($line); 579 | 580 | if ($this->startsMappedValue($line)) 581 | return $this->returnMappedValue($line); 582 | 583 | if ($this->isArrayElement($line)) 584 | return $this->returnArrayElement($line); 585 | 586 | if ($this->isPlainArray($line)) 587 | return $this->returnPlainArray($line); 588 | 589 | 590 | return $this->returnKeyValuePair($line); 591 | 592 | } 593 | 594 | /** 595 | * Finds the type of the passed value, returns the value as the new type. 596 | * @access private 597 | * @param string $value 598 | * @return mixed 599 | */ 600 | private function _toType($value) { 601 | if ($value === '') return ""; 602 | $first_character = $value[0]; 603 | $last_character = substr($value, -1, 1); 604 | 605 | $is_quoted = false; 606 | do { 607 | if (!$value) break; 608 | if ($first_character != '"' && $first_character != "'") break; 609 | if ($last_character != '"' && $last_character != "'") break; 610 | $is_quoted = true; 611 | } while (0); 612 | 613 | if ($is_quoted) { 614 | $value = str_replace('\n', "\n", $value); 615 | if ($first_character == "'") 616 | return strtr(substr ($value, 1, -1), array ('\'\'' => '\'', '\\\''=> '\'')); 617 | return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\\\''=> '\'')); 618 | } 619 | 620 | if (strpos($value, ' #') !== false && !$is_quoted) 621 | $value = preg_replace('/\s+#(.+)$/','',$value); 622 | 623 | if ($first_character == '[' && $last_character == ']') { 624 | // Take out strings sequences and mappings 625 | $innerValue = trim(substr ($value, 1, -1)); 626 | if ($innerValue === '') return array(); 627 | $explode = $this->_inlineEscape($innerValue); 628 | // Propagate value array 629 | $value = array(); 630 | foreach ($explode as $v) { 631 | $value[] = $this->_toType($v); 632 | } 633 | return $value; 634 | } 635 | 636 | if (strpos($value,': ')!==false && $first_character != '{') { 637 | $array = explode(': ',$value); 638 | $key = trim($array[0]); 639 | array_shift($array); 640 | $value = trim(implode(': ',$array)); 641 | $value = $this->_toType($value); 642 | return array($key => $value); 643 | } 644 | 645 | if ($first_character == '{' && $last_character == '}') { 646 | $innerValue = trim(substr ($value, 1, -1)); 647 | if ($innerValue === '') return array(); 648 | // Inline Mapping 649 | // Take out strings sequences and mappings 650 | $explode = $this->_inlineEscape($innerValue); 651 | // Propagate value array 652 | $array = array(); 653 | foreach ($explode as $v) { 654 | $SubArr = $this->_toType($v); 655 | if (empty($SubArr)) continue; 656 | if (is_array ($SubArr)) { 657 | $array[key($SubArr)] = $SubArr[key($SubArr)]; continue; 658 | } 659 | $array[] = $SubArr; 660 | } 661 | return $array; 662 | } 663 | 664 | if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') { 665 | return null; 666 | } 667 | 668 | if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){ 669 | $intvalue = (int)$value; 670 | if ($intvalue != PHP_INT_MAX && $intvalue != ~PHP_INT_MAX) 671 | $value = $intvalue; 672 | return $value; 673 | } 674 | 675 | if ( is_string($value) && preg_match('/^0[xX][0-9a-fA-F]+$/', $value)) { 676 | // Hexadecimal value. 677 | return hexdec($value); 678 | } 679 | 680 | $this->coerceValue($value); 681 | 682 | if (is_numeric($value)) { 683 | if ($value === '0') return 0; 684 | if (rtrim ($value, 0) === $value) 685 | $value = (float)$value; 686 | return $value; 687 | } 688 | 689 | return $value; 690 | } 691 | 692 | /** 693 | * Used in inlines to check for more inlines or quoted strings 694 | * @access private 695 | * @return array 696 | */ 697 | private function _inlineEscape($inline) { 698 | // There's gotta be a cleaner way to do this... 699 | // While pure sequences seem to be nesting just fine, 700 | // pure mappings and mappings with sequences inside can't go very 701 | // deep. This needs to be fixed. 702 | 703 | $seqs = array(); 704 | $maps = array(); 705 | $saved_strings = array(); 706 | $saved_empties = array(); 707 | 708 | // Check for empty strings 709 | $regex = '/("")|(\'\')/'; 710 | if (preg_match_all($regex,$inline,$strings)) { 711 | $saved_empties = $strings[0]; 712 | $inline = preg_replace($regex,'YAMLEmpty',$inline); 713 | } 714 | unset($regex); 715 | 716 | // Check for strings 717 | $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; 718 | if (preg_match_all($regex,$inline,$strings)) { 719 | $saved_strings = $strings[0]; 720 | $inline = preg_replace($regex,'YAMLString',$inline); 721 | } 722 | unset($regex); 723 | 724 | // echo $inline; 725 | 726 | $i = 0; 727 | do { 728 | 729 | // Check for sequences 730 | while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) { 731 | $seqs[] = $matchseqs[0]; 732 | $inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1); 733 | } 734 | 735 | // Check for mappings 736 | while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) { 737 | $maps[] = $matchmaps[0]; 738 | $inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1); 739 | } 740 | 741 | if ($i++ >= 10) break; 742 | 743 | } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); 744 | 745 | $explode = explode(',',$inline); 746 | $explode = array_map('trim', $explode); 747 | $stringi = 0; $i = 0; 748 | 749 | while (1) { 750 | 751 | // Re-add the sequences 752 | if (!empty($seqs)) { 753 | foreach ($explode as $key => $value) { 754 | if (strpos($value,'YAMLSeq') !== false) { 755 | foreach ($seqs as $seqk => $seq) { 756 | $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value); 757 | $value = $explode[$key]; 758 | } 759 | } 760 | } 761 | } 762 | 763 | // Re-add the mappings 764 | if (!empty($maps)) { 765 | foreach ($explode as $key => $value) { 766 | if (strpos($value,'YAMLMap') !== false) { 767 | foreach ($maps as $mapk => $map) { 768 | $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value); 769 | $value = $explode[$key]; 770 | } 771 | } 772 | } 773 | } 774 | 775 | 776 | // Re-add the strings 777 | if (!empty($saved_strings)) { 778 | foreach ($explode as $key => $value) { 779 | while (strpos($value,'YAMLString') !== false) { 780 | $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1); 781 | unset($saved_strings[$stringi]); 782 | ++$stringi; 783 | $value = $explode[$key]; 784 | } 785 | } 786 | } 787 | 788 | 789 | // Re-add the empties 790 | if (!empty($saved_empties)) { 791 | foreach ($explode as $key => $value) { 792 | while (strpos($value,'YAMLEmpty') !== false) { 793 | $explode[$key] = preg_replace('/YAMLEmpty/', '', $value, 1); 794 | $value = $explode[$key]; 795 | } 796 | } 797 | } 798 | 799 | $finished = true; 800 | foreach ($explode as $key => $value) { 801 | if (strpos($value,'YAMLSeq') !== false) { 802 | $finished = false; break; 803 | } 804 | if (strpos($value,'YAMLMap') !== false) { 805 | $finished = false; break; 806 | } 807 | if (strpos($value,'YAMLString') !== false) { 808 | $finished = false; break; 809 | } 810 | if (strpos($value,'YAMLEmpty') !== false) { 811 | $finished = false; break; 812 | } 813 | } 814 | if ($finished) break; 815 | 816 | $i++; 817 | if ($i > 10) 818 | break; // Prevent infinite loops. 819 | } 820 | 821 | 822 | return $explode; 823 | } 824 | 825 | private function literalBlockContinues ($line, $lineIndent) { 826 | if (!trim($line)) return true; 827 | if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true; 828 | return false; 829 | } 830 | 831 | private function referenceContentsByAlias ($alias) { 832 | do { 833 | if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; } 834 | $groupPath = $this->SavedGroups[$alias]; 835 | $value = $this->result; 836 | foreach ($groupPath as $k) { 837 | $value = $value[$k]; 838 | } 839 | } while (false); 840 | return $value; 841 | } 842 | 843 | private function addArrayInline ($array, $indent) { 844 | $CommonGroupPath = $this->path; 845 | if (empty ($array)) return false; 846 | 847 | foreach ($array as $k => $_) { 848 | $this->addArray(array($k => $_), $indent); 849 | $this->path = $CommonGroupPath; 850 | } 851 | return true; 852 | } 853 | 854 | private function addArray ($incoming_data, $incoming_indent) { 855 | 856 | // print_r ($incoming_data); 857 | 858 | if (count ($incoming_data) > 1) 859 | return $this->addArrayInline ($incoming_data, $incoming_indent); 860 | 861 | $key = key ($incoming_data); 862 | $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null; 863 | if ($key === '__!YAMLZero') $key = '0'; 864 | 865 | if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values. 866 | if ($key || $key === '' || $key === '0') { 867 | $this->result[$key] = $value; 868 | } else { 869 | $this->result[] = $value; end ($this->result); $key = key ($this->result); 870 | } 871 | $this->path[$incoming_indent] = $key; 872 | return; 873 | } 874 | 875 | 876 | 877 | $history = array(); 878 | // Unfolding inner array tree. 879 | $history[] = $_arr = $this->result; 880 | foreach ($this->path as $k) { 881 | $history[] = $_arr = $_arr[$k]; 882 | } 883 | 884 | if ($this->_containsGroupAlias) { 885 | $value = $this->referenceContentsByAlias($this->_containsGroupAlias); 886 | $this->_containsGroupAlias = false; 887 | } 888 | 889 | 890 | // Adding string or numeric key to the innermost level or $this->arr. 891 | if (is_string($key) && $key == '<<') { 892 | if (!is_array ($_arr)) { $_arr = array (); } 893 | 894 | $_arr = array_merge ($_arr, $value); 895 | } else if ($key || $key === '' || $key === '0') { 896 | if (!is_array ($_arr)) 897 | $_arr = array ($key=>$value); 898 | else 899 | $_arr[$key] = $value; 900 | } else { 901 | if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; } 902 | else { $_arr[] = $value; end ($_arr); $key = key ($_arr); } 903 | } 904 | 905 | $reverse_path = array_reverse($this->path); 906 | $reverse_history = array_reverse ($history); 907 | $reverse_history[0] = $_arr; 908 | $cnt = count($reverse_history) - 1; 909 | for ($i = 0; $i < $cnt; $i++) { 910 | $reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i]; 911 | } 912 | $this->result = $reverse_history[$cnt]; 913 | 914 | $this->path[$incoming_indent] = $key; 915 | 916 | if ($this->_containsGroupAnchor) { 917 | $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; 918 | if (is_array ($value)) { 919 | $k = key ($value); 920 | if (!is_int ($k)) { 921 | $this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k; 922 | } 923 | } 924 | $this->_containsGroupAnchor = false; 925 | } 926 | 927 | } 928 | 929 | private static function startsLiteralBlock ($line) { 930 | $lastChar = substr (trim($line), -1); 931 | if ($lastChar != '>' && $lastChar != '|') return false; 932 | if ($lastChar == '|') return $lastChar; 933 | // HTML tags should not be counted as literal blocks. 934 | if (preg_match ('#<.*?>$#', $line)) return false; 935 | return $lastChar; 936 | } 937 | 938 | private static function greedilyNeedNextLine($line) { 939 | $line = trim ($line); 940 | if (!strlen($line)) return false; 941 | if (substr ($line, -1, 1) == ']') return false; 942 | if ($line[0] == '[') return true; 943 | if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true; 944 | return false; 945 | } 946 | 947 | private function addLiteralLine ($literalBlock, $line, $literalBlockStyle, $indent = -1) { 948 | $line = self::stripIndent($line, $indent); 949 | if ($literalBlockStyle !== '|') { 950 | $line = self::stripIndent($line); 951 | } 952 | $line = rtrim ($line, "\r\n\t ") . "\n"; 953 | if ($literalBlockStyle == '|') { 954 | return $literalBlock . $line; 955 | } 956 | if (strlen($line) == 0) 957 | return rtrim($literalBlock, ' ') . "\n"; 958 | if ($line == "\n" && $literalBlockStyle == '>') { 959 | return rtrim ($literalBlock, " \t") . "\n"; 960 | } 961 | if ($line != "\n") 962 | $line = trim ($line, "\r\n ") . " "; 963 | return $literalBlock . $line; 964 | } 965 | 966 | function revertLiteralPlaceHolder ($lineArray, $literalBlock) { 967 | foreach ($lineArray as $k => $_) { 968 | if (is_array($_)) 969 | $lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock); 970 | else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder) 971 | $lineArray[$k] = rtrim ($literalBlock, " \r\n"); 972 | } 973 | return $lineArray; 974 | } 975 | 976 | private static function stripIndent ($line, $indent = -1) { 977 | if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line)); 978 | return substr ($line, $indent); 979 | } 980 | 981 | private function getParentPathByIndent ($indent) { 982 | if ($indent == 0) return array(); 983 | $linePath = $this->path; 984 | do { 985 | end($linePath); $lastIndentInParentPath = key($linePath); 986 | if ($indent <= $lastIndentInParentPath) array_pop ($linePath); 987 | } while ($indent <= $lastIndentInParentPath); 988 | return $linePath; 989 | } 990 | 991 | 992 | private function clearBiggerPathValues ($indent) { 993 | 994 | 995 | if ($indent == 0) $this->path = array(); 996 | if (empty ($this->path)) return true; 997 | 998 | foreach ($this->path as $k => $_) { 999 | if ($k > $indent) unset ($this->path[$k]); 1000 | } 1001 | 1002 | return true; 1003 | } 1004 | 1005 | 1006 | private static function isComment ($line) { 1007 | if (!$line) return false; 1008 | if ($line[0] == '#') return true; 1009 | if (trim($line, " \r\n\t") == '---') return true; 1010 | return false; 1011 | } 1012 | 1013 | private static function isEmpty ($line) { 1014 | return (trim ($line) === ''); 1015 | } 1016 | 1017 | 1018 | private function isArrayElement ($line) { 1019 | if (!$line || !is_scalar($line)) return false; 1020 | if (substr($line, 0, 2) != '- ') return false; 1021 | if (strlen ($line) > 3) 1022 | if (substr($line,0,3) == '---') return false; 1023 | 1024 | return true; 1025 | } 1026 | 1027 | private function isHashElement ($line) { 1028 | return strpos($line, ':'); 1029 | } 1030 | 1031 | private function isLiteral ($line) { 1032 | if ($this->isArrayElement($line)) return false; 1033 | if ($this->isHashElement($line)) return false; 1034 | return true; 1035 | } 1036 | 1037 | 1038 | private static function unquote ($value) { 1039 | if (!$value) return $value; 1040 | if (!is_string($value)) return $value; 1041 | if ($value[0] == '\'') return trim ($value, '\''); 1042 | if ($value[0] == '"') return trim ($value, '"'); 1043 | return $value; 1044 | } 1045 | 1046 | private function startsMappedSequence ($line) { 1047 | return (substr($line, 0, 2) == '- ' && substr ($line, -1, 1) == ':'); 1048 | } 1049 | 1050 | private function returnMappedSequence ($line) { 1051 | $array = array(); 1052 | $key = self::unquote(trim(substr($line,1,-1))); 1053 | $array[$key] = array(); 1054 | $this->delayedPath = array(strpos ($line, $key) + $this->indent => $key); 1055 | return array($array); 1056 | } 1057 | 1058 | private function checkKeysInValue($value) { 1059 | if (strchr('[{"\'', $value[0]) === false) { 1060 | if (strchr($value, ': ') !== false) { 1061 | throw new Exception('Too many keys: '.$value); 1062 | } 1063 | } 1064 | } 1065 | 1066 | private function returnMappedValue ($line) { 1067 | $this->checkKeysInValue($line); 1068 | $array = array(); 1069 | $key = self::unquote (trim(substr($line,0,-1))); 1070 | $array[$key] = ''; 1071 | return $array; 1072 | } 1073 | 1074 | private function startsMappedValue ($line) { 1075 | return (substr ($line, -1, 1) == ':'); 1076 | } 1077 | 1078 | private function isPlainArray ($line) { 1079 | return ($line[0] == '[' && substr ($line, -1, 1) == ']'); 1080 | } 1081 | 1082 | private function returnPlainArray ($line) { 1083 | return $this->_toType($line); 1084 | } 1085 | 1086 | private function returnKeyValuePair ($line) { 1087 | $array = array(); 1088 | $key = ''; 1089 | if (strpos ($line, ': ')) { 1090 | // It's a key/value pair most likely 1091 | // If the key is in double quotes pull it out 1092 | if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) { 1093 | $value = trim(str_replace($matches[1],'',$line)); 1094 | $key = $matches[2]; 1095 | } else { 1096 | // Do some guesswork as to the key and the value 1097 | $explode = explode(': ', $line); 1098 | $key = trim(array_shift($explode)); 1099 | $value = trim(implode(': ', $explode)); 1100 | $this->checkKeysInValue($value); 1101 | } 1102 | // Set the type of the value. Int, string, etc 1103 | $value = $this->_toType($value); 1104 | if ($key === '0') $key = '__!YAMLZero'; 1105 | $array[$key] = $value; 1106 | } else { 1107 | $array = array ($line); 1108 | } 1109 | return $array; 1110 | 1111 | } 1112 | 1113 | 1114 | private function returnArrayElement ($line) { 1115 | if (strlen($line) <= 1) return array(array()); // Weird %) 1116 | $array = array(); 1117 | $value = trim(substr($line,1)); 1118 | $value = $this->_toType($value); 1119 | if ($this->isArrayElement($value)) { 1120 | $value = $this->returnArrayElement($value); 1121 | } 1122 | $array[] = $value; 1123 | return $array; 1124 | } 1125 | 1126 | 1127 | private function nodeContainsGroup ($line) { 1128 | $symbolsForReference = 'A-z0-9_\-'; 1129 | if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-) 1130 | if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; 1131 | if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; 1132 | if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1]; 1133 | if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1]; 1134 | if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1]; 1135 | return false; 1136 | 1137 | } 1138 | 1139 | private function addGroup ($line, $group) { 1140 | if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1); 1141 | if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1); 1142 | //print_r ($this->path); 1143 | } 1144 | 1145 | private function stripGroup ($line, $group) { 1146 | $line = trim(str_replace($group, '', $line)); 1147 | return $line; 1148 | } 1149 | } 1150 | } 1151 | 1152 | // Enable use of Spyc from command line 1153 | // The syntax is the following: php Spyc.php spyc.yaml 1154 | 1155 | do { 1156 | if (PHP_SAPI != 'cli') break; 1157 | if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; 1158 | if (empty ($_SERVER['PHP_SELF']) || FALSE === strpos ($_SERVER['PHP_SELF'], 'Spyc.php') ) break; 1159 | $file = $argv[1]; 1160 | echo json_encode (spyc_load_file ($file)); 1161 | } while (0); 1162 | --------------------------------------------------------------------------------