Exemplo n.º 1
0
function help_invoke_main()
{
    $section = REQ('section');
    $path = SKIN . '/help/sections/';
    $scan = scan_dir($path);
    $result = array();
    foreach ($scan as $id) {
        $id = str_replace('.tpl', '', $id);
        if (!$section || $section && $section == $id) {
            $result[$id] = proc_tpl("help/sections/{$id}");
        }
    }
    cn_assign('help_sections', $result);
    if ($section) {
        echo exec_tpl('window', "style=help/style.css", "title=HELP - {$section}", 'content=' . exec_tpl('help/main'));
    } else {
        echoheader('-@help/style.css', 'Help section');
        echo exec_tpl('help/main');
        echofooter();
    }
}
function PN_AdminOptions($hook)
{
    // Load the plugin settings
    $PN = new PluginSettings('Previous-Next');
    if (!empty($_GET['PN'])) {
        $PN->settings['prevnext'] = $_GET['PN'];
        $PN->save();
        msg('info', 'Previous Next Settings Saved', 'Your settings were saved successfully', '?mod=options&action=PN');
    }
    // Display header
    echoheader('user', 'Previous Next Configuration');
    $catrestrict = $PN->settings['prevnext'];
    if (empty($catrestrict)) {
        $catrestrict = STAY_IN_CATEGORIES;
    }
    if ($catrestrict == 'true') {
        $text = "Staying In Category<br />";
        $link = "false";
        $linktext = "Check all categories";
    } else {
        $text = "Checking all categories<br />";
        $link = "true";
        $linktext = "Stay In Category";
    }
    $buffer = $text . '<br /><a href="?mod=options&amp;action=PN&amp;subaction=save&amp;PN=' . $link . '">' . $linktext . '</a>';
    echo $buffer;
    // Display footer
    echofooter();
}
function ping_options()
{
    global $PHP_SELF;
    $blogname = $_POST['blogname'];
    $mainpage = $_POST['mainpage'];
    $defaultsites = $_POST['defaultsites'];
    $defaultsites = str_replace("\n", "|", $defaultsites);
    echoheader("pingsetup", "Trackback Ping Setup");
    $pingsettings = new PluginSettings('Ping_Settings');
    if (!empty($blogname) || !empty($mainpage)) {
        $pingsettings->settings['blogname'] = $blogname;
        $pingsettings->settings['mainpage'] = $mainpage;
        $pingsettings->settings['defaultsites'] = stripslashes($defaultsites);
        $pingsettings->save();
    }
    $buffer = '<form action="' . $PHP_SELF . '?mod=options&action=ping" method="post">
<label for="blogname">Blog Name:</label><br />
<input type="text" id="blogname" name="blogname" value="' . stripslashes($pingsettings->settings['blogname']) . '"><br />
<label for="mainpage">Full path to main page that news will be displayed on:</label><br />
<input type="text" id="mainpage" name="mainpage" value="' . $pingsettings->settings['mainpage'] . '"><br />
<label for="defaultsites">Default XML/RPC sites to ping:</label><br />
<textarea rows="10" id="defaultsites" cols="40" name="defaultsites" wrap="off">' . stripslashes($pingsettings->settings['defaultsites']) . '</textarea><br />
<input type="submit" value="update"></form>
				';
    echo $buffer;
    echofooter();
}
function furls_AdminOptions()
{
    global $cutepath, $cute_query_string;
    include $cutepath . '/data/config.php';
    echoheader('user', 'Userfriendly URL Setup');
    $furls = new PluginSettings('Userfriendly_URLs');
    $bhelp = '<p><a href="?mod=options&action=furls">Back</a> / <a href="http://www.brandedthoughts.co.uk/cutewiki/index.php/Userfriendly%20URLs%20Plugin">Help</a></p>';
    switch ($_GET['subaction']) {
        case 'edit':
            $linkdata = $furls->settings['text']['0'];
            $buffer = $bhelp . '
	<p>This version of the plugin only needs to know the path to your include-file and what prefix you want on archived entry and category links.</p>
	<form method="post" action="?mod=options&amp;action=furls&amp;subaction=doadd" class="easyform">
		<div>
			<label for="txtCA">Category</label>
			<input id="txtCA" name="furls[category]" value="' . $linkdata[CA] . '" />
		</div>
		<div>
			<label for="txtAR">Archive prefix</label>
			<input id="txtAR" name="furls[archives]" value="' . $linkdata[AR] . '" />
		</div>
		<div style="padding-top: 10px;"><label for="txtPATH" style="width: 100%;">Path to including file<br /><small>If your including file is located at http://yoursite.com/content/news/index.php, type &quot;/content/news/index.php&quot; in this box. <br />Note that it\'s the full url to the file without &quot;http://yoursite.com/&quot;.</small></label>
			<input style="width: 200px;" id="txtPATH" name="furls[path]" value="' . $linkdata[PATH] . '" />
		</div>
		<div>
		<input type="submit" value="Save" />
		</div>
	</form>';
            break;
        case 'templates':
            // List templates
            $templates_list = array();
            if (!($handle = opendir("{$cutepath}/data"))) {
                die("<center>Can not open directory {$cutepath}/data ");
            }
            while (false !== ($file = readdir($handle))) {
                if (eregi(".tpl", $file)) {
                    $file_arr = explode(".", $file);
                    $templates_list[] = $file_arr[0];
                }
            }
            closedir($handle);
            echo $bhelp;
            echo '<p>This tool will automatically convert your old link, full-link and com-link tags to the new humanlink, 
			humanmorelink and humancomlink tags used by this plugin to create friendly url links to your posts. If you want to reverse 
			the process, check the &quot;reverse&quot; checkbox.</p>
		
		<form method="post" action="?mod=options&amp;action=furls&amp;subaction=dotemplates" class="easyform">
		<div>
			<label for="txtTemplate">Template</label>
		<select id="txtTemplate" name="furls[template]">';
            foreach ($templates_list as $null => $single_template) {
                if ($single_template == "Default") {
                    echo "<option selected=\"selected\" value=\"{$single_template}\">{$single_template}</option>";
                } else {
                    echo "<option value=\"{$single_template}\">{$single_template}</option>";
                }
            }
            echo '</select></div>
   		<div>
			<label for="txtReverse">Reverse</label>
			<input type="checkbox" id="txtReverse" name="furls[reverse]" value="true" />
		</div>
			<div>
				<input type="submit" value="Update my templates" />
			</div>
		</form>';
            break;
        case 'htaccess':
            $info = $furls->settings['text']['0'];
            $rewritebase = dirname($info[PATH]);
            if ($rewritebase != "/") {
                $rewritebase = $rewritebase . "/";
            }
            $includefile = str_replace(dirname($info[PATH]) . "/", "", $info[PATH]);
            $htaccesscont = 'RewriteEngine On
RewriteBase ' . $rewritebase . '
RewriteRule ^' . $info[AR] . '/([0-9]{10})/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)/(.*)\\.html$ ' . $includefile . '?archive=$1&furls_date=$2/$3/$4&aj_go=more&category=$5&id=$6 [QSA]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)/(.*)\\.html$ ' . $includefile . '?furls_date=$1/$2/$3&aj_go=more&category=$4&id=$5 [QSA]
RewriteRule ^' . $info[CA] . '/(.*)\\.html$ ' . $includefile . '?category=$1 [QSA]';
            echo $bhelp;
            echo '<p>This tool will try to create a .htaccess-file in the location you specify. If you\'ve pointed the plugin to the correct include-file-path, 
	the content shown below should be ready for use. You can add variables to the last part of each rewriterule-line. Say you have your include-code in 
	index.php, but it only shows news if you have show=news in your url; you would then add &quot;&show=news&quot; to the end of each line.</p>
	
	
		<form method="post" action="?mod=options&amp;action=furls&amp;subaction=dohtaccess" class="easyform">
		<div>
			<label style="width: 300px;" for="txtHtaccess">.htaccess contents:</label>
			<textarea style="width: 100%; height: 200px;" wrap="off" id="txtHtaccess" name="furls[htaccess]">' . $htaccesscont . '</textarea>
		</div>
		<div>
		
		<p>The location must be relative to 
	your cutenews directory. If you type just &quot;.htaccess&quot;, the file will be created in your cutenews directory. 
	If you type &quot;../.htaccess&quot;, the file will be created in the parent directory of your cutenews installation.
	If you have cutenews installed in &quot;/content/cutenews&quot; and your include-file in &quot;/&quot;, type &quot;../../.htaccess&quot; in the field (&quot;../&quot; means one directory up).<br /></p>

			<p><span class="warning">This <b>might</b> cause your server to crash - so be warned! Not exactly crash, but create a file that is 
			unreadable/unwritable/assigned to another user than yourself on the host machine, thus in a worst-case scenario rendering 
			your site non-functional. If you\'re uncomfortable 
			risking a server&quot;crash&quot;, you should do this manually by writing and uploading the .htaccess file yourself. 
			The directory you are writing .htaccess to must be writable and readable for this tool to work. (' . $_SERVER["PHP_SELF"] . ')</span></p>
			
			<label for="txtTemplate">Write to file:</label>
			<input id="txtTemplate" name="furls[htaccessfile]" value="../.htaccess" />
		</div>
		
			<div>
				<input type="submit" value="Write file!" />
				
			</div>
		</form>';
            break;
        case 'dohtaccess':
            if (WriteContents(stripslashes($_POST[furls][htaccess]), stripslashes($_POST[furls][htaccessfile])) == "true") {
                echo "{$bhelp} <p>Written to " . stripslashes($_POST[furls][htaccessfile]) . "</p>";
            } else {
                echo "{$bhelp} <p>Couldn't write file - make sure the directory you are writing to is actually writable (CHMOD 777)</p>";
            }
            break;
        case 'dotemplates':
            $templatefile = "{$cutepath}/data/" . stripslashes($_POST[furls][template]) . ".tpl";
            $furl_templatec = GetContents($templatefile);
            if (stripslashes($_POST[furls][reverse]) == "true") {
                $furl_templatec = str_replace("humanmorelink", "full-link", $furl_templatec);
                $furl_templatec = str_replace("humancomlink", "com-link", $furl_templatec);
                $furl_templatec = str_replace("humanlink", "link", $furl_templatec);
                $state = "Original links placed";
            } else {
                $furl_templatec = str_replace("full-link", "humanmorelink", $furl_templatec);
                $furl_templatec = str_replace("com-link", "humancomlink", $furl_templatec);
                $furl_templatec = str_replace("[link]", "[humanlink]", $furl_templatec);
                $furl_templatec = str_replace("[/link]", "[/humanlink]", $furl_templatec);
                $state = "Friendly links placed";
            }
            if (WriteContents($furl_templatec, $templatefile) == "true") {
                echo $bhelp;
                echo "<p>Template <b>" . stripslashes($_POST[furls][template]) . "</b> updated successfully! ({$state})</p>";
            } else {
                echo $bhelp;
                echo "<p>Something bad happened... couldn't write to template-file specified!<br /><a href=\"?mod=options&action=furls\">Back</a></p>";
            }
            break;
        case 'doadd':
            $linkdata = array(CA => stripslashes($_POST[furls][category]), AR => stripslashes($_POST[furls][archives]), PATH => stripslashes($_POST[furls][path]));
            $furls->settings['text']['0'] = $linkdata;
            $buffer = $bhelp . '<p>Saved link info</p>';
            $furls->save();
            break;
        default:
            $info = $furls->settings['text']['0'];
            $buffer .= '
		<ul>
			<li><a href="?mod=options&amp;action=furls&amp;subaction=edit">Edit friendly link settings</a></li>
			<li><a href="?mod=options&amp;action=furls&amp;subaction=templates">Auto-update templates</a></li>
			<li><a href="?mod=options&amp;action=furls&amp;subaction=htaccess">Write required .htaccess-file</a></li>
		</ul>';
            $buffer .= '
		<h2>General help:</h2>
		<p>To make these new links work, you\'ll need to upload the .htaccess-file generated in step two above and place it in the same
		 directory as the file you\'re including show_news.php in resides in. The plugin can also 
		 <a href="?mod=options&amp;action=furls&amp;subaction=htaccess">do this for you</a> if this directory is writable. 
		 Read the warning text given there before pressing submit!</p>
		 
		<p>After uploading the .htaccess-file to the correct directory, you can replace [link][/link], [full-link][/full-link]
		 and [com-link][/com-link] in your templates with [humanlink][/humanlink], [humanmorelink][/humanmorelink] and [humancomlink][/humancomlink] 
		 to make the plugin output your new, more aesthetical URLs. You can also 
		 <a href="?mod=options&amp;action=furls&amp;subaction=templates">make the plugin do this</a> for you.</p>
		 <p>The last thing you need to do is put a &lt;base href=&quot;http://path/&quot; /&gt; tag in the &lt;head&gt; section of your including file. 
		 If your including file is at http://yoursite.org/news/, the base tag href mentioned here should reflect that.</p>
		 <h2>Requirements</h2>
		<p>- Apache with mod_rewrite enabled<br />
		- Linux/Unix or Win32 OS<br />
		- Host must allow .htaccess overrides<br />
		- Host must have FollowSymLinks enabled</p>
		';
    }
    echo $buffer;
    echofooter();
}
Exemplo n.º 5
0
function msg($type, $title, $text, $back = FALSE)
{
    global $lang;
    if ($back) {
        $back = "<div class=\"row box-section\"><div class=\"col-md-12 text-center\"><a class=\"btn btn btn-red\" href=\"{$back}\">{$lang['func_msg']}</a></div></div>";
    }
    if ($title == "error") {
        $title = $lang['addnews_error'];
    }
    echoheader("<i class=\"icon-comment-alt\"></i>" . $lang['header_box_title'], $title);
    echo <<<HTML
<div class="box">
  <div class="box-header">
    <div class="title">{$title}</div>
  </div>
  <div class="box-content">
\t<div class="row box-section">
\t\t<table width="100%">
\t\t    <tr>
\t\t        <td height="100" class="text-center settingstd">{$text}</td>
\t\t    </tr>
\t\t</table>
\t</div>
\t{$back}
  </div>
</div>
HTML;
    echofooter();
    die;
}
Exemplo n.º 6
0
function msg($type, $title, $text, $back = false, $bc = false)
{
    echoheader($type, $title, $bc);
    // Back By Referef
    if ($back == '#GOBACK') {
        $back = '| <a href="' . htmlspecialchars($_SERVER['HTTP_REFERER']) . '">' . lang('Go back') . '</a>';
    }
    echo proc_tpl('msg', array('text' => $text, 'back' => $back));
    echofooter();
    die;
}
Exemplo n.º 7
0
 function foother()
 {
     return "<p style=\"text-align:center;\">\n\t\t\t\t\t[ <a href=\"http://dle-billing.ru/\">" . $this->lang['support'] . "</a> ]\n\t\t\t\t\t<br />\n\t\t\t\t\t&copy 2012 <a href=\"mailto:evgeny.tc@gmail.com\">mr_Evgen</a>\n\t\t\t\t</p>";
     echofooter();
 }
Exemplo n.º 8
0
    public function footer($footer = false, $year = '')
    {
        if (self::$Debug_info) {
            echo "<pre>";
            echo function_exists(StringLength) ? StringLength(print_r(self::$Debug_info, true)) : print_r(self::$Debug_info, true);
            echo "</pre>";
        }
        if ($year && $year < date('Y')) {
            $year = $year . " - ";
        } elseif ($this->year && $this->year < date('Y')) {
            $year = $this->year . " - ";
        }
        $cur_yaer = date('Y');
        $output = <<<HTML
\t\t<table width="100%">
\t\t    <tr>
\t\t        <td bgcolor="#EFEFEF" height="20" align="center" style="padding-right:10px;"><div class="navigation">Copyright © {$year}{$cur_yaer} <a href="http://www.kaliostro.net" style="text-decoration:underline;color:green">kaliostro</a></div></td>
\t\t    </tr>
\t\t</table>
HTML;
        if ($this->footer || $footer) {
            $this->show_return($output);
            echofooter();
        }
        exit;
    }
Exemplo n.º 9
0
function list_archs()
{
    global $cutepath, $_GET;
    $archive = $_GET['archtounarch'];
    echoheader("archives", "UnArchives");
    echo "<p><b>Send news from archive to active news.</b></p>";
    if (!empty($archive)) {
        $success = 0;
        if (!($handle = opendir("{$cutepath}/data/archives"))) {
            die("Can not open directory {$cutepath}/data/archive ");
        }
        while (false !== ($file = readdir($handle))) {
            if ($file == "{$archive}.desc.arch") {
                unlink("./data/archives/{$file}");
                $success++;
            } else {
                if ($file == "{$archive}.news.arch") {
                    $newsfp = fopen("{$cutepath}/data/news.txt", 'a');
                    $newsarch = file("{$cutepath}/data/archives/{$file}");
                    foreach ($newsarch as $null => $newsline) {
                        fwrite($newsfp, $newsline);
                    }
                    fclose($newsfp);
                    unlink("{$cutepath}/data/archives/{$file}");
                    $success++;
                } else {
                    if ($file == "{$archive}.comments.arch") {
                        $commfp = fopen("{$cutepath}/data/comments.txt", 'a');
                        $commarch = file("{$cutepath}/data/archives/{$file}");
                        foreach ($commarch as $null => $commline) {
                            fwrite($commfp, $commline);
                        }
                        fclose($commfp);
                        unlink("{$cutepath}/data/archives/{$file}");
                        $success++;
                    }
                }
            }
        }
        closedir($handle);
    }
    if (!($handle = opendir("{$cutepath}/data/archives"))) {
        die("<center>Can not open directory {$cutepath}/data/archives ");
    }
    echo '<b>Available archives</b>
  <table style="width: 100%;">
    <tr>
      <td class="alternate"><u>description</u></td>
      <td class="alternate"><u>archivation date</u></td>
      <td class="alternate"><u>duration</u></td>
      <td class="alternate"><u>news</u></td>
      <td class="alternate"><u>action</u></td>
    </tr>';
    while (false !== ($file = readdir($handle))) {
        if ($file != "." and $file != ".." and !is_dir("./data/archives/{$file}") and eregi("news.arch", $file)) {
            $file_arr = explode(".", $file);
            $id = $file_arr[0];
            $news_lines = file("./data/archives/{$file}");
            $creation_date = date("d F Y", $file_arr[0]);
            $archive_description = @file("./data/archives/{$id}.desc.arch");
            $archive_description = $archive_description[0];
            $count = count($news_lines);
            $last = $count - 1;
            $first_news_arr = explode("|", $news_lines[$last]);
            $last_news_arr = explode("|", $news_lines[0]);
            $first_timestamp = $first_news_arr[0];
            $last_timestamp = $last_news_arr[0];
            $duration = date("d M Y", $first_timestamp) . " - " . date("d M Y", $last_timestamp);
            echo "\n\t\t\t<tr>\n\t\t      <td>{$archive_description}</td>\n\t\t      <td>{$creation_date}</td>\n\t\t      <td>{$duration}</td>\n\t\t      <td>{$count}</td>\n\t\t      <td><a title='Restore Archive' href=\"{$PHP_SELF}?mod=options&amp;action=unarch&amp;archtounarch={$id}\">[restore]</a></td>\n\t\t\t</tr>\n               ";
        }
    }
    closedir($handle);
    if ($count == 0) {
        echo "<tr><td colspan=\"5\">There are no archives</td></tr>";
    }
    echo "</table>";
    echofooter();
}
Exemplo n.º 10
0
function dashboard_comments()
{
    list($list, $count) = db_comm_lst();
    $params = array('list' => $list, 'count' => $count);
    echoheader('-@dashboard/style.css', 'Comments');
    echo exec_tpl('dashboard/comments', $params);
    echofooter();
}
Exemplo n.º 11
0
function media_invoke()
{
    $popup_form = '';
    list($path, $opt) = GET('folder, opt', 'GETPOST');
    list($do_action, $pending) = GET('do_action, pending', 'POST');
    // Change default uploads dir
    $udir = cn_path_construct(SERVDIR, 'uploads');
    if (getoption('uploads_dir')) {
        $udir = preparation_path(getoption('uploads_dir'));
    }
    $edir = getoption('uploads_ext') ? getoption('uploads_ext') : getoption('http_script_dir') . '/uploads';
    $dfile = cn_path_construct($udir, $path);
    // Remove root identifier
    $path = preparation_path($path);
    // Path detection
    $path = preg_replace('/[^a-z0-9\\/_\\\\]/i', '-', $path);
    $root_dir = cn_path_construct($udir, $path) . DIRECTORY_SEPARATOR;
    $just_uploaded = array();
    // Get path struct
    $pathes = spsep($path, DIRECTORY_SEPARATOR);
    if (isset($pathes[0]) && $pathes[0] === '') {
        unset($pathes[0]);
    }
    // Do upload files
    if (request_type('POST')) {
        cn_dsi_check();
        // Allowed Exts.
        $AE = spsep(getoption('allowed_extensions'));
        // Generate thumbnail after upload
        $thumbnail_with_upload = getoption('thumbnail_with_upload');
        // UPLOAD FILES
        if (REQ('upload', 'POST')) {
            list($overwrite) = GET('overwrite');
            $is_uploaded = FALSE;
            // Try for fopen url upload
            if ($upload_from_inet = REQ('upload_from_inet')) {
                if (ini_get('allow_url_fopen')) {
                    // Get filename
                    $url_name = spsep($upload_from_inet, '/');
                    $url_name = $url_name[count($url_name) - 1];
                    $url_name = preg_replace('/(%20|\\s|\\?|&|\\/)/', '_', $url_name);
                    $url_name = str_replace('%', '_', $url_name);
                    // resolve filename
                    $c_file = $dfile . $url_name;
                    // Overwrite [if can], or add file
                    if ($overwrite && file_exists($c_file) || !file_exists($c_file)) {
                        // Use context for disable error notices
                        if (function_exists('stream_context_create')) {
                            $context = stream_context_create(array('http' => array('ignore_errors' => true)));
                            $fw = fopen($upload_from_inet, 'rb', false, $context);
                        } else {
                            // Read file
                            $fw = fopen($upload_from_inet, 'rb');
                        }
                        // --------- (fetch content) ------
                        ob_start();
                        fpassthru($fw);
                        $file_image = ob_get_clean();
                        fclose($fw);
                        // ---------
                        // write2disk
                        if ($wf = fopen($c_file, 'w')) {
                            fwrite($wf, $file_image);
                            fclose($wf);
                        }
                        // check image
                        list($w, $h) = getimagesize($c_file);
                        if ($w && $h) {
                            cn_throw_message('File uploaded');
                            $max_width = getoption('max_thumbnail_width');
                            if ($w > $max_width && $thumbnail_with_upload) {
                                $resize_result = resize_image($c_file, $max_width, 0);
                                cn_throw_message($resize_result['msg'], $resize_result['status'] ? 'n' : 'w');
                            }
                            $is_uploaded = TRUE;
                            $just_uploaded[$url_name] = TRUE;
                        } else {
                            cn_throw_message("Wrong image file", 'e');
                            unlink($c_file);
                        }
                    } else {
                        cn_throw_message("Can't overwrite or save", 'e');
                    }
                } else {
                    cn_throw_message('allow_url_fopen=0, check server configurations');
                }
            }
            // Upload from local
            foreach ($_FILES['upload_file']['name'] as $id => $name) {
                if ($name) {
                    $ext = NULL;
                    if (preg_match('/\\.(\\w+)$/i', $name, $c)) {
                        $ext = strtolower($c[1]);
                    }
                    // Check allowed ext
                    if ($ext && in_array($ext, $AE)) {
                        // encode url
                        $name = str_replace('%2F', '/', urlencode($name));
                        // encoded? replace filename
                        if (strpos($name, '%') !== FALSE) {
                            $name = str_replace('%', '', strtolower($name));
                        }
                        // check file for exist
                        if (file_exists($c_file = $dfile . $name)) {
                            if ($overwrite) {
                                cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] overwritten', 'w');
                            } else {
                                cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] already exists', 'e');
                                continue;
                            }
                        }
                        // Upload file to server
                        if (move_uploaded_file($_FILES['upload_file']['tmp_name'][$id], $c_file)) {
                            $just_uploaded[$name] = TRUE;
                            cn_throw_message('File uploaded [<b>' . cn_htmlspecialchars($name) . '</b>]');
                            $max_width = getoption('max_thumbnail_width');
                            list($w, $h) = getimagesize($c_file);
                            if ($w > $max_width && $thumbnail_with_upload) {
                                $resize_result = resize_image($c_file, $max_width, 0);
                                cn_throw_message($resize_result['msg'], $resize_result['status'] ? 'n' : 'w');
                            }
                        } else {
                            cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] not uploaded! Please, check upload_max_filesize in PHP settings.', 'e');
                        }
                    } else {
                        cn_throw_message('File extension [' . cn_htmlspecialchars($ext) . '] not allowed', 'e');
                    }
                } elseif (!$is_uploaded) {
                    cn_throw_message('No selected files for upload', 'e');
                }
            }
        } elseif ($do_action || $pending) {
            list($rm) = GET('rm', 'POST');
            // action --> delete entries
            if ($do_action == 'delete') {
                if (empty($rm)) {
                    cn_throw_message('No files selected', 'w');
                } else {
                    foreach ($rm as $file) {
                        if (file_exists($cfile = $dfile . $file)) {
                            if (is_dir($cfile)) {
                                rmdir($cfile);
                            } else {
                                //get thumbnail path
                                $path_parts = pathinfo($cfile);
                                $thumbnail_path = $path_parts['dirname'] . DIRECTORY_SEPARATOR . '.thumb.' . $path_parts['basename'];
                                if (file_exists($thumbnail_path)) {
                                    unlink($thumbnail_path);
                                }
                                unlink($cfile);
                            }
                        }
                        if (file_exists($cfile)) {
                            cn_throw_message('File [' . cn_htmlspecialchars($cfile) . '] not deleted!', 'e');
                        } else {
                            cn_throw_message('File [' . cn_htmlspecialchars($file) . '] deleted successfully');
                        }
                    }
                }
            } elseif ($do_action == 'create') {
                $popup_form = i18n('Enter directory name') . ' <input type="text" name="new_dir" value="" />';
            } elseif ($pending == 'create') {
                $new_dir_arr = GET('new_dir', 'POST');
                $new_folder = array_pop($new_dir_arr);
                $new_folder = preg_replace('/[^a-z0-9_]/i', '-', $new_folder);
                if ($new_folder) {
                    $cfile = $dfile . $new_folder;
                    if (is_dir($cfile)) {
                        cn_throw_message('Folder [' . $new_folder . '] already exists!', 'e');
                    } else {
                        mkdir($cfile);
                        if (!is_dir($cfile)) {
                            cn_throw_message('Folder [' . cn_htmlspecialchars($cfile) . ' not created]', 'e');
                        } else {
                            cn_throw_message('Folder [' . $new_folder . '] created!');
                        }
                    }
                } else {
                    cn_throw_message('Specify folder name', 'w');
                }
                $popup_form = '';
            } elseif ($do_action == 'rename') {
                if ($rm) {
                    $popup_form = '<div class="big_font">' . i18n('Rename file to') . '</div>';
                    $popup_form .= i18n('Tip: Write new file name') . '<br />';
                    $popup_form .= '<table>';
                    foreach ($rm as $id => $fn) {
                        $hfn = cn_htmlspecialchars($fn);
                        $popup_form .= '<tr><td align="right" class="indent"><b>' . $hfn . '</b><td>';
                        $popup_form .= '<td><input type="hidden" name="ids[' . $id . ']" value="' . $hfn . '"/>&rarr;</td>';
                        $popup_form .= '<td><input style="width: 300px;" type="text" name="place[' . $id . ']" value="' . $hfn . '" /> ';
                        $popup_form .= '</td></tr>';
                    }
                    $popup_form .= '</table>';
                } else {
                    cn_throw_message('Select files to rename', 'w');
                }
            } elseif ($pending == 'rename') {
                // ...
                list($ids, $place) = GET('ids, place', 'POST');
                // prevent illegal moves
                $safe_dir = scan_dir($root_dir);
                foreach ($safe_dir as $id => $v) {
                    $safe_dir[$id] = md5($v);
                }
                // do move all files / dirs
                foreach ($ids as $id => $file) {
                    if (in_array(md5($file), $safe_dir)) {
                        $filename = $place[$id];
                        if (strpos($filename, '\\') || strpos($filename, '/')) {
                            cn_throw_message(i18n('The name of file [%1] should not contain special characters', cn_htmlspecialchars($file)), 'e');
                            continue;
                        }
                        $renameto = $root_dir . $filename;
                        $thumb = $root_dir . '.thumb.' . $file;
                        // do move
                        if (rename($root_dir . $file, $renameto)) {
                            if (file_exists($thumb)) {
                                rename($thumb, $root_dir . '.thumb.' . $filename);
                            }
                            cn_throw_message(i18n('File [%1] renamed to [%2]', cn_htmlspecialchars($file), cn_htmlspecialchars($filename)));
                        } else {
                            cn_throw_message(i18n('File [%1] not renamed', cn_htmlspecialchars($file)), 'e');
                        }
                    }
                }
            } elseif ($do_action == 'move') {
                if ($rm) {
                    $popup_form = '<div class="big_font">' . i18n('Move files to') . '</div>';
                    $popup_form .= i18n('Tip: You can select the folder to move the file') . '<br />';
                    $popup_form .= '<table>';
                    $folders = array();
                    $dirs = scan_dir($root_dir);
                    foreach ($dirs as $entry) {
                        if (is_dir($root_dir . $entry) && !($entry === '..' || $entry === '.')) {
                            $folders[] = $entry;
                        }
                    }
                    foreach ($rm as $id => $fn) {
                        $hfn = cn_htmlspecialchars($fn);
                        $popup_form .= '<tr><td align="right" class="indent"><b>' . $hfn . '</b><td>';
                        $popup_form .= '<td><input type="hidden" name="ids[' . $id . ']" value="' . $hfn . '"/>&rarr;</td>';
                        $popup_form .= '<td>';
                        $cnt_folders = count($folders);
                        if ($cnt_folders != 0 && !($cnt_folders == 1 && in_array($hfn, $folders))) {
                            $popup_form .= '<select name="place_folder_' . $id . '">';
                            foreach ($folders as $dirn) {
                                if ($dirn != $hfn) {
                                    $popup_form .= '<option value="' . $dirn . '">' . $dirn . '</option>';
                                }
                            }
                            $popup_form .= '</select>';
                        }
                        if ($root_dir != $udir) {
                            $popup_form .= '<nobr><input type="checkbox" onclick="javascript:hideFolderList(this,' . $id . ')" name="moveup[' . $id . ']" value="Y" /> Move up</nobr>';
                        } else {
                            $popup_form .= '<nobr> X Move up (You are in root folder)</nobr>';
                        }
                        $popup_form .= '</td></tr>';
                    }
                    $popup_form .= '</table>';
                } else {
                    cn_throw_message('Select files to move', 'w');
                }
            } elseif ($pending == 'move') {
                // ...
                list($ids, $moveup) = GET('ids, moveup', 'POST');
                // prevent illegal moves
                $safe_dir = scan_dir($root_dir);
                foreach ($safe_dir as $id => $v) {
                    $safe_dir[$id] = md5($v);
                }
                // do move all files / dirs
                foreach ($ids as $id => $file) {
                    list($place_folder) = GET('place_folder_' . $id);
                    if (in_array(md5($file), $safe_dir)) {
                        $NF = '';
                        $foldername = preg_replace('/\\.\\//i', '', $place_folder);
                        // move this file up
                        if (isset($moveup[$id]) && count($pathes) > 0) {
                            $nwfolder = dirname($root_dir);
                            $foldername = 'up folder';
                        } else {
                            $nwfolder = $root_dir . ($NF = isset($rm[0]) ? $rm[0] : '') . DIRECTORY_SEPARATOR . $foldername;
                            if ($rm[0]) {
                                $NF = $rm[0] . DIRECTORY_SEPARATOR;
                            }
                        }
                        $moveto = $nwfolder . DIRECTORY_SEPARATOR . $file;
                        //check for image thumbnail
                        $thumb = $root_dir . '.thumb.' . $file;
                        // do move
                        if (rename($root_dir . $file, $moveto)) {
                            if (file_exists($thumb)) {
                                rename($thumb, $nwfolder . DIRECTORY_SEPARATOR . '.thumb.' . $file);
                            }
                            cn_throw_message(i18n('File [%1] moved to [%2]', cn_htmlspecialchars($file), cn_htmlspecialchars($foldername)));
                        } else {
                            cn_throw_message(i18n('File [%1] not moved', cn_htmlspecialchars($file)), 'e');
                        }
                    }
                }
            } elseif ($do_action == 'thumb') {
                if (!empty($_POST['rm'])) {
                    $popup_form = get_sizes_form('Make thumbnails', $do_action);
                } else {
                    cn_throw_message('Select files to make thumbnail', 'w');
                }
            } elseif ($pending == 'thumb') {
                do_resize_image($root_dir);
            } elseif ($do_action == 'resize') {
                if (!empty($_POST['rm'])) {
                    $popup_form = get_sizes_form('Resize source image', $do_action);
                } else {
                    cn_throw_message('Select files to resize', 'w');
                }
            } elseif ($pending == 'resize') {
                do_resize_image($root_dir, false);
            } elseif (!hook('media/post_action')) {
                msg_info("Action error");
            }
        }
    }
    // Check dir exists
    if (is_dir($root_dir)) {
        $raw_files = scan_dir($root_dir);
    } else {
        cn_throw_message('Dir not exists', 'e');
        $raw_files = array();
    }
    $dirs = $files = array();
    foreach ($raw_files as $file) {
        if (preg_match('/avatar_/', $file)) {
            continue;
        }
        $file_location = "{$root_dir}/{$file}";
        if (is_dir($file_location)) {
            $dirs[] = array('url' => "{$path}/{$file}", 'name' => $file);
        } elseif (filesize(cn_path_construct($udir, $path) . $file) != 0) {
            list($w, $h) = getimagesize(cn_path_construct($udir, $path) . $file);
            $is_thumb = preg_match('/\\.thumb\\./', $file);
            $files[] = array('name' => $file, 'url' => $edir . '/' . ($path ? $path . '/' : '') . $file, 'thumb' => file_exists($root_dir . '/.thumb.' . pathinfo($file, PATHINFO_BASENAME)) ? $edir . '/' . ($path ? $path . '/' : '') . '.thumb.' . pathinfo($file, PATHINFO_BASENAME) : '', 'local' => ($path ? $path . '/' : '') . $file, 'just_uploaded' => isset($just_uploaded[$file]) ? TRUE : FALSE, 'is_thumb' => $is_thumb, 'w' => $w, 'h' => $h, 'fs' => round(filesize($file_location) / 1024, 1));
        }
    }
    uasort($dirs, 'usort_by_name_asc');
    uasort($files, 'usort_by_name_asc');
    // Top level (dashboard)
    cn_bc_add('Dashboard', cn_url_modify(array('reset')));
    cn_bc_add('Media manager', cn_url_modify());
    cn_assign("files, dirs, path, pathes, popup_form, root_dir", $files, $dirs, $path, $pathes, $popup_form, $root_dir);
    if ($opt === 'inline') {
        echo exec_tpl('window', 'title=Quick insert image', 'style=media/style.css', 'content=' . exec_tpl('media/general'));
    } else {
        echoheader('-@media/style.css', 'Media manager');
        echo exec_tpl('media/general');
        echofooter();
    }
}
Exemplo n.º 12
0
function edit_news_action_edit()
{
    $flatdb = new FlatDB();
    $preview_html = $preview_html_full = '';
    $ID = $gstamp = intval(REQ('id', 'GETPOST'));
    list($status, $preview) = GET('m, preview');
    list($vConcat, $vTags, $faddm, $archive_id, $source) = GET('concat, tags, faddm, archive_id, source', 'GETPOST');
    // get news part by day
    $news = db_news_load(db_get_nloc($ID));
    if ($ID == 0) {
        msg_info("Can't edit news without ID");
    }
    if (!isset($news[$ID])) {
        msg_info("News entry not found!");
    }
    // load entry
    $entry = $news[$ID];
    $oldentry = $entry;
    // disallowed by category
    if (!test_cat($entry['c'])) {
        msg_info("You can't view entry. Category disallow");
    }
    // set status message
    if ($status == 'added') {
        cn_throw_message('News was added');
    }
    if ($status == 'moved') {
        cn_throw_message('Moved to another time');
    }
    // load more fields
    list($morefields) = cn_get_more_fields($entry['mf']);
    // do save news?
    if (request_type('POST')) {
        $flatdb->cache_clean();
        // check exists news
        if (isset($news[$ID])) {
            // extract data
            $entry = $storent = $news[$ID];
            // Prepare text
            list($title, $page, $category, $short_story, $full_story, $if_use_html, $postpone_draft) = GET('title, page, category, short_story, full_story, if_use_html, postpone_draft', 'GETPOST');
            // Change date?
            list($from_date_hour, $from_date_minutes, $from_date_seconds, $from_date_month, $from_date_day, $from_date_year) = GET('from_date_hour, from_date_minutes, from_date_seconds, from_date_month, from_date_day, from_date_year', 'GETPOST');
            $c_time = intval(mktime($from_date_hour, $from_date_minutes, $from_date_seconds, $from_date_month, $from_date_day, $from_date_year));
            // sanitize page name
            $page = preg_replace('/[^a-z0-9_\\.]/i', '-', $page);
            if (empty($page) && !empty($title) && getoption('auto_news_alias')) {
                $page = strtolower(preg_replace('/[^a-z0-9_\\.]/i', '-', cn_transliterate($title)));
            }
            // current source is archive, active (postponed) or draft news
            $draft_target = $postpone_draft === 'draft';
            // User can't post active news
            if (test('Bd') && $draft_target !== 'draft') {
                $draft_target = 'draft';
            }
            // if archive_id is present, unable send to draft
            $current_source = $archive_id ? "archive-{$archive_id}" : ($source == 'draft' ? 'draft' : '');
            $target_source = $archive_id ? "archive-{$archive_id}" : ($draft_target ? 'draft' : '');
            $if_use_html = $if_use_html ? TRUE : (getoption('use_wysiwyg') ? TRUE : FALSE);
            $entry['t'] = cn_htmlclear($title);
            $entry['c'] = is_array($category) ? join(',', $category) : $category;
            $entry['s'] = cn_htmlclear($short_story);
            $entry['f'] = cn_htmlclear($full_story);
            $entry['ht'] = $if_use_html;
            $entry['st'] = $draft_target ? 'd' : '';
            $entry['pg'] = $page;
            $entry['cc'] = $vConcat ? TRUE : FALSE;
            $entry['tg'] = strip_tags($vTags);
            // apply more field (for news & frontend)
            list($entry, $disallow_message) = cn_more_fields_apply($entry, $faddm);
            list($morefields) = cn_get_more_fields($faddm);
            // has message from function
            if ($disallow_message) {
                cn_throw_message($disallow_message, 'e');
            }
            // Make preview
            if ($preview) {
                //correct preview links
                $gstamp = $entry['id'] = $c_time;
                $preview_html = preg_replace('/href="(.*?)"/', 'href="#"', entry_make($entry, 'active'));
                $preview_html_full = preg_replace('/href="(.*?)"/', 'href="#"', entry_make($entry, 'full'));
            } elseif (REQ('do_editsave', 'POST')) {
                if (!getoption('disable_title') && empty($title)) {
                    cn_throw_message('The title cannot be blank', 'e');
                }
                if (!getoption('disable_short') && empty($short_story)) {
                    cn_throw_message('The story cannot be blank', 'e');
                }
                // Check for change alias
                $pgts = bt_get_id($ID, 'ts_pg');
                if ($pgts && $pgts !== $page) {
                    if ($page) {
                        if (bt_get_id($page, 'pg_ts')) {
                            cn_throw_message('For other news page alias already exists!', 'e');
                        }
                    } else {
                        bt_del_id($pgts, 'pg_ts');
                        bt_del_id($ID, 'ts_pg');
                    }
                }
                // no errors in a[rticle] area
                if (cn_get_message('e', 'c') == 0) {
                    $FlatDB = new FlatDB();
                    $ida = db_index_load($current_source);
                    $idd = db_index_load($target_source);
                    // Time is changed
                    if ($c_time != intval($ID)) {
                        // Load next block (or current)
                        $next = db_news_load(db_get_nloc($c_time));
                        if (isset($next[$c_time])) {
                            cn_throw_message('The article time already busy, select another', 'e');
                        } else {
                            // set new time
                            $entry['id'] = $c_time;
                            $next[$c_time] = $entry;
                            // remove old news [from source / dest]
                            if (isset($news[$ID])) {
                                unset($news[$ID]);
                            }
                            if (isset($next[$ID])) {
                                unset($next[$ID]);
                            }
                            // remove old index
                            if (isset($idd[$ID])) {
                                unset($idd[$ID]);
                            }
                            // Delete old indexes
                            $_ts_id = bt_get_id($ID, 'nts_id');
                            bt_del_id($ID, 'nts_id');
                            // Update
                            bt_set_id($_ts_id, $c_time, 'nid_ts');
                            bt_set_id($c_time, $_ts_id, 'nts_id');
                            // save 2 blocks
                            db_save_news($news, db_get_nloc($ID));
                            db_save_news($next, db_get_nloc($c_time));
                            cn_throw_message('News moved from <b>' . date('Y-m-d H:i:s', $ID) . '</b> to <b>' . date('Y-m-d H:i:s', $c_time) . '</b>');
                        }
                    } else {
                        $news[$ID] = $entry;
                        db_save_news($news, db_get_nloc($ID));
                        cn_throw_message('News was edited');
                    }
                    // Update page aliases
                    $_ts_pg = bt_get_id($ID, 'ts_pg');
                    bt_del_id($ID, 'ts_pg');
                    bt_del_id($_ts_pg, 'pg_ts');
                    if ($page) {
                        bt_set_id($c_time, $page, 'ts_pg');
                        bt_set_id($page, $c_time, 'pg_ts');
                    }
                    // 1) remove from old index
                    if (isset($ida[$ID])) {
                        unset($ida[$ID]);
                    }
                    // Fill probably unused
                    $storent['tg'] = isset($storent['tg']) ? $storent['tg'] : '';
                    // 2) add new index
                    $idd[$c_time] = db_index_create($entry);
                    // 3) sync indexes
                    db_index_save($ida, $current_source);
                    db_index_update_overall($current_source);
                    db_index_save($idd, $target_source);
                    db_index_update_overall($target_source);
                    // ------
                    // UPDATE categories
                    $FlatDB->cn_remove_categories($storent['c'], $storent['id']);
                    $FlatDB->cn_add_categories($entry['c'], $c_time);
                    // UPDATE tags
                    $FlatDB->cn_remove_tags($storent['tg'], $storent['id']);
                    $FlatDB->cn_add_tags($entry['tg'], $c_time);
                    // UPDATE date / id storage [with comments count]
                    $FlatDB->cn_update_date($entry['id'], $storent['id'], count($storent['co']));
                    // ------
                }
            }
        } else {
            msg_info("News entry not found or has been deleted");
        }
    }
    if (empty($entry['pg']) && isset($entry['t']) && getoption('auto_news_alias')) {
        $entry['pg'] = strtolower(preg_replace('/[^a-z0-9_\\.]/i', '-', cn_transliterate($entry['t'])));
    }
    // Assign template vars
    $category = spsep($entry['c']);
    $categories = cn_get_categories(false);
    $title = isset($entry['t']) ? $entry['t'] : '';
    $short_story = isset($entry['s']) ? $entry['s'] : '';
    $page = isset($entry['pg']) ? $entry['pg'] : '';
    $full_story = isset($entry['f']) ? $entry['f'] : '';
    $is_draft = isset($entry['st']) ? $entry['st'] == 'd' : false;
    $vConcat = isset($entry['cc']) ? $entry['cc'] : '';
    $vTags = isset($entry['tg']) ? $entry['tg'] : '';
    $if_use_html = isset($entry['ht']) ? $entry['ht'] : false;
    $is_active_html = test('Csr');
    cn_assign('categories, vCategory, vTitle, vPage, vShort, vFull, vUseHtml, preview_html, preview_html_full, gstamp, is_draft, vConcat, vTags, morefields, archive_id, is_active_html', $categories, $category, $title, $page, $short_story, $full_story, $if_use_html, $preview_html, $preview_html_full, $gstamp, $is_draft, $vConcat, $vTags, $morefields, $archive_id, $is_active_html);
    cn_assign("EDITMODE", 1);
    // show edit page
    echoheader("addedit@addedit/main.css", i18n("Edit news"));
    echo exec_tpl('addedit/main');
    echofooter();
}
Exemplo n.º 13
0
function msg($type, $title, $text, $back = false, $bc = false)
{
    echoheader($type, $title, $bc);
    // Back By Referef
    if ($back == '#GOBACK') {
        $back = '| <a href="' . make_nocache() . '">' . lang('Go back') . '</a>';
    }
    echo proc_tpl('msg', array('text' => $text, 'back' => $back));
    echofooter();
    die;
}
Exemplo n.º 14
0
function msp_AdminOptions()
{
    global $cutepath;
    include $cutepath . '/data/config.php';
    echoheader('user', 'Mailing System Setup');
    $msp = new PluginSettings('Mailing_System');
    $mhelp = '<p><a href="?mod=options&action=msp">Back</a> / <a href="http://www.brandedthoughts.co.uk/cutewiki/index.php/Mailing_System">Help</a></p>';
    switch ($_GET['subaction']) {
        case 'doedit':
            $mails = array("AddedEmails" => stripslashes($_POST[msp][addedmails]), "EditedEmails" => stripslashes($_POST[msp][editedmails]), "CommentEmails" => stripslashes($_POST[msp][commentmails]), "AuthorEdited" => stripslashes($_POST[msp][authoredited]), "AuthorComments" => stripslashes($_POST[msp][authorcomments]));
            $msp->settings['mails']['me'] = stripslashes($_POST['AdminEmail']);
            //From
            $msp->settings['mails']['subject'] = stripslashes($_POST['subject']);
            //Subject Template
            $msp->settings['mails']['0'] = $mails;
            $buffer = $mhelp . '<p>Saved mailing list</p>';
            $msp->save();
            break;
        default:
            $mails = $msp->settings['mails']['0'];
            $me = $msp->settings['mails']['me'];
            if (empty($me)) {
                $me = 'ajfork@' . $_SERVER['SERVER_NAME'];
            }
            $subject = $msp->settings['mails']['subject'];
            if (empty($subject)) {
                $subject = "Site updated @ {maildate} by {mailuser}";
            }
            if ($mails[AuthorEdited] == "true") {
                $aesel = "checked=\"checked\"";
            }
            if ($mails[AuthorComments] == "true") {
                $acsel = "checked=\"checked\"";
            }
            $buffer = $mhelp . '
	<p>This is where you set up the mailing lists. Input emails in the textareas seperated by comma+space. ie &quot;<strong>first@email.com, second@email.com</strong>&quot;</p>
	<form method="post" action="?mod=options&amp;action=msp&amp;subaction=doedit" class="easyform">		
		<div>
			<label style="width: 50%;" for="txtAdminEmail">Admin Email</label>
			<input type="text" style="width: 100%;" id="txtAdminEmail" name="AdminEmail" value="' . $me . '" />
		</div>
		<div>
			<label style="width: 50%;" for="txtSubject">Subject: Use {maildate} and {mailuser}</label>
			<input type="text" style="width: 100%;" id="txtSubject" name="subject" value="' . $subject . '" />
		</div>
		<div>
			<label style="width: 50%;" for="txtAddedEmails">Who to mail when a story is added</label>
			<textarea class="medium" style="width: 100%;" id="txtAddedEmails" name="msp[addedmails]">' . $mails[AddedEmails] . '</textarea>
		</div>
		<div>
			<label style="width: 50%;" for="txtEditedEmails">Who to mail when a story is edited</label>
			<input type="checkbox" id="txtAuthoredited" name="msp[authoredited]" value="true" ' . $aesel . '/>
			<label style="width: 300px;" for="txtAuthoredited">Mail author</label>
			<textarea class="medium" style="width: 100%;" id="txtEditedEmails" name="msp[editedmails]">' . $mails[EditedEmails] . '</textarea>
		</div>		
		<div>
			<label style="width: 50%;" for="txtCommentEmails">Who to mail when a comment is added</label>
			<input type="checkbox" id="txtAuthorcomments" name="msp[authorcomments]" value="true" ' . $acsel . '/>
			<label style="width: 300px;" for="txtAuthorcomment">Mail author</label>
			<textarea class="medium" style="width: 100%;" id="txtCommentEmails" name="msp[commentmails]">' . $mails[CommentEmails] . '</textarea>
		</div>
		<div>
		<input type="submit" value="Save" />
		</div>
	</form>';
    }
    echo $buffer;
    echofooter();
}
Exemplo n.º 15
0
function footer_dle_vb()
{
    global $dle_vb_conf;
    $year = date("Y");
    echo <<<HTML
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px; text-align:center"><div class="navigation">Copyright © 2007 - {$year} created by <a href="http://kaliostro.net/" style="text-decoration:underline;color:green">kaliostro</a></div></td>
    </tr>
</table>
HTML;
    echofooter();
}
Exemplo n.º 16
0
function streamMsg($title, $text, $back = FALSE)
{
    global $lang;
    if ($back) {
        $back = "<br /><br> <a class=\"main\" href=\"{$back}\">{$lang['func_msg']}</a>";
    }
    echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
    <tr>
        <td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
        <td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
        <td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
    </tr>
    <tr>
        <td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
        <td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$title}</div></td>
    </tr>
</table>
<div class="unterline"></div>
<table width="100%">
    <tr>
        <td height="100" align="center">{$text} {$back}</td>
    </tr>
</table>
</td>
        <td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div>
HTML;
    echofooter();
    die;
}
    function footer($footer = false)
    {
        $c_year = date('Y');
        if ($c_year != $this->year) {
            $this->year .= " - " . $c_year;
        }
        $output = <<<HTML
\t\t<table width="100%">
\t\t    <tr>
\t\t        <td bgcolor="#EFEFEF" height="20" align="center" style="padding-right:10px;"><div class="navigation">Copyright © {$this->year} <a href="http://www.kaliostro.net" style="text-decoration:underline;color:green">kaliostro</a></div></td>
\t\t    </tr>
\t\t</table>
HTML;
        if ($this->footer || $footer) {
            $this->show_return($output);
            echofooter();
        }
        exit;
    }
Exemplo n.º 18
0
function msg($type, $title, $text, $back = FALSE)
{
    echoheader($type, $title);
    global $lang;
    echo "{$text}";
    if ($back) {
        echo "<br /><br /> <a href=\"{$back}\">go back</a>";
    }
    echofooter();
    exit;
}
function cqt_AdminOptions()
{
    echoheader('user', 'Custom Quick Tags');
    $cqt = new PluginSettings('Custom_Quick_Tags');
    switch ($_GET['subaction']) {
        case 'edit':
            $tag = $cqt->settings['tags'][$_GET['id']];
        case 'add':
            $id = $tag ? '&amp;id=' . $_GET['id'] : '';
            $buffer = '
	<p><a href="http://www.brandedthoughts.co.uk/cutewiki/index.php/Custom%20Quick%20Tags%20Plugin">Help</a></p>
	<form method="post" action="?mod=options&amp;action=cqt&amp;subaction=doadd' . $id . '" class="easyform">
		<div>
			<label for="txtName">Name</label>
			<input id="txtName" name="cqt[name]" value="' . $tag[name] . '" />
		</div>
		<div>
			<label for="txtTag">Tag</label>
			<input id="txtTag" name="cqt[tag]" value="' . $tag[tag] . '" />
		</div>
		<div>
			<label for="txtComplex">Complex</label>
			<input type="checkbox" id="txtComplex" name="cqt[complex]"' . ($tag[complex] ? ' checked="checked"' : '') . ' value="true" />
		</div>
		<div>
			<label for="txtReplace">Replace</label>
			<textarea id="txtReplace" rows="2" name="cqt[replace]">' . $tag[replace] . '</textarea>
		</div>
		<input type="submit" value="Save" />
	</form>';
            break;
        case 'delete':
            $tag = $cqt->settings['tags'][$_GET['id']];
            if ($tag[name]) {
                $buffer = '<p>Removed tag: <strong>' . $tag[name] . '</strong></p>';
            }
            unset($cqt->settings['tags'][$_GET['id']]);
            $cqt->save();
            break;
        case 'doadd':
            $tag = array(name => stripslashes($_POST[cqt][name]), tag => stripslashes($_POST[cqt][tag]), complex => stripslashes($_POST[cqt][complex]), replace => stripslashes($_POST[cqt][replace]));
            if ($_GET['id']) {
                $cqt->settings['tags'][$_GET['id']] = $tag;
            } else {
                $cqt->settings['tags'][] = $tag;
            }
            $buffer = '<p>Saved tag: <strong>' . $_POST[cqt][name] . '</strong></p>';
            $cqt->save();
        default:
            $buffer .= '
		<table class="grid" id="cqt_tags">
			<thead>
				<tr>
					<th>Name</th>
					<th>Tag</th>
					<th>Type</th>
					<th>Replace</th>
					<th>Action</th>
				</tr>
			</thead>
			<tbody>';
            $tags = $cqt->settings['tags'];
            if (empty($tags)) {
                $buffer .= '<td colspan="5">No custom quick tags</td>';
            } else {
                foreach ($cqt->settings['tags'] as $id => $tag) {
                    $buffer .= '
				<tr>
					<td>' . $tag[name] . '</td>
					<td>[' . $tag[tag] . ']</td>
					<td>' . ($tag[complex] ? 'Complex' : 'Simple') . '</td>
					<td>' . htmlentities($tag[replace]) . '</td>
					<td><a href="?mod=options&amp;action=cqt&amp;subaction=edit&amp;id=' . $id . '">Edit</a> <a href="?mod=options&amp;action=cqt&amp;subaction=delete&amp;id=' . $id . '">Delete</a></td>
				</tr>';
                }
            }
            $buffer .= '
			<tbody>
		</table>
		<p><a href="?mod=options&amp;action=cqt&amp;subaction=add">Add</a></p>';
    }
    echo $buffer;
    echofooter();
}
Exemplo n.º 20
0
    echo <<<HTML
<input type=hidden name=user_hash value="{$dle_login_hash}"><input type="hidden" name="action" value="do_mass_edit_author"><input type="hidden" name="mod" value="massactions">&nbsp;<input type="submit" value="{$lang['b_start']}" class="btn btn-primary btn-mini"></td>
    </tr>
</table>
</td>
        <td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div></form>
HTML;
    echofooter();
    exit;
} elseif ($action == "do_mass_move_to_cat") {
    $moved_articles = 0;
    $move_to_category = $db->safesql(implode(',', $_REQUEST['move_to_category']));
    foreach ($selected_news as $id) {
        $moved_articles++;
        $id = intval($id);
        $db->query("UPDATE " . PREFIX . "_post set category='{$move_to_category}' WHERE id='{$id}'");
    }
    $db->query("INSERT INTO " . USERPREFIX . "_admin_logs (name, date, ip, action, extras) values ('" . $db->safesql($member_id['name']) . "', '{$_TIME}', '{$_IP}', '46', '')");
    clear_cache();
    if (count($selected_news) == $moved_articles) {
        msg("info", $lang['mass_cat_ok'], "{$lang['mass_cat_ok']} ({$moved_articles})", $_SESSION['admin_referrer']);
    } else {
        msg("error", $lang['mass_cat_notok'], $lang['mass_cat_notok_1'], $_SESSION['admin_referrer']);
Exemplo n.º 21
0
function add_news_invoke()
{
    $FlatDB = new FlatDB();
    // loadall
    list($article_type, $preview) = GET('postpone_draft, preview', 'GETPOST');
    list($from_date_hour, $from_date_minutes, $from_date_seconds, $from_date_month, $from_date_day, $from_date_year) = GET('from_date_hour, from_date_minutes, from_date_seconds, from_date_month, from_date_day, from_date_year', 'GETPOST');
    list($title, $page, $category, $short_story, $full_story, $if_use_html, $vConcat, $vTags, $faddm) = GET('title, page, category, short_story, full_story, if_use_html, concat, tags, faddm', 'GETPOST');
    $categories = cn_get_categories(false);
    list($morefields) = cn_get_more_fields($faddm);
    $is_active_html = test('Csr');
    // Prepare data to add new item
    if (request_type('POST')) {
        cn_dsi_check();
        if (!preg_match("~^[0-9]{1,}\$~", $from_date_hour) or !preg_match("~^[0-9]{1,}\$~", $from_date_minutes) or !preg_match("~^[0-9]{1,}\$~", $from_date_seconds)) {
            cn_throw_message("You want to add article, but the hour format is invalid.", 'e');
        }
        // create publish time
        $c_time = mktime($from_date_hour, $from_date_minutes, $from_date_seconds, $from_date_month, $from_date_day, $from_date_year);
        // flat category to array
        if ($category == '') {
            $category = array();
        } elseif (!is_array($category)) {
            $category = array($category);
        }
        // article is draft?
        if ($article_type == 'draft') {
            $draft = 1;
        } else {
            $draft = 0;
        }
        $if_use_html = $if_use_html ? TRUE : (getoption('use_wysiwyg') ? TRUE : FALSE);
        // draft, if Behavior Draft is set
        if (test('Bd')) {
            $draft = 1;
        }
        // sanitize page name
        $page = preg_replace('/[^a-z0-9_\\.]/i', '-', $page);
        if (empty($page) && getoption('auto_news_alias')) {
            $page = strtolower(preg_replace('/[^a-z0-9_\\.]/i', '-', cn_transliterate($title)));
        }
        // basic news
        $member = member_get();
        $entry = array();
        $entry['id'] = $c_time;
        $entry['t'] = cn_htmlclear($title);
        $entry['u'] = $member['name'];
        $entry['c'] = news_make_category($category);
        $entry['s'] = cn_htmlclear($short_story);
        $entry['f'] = cn_htmlclear($full_story);
        $entry['ht'] = $if_use_html;
        $entry['st'] = $draft ? 'd' : '';
        $entry['co'] = array();
        // 0 comments
        $entry['cc'] = $vConcat ? TRUE : FALSE;
        $entry['tg'] = strip_tags($vTags);
        $entry['pg'] = $page;
        // Check page alias for exists
        if ($page && bt_get_id($page, 'pg_ts') && !$preview) {
            cn_throw_message('Page alias already exists', 'e');
        } else {
            // Get latest id for news
            $latest_id = intval(bt_get_id('latest_id', 'conf'));
            $latest_id++;
            bt_set_id($latest_id, $c_time, 'nid_ts');
            bt_set_id($c_time, $latest_id, 'nts_id');
            bt_set_id('latest_id', $latest_id, 'conf');
            // apply more field
            list($entry, $disallow_message) = cn_more_fields_apply($entry, $faddm);
            // has message from function
            if ($disallow_message) {
                cn_throw_message($disallow_message, 'e');
            }
        }
        // ----
        if (!$preview) {
            if (!getoption('disable_title') && empty($title)) {
                cn_throw_message('The title cannot be blank', 'e');
            }
            if (getoption('news_title_max_long') && strlen($title) > getoption('news_title_max_long')) {
                cn_throw_message('The title cannon be greater then ' . getoption('news_title_max_long') . ' charecters', 'e');
            }
            if (!getoption('disable_short') && empty($short_story)) {
                cn_throw_message('The story cannot be blank', 'e');
            }
            // no errors in a[rticle] area
            if (cn_get_message('e', 'c') == 0) {
                // Add page alias
                bt_set_id($page, $c_time, 'pg_ts');
                bt_set_id($c_time, $page, 'ts_pg');
                $sc = $draft ? 'draft' : '';
                $es = db_news_load(db_get_nloc($entry['id']));
                // make unique id
                while (isset($es[$c_time])) {
                    $c_time++;
                }
                // override ts
                $entry['id'] = $c_time;
                // add default group permission
                $member = member_get();
                // add to database
                $es[$c_time] = $entry;
                // do save item
                db_save_news($es, db_get_nloc($c_time));
                // add news to index
                db_index_add($c_time, $entry['c'], $member['id'], $sc);
                // ------------------------
                $FlatDB->cn_update_date($c_time, 0);
                $FlatDB->cn_source_update($c_time, $draft ? 'D' : '');
                $FlatDB->cn_add_categories($entry['c'], $c_time);
                $FlatDB->cn_add_tags($entry['tg'], $c_time);
                $FlatDB->cn_user_sync($entry['u'], $c_time);
                // ------------------------
                // increase user count written news
                $cnt = intval($member['cnt']) + 1;
                db_user_update($member['name'], "cnt={$cnt}");
                // do update meta-index
                db_index_update_overall($sc);
                // Notify for unapproved
                if (getoption('notify_unapproved') && test('Bd')) {
                    cn_send_mail(getoption('notify_email'), i18n('CuteNews unapproved article was added'), "CuteNews - Unapproved article was added CuUnArWaAd", cn_replace_text(cn_get_template('notify_unapproved', 'mail'), '%username%, %article_title%', $member['name'], $title));
                }
                $FlatDB->cache_clean();
                // view in editor
                cn_relocation(PHP_SELF . '?mod=editnews&action=editnews&id=' . $c_time . '&m=added');
            }
        } else {
            //correct preview links
            $preview_html = preg_replace('/href="(.*?)"/', 'href="#"', entry_make($entry, 'active'));
            $preview_html_full = preg_replace('/href="(.*?)"/', 'href="#"', entry_make($entry, 'full'));
            cn_assign('preview_html, preview_html_full, gstamp', $preview_html, $preview_html_full, $c_time);
        }
    }
    if (empty($category)) {
        $category = array();
    }
    // -----------------------------------------------------------------------------------------------------------------
    cn_assign('categories, vCategory, vTitle, vShort, vFull, is_active_html, vUseHtml, vConcat, vTags, morefields,vPage', $categories, $category, $title, $short_story, $full_story, $is_active_html, $if_use_html, $vConcat, $vTags, $morefields, $page);
    // ---
    echoheader("addedit@addedit/main.css", i18n("Add News"));
    echo exec_tpl('addedit/main');
    echofooter();
}