Esempio n. 1
0
 public function testUpdate()
 {
     $class = __NAMESPACE__ . '\\FakePlug';
     $plug_name = 'fake_plug';
     $plug = plug($plug_name, [_CLASS => $class]);
     $plug->update(new fakeSplSubject());
     $this->assertEquals('ontest', getoption('test'));
 }
Esempio n. 2
0
    ?>
        </div>
    <?php 
}
?>

    <!-- MORE FIELDS -->
    <?php 
include SKIN . '/dashboard/snippet/morefields.php';
?>

    <!-- Short story -->
    <div class="section">

        <div class="name">Short Story<?php 
if (!getoption('disable_short')) {
    echo ' <span class="req">*</span>';
}
?>
</div>
        <div><textarea rows="12" cols="74" id="short_story" name="short_story" tabindex=2><?php 
echo cn_htmlspecialchars($vShort);
?>
</textarea></div>

        <?php 
if ($CKEDITOR_Active == 0) {
    ?>
            <div class="ballon">
                <?php 
    $GLOBALS['callback'] = 'short_story';
Esempio n. 3
0
    if (!$comment) {
        $comment = $bkp;
    }
}
// ID => [u]ser, [c]comment text, [e]mail, [ip] */
$db[$id]['co'][$cid] = array('id' => $cid, 'u' => $name, 'e' => $mail, 'ip' => CLIENT_IP, 'c' => $comment, 'ed' => $edit_id);
db_save_news($db, $nloc);
// save db piece
db_comm_sync($id, $cid);
// update latest comments
// Hook comment checker
if (hook('add_comment_checker', FALSE)) {
    return FALSE;
}
// Notify for New Comment
if (getoption('notify_comment')) {
    $url = $_SERVER['HTTP_REFERER'];
    $date = date(getoption('timestamp_active'), ctime());
    $subject = i18n("CuteNews - New Comment Added");
    $message = i18n("New Comment was added by %1 on %3 at %4\n\n%2 ", $name, $comment, $date, $url);
    cn_send_mail(getoption('notify_email'), $subject, $message);
}
// Also, remember non authorized user
if (!$logged_as_member && isset($_POST['cn_remember_me'])) {
    cn_guest_auth($name, $mail);
}
// Redirect...
$ref = preg_replace('/&edit_id=\\d+/', '', REQ('referer'));
echo '<script type="text/javascript">window.location="' . addslashes($ref) . '";</script>';
echo '<div><a href="' . $refer . '">click there</a> if automatic redirect not work</div>';
return FALSE;
Esempio n. 4
0
    echo '<script type="text/javascript">function d(){var a=document.getElementById("del_btn"); var ck=document.getElementsByName("comm_delete[]"); var i=0; var en="visibility:hidden;"; var dl=document.getElementById("btn_delete"); var cheked=0; ' . 'for(i=0;i<ck.length;i++){ if(ck[i].checked){ cheked++; en="visibility:visible;"; }} a.setAttribute("style", en); ' . 'var btn_name="Delete comment"; if(cheked>1){btn_name=btn_name+"s";} dl.setAttribute("value",btn_name);}';
    echo 'var ss=document.getElementsByName("comm_delete[]"); var i=0; for (i=0; i<ss.length; i++){ ss[i].onclick=d; }</script>';
}
// ---------------------------------------------------------------------------------------------------------------------
/* Available placeholders:

 - {input_username}
 - {input_email}
 - {input_commentbox}
 - {smiles}
 - [captcha] ... {captcha} ... [/captcha] - if captcha enabled only
 - [submit]..[/submit] - make submit box
*/
$member = member_get();
if ($member && test('Mac') || !$member) {
    $comment_url = getoption('rw_engine') ? $_SERVER['REQUEST_URI'] : PHP_SELF;
    echo '<form name="comment_frm" action="' . $comment_url . '" method="POST"/>';
    echo '<input type="hidden" name="id" value="' . $id . '" />';
    echo '<input type="hidden" name="subaction" value="addcomment" />';
    echo '<input type="hidden" name="popup" value="' . cn_htmlspecialchars(REQ('popup')) . '" />';
    echo '<input type="hidden" name="referer" value="' . cn_htmlspecialchars($_SERVER['REQUEST_URI']) . '" />';
    $edit_id = intval(REQ('edit_id'));
    if ($edit_id) {
        echo '<input id="edt_comm_mode" type="hidden" name="edit_id" value="' . intval($edit_id) . '" />';
    }
    if ($is_encode) {
        $comments = $entry['co'];
        foreach ($comments as $item) {
            $ni = iconv('UTF-8', $user_encoding . '//TRANSLIT', $item['c']);
            if ($ni) {
                $entry['co'][$item['id']]['c'] = $ni;
Esempio n. 5
0
?>
<form  name="login" id="login_form" action='<?php 
echo PHP_SELF;
?>
' method="post">

    <input type="hidden" name="action" value="dologin">
    <table width="100%">
        <tr>
            <td width='80'>Username: </td>
            <td width='160'><input tabindex=1 type="text" name="username" id="login_username" value="<?php 
echo $last_user_name;
?>
" style="width: 150px;"></td>
            <td>&nbsp;<?php 
if (getoption('allow_registration')) {
    ?>
<a href="?register">(register)</a><?php 
}
?>
</td>
        </tr>
        <tr>
            <td>Password: </td>
            <td><input tabindex="1" type="password" name="password" id="login_password" style='width: 150px'></td>
            <td>&nbsp;<a href="?register&lostpass">(lost password)</a> </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td style='text-align:left'>
                <input tabindex=1 accesskey='s' type=submit style="width:150px; background-color: #F3F3F3;" value='      Login...      '><br/>
Esempio n. 6
0
    <div id="wrapper">

        <div class="nav">
            <?php 
$_self_page = explode('/', PHP_SELF);
$_self_page = $_self_page[count($_self_page) - 1];
if ($_self_page[0] === '/') {
    $_self_page = substr($_self_page, 1);
}
$_self_page = getoption('http_script_dir') . '/' . $_self_page;
?>
            <div style="float: right"><a href="<?php 
echo getoption('http_script_dir');
?>
/rss.php"><img src="<?php 
echo getoption('http_script_dir');
?>
/skins/images/rss_icon.gif" alt="RSS"></a></div>
            <b>Navigation</b>:
            <a href="<?php 
echo $_self_page;
?>
">Main page</a> |
            <a href="<?php 
echo $_self_page;
?>
?do=archives">Archives</a> |
            <a href="<?php 
echo $_self_page;
?>
?do=rss">RSS</a> |
Esempio n. 7
0
<?php

require_once 'core/init.php';
// plugin tells us: he is fork, stop
if (hook('fork_rss', false)) {
    return;
}
$rss = getoption('#rss');
if (empty($rss)) {
    die(proc_tpl('help/manual/rss'));
}
$config_http_script_dir = getoption('http_script_dir');
$rss_encoding = $rss['encoding'];
$rss_news_include_url = $rss['news_include_url'];
$rss_title = $rss['title'];
$rss_language = $rss['language'];
// -------
header("Content-type: text/xml", true);
echo "<?xml version=\"1.0\" encoding=\"{$rss_encoding}\" ?>\r\n<?xml-stylesheet type=\"text/css\" href=\"{$config_http_script_dir}/skins/rss_style.css\" ?>\r\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\r\n<channel>\r\n<title>{$rss_title}</title>\r\n<link>{$rss_news_include_url}</link>\r\n<language>{$rss_language}</language>\r\n<description></description>\r\n<!-- <docs>This is an RSS 2.0 file intended to be viewed in a newsreader or syndicated to another site. For more information on RSS check: http://www.feedburner.com/fb/a/aboutrss</docs> -->\r\n<generator>CuteNews</generator>\r\n<atom:link href=\"" . $config_http_script_dir . "/rss.php\" rel=\"self\" type=\"application/rss+xml\" />";
// ---------------------------------------------------------------------------------------------------------------------
if (isset($_GET['number'])) {
    $number = intval($_GET['number']);
} else {
    $number = 15;
}
if (isset($_GET['only_active']) && $_GET['only_active']) {
    $only_active = $_GET['only_active'];
} else {
    $only_active = true;
}
$template = 'rss';
Esempio n. 8
0
     if ($st < $search_st) {
         continue;
     }
     if ($found == 0) {
         echo "<p class='cutenews_found_news'>" . i18n('Search results for') . " &quot;" . cn_htmlspecialchars($search) . "&quot;</p><div class='cn_search_body'>";
     }
     $found++;
     $title = cn_htmlspecialchars($item['t']);
     // Call: id, archiveid, template
     if (getoption('rw_engine')) {
         $url = cn_rewrite('full_story', cn_put_alias($id));
         if (getoption('search_hl')) {
             $url .= "?qhl=" . urlencode($search);
         }
     } else {
         if (getoption('search_hl')) {
             $url = cn_url_modify($_static_qr, 'id=' . $id, "qhl=" . urlencode($search));
         } else {
             $url = cn_url_modify($_static_qr, 'id=' . $id);
         }
     }
     $itemid++;
     echo "<div class='cutenews_search_item'>{$itemid} <b><a href='{$url}'>{$title}</a></b> (" . date("d F, Y", $id) . ")</div>";
     $_number--;
     if ($_number == 0) {
         $_next_link = TRUE;
         break 2;
     }
 }
 // Next archive, if present
 if ($archives && count($_list_archives)) {
Esempio n. 9
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();
    }
}
Esempio n. 10
0
function cn_extrn_init()
{
    global $template;
    if ($template == 'rss') {
        return;
    }
    $i18n = getoption('i18n');
    if (!$i18n) {
        $i18n = 'en_US';
    }
    // Facebook initialzie
    if ((getoption('use_fbcomments') || getoption('use_fblike')) && !mcache_get('fb_js_on') && $template != 'rss') {
        echo str_replace(array('{appID}', '{fbi18n}'), array(getoption('fb_appid'), str_replace('-', '_', $i18n)), read_tpl('fb_comments'));
        mcache_set('fb_js_on', true);
    }
    // Definition G+ code uses
    if (getoption('use_gplus') && !mcache_get('gplus_js_on') && $template != 'rss') {
        echo str_replace('{lang}', $i18n, read_tpl('google_plus'));
        mcache_set('gplus_js_on', true);
    }
    // First init CN script
    if (!mcache_get('cn:extr_init')) {
        echo preg_replace('/\\s{2,}/s', ' ', read_tpl('cnscript'));
        mcache_set('cn:extr_init', true);
    }
}
Esempio n. 11
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();
}
Esempio n. 12
0
$pdo->query('set names utf8;');
$query = "SELECT id,url FROM mediumgaugecarportfolio WHERE type='SERIES'";
$rs = $pdo->query($query);
while ($row = $rs->fetch()) {
    $Idurl = $row['url'];
    $seriesId = $row['id'];
    //获取页面信息
    $text = file_get_contents($Idurl);
    $text = iconv("GB2312", "UTF-8//IGNORE", $text);
    //var_dump($text);
    $patten = "'var config =(.*?);'is";
    $config = getVarInjs($text, getoption("config "));
    $option = getVarInjs($text, getoption("option "));
    $bag = getVarInjs($text, getoption("bag "));
    $color = getVarInjs($text, getoption("color "));
    $innerColor = getVarInjs($text, getoption("innerColor"));
    $innerColor = str_replace('\\色', "黑色", $innerColor);
    //echo $config."<br>";
    //echo $option."<br>";
    //echo $bag."<br>";
    //echo $color."<br>";
    //echo $innerColor . "<br>";
    $config = json_decode($config, true);
    $seriesId = $config['result']['seriesid'];
    //解析congig
    foreach ($config['result']['paramtypeitems'] as $paramNames) {
        $paramName = $paramNames['name'];
        //echo $paramName;
        foreach ($paramNames['paramitems'] as $valueNames) {
            $valueName = $valueNames['name'];
            //echo $valueName;
Esempio n. 13
0
    // --- Determine what user want to do ---
    hook('show_news/determs_before');
    if (empty($static) and in_array($subaction, array("showcomments", "showfull", "addcomment", "only_comments"))) {
        if ($subaction == "addcomment") {
            $allow_add_comment = true;
            $allow_comments = true;
        } elseif ($subaction == "showcomments") {
            $allow_comments = true;
        } elseif ($subaction == "showfull") {
            $allow_full_story = true;
        }
        // Additional tuning
        if (($subaction == "showcomments" || $allow_comments == true) && getoption('show_full_with_comments')) {
            $allow_full_story = true;
        }
        if ($subaction == "showfull" && getoption('show_comments_with_full')) {
            $allow_comments = true;
        }
        // For popup
        if ($subaction == "only_comments") {
            $allow_comments = true;
            $allow_full_story = false;
        }
    } else {
        $allow_active_news = true;
    }
    hook('show_news/determs_after');
    // Main operations
    include SERVDIR . '/core/includes/dispatcher.php';
}
// Unset all used variables
Esempio n. 14
0
        $_SESS = unserialize($xb64d);
    } else {
        $_SESS = array();
    }
} else {
    $_SESS = array();
}
// create cache
$_CACHE = array();
// save cfg file
$cfg = hook('init_modify_cfg', $cfg);
$fx = fopen(SERVDIR . '/cdata/conf.php', 'w');
fwrite($fx, "<?php die(); ?>\n" . serialize($cfg));
fclose($fx);
// More default options
if (!getoption('ckeditor_customize')) {
    $config_ckeditor_customize = read_tpl('default/ckeditor.options');
}
//----------------------------------
// Html Special Chars (HEX -> UTF-8) L-Endian
//----------------------------------
$HTML_SPECIAL_CHARS_UTF8 = array('c2a1' => '&iexcl;', 'c2a2' => '&cent;', 'c2a3' => '&pound;', 'c2a4' => '&curren;', 'c2a5' => '&yen;', 'c2a6' => '&brvbar;', 'c2a7' => '&sect;', 'c2a8' => '&uml;', 'c2a9' => '&copy;', 'c2aa' => '&ordf;', 'c2ab' => '&laquo;', 'c2bb' => '&raquo;', 'c2ac' => '&not;', 'c2ae' => '&reg;', 'c2af' => '&macr;', 'c2b0' => '&deg;', 'c2ba' => '&ordm;', 'c2b1' => '&plusmn;', 'c2b9' => '&sup1;', 'c2b2' => '&sup2;', 'c2b3' => '&sup3;', 'c2b4' => '&acute;', 'c2b7' => '&middot;', 'c2b8' => '&cedil;', 'c2bc' => '&frac14;', 'c2bd' => '&frac12;', 'c2be' => '&frac34;', 'c2bf' => '&iquest;', 'c380' => '&Agrave;', 'c381' => '&Aacute;', 'c382' => '&Acirc;', 'c383' => '&Atilde;', 'c384' => '&Auml;', 'c385' => '&Aring;', 'c386' => '&AElig;', 'c387' => '&Ccedil;', 'c388' => '&Egrave;', 'c389' => '&Eacute;', 'c38a' => '&Ecirc;', 'c38b' => '&Euml;', 'c38c' => '&Igrave;', 'c38d' => '&Iacute;', 'c38e' => '&Icirc;', 'c38f' => '&Iuml;', 'c390' => '&ETH;', 'c391' => '&Ntilde;', 'c392' => '&Ograve;', 'c393' => '&Oacute;', 'c394' => '&Ocirc;', 'c395' => '&Otilde;', 'c396' => '&Ouml;', 'c397' => '&times;', 'c398' => '&Oslash;', 'c399' => '&Ugrave;', 'c39a' => '&Uacute;', 'c39b' => '&Ucirc;', 'c39c' => '&Uuml;', 'c39d' => '&Yacute;', 'c39e' => '&THORN;', 'c39f' => '&szlig;', 'c3a0' => '&agrave;', 'c3a1' => '&aacute;', 'c3a2' => '&acirc;', 'c3a3' => '&atilde;', 'c3a4' => '&auml;', 'c3a5' => '&aring;', 'c3a6' => '&aelig;', 'c3a7' => '&ccedil;', 'c3a8' => '&egrave;', 'c3a9' => '&eacute;', 'c3aa' => '&ecirc;', 'c3ab' => '&euml;', 'c3ac' => '&igrave;', 'c3ad' => '&iacute;', 'c3ae' => '&icirc;', 'c3af' => '&iuml;', 'c3b0' => '&eth;', 'c3b1' => '&ntilde;', 'c3b2' => '&ograve;', 'c3b3' => '&oacute;', 'c3b4' => '&ocirc;', 'c3b5' => '&otilde;', 'c3b6' => '&ouml;', 'c3b7' => '&divide;', 'c3b8' => '&oslash;', 'c3b9' => '&ugrave;', 'c3ba' => '&uacute;', 'c3bb' => '&ucirc;', 'c3bc' => '&uuml;', 'c3bd' => '&yacute;', 'c3be' => '&thorn;', 'c3bf' => '&yuml;', 'c592' => '&OElig;', 'c593' => '&oelig;', 'c5a0' => '&Scaron;', 'c5a1' => '&scaron;', 'c5b8' => '&Yuml;', 'cb86' => '&circ;', 'cb9c' => '&tilde;', 'c692' => '&fnof;', 'ce91' => '&Alpha;', 'ce92' => '&Beta;', 'ce93' => '&Gamma;', 'ce94' => '&Delta;', 'ce95' => '&Epsilon;', 'ce96' => '&Zeta;', 'ce97' => '&Eta;', 'ce98' => '&Theta;', 'ce99' => '&Iota;', 'ce9a' => '&Kappa;', 'ce9b' => '&Lambda;', 'ce9c' => '&Mu;', 'ce9d' => '&Nu;', 'ce9e' => '&Xi;', 'ce9f' => '&Omicron;', 'cea0' => '&Pi;', 'cea1' => '&Rho;', 'cea3' => '&Sigma;', 'cea4' => '&Tau;', 'cea5' => '&Upsilon;', 'cea6' => '&Phi;', 'cea7' => '&Chi;', 'cea8' => '&Psi;', 'cea9' => '&Omega;', 'ceb1' => '&alpha;', 'ceb2' => '&beta;', 'ceb3' => '&gamma;', 'ceb4' => '&delta;', 'ceb5' => '&epsilon;', 'ceb6' => '&zeta;', 'ceb7' => '&eta;', 'ceb8' => '&theta;', 'ceb9' => '&iota;', 'ceba' => '&kappa;', 'cebb' => '&lambda;', 'cebc' => '&mu;', 'cebd' => '&nu;', 'cebe' => '&xi;', 'cebf' => '&omicron;', 'cf80' => '&pi;', 'cf81' => '&rho;', 'cf82' => '&sigmaf;', 'cf83' => '&sigma;', 'cf84' => '&tau;', 'cf85' => '&upsilon;', 'cf86' => '&phi;', 'cf87' => '&chi;', 'cf88' => '&psi;', 'cf89' => '&omega;', 'cf91' => '&thetasym;', 'cf92' => '&upsih;', 'cf96' => '&piv;', 'e2809d' => '&rdquo;', 'e2809c' => '&ldquo;', 'e284a2' => '&trade;', 'e28099' => '&rsquo;', 'e28098' => '&lsquo;', 'e280b0' => '&permil;', 'e280a6' => '&hellip;', 'e282ac' => '&euro;', 'e28093' => '&ndash;', 'e28094' => '&mdash;', 'e280a0' => '&dagger;', 'e280a1' => '&Dagger;', 'e280b9' => '&lsaquo;', 'e280ba' => '&rsaquo;', 'e280b2' => '&prime;', 'e280b3' => '&Prime;', 'e280be' => '&oline;', 'e28498' => '&weierp;', 'e28491' => '&image;', 'e2849c' => '&real;', 'e284b5' => '&alefsym;', 'e28690' => '&larr;', 'e28691' => '&uarr;', 'e28692' => '&rarr;', 'e28693' => '&darr;', 'e28694' => '&harr;', 'e286b5' => '&crarr;', 'e28790' => '&lArr;', 'e28791' => '&uArr;', 'e28792' => '&rArr;', 'e28793' => '&dArr;', 'e28794' => '&hArr;', 'e28880' => '&forall;', 'e28882' => '&part;', 'e28883' => '&exist;', 'e28885' => '&empty;', 'e28887' => '&nabla;', 'e28888' => '&isin;', 'e28889' => '&notin;', 'e2888b' => '&ni;', 'e2888f' => '&prod;', 'e28891' => '&sum;', 'e28892' => '&minus;', 'e28897' => '&lowast;', 'e2889a' => '&radic;', 'e2889d' => '&prop;', 'e2889e' => '&infin;', 'e288a0' => '&ang;', 'e288a7' => '&and;', 'e288a8' => '&or;', 'e288a9' => '&cap;', 'e288aa' => '&cup;', 'e288ab' => '&int;', 'e288b4' => '&there4;', 'e288bc' => '&sim;', 'e28985' => '&cong;', 'e28988' => '&asymp;', 'e289a0' => '&ne;', 'e289a1' => '&equiv;', 'e289a4' => '&le;', 'e289a5' => '&ge;', 'e28a82' => '&sub;', 'e28a83' => '&sup;', 'e28a84' => '&nsub;', 'e28a86' => '&sube;', 'e28a87' => '&supe;', 'e28a95' => '&oplus;', 'e28a97' => '&otimes;', 'e28aa5' => '&perp;', 'e28b85' => '&sdot;', 'e28c88' => '&lceil;', 'e28c89' => '&rceil;', 'e28c8a' => '&lfloor;', 'e28c8b' => '&rfloor;', 'e29fa8' => '&lang;', 'e29fa9' => '&rang;', 'e2978a' => '&loz;', 'e299a0' => '&spades;', 'e299a3' => '&clubs;', 'e299a5' => '&hearts;', 'e299a6' => '&diams;');
// Decode UTF-8 code-table
$HTML_SPECIAL_CHARS = array();
foreach ($HTML_SPECIAL_CHARS_UTF8 as $hex => $html) {
    $key = '';
    if (strlen($hex) == 4) {
        $key = pack("CC", hexdec(substr($hex, 0, 2)), hexdec(substr($hex, 2, 2)));
    } elseif (strlen($hex) == 6) {
        $key = pack("CCC", hexdec(substr($hex, 0, 2)), hexdec(substr($hex, 2, 2)), hexdec(substr($hex, 4, 2)));
    }
Esempio n. 15
0
 /**
  * Filter for handling image objects
  *
  * @param object $image
  * @return object
  */
 static function new_image($image)
 {
     $source = '';
     $metadata_path = '';
     $files = safe_glob(substr($image->localpath, 0, strrpos($image->localpath, '.')) . '.*');
     if (count($files) > 0) {
         foreach ($files as $file) {
             if (strtolower(getSuffix($file)) == XMP_EXTENSION) {
                 $metadata_path = $file;
                 break;
             }
         }
     }
     if (!empty($metadata_path)) {
         $source = self::extractXMP(file_get_contents($metadata_path));
     } else {
         if (getOption('xmpMetadata_examine_images_' . strtolower(substr(strrchr($image->localpath, "."), 1)))) {
             $f = file_get_contents($image->localpath);
             $l = filesize($image->localpath);
             $abort = 0;
             $i = 0;
             while ($i < $l && $abort < 200 && !$source) {
                 $tag = bin2hex(substr($f, $i, 2));
                 $size = hexdec(bin2hex(substr($f, $i + 2, 2)));
                 switch ($tag) {
                     case 'ffe1':
                         // EXIF
                     // EXIF
                     case 'ffe2':
                         // EXIF extension
                     // EXIF extension
                     case 'fffe':
                         // COM
                     // COM
                     case 'ffe0':
                         // IPTC marker
                         $source = self::extractXMP($f);
                         $i = $i + $size + 2;
                         $abort = 0;
                         break;
                     default:
                         if ($f[$i] == '<') {
                             $source = self::extractXMP($f);
                         }
                         $i = $i + 1;
                         $abort++;
                         break;
                 }
             }
         }
     }
     // direct import to ZenPhoto20 fields with no processing required
     $import = array('location' => 'XMPSubLocation', 'city' => 'XMPCity', 'city' => 'XMPCity', 'state' => 'XMPState', 'country' => 'XMPLocationName', 'copyright' => 'XMPCopyright', 'rotation' => 'XMPOrientation');
     if (!empty($source)) {
         $metadata = self::extract($source);
         if (count($metadata > 0)) {
             $exifVars = self::getMetadataFields();
             foreach ($metadata as $field => $element) {
                 if (!array_key_exists($field, $exifVars) || $exifVars[$field][5]) {
                     $image->set('hasMetadata', 1);
                     $v = self::to_string($element);
                     if (($key = array_search($field, $import)) !== false) {
                         $image->set($key, $v);
                     } else {
                         switch ($field) {
                             case 'XMPSource':
                                 if (!isset($metadata['XMPImageCredit'])) {
                                     $this->set('credit', $v);
                                 }
                                 break;
                             case 'XMPImageCredit':
                                 $this->set('credit', $v);
                                 break;
                             case 'XMPImageHeadline':
                                 if (getoption('transform_newlines')) {
                                     $v = nl2br($v);
                                 }
                                 $image->setTitle($v);
                                 break;
                             case 'XMPImageCaption':
                                 if (getoption('transform_newlines')) {
                                     $v = nl2br(v);
                                 }
                                 $image->setDesc($v);
                                 break;
                             case 'XMPDateTimeOriginal':
                                 $image->setDateTime($element);
                                 break;
                             case 'XMPExposureTime':
                                 $v = formatExposure(self::rationalNum($element));
                                 break;
                             case 'XMPFocalLength':
                                 $v = self::rationalNum($element) . ' mm';
                                 break;
                             case 'XMPAperatureValue':
                             case 'XMPFNumber':
                                 $v = 'f/' . self::rationalNum($element);
                                 break;
                             case 'XMPExposureBiasValue':
                             case 'XMPGPSAltitude':
                                 $v = self::rationalNum($element);
                                 break;
                             case 'XMPGPSLatitude':
                             case 'XMPGPSLongitude':
                                 $n = explode(',', substr($element, 0, -1));
                                 $r = $n[0] + $n[1] / 60;
                                 $ref = strtoupper(substr($element, -1, 1));
                                 $v = Image::toDMS($r, $ref);
                                 if (in_array($ref, array('S', 'W'))) {
                                     $r = -$r;
                                 }
                                 $r = (double) $r;
                                 $image->set(substr($field, 3), $r);
                                 break;
                             case 'XMPLensInfo':
                                 preg_match_all('~(\\d+/\\d+)~', $v, $matches);
                                 if (isset($matches[1]) && !empty($matches[1])) {
                                     $lens = array();
                                     foreach ($matches[1] as $i => $f) {
                                         $term = explode('/', $f);
                                         if ($term[0] != 0 && $term[1] != 0) {
                                             $lens[$i] = convertToFraction($term[0] / $term[1]);
                                         } else {
                                             $lens[$i] = 0;
                                         }
                                     }
                                     if ($lens[0] == $lens[1]) {
                                         $v = sprintf('%0.0fmm', $lens[0]);
                                     } else {
                                         $v = sprintf('%0.0f-%0.0fmm', $lens[0], $lens[1]);
                                     }
                                     if ($lens[2] == $lens[3]) {
                                         if ($lens[2] != 0) {
                                             $v .= sprintf(' f/%0.1f', $lens[2]);
                                         }
                                     } else {
                                         $v .= sprintf(' f/%0.1f-%0.1f', $lens[3], $lens[2]);
                                     }
                                 }
                                 break;
                             case 'rating':
                                 $v = min(getoption('rating_stars_count'), $v) * min(1, getOption('rating_split_stars'));
                                 $image->set('total_value', $v);
                                 $image->set('total_votes', 1);
                                 break;
                             case 'XMPKeywords':
                                 if (!is_array($element)) {
                                     $element = explode(',', $element);
                                 }
                                 $element = array_unique(array_merge($image->getTags(), $element));
                                 $image->setTags($element);
                                 break;
                         }
                     }
                     $image->set($field, $v);
                 }
             }
             $image->save();
         }
     }
     return $image;
 }
Esempio n. 16
0
<?php

list($member, $acl_write_news, $accesslevel, $personal_more) = _GL('member, acl_write_news, acl_desc, personal_more');
$username = isset($member['name']) ? $member['name'] : '';
$nickname = isset($member['nick']) ? $member['nick'] : '';
$avatar_url = isset($member['avatar']) ? (getoption('uploads_ext') ? getoption('uploads_ext') : getoption('http_script_dir') . '/uploads') . '/' . $member['avatar'] : '';
$usermail = isset($member['email']) ? $member['email'] : '';
$written_news = isset($member['cnt']) ? $member['cnt'] : 0;
$register_date = isset($member['id']) ? $member['id'] : 0;
$hide_email = isset($member['e-hide']) ? $member['e-hide'] : 0;
$ban_times = isset($member['ban']) ? $member['ban'] : 0;
$callback = 'personal';
cn_snippet_messages();
cn_snippet_bc();
?>

<form action="<?php 
echo PHP_SELF;
?>
" enctype="multipart/form-data" method="POST">

    <?php 
cn_form_open('mod, opt');
?>

    <table class="std-table" width="100%">

        <tr><th colspan="2" align="left">General options</th></tr>
        <tr>
            <td align="right">Username</td>
            <td><input type="text" name="username" disabled="disabled" style="background: #f0f0f0; width: 250px;" value="<?php 
Esempio n. 17
0
 /**
  * Parses Exif/IPTC data
  *
  */
 function updateMetaData()
 {
     global $_zp_exifvars, $_zp_gallery;
     if ($_zp_exifvars) {
         require_once dirname(__FILE__) . '/exif/exif.php';
         $IPTCtags = array('SKIP' => '2#000', 'ObjectType' => '2#003', 'ObjectAttr' => '2#004', 'ObjectName' => '2#005', 'EditStatus' => '2#007', 'EditorialUpdate' => '2#008', 'Urgency' => '2#010', 'SubRef' => '2#012', 'Category' => '2#015', 'SuppCategory' => '2#020', 'FixtureID' => '2#022', 'Keywords' => '2#025', 'ContentLocationCode' => '2#026', 'ContentLocationName' => '2#027', 'ReleaseDate' => '2#030', 'ReleaseTime' => '2#035', 'ExpireDate' => '2#037', 'ExpireTime' => '2#038', 'SpecialInstru' => '2#040', 'ActionAdvised' => '2#042', 'RefService' => '2#045', 'RefDate' => '2#047', 'RefNumber' => '2#050', 'DateCreated' => '2#055', 'TimeCreated' => '2#060', 'DigitizeDate' => '2#062', 'DigitizeTime' => '2#063', 'OriginatingProgram' => '2#065', 'ProgramVersion' => '2#070', 'ObjectCycle' => '2#075', 'ByLine' => '2#080', 'ByLineTitle' => '2#085', 'City' => '2#090', 'SubLocation' => '2#092', 'State' => '2#095', 'LocationCode' => '2#100', 'LocationName' => '2#101', 'TransmissionRef' => '2#103', 'ImageHeadline' => '2#105', 'ImageCredit' => '2#110', 'Source' => '2#115', 'Copyright' => '2#116', 'Contact' => '2#118', 'ImageCaption' => '2#120', 'ImageCaptionWriter' => '2#122', 'ImageType' => '2#130', 'Orientation' => '2#131', 'LangID' => '2#135', 'Subfile' => '8#010');
         $this->set('hasMetadata', 0);
         foreach ($_zp_exifvars as $field => $exifvar) {
             $this->set($field, NULL);
         }
         $result = array();
         if (get_class($this) == 'Image') {
             $localpath = $this->localpath;
         } else {
             $localpath = $this->getThumbImageFile();
         }
         if (!empty($localpath)) {
             // there is some kind of image to get metadata from
             $exifraw = read_exif_data_protected($localpath);
             if (isset($exifraw['ValidEXIFData'])) {
                 $this->set('hasMetadata', 1);
                 foreach ($_zp_exifvars as $field => $exifvar) {
                     $exif = NULL;
                     if (isset($exifraw[$exifvar[0]][$exifvar[1]])) {
                         $exif = trim(sanitize($exifraw[$exifvar[0]][$exifvar[1]], 1));
                     } else {
                         if (isset($exifraw[$exifvar[0]]['MakerNote'][$exifvar[1]])) {
                             $exif = trim(sanitize($exifraw[$exifvar[0]]['MakerNote'][$exifvar[1]], 1));
                         }
                     }
                     $this->set($field, $exif);
                 }
             }
             /* check IPTC data */
             $iptcdata = zp_imageIPTC($localpath);
             if (!empty($iptcdata)) {
                 $iptc = iptcparse($iptcdata);
                 if ($iptc) {
                     $this->set('hasMetadata', 1);
                     $characterset = self::getIPTCTag('1#090', $iptc);
                     if (!$characterset) {
                         $characterset = getOption('IPTC_encoding');
                     } else {
                         if (substr($characterset, 0, 1) == chr(27)) {
                             // IPTC escape encoding
                             $characterset = substr($characterset, 1);
                             if ($characterset == '%G') {
                                 $characterset = 'UTF-8';
                             } else {
                                 // we don't know, need to understand the IPTC standard here. In the mean time, default it.
                                 $characterset = getOption('IPTC_encoding');
                             }
                         } else {
                             if ($characterset == 'UTF8') {
                                 $characterset = 'UTF-8';
                             }
                         }
                     }
                     // Extract IPTC fields of interest
                     foreach ($_zp_exifvars as $field => $exifvar) {
                         if ($exifvar[0] == 'IPTC') {
                             $datum = self::getIPTCTag($IPTCtags[$exifvar[1]], $iptc);
                             $this->set($field, $this->prepIPTCString($datum, $characterset));
                         }
                     }
                     /* iptc keywords (tags) */
                     if ($_zp_exifvars['IPTCKeywords'][5]) {
                         $datum = self::getIPTCTagArray($IPTCtags['Keywords'], $iptc);
                         if (is_array($datum)) {
                             $tags = array();
                             $result['tags'] = array();
                             foreach ($datum as $item) {
                                 $tags[] = $this->prepIPTCString(sanitize($item, 3), $characterset);
                             }
                             $this->setTags($tags);
                         }
                     }
                 }
             }
         }
         /* "import" metadata into database fields as makes sense */
         /* ZenPhoto20 Image Rotation */
         $this->set('rotation', substr(trim(self::fetchMetadata('EXIFOrientation'), '!'), 0, 1));
         /* ZenPhoto20 "date" field population */
         if ($date = self::fetchMetadata('IPTCDateCreated')) {
             if (strlen($date) > 8) {
                 $time = substr($date, 8);
             } else {
                 /* got date from IPTC, now must get time */
                 $time = $this->get('IPTCTimeCreated');
             }
             $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
             if (!empty($time)) {
                 $date = $date . ' ' . substr($time, 0, 2) . ':' . substr($time, 2, 2) . ':' . substr($time, 4, 2);
             }
         }
         if (empty($date)) {
             $date = self::fetchMetadata('EXIFDateTime');
         }
         if (empty($date)) {
             $date = self::fetchMetadata('EXIFDateTimeOriginal');
         }
         if (empty($date)) {
             $date = self::fetchMetadata('EXIFDateTimeDigitized');
         }
         if (empty($date)) {
             $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->filemtime));
         } else {
             $this->setDateTime($date);
         }
         /* ZenPhoto20 "title" field population */
         $title = self::fetchMetadata('IPTCObjectName');
         if (empty($title)) {
             $title = self::fetchMetadata('IPTCImageHeadline');
         }
         if (empty($title)) {
             $title = self::fetchMetadata('EXIFDescription');
             //EXIF title [sic]
         }
         if (!empty($title)) {
             if (getoption('transform_newlines')) {
                 $title = nl2br($title);
             }
             $this->setTitle($title);
         }
         /* ZenPhoto20 "description" field population */
         $desc = self::fetchMetadata('IPTCImageCaption');
         if (!empty($desc)) {
             if (getoption('transform_newlines')) {
                 $desc = nl2br($desc);
             }
             $this->setDesc($desc);
         }
         //	ZenPhoyo20 GPS data
         foreach (array('EXIFGPSLatitude', 'EXIFGPSLongitude') as $source) {
             $data = self::fetchMetadata($source);
             if (!empty($data)) {
                 $ref = strtoupper($this->get($source . 'Ref'));
                 $this->set($source, self::toDMS($data, $ref));
                 if (in_array($ref, array('S', 'W'))) {
                     $data = '-' . $data;
                 }
                 $this->set(substr($source, 4), $data);
             }
         }
         $alt = self::fetchMetadata('EXIFGPSAltitude');
         if (!empty($alt)) {
             if (self::fetchMetadata('EXIFGPSAltitudeRef') == '-') {
                 $alt = -$alt;
             }
             $this->set('GPSAltitude', $alt);
         }
         //	simple field imports
         $import = array('location' => 'IPTCSubLocation', 'city' => 'IPTCCity', 'state' => 'IPTCState', 'country' => 'IPTCLocationName', 'copyright' => 'IPTCCopyright');
         foreach ($import as $key => $source) {
             $data = self::fetchMetadata($source);
             $this->set($key, $data);
         }
         /* ZenPhoto20 "credit" field population */
         $credit = self::fetchMetadata('IPTCByLine');
         if (empty($credit)) {
             $credit = self::fetchMetadata('IPTCImageCredit');
         }
         if (empty($credit)) {
             $credit = self::fetchMetadata('IPTCSource');
         }
         if (!empty($credit)) {
             $this->setCredit($credit);
         }
         zp_apply_filter('image_metadata', $this);
         $alb = $this->album;
         if (is_object($alb)) {
             if (!$this->get('owner')) {
                 $this->setOwner($alb->getOwner());
             }
             $save = false;
             if (strtotime($alb->getUpdatedDate()) < strtotime($this->getDateTime())) {
                 $alb->setUpdatedDate($this->getDateTime());
                 $save = true;
             }
             if (is_null($albdate = $alb->getDateTime()) || $_zp_gallery->getAlbumUseImagedate() && strtotime($albdate) < strtotime($this->getDateTime())) {
                 $alb->setDateTime($this->getDateTime());
                 //  not necessarily the right one, but will do. Can be changed in Admin
                 $save = true;
             }
             if ($save) {
                 $alb->save();
             }
         }
     }
 }
Esempio n. 18
0
 // One is has
 if (!$no_prev || !$no_next) {
     $links = '';
     $out = preg_replace('/\\[prev\\-link\\](.*)\\[\\/prev\\-link\\]/is', $PREV, $out);
     $out = preg_replace('/\\[next\\-link\\](.*)\\[\\/next\\-link\\]/is', $NEXT, $out);
     // Get page count, if $number is present
     $pages = $number ? intval($_cn / $number) + ($_cn % $number == 0 ? 0 : 1) : 0;
     // Limits
     $limit_skip = false;
     $page_limits = getoption('pagination_pages') ? getoption('pagination_pages') : 10;
     $current_page = intval($start_from / $number);
     $limit_left = $current_page - $page_limits;
     $limit_right = $current_page + $page_limits;
     for ($i = 0; $i < $pages; $i++) {
         $_next_num = $number * $i;
         if (getoption('rw_engine') && !$_ignore_rewrite) {
             if ($tag) {
                 $url = cn_rewrite('tag', $tag, $_next_num, $PSTF);
             } else {
                 $url = cn_rewrite('list', $_next_num, $archive, $PSTF);
             }
         } else {
             $url = cn_url_modify("start_from={$_next_num}");
         }
         if ($limit_skip == false && ($limit_left >= $i || $i > $limit_right)) {
             $links .= '<span class="cn-page-skip">...</span> ';
             $limit_skip = true;
         } elseif ($i != $current_page) {
             $links .= '<a class="cn-page-news" href="' . $url . '">' . ($i + 1) . '</a> ';
             $limit_skip = false;
         } else {
Esempio n. 19
0
function db_index_update_overall($source = '')
{
    $ct = ctime();
    $period = 30 * 24 * 3600;
    $fn = db_index_file_detect($source);
    $ls = file($fn);
    $index_data = array('uids' => array(), 'locs' => array(), 'coms' => 0, 'min_id' => $ct);
    foreach ($ls as $vi) {
        $vips = explode(':', $vi);
        $id = isset($vips[0]) ? $vips[0] : false;
        $ui = isset($vips[2]) ? $vips[2] : false;
        $co = isset($vips[3]) ? $vips[3] : false;
        if ($id !== FALSE) {
            $id = base_convert($id, 36, 10);
            $loc = db_get_nloc($id);
            if (isset($index_data['locs'][$loc])) {
                $index_data['locs'][$loc]++;
            } else {
                $index_data['locs'][$loc] = 1;
            }
            if ($index_data['min_id'] > $id) {
                $index_data['min_id'] = $id;
            }
        }
        if ($ui !== FALSE) {
            if (isset($index_data['uids'][$ui])) {
                $index_data['uids'][$ui]++;
            } else {
                $index_data['uids'][$ui] = 1;
            }
        }
        if ($co !== FALSE) {
            $index_data['coms'] += $co;
        }
    }
    // Active news is many, auto archive it (and user is hasn't draft rights)
    if ($source == '' && $index_data['min_id'] < $ct - $period && getoption('auto_archive') && !test('Bd')) {
        $cc = db_make_archive(0, ctime());
        cn_throw_message('Autoarchive performed');
        if (getoption('notify_archive')) {
            cn_send_mail(getoption('notify_email'), i18n("Auto archive news"), i18n("Active news has been archived (%1 articles)", $cc));
        }
        // Refresh overall index
        return db_index_update_overall();
    }
    // save meta-data
    $meta = db_index_file_detect("meta-{$source}");
    if ($w = fopen($meta, "w+")) {
        fwrite($w, base64_encode(serialize($index_data)));
        fclose($w);
    }
    return TRUE;
}
Esempio n. 20
0
" method="POST">

    <!-- view template data -->
    <?php 
if ($template && $sub) {
    ?>

        <?php 
    cn_form_open('mod, opt, template, sub');
    ?>
        <textarea id="template_text" style="width: 100%; height: 480px; font: 12px/1.2em Monospace;" name="save_template_text"><?php 
    echo cn_htmlspecialchars($template_text);
    ?>
</textarea>
        <?php 
    if (getoption('ckeditor2template')) {
        cn_snippet_ckeditor('template_text');
    }
    ?>

    <?php 
}
?>

    <!-- template actions -->
    <?php 
if ($template) {
    ?>

        <?php 
    cn_form_open('mod, opt, template, sub');
Esempio n. 21
0
function dashboard_script()
{
    list($snippet, $text) = GET('snippet, text');
    if ($snippet == '') {
        $snippet = 'sandbox';
    }
    // Prevent subfoldering
    $snippet = preg_replace('/[^a-z0-9\\-\\.]/i', '_', $snippet);
    if (request_type('POST')) {
        cn_dsi_check();
        // Click select only
        if (!REQ('select', 'POST')) {
            if (REQ('delete', 'POST')) {
                $_t = getoption('#snippets');
                unset($_t[$snippet]);
                setoption('#snippets', $_t);
                $snippet = 'sandbox';
            } else {
                // Create new snippet
                if (REQ('create', 'POST')) {
                    $snippet = REQ('create');
                }
                setoption('#snippets/' . $snippet, $text);
                cn_throw_message('Changes saved');
            }
        } else {
            cn_throw_message('Select snippet [' . cn_htmlspecialchars($snippet) . ']');
        }
    }
    $list = getoption('#snippets');
    if (empty($list)) {
        $list['sandbox'] = '';
    }
    $opt_txt = getoption('#snippets/' . $snippet);
    $params = array('list' => $list, 'text' => !empty($opt_txt) ? $opt_txt : '', 'can_delete' => $snippet !== 'sandbox' ? TRUE : FALSE, 'snippet' => $snippet, 'snippets' => getoption('#snippets'));
    echoheader('-@dashboard/style.css', 'HTML Scripts');
    echo exec_tpl('dashboard/script', $params);
    echofooter();
}
Esempio n. 22
0
 /**
  * Filter for handling image objects
  *
  * @param object $image
  * @return object
  */
 static function new_image($image)
 {
     global $_zp_exifvars;
     $source = '';
     $metadata_path = '';
     $files = safe_glob(substr($image->localpath, 0, strrpos($image->localpath, '.')) . '.*');
     if (count($files) > 0) {
         foreach ($files as $file) {
             if (strtolower(getSuffix($file)) == XMP_EXTENSION) {
                 $metadata_path = $file;
                 break;
             }
         }
     }
     if (!empty($metadata_path)) {
         $source = self::extractXMP(file_get_contents($metadata_path));
     } else {
         if (getOption('xmpMetadata_examine_images_' . strtolower(substr(strrchr($image->localpath, "."), 1)))) {
             $f = file_get_contents($image->localpath);
             $l = filesize($image->localpath);
             $abort = 0;
             $i = 0;
             while ($i < $l && $abort < 200 && !$source) {
                 $tag = bin2hex(substr($f, $i, 2));
                 $size = hexdec(bin2hex(substr($f, $i + 2, 2)));
                 switch ($tag) {
                     case 'ffe1':
                         // EXIF
                     // EXIF
                     case 'ffe2':
                         // EXIF extension
                     // EXIF extension
                     case 'fffe':
                         // COM
                     // COM
                     case 'ffe0':
                         // IPTC marker
                         $source = self::extractXMP($f);
                         $i = $i + $size + 2;
                         $abort = 0;
                         break;
                     default:
                         if ($f[$i] == '<') {
                             $source = self::extractXMP($f);
                         }
                         $i = $i + 1;
                         $abort++;
                         break;
                 }
             }
         }
     }
     if (!empty($source)) {
         $metadata = self::extract($source);
         $image->set('hasMetadata', count($metadata > 0));
         foreach ($metadata as $field => $element) {
             if (array_key_exists($field, $_zp_exifvars)) {
                 if (!$_zp_exifvars[$field][5]) {
                     continue;
                     //	the field has been disabled
                 }
             }
             $v = self::to_string($element);
             switch ($field) {
                 case 'EXIFDateTimeOriginal':
                     $image->setDateTime($element);
                     break;
                 case 'IPTCImageCaption':
                     $image->setDesc($v);
                     break;
                 case 'IPTCCity':
                     $image->setCity($v);
                     break;
                 case 'IPTCState':
                     $image->setState($v);
                     break;
                 case 'IPTCLocationName':
                     $image->setCountry($v);
                     break;
                 case 'IPTCSubLocation':
                     $image->setLocation($v);
                     break;
                 case 'EXIFExposureTime':
                     $v = formatExposure(self::rationalNum($element));
                     break;
                 case 'EXIFFocalLength':
                     $v = self::rationalNum($element) . ' mm';
                     break;
                 case 'EXIFAperatureValue':
                 case 'EXIFFNumber':
                     $v = 'f/' . self::rationalNum($element);
                     break;
                 case 'EXIFExposureBiasValue':
                 case 'EXIFGPSAltitude':
                     $v = self::rationalNum($element);
                     break;
                 case 'EXIFGPSLatitude':
                 case 'EXIFGPSLongitude':
                     $ref = substr($element, -1, 1);
                     $image->set($field . 'Ref', $ref);
                     $element = substr($element, 0, -1);
                     $n = explode(',', $element);
                     if (count($n) == 3) {
                         $v = $n[0] + ($n[1] + $n[2] / 60 / 60);
                     } else {
                         $v = $n[0] + $n[1] / 60;
                     }
                     break;
                 case 'rating':
                     $v = min(getoption('rating_stars_count'), $v) * min(1, getOption('rating_split_stars'));
                     $image->set('total_value', $v);
                     $image->set('total_votes', 1);
                     break;
                 case 'watermark':
                 case 'watermark_use':
                 case 'custom_data':
                 case 'codeblock':
                 case 'owner':
                     $image->set($field, $v);
                     break;
                 case 'IPTCKeywords':
                     if (!is_array($element)) {
                         $element = explode(',', $element);
                     }
                     $image->setTags($element);
                     break;
             }
             if (array_key_exists($field, $_zp_exifvars)) {
                 $image->set($field, $v);
             }
         }
         $image->save();
     }
     return $image;
 }
Esempio n. 23
0
function cn_modify_bb_comm_edited($e, $t)
{
    if ($e['ed']) {
        return str_replace('%edited', date(getoption('timestamp_active'), $e['ed']), $t);
    }
    return '';
}
<?php

/**
 * Provides the means to set an limit of the number of images that can be uploaded to an album in total.
 * Of course this is bypassed if using FTP upload or ZIP files!
 * If you want to limit the latter you need to use the quota_managment plugin additionally.
 * NOTE: The http browser single file upload is disabled if using this plugin!
 *
 * @author Malte Müller (acrylian)
 * @package plugins
 * @subpackage users
 */
$plugin_is_filter = 5 | ADMIN_PLUGIN;
$plugin_description = gettext("Limits the number of images that can be uploaded to an album via the Zenphoto upload.");
$plugin_author = "Malte Müller (acrylian)";
$plugin_disable = zp_has_filter('get_upload_header_text') && !getoption('zp_plugin_image_upload_limiter') ? sprintf(gettext('<a href="#%1$s"><code>%1$s</code></a> is already enabled.'), stripSuffix(get_filterScript('get_upload_header_text'))) : '';
$option_interface = 'uploadlimit';
if ($plugin_disable) {
    setOption('zp_plugin_image_upload_limiter', 0);
} else {
    zp_register_filter('upload_helper_js', 'uploadLimiterJS');
    zp_register_filter('get_upload_header_text', 'uploadLimiterHeaderMessage');
    zp_register_filter('upload_filetypes', 'limitUploadFiletypes');
    zp_register_filter('upload_handlers', 'limitUploadHandlers', 0);
}
/**
 * Option handler class
 *
 */
class uploadlimit
{
Esempio n. 25
0
    echo cn_htmlspecialchars($dir['name']);
    ?>
" /></td>
            </tr>
        <?php 
}
?>

        <!-- show files -->
        <?php 
if (is_array($files)) {
    foreach ($files as $file) {
        ?>
            <tr<?php 
        if ($file['is_thumb']) {
            echo ' style="background: #f0f0f0; ' . (getoption('show_thumbs') ? '' : 'display: none;') . '" ';
        } elseif ($file['just_uploaded']) {
            echo ' style="background: #f0fff0" ';
        }
        ?>
>
                <td align="center"><a href="<?php 
        echo $file['url'];
        ?>
" target="_blank">
                <?php 
        if ($file['w'] == 0) {
            echo 'n/a';
        } elseif ($file['thumb']) {
            ?>
<img src="<?php 
Esempio n. 26
0
 function syscon($config_name, $title, $options = null)
 {
     global $counter;
     list($title, $desc) = explode('|', $title, 2);
     list($config_name, $opt) = explode('=', $config_name, 2);
     $out = '';
     $var = getoption($config_name);
     // Is digits or empty - INPUT
     if (!is_array($options)) {
         $opt = $opt ? $opt : 40;
         if ($options == ':text:') {
             list($cols, $rows) = explode('/', $opt);
             $out = '<textarea cols="' . $cols . '" rows="' . $rows . '" name="save_con[' . $config_name . ']">' . htmlspecialchars($var) . '</textarea>';
         } elseif ($options == 'Y/N') {
             $checked = $var ? 'checked="checked"' : '';
             $out = '<input type="checkbox" name="save_con[' . $config_name . ']" value="1" ' . $checked . ' />';
         } elseif ($options == 'y/n') {
             $out = '<input type="radio" name="save_con[' . $config_name . ']" value="no" ' . ($var == 'no' ? 'checked="checked"' : '') . ' /> No ';
             $out .= '<input type="radio" name="save_con[' . $config_name . ']" value="yes" ' . ($var != 'no' ? 'checked="checked"' : '') . ' /> Yes';
         } else {
             $out = '<input type="text" class="cn" name="save_con[' . $config_name . ']" value="' . $var . '" size="' . $opt . '" />';
         }
     } elseif (is_array($options)) {
         $out = '<select name="save_con[' . $config_name . ']">';
         foreach ($options as $key => $value) {
             if ($var == $key) {
                 $selected = ' selected="selected" ';
             } else {
                 $selected = '';
             }
             $out .= '<option value="' . $key . '"' . $selected . '>' . htmlspecialchars($value) . '</option>';
         }
         $out .= '</select>';
     }
     // --- make line ---
     if ($counter++ % 2 == 0) {
         $bg = "bgcolor=#F7F6F4";
     } else {
         $bg = "";
     }
     return proc_tpl("options/syscon.row", array('bg' => $bg, 'title' => lang($title), 'field' => $out, 'description' => lang($desc)));
 }
Esempio n. 27
0
/**
 * Removes ZIP from list of upload suffixes
 * @param array $types
 * @return array
 */
function quota_upload_filetypes($types)
{
    if (zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS) || getoption('quota_allowZIP')) {
        return $types;
    }
    $key = array_search('ZIP', $types);
    if ($key !== false) {
        unset($types[$key]);
    }
    return $types;
}
Esempio n. 28
0
<?php

// Show code snippets
require_once dirname(__FILE__) . '/core/init.php';
// Get extrn variables
list($snippet) = GET('snippet', 'GPG');
// Default values
if (!$snippet) {
    $snippet = 'sandbox';
}
$_snipdb = getoption('#snippets');
$_html = isset($_snipdb[$snippet]) ? $_snipdb[$snippet] : '';
$_assign = array();
// Catch all brackets
if (preg_match_all('/\\[(.*?)\\]/is', $_html, $_c, PREG_SET_ORDER)) {
    foreach ($_c as $_vs) {
        $_echo = '';
        $_options = array();
        list($_mod, $_opt) = explode('|', $_vs[1], 2);
        $_opts = spsep($_opt);
        foreach ($_opts as $_opt) {
            list($_id, $_value) = explode('=', $_opt, 2);
            $_options[$_id] = is_null($_value) ? TRUE : $_value;
        }
        // MODULES
        if ($_mod == 'news') {
            $_gGET = $_GET;
            $_GET = array();
            foreach ($_options as $_id => $_var) {
                ${$_id} = $_var;
            }
Esempio n. 29
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();
}