Ejemplo n.º 1
0
function udpate_database($value = '', $type = '', $id)
{
    echo "<br>[process]:update database process started<br>";
    include "getpath.php";
    $targetdir = $localhost . "Matching-Game/assets/" . $type . "/";
    $srno = getsrno($value);
    include $localhost . 'Matching-Game/assets/getconfig.php';
    $conn = new mysqli("localhost", $sqlun, $sqlp, $sqld);
    if ($conn->connect_error) {
        die("Connection Failed:" . $conn->connect_error);
    }
    $query = "SELECT * from pairs where id>{$id} ";
    $result = $conn->query($query);
    while ($row = mysqli_fetch_row($result)) {
        if ($row[1] == $type) {
            $ext = getextension($row[0]);
            rename($targetdir . $row[0], $targetdir . $type . $srno . "." . $ext);
            $query = "UPDATE pairs SET c1name='{$type}{$srno}.{$ext}' WHERE c1name='{$row['0']}'";
            $res = $conn->query($query);
            echo "<br>[process]:{$row['0']} renamed to {$type}{$srno}.{$ext}<br>";
            $srno++;
        }
        if ($row[3] == $type) {
            $ext = getextension($row[2]);
            rename($targetdir . $row[2], $targetdir . $type . $srno . "." . $ext);
            $query = "UPDATE pairs SET c2name='{$type}{$srno}.{$ext}' WHERE c2name='{$row['2']}'";
            $res = $conn->query($query);
            echo "<br>[process]:{$row['2']} renamed to {$type}{$srno}.{$ext}<br>";
            $srno++;
        }
    }
}
Ejemplo n.º 2
0
function create_backup_is_admin($_cid)
{
    $this_section = SECTION_COURSES;
    if (isset($_GET['session']) && $_GET['session']) {
        $archive_path = api_get_path(SYS_ARCHIVE_PATH);
        $_cid = true;
        $is_courseAdmin = true;
    } else {
        $archive_path = api_get_path(SYS_ARCHIVE_PATH);
    }
    $archive_file = $_GET['archive'];
    $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
    list($extension) = getextension($archive_file);
    if (empty($extension) || !file_exists($archive_path . $archive_file)) {
        return false;
    }
    $extension = strtolower($extension);
    $content_type = '';
    if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
        $content_type = 'application/force-download';
        // TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed.
        //} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
    } elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
        //
        $content_type = 'application/force-download';
    }
    if (empty($content_type)) {
        return false;
    }
    return true;
}
Ejemplo n.º 3
0
 $jumpurl = 'cp.php?job=tools&action=dothumbdata&step=' . $step . '&percount=' . $percount;
 $goon = 0;
 $size = explode('x', strtolower($options['attachments_thumbs_size']));
 $attachquery = $DB->query("SELECT * FROM {$db_prefix}attachments WHERE isimage='1' AND thumb_filepath <> '' LIMIT {$start}, {$percount}");
 while ($attach = $DB->fetch_array($attachquery)) {
     $goon = 1;
     if (file_exists(SABLOG_ROOT . $options['attachments_dir'] . $attach['thumb_filepath'])) {
         @unlink(SABLOG_ROOT . $options['attachments_dir'] . $attach['thumb_filepath']);
         $DB->unbuffered_query("UPDATE {$db_prefix}attachments SET thumb_filepath='', thumb_width='', thumb_height='' WHERE attachmentid='" . $attach['attachmentid'] . "'");
     }
     if (!$options['attachments_thumbs']) {
         $attach_data['thumbwidth'] = '';
         $attach_data['thumbheight'] = '';
         $attach_data['thumbfilepath'] = '';
     } else {
         $extension = getextension($attach['filepath']);
         $attachsubdir = '/date_' . sadate('Ym', $attach['dateline']) . '/';
         $thumbname = substr($attach['filepath'], getstrlen($attachsubdir), 32);
         if ($imginfo = @getimagesize(SABLOG_ROOT . $options['attachments_dir'] . $attach['filepath'])) {
             if ($imginfo[2]) {
                 if ($imginfo[0] > $size[0] || $imginfo[1] > $size[1]) {
                     $attach_thumb = array('filepath' => SABLOG_ROOT . $options['attachments_dir'] . $attach['filepath'], 'filename' => $thumbname, 'extension' => $extension, 'attachsubdir' => $attachsubdir, 'thumbswidth' => $size[0], 'thumbsheight' => $size[1]);
                     $thumb_data = generate_thumbnail($attach_thumb);
                     $attach_data['thumbwidth'] = $thumb_data['thumbwidth'];
                     $attach_data['thumbheight'] = $thumb_data['thumbheight'];
                     $attach_data['thumbfilepath'] = $attachsubdir . $thumb_data['thumbfilepath'];
                 }
             }
         }
     }
     $DB->unbuffered_query("UPDATE {$db_prefix}attachments SET thumb_filepath='" . $attach_data['thumbfilepath'] . "', thumb_width='" . $attach_data['thumbwidth'] . "', thumb_height='" . $attach_data['thumbheight'] . "' WHERE attachmentid='" . $attach['attachmentid'] . "'");
Ejemplo n.º 4
0
/**
 * The screen that's shown when you click 'rebuild index'.
 *
 */
function build_index()
{
    global $config_array, $Archive_array;
    PageHeader(lang('adminbar', 'buildindex'), 1);
    PageAnkeiler(lang('adminbar', 'buildindex') . ' &raquo; ' . lang('adminbar', 'buildindex_title'));
    @set_time_limit(0);
    // Force the archive index and tag index file to be updated
    @unlink('db/ser-archives.php');
    // Make a new archive array.
    $Archive_array = make_archive_array();
    // Force the tag index to be updated
    @unlink('db/ser_tags.php');
    $dir = dir('db/tagdata/');
    while (false !== ($entry = $dir->read())) {
        if (getextension($entry) == "cache") {
            unlink('db/tagdata/' . $entry);
        }
    }
    $dir->close();
    echo "<p>" . lang('adminbar', 'buildindex_start') . "<br />\n";
    flush();
    $db = new db();
    $db->generate_index();
    echo "<br /><br />\n\n<b>" . str_replace("%num%", timetaken(), lang('adminbar', 'buildindex_finished')) . "</b><br /><br /></p>\n";
    // stuff stops here..
    PageFooter();
}
Ejemplo n.º 5
0
function snippet_editlink($name = "")
{
    global $Pivot_Vars, $Paths, $Cfg, $db, $Weblogs, $Current_weblog, $set_output_paths;
    if ($name == "") {
        $name = lang('general', 'edit');
    }
    if (defined('LIVEPAGE')) {
        $output = get_editentrylink($name);
    } else {
        $ext = strtolower(getextension($Weblogs[$Current_weblog]['front_filename']));
        if (substr($ext, 0, 3) == "php") {
            $output = "";
            if (!isset($set_output_paths) || $set_output_paths == FALSE) {
                $set_output_paths = TRUE;
                $output .= "<?php \n";
                $output .= "DEFINE('INWEBLOG', TRUE);\n";
                $output .= sprintf("\$weblog='%s';\n ", $Current_weblog);
                $output .= "include_once '" . $Paths['pivot_path'] . "pv_core.php'; \n?" . ">";
            }
            $output .= sprintf("<?php echo get_editentrylink(\"%s\", '%s'); ?>", addslashes($name), $db->entry['code']);
        } else {
            $output = "";
        }
    }
    return $output;
}
Ejemplo n.º 6
0
/**
 * Helper function for cleanCache().
 *
 * @see cleanCache();
 * @param string $path
 */
function cleanCacheFolder($path)
{
    global $PIVOTX, $scheduler, $filecounter;
    // Make sure we do not take too long..
    if (timeTaken('int') > $scheduler['duration']) {
        return;
    }
    $d = dir($path);
    while (false !== ($entry = $d->read())) {
        if ($entry == "." || $entry == ".." || $entry == ".svn") {
            continue;
        }
        // Recursively go through the sub folders
        if (is_dir($path . $entry)) {
            cleanCacheFolder($path . $entry . "/");
            continue;
        }
        // Then handle any files in the folder
        $ext = getextension($entry);
        if (strpos($entry, "%%") === 0 || $ext == "cache") {
            cleanCacheDelete($path, $entry, $scheduler['max_age_template']);
        }
        $filecounter++;
        if ($ext == "gz" || $ext == "" || $ext == "zd" || $ext == "zg") {
            cleanCacheDelete($path, $entry, $scheduler['max_age_zip']);
        } else {
            if ($ext == "mpc") {
                cleanCacheDelete($path, $entry, $scheduler['max_age_feed']);
            } else {
                if ($ext == "jpg" || $ext == "png" || $ext == "timthumb") {
                    cleanCacheDelete($path, $entry, $scheduler['max_age_image']);
                } else {
                    cleanCacheDelete($path, $entry, $scheduler['max_age_other']);
                }
            }
        }
    }
    $d->close();
}
Ejemplo n.º 7
0
} while ($loop < $count);
if (count($slice_arr) > 1) {
    echo "<form name='form1' action=''>";
    echo "<select name='selectedPage' onchange='changePage(this.form.selectedPage)'><option value='#'>Jump to: </option>";
    echo implode("\n", $slice_arr);
    echo "</select></form><hr size='1' noshade='noshade' />";
}
if (isset($Pivot_Vars['slice'])) {
    $slice = $Pivot_Vars['slice'];
} else {
    $slice = 0;
}
$fileArray = array_slice($fileArray, $Pivot_Vars['slice'], $show);
$thumbArray = array_slice($thumbArray, $Pivot_Vars['slice'], $show);
foreach ($fileArray as $file) {
    $ext = getextension($file['name']);
    if (strtolower($ext) == "jpg" || strtolower($ext) == "gif" || strtolower($ext) == "png") {
        $fullentry = urlencode($Paths['upload_url'] . $file['name']);
        //debug("full: $fullentry");
        // get the image's witdh and height
        list($x, $y) = getimagesize(urldecode($Paths['upload_path'] . $file['name']));
        $filesize = $file['size'];
        $disp_entry = trimtext(strtolower(urldecode($file['name'])), 30, TRUE);
        echo "<tr><td><a href=\"javascript:select('" . $file['name'] . "', {$x}, {$y});\">{$disp_entry}</a></td><td>( {$x} x {$y} px, {$filesize} kb. )\n";
        echo "</td><td><a href=\"javascript:popup('{$fullentry}', {$x}, {$y});\">preview</a></td></tr>\n";
    } else {
        if ($file['name'] != "." && $file['name'] != "..") {
            $fullentry = urlencode($Paths['upload_url'] . $file['name']);
            $filesize = $file['size'];
            $disp_entry = trimtext(strtolower(urldecode($file['name'])), 30, TRUE);
            echo "<tr><td><a href=\"javascript:select('" . $file['name'] . "', 0, 0);\">{$disp_entry}</a></td><td> ( {$filesize} kb. )</td><td>&nbsp;</td></tr>\n";
Ejemplo n.º 8
0
/**
 * Get the TagCosmos. Preferably use the cached version, otherwise just make it
 * on the fly. (and then we store the cached version)
 *
 * If $max is given, it will return at most that many tags, ordered by size.
 * If $weblogname is given, only tags for that weblog will be returned.
 *
 * Returns an array with the following elements:
 * 'minvalue' => minimum value of a tag
 * 'maxvalue' => maximum value of a tag
 * 'amount' => number of tags
 * 'tags' => array of the tags. The indices are the tags, the values the number of occurences
 *
 * @param integer $max
 * @param string $weblogname 
 * @return array
 *
 */
function getTagCosmos($max = 0, $weblogname = '')
{
    global $Paths, $Cfg, $Weblogs;
    if ($weblogname == '' || $Cfg['weblog_count'] == 1) {
        $weblogname = '_all_';
    }
    // If the cached version is fresh enough, we restore that
    if (file_exists($Paths['pivot_path'] . "db/ser_tags.php") && filectime($Paths['pivot_path'] . "db/ser_tags.php") > time() - 60 * $Cfg['tag_cache_timeout']) {
        // Just load it..
        $data = load_serialize("db/ser_tags.php");
        $tagcosmos = $data[$weblogname];
    } else {
        // We have to read it..
        $tagcosmos = array();
        if ($Cfg['weblog_count'] > 1) {
            $temp_db = new db(FALSE);
        }
        foreach ($Weblogs as $weblog => $weblogdata) {
            $tagcosmos[$weblog] = array();
        }
        $tagdir = dir($Paths['pivot_path'] . "db/tagdata/");
        // Read all tags, build the tag index and save it or later.
        while (false !== ($entry = $tagdir->read())) {
            if (getextension($entry) == "tag") {
                list($tagname) = explode(".", $entry);
                $tagfile = implode("", file($Paths['pivot_path'] . "db/tagdata/" . $entry));
                $tagfile = explode(",", $tagfile);
                // If magic_quotes_gpc is set, we need to strip slashes..
                if (get_magic_quotes_gpc()) {
                    $tagname = stripslashes($tagname);
                }
                if ($tagname != "") {
                    $tagcosmos['_all_']['tags'][$tagname] = count($tagfile);
                    if ($Cfg['weblog_count'] > 1) {
                        foreach ($tagfile as $entrycode) {
                            $temp_entry = $temp_db->read_entry($entrycode);
                            $cat_weblogs = find_weblogs_with_cat($temp_entry['category']);
                            foreach ($cat_weblogs as $cat_weblog) {
                                $tagcosmos[$cat_weblog]['tags'][$tagname]++;
                            }
                        }
                    }
                }
            }
        }
        $tagdir->close();
        save_serialize($Paths['pivot_path'] . "db/ser_tags.php", $tagcosmos);
        $tagcosmos = $tagcosmos[$weblogname];
    }
    $tagcosmos['amount'] = count($tagcosmos['tags']);
    // if $max is given, we need to filter out the smaller tags, until the required size is reached.
    if ($max != 0 && $max < count($tagcosmos['tags'])) {
        arsort($tagcosmos['tags']);
        $tagcosmos['tags'] = array_slice($tagcosmos['tags'], 0, $max);
    }
    ksort($tagcosmos['tags']);
    $tagcosmos['minvalue'] = 1000;
    $tagcosmos['maxvalue'] = 0;
    // We determine what the min and max-value in the cosmos is.
    foreach ($tagcosmos['tags'] as $key => $value) {
        $tagcosmos['maxvalue'] = max($tagcosmos['maxvalue'], $value);
        $tagcosmos['minvalue'] = min($tagcosmos['minvalue'], $value);
    }
    return $tagcosmos;
}
Ejemplo n.º 9
0
/**
 * Get the config options for the third screen in weblog setup
 *
 * @return array
 */
function get_weblog_config3()
{
    $d = dir("templates");
    while ($entry = $d->read()) {
        $ext = getextension($entry);
        if ($ext == "htm" || $ext == "html") {
            $fullentry = "templates/" . $entry;
            $templates[] = $entry;
            $templates[] = $fullentry;
        }
    }
    $d->close();
    $config_array = array(array('heading', lang('weblog_config', 'setup_rss_head'), '', 8, '', 2), array('rss', lang('weblog_config', 'rss_use'), lang('weblog_config', 'rss_use_desc'), 3, 'yn'), array('rss_filename', lang('weblog_config', 'rss_filename'), '', 0), array('atom_filename', lang('weblog_config', 'atom_filename'), '', 0), array('rss_path', lang('weblog_config', 'rss_path'), lang('weblog_config', 'rss_path_desc'), 0), array('rss_full', lang('weblog_config', 'rss_full'), lang('weblog_config', 'rss_full_desc'), 3, 'yn'), array('rss_link', lang('weblog_config', 'rss_link'), lang('weblog_config', 'rss_link_desc'), 0, '', 60), array('rss_img', lang('weblog_config', 'rss_img'), lang('weblog_config', 'rss_img_desc'), 0, '', 60), array('heading', lang('weblog_config', 'various_head'), '', 8, '', 2), array('emoticons', lang('weblog_config', 'emoticons'), lang('weblog_config', 'emoticons_desc'), 3, 'yn'), array('encode_email_addresses', lang('weblog_config', 'encode_email_addresses'), lang('weblog_config', 'encode_email_addresses_desc'), 3, 'yn'), array('target_blank', lang('weblog_config', 'target_blank'), lang('weblog_config', 'target_blank_desc'), 3, array(lang('no'), '0', lang('yes'), '1', lang('weblog_config', 'xhtml_workaround'), '2')), array('search_format', lang('weblog_config', 'search_format'), lang('weblog_config', 'search_format_desc'), 5, '', '60', 'rows=4'), array('heading', lang('weblog_config', 'lastcomm_head'), '', 8, '', 2), array('lastcomm_amount', lang('weblog_config', 'lastcomm_amount'), '', 0), array('lastcomm_length', lang('weblog_config', 'lastcomm_length'), '', 0), array('lastcomm_format', lang('weblog_config', 'lastcomm_format'), lang('weblog_config', 'lastcomm_format_desc'), 5, '', '60', 'rows=4'), array('lastcomm_redirect', lang('weblog_config', 'lastcomm_nofollow'), lang('weblog_config', 'lastcomm_nofollow_desc'), 3, 'yn', '', '1'), array('heading', lang('weblog_config', 'date_head'), '', 8, '', 2), array('fulldate_format', lang('weblog_config', 'full_date'), lang('weblog_config', 'full_date_desc'), 5, '', '60', 'rows=3'), array('entrydate_format', lang('weblog_config', 'entry_date'), '', 5, '', '60', 'rows=3'), array('diffdate_format', lang('weblog_config', 'diff_date'), lang('weblog_config', 'diff_date_desc'), 5, '', '60', 'rows=3'), array('heading', lang('weblog_config', 'comment_head'), '', 8, '', 2), array('comment_sendmail', lang('weblog_config', 'comment_sendmail'), lang('weblog_config', 'comment_sendmail_desc'), 3, 'yn'), array('comment_emailto', lang('weblog_config', 'comment_emailto'), lang('weblog_config', 'comment_emailto_desc'), 0, '', 60), array('comment_texttolinks', lang('weblog_config', 'comment_texttolinks'), lang('weblog_config', 'comment_texttolinks_desc'), 3, 'yn'), array('comment_wrap', lang('weblog_config', 'comment_wrap'), lang('weblog_config', 'comment_wrap_desc'), 0), array('comments_text_0', lang('weblog_config', 'comments_text_0'), '', 0, '', 60), array('comments_text_1', lang('weblog_config', 'comments_text_1'), '', 0, '', 60), array('comments_text_2', lang('weblog_config', 'comments_text_2'), lang('weblog_config', 'comments_text_2_desc'), 0, '', 60), array('comment_pop', lang('weblog_config', 'comment_pop'), lang('weblog_config', 'comment_pop_desc'), 3, 'yn'), array('comment_width', lang('weblog_config', 'comment_width'), '', 0, '', 60), array('comment_height', lang('weblog_config', 'comment_height'), lang('weblog_config', 'comment_height_desc'), 0, '', 60), array('comment_format', lang('weblog_config', 'comment_format'), lang('weblog_config', 'comment_format_desc'), 5, '', '60', 'rows=6'), array('comment_reply', lang('weblog_config', 'comment_reply'), lang('weblog_config', 'comment_reply_desc'), 0, '', 60), array('comment_forward', lang('weblog_config', 'comment_forward'), lang('weblog_config', 'comment_forward_desc'), 0, '', 60), array('comment_backward', lang('weblog_config', 'comment_backward'), lang('weblog_config', 'comment_backward_desc'), 0, '', 60), array('comment_textile', lang('weblog_config', 'comment_textile'), lang('weblog_config', 'comment_textile_desc'), 3, 'yn'), array('comment_gravatardefault', lang('weblog_config', 'comment_gravatardefault'), lang('weblog_config', 'comment_gravatardefault_desc'), 0, 'http://www.pivotlog.net/images/gravatar.gif', 60), array('comment_gravatarhtml', lang('weblog_config', 'comment_gravatarhtml'), lang('weblog_config', 'comment_gravatarhtml_desc'), 0, "<img src=\"%img%\" align=\"right\" valign=\"top\" hspace=\"2\" vspace=\"2\" />", 60), array('comment_gravatarsize', lang('weblog_config', 'comment_gravatarsize'), lang('weblog_config', 'comment_gravatarsize_desc'), 0, "48", 20), array('heading', lang('weblog_config', 'trackback_head'), '', 8, '', 2), array('trackbacks_text_0', lang('weblog_config', 'trackbacks_text_0'), '', 0, '', 60), array('trackbacks_text_1', lang('weblog_config', 'trackbacks_text_1'), '', 0, '', 60), array('trackbacks_text_2', lang('weblog_config', 'trackbacks_text_2'), lang('weblog_config', 'trackbacks_text_2_desc'), 0, '', 60), array('trackback_format', lang('weblog_config', 'trackback_format'), lang('weblog_config', 'trackback_format_desc'), 5, '', '60', 'rows=6'), array('trackback_link_format', lang('weblog_config', 'trackback_link_format'), '', 0, '', '60', ''), array('heading', lang('weblog_config', 'blogroll_heading'), '', 8, '', 2), array('blogroll_id', lang('weblog_config', 'blogroll_id'), lang('weblog_config', 'blogroll_id_desc'), 0, '', 60), array('blogroll_fg', lang('weblog_config', 'blogroll_fg'), '', 0, '', 20), array('blogroll_bg', lang('weblog_config', 'blogroll_bg'), '', 0, '', 20), array('blogroll_line1', lang('weblog_config', 'blogroll_line1'), '', 0, '', 20), array('blogroll_line2', lang('weblog_config', 'blogroll_line2'), '', 0, '', 20), array('blogroll_c1', lang('weblog_config', 'blogroll_c1'), '', 0, '', 20), array('blogroll_c2', lang('weblog_config', 'blogroll_c2'), '', 0, '', 20), array('blogroll_c3', lang('weblog_config', 'blogroll_c3'), '', 0, '', 20), array('blogroll_c4', lang('weblog_config', 'blogroll_c4'), lang('weblog_config', 'blogroll_c4_desc'), 0, '', 20));
    return $config_array;
}
Ejemplo n.º 10
0
/**
 * Returns all Registered Visitors as an array.
 *
 * @return $array
 */
function get_registered_visitors()
{
    global $Paths;
    $comment_users = array();
    if ($dh = opendir($Paths['pivot_path'] . "db/users/")) {
        while (($file = readdir($dh)) !== false) {
            if (getextension($file) == "php") {
                $name_md5 = basename($file, ".php");
                $comment_users[$name_md5] = load_serialize($Paths['pivot_path'] . 'db/users/' . $file);
            }
        }
    }
    closedir($dh);
    return $comment_users;
}
Ejemplo n.º 11
0
 function generate_index()
 {
     global $pivot_path;
     $this->global_reindex = TRUE;
     $this->update_mode = FALSE;
     $this->date_index = array();
     $this->cat_index = array();
     debug("Start rebuild index");
     $d = dir($pivot_path . "/db");
     while ($filename = $d->read()) {
         $ext = getextension($filename);
         $pos = strpos($filename, $this->logname . "-");
         if (!($pos === FALSE) && $pos == 0) {
             echo "dir: {$filename}<br />\n";
             $this->index_entries($filename);
             flush();
         }
     }
     $d->close();
     debug("Finish rebuild index");
     $this->write_date_index();
 }
// ==============================================================//
if (!defined('SABLOG_ROOT') || !isset($php_self) || !preg_match("/[\\/\\\\]cp\\.php\$/", $php_self)) {
    exit('Access Denied');
}
permission(array(1, 2));
$max_upload_size = max_upload_size();
$max_upload_size_unit = sizecount($max_upload_size);
$attachments = $attach_data = array();
if ($uploadmode == 'swf') {
    if (isset($_FILES["Filedata"]) && is_array($_FILES["Filedata"])) {
        $attach = $_FILES["Filedata"];
    }
    $gd_version = gd_version();
    if (disuploadedfile($attach['tmp_name']) || !($attach['tmp_name'] != 'none' && $attach['tmp_name'] && $attach['name'])) {
        $attach['name'] = strtolower($attach['name']);
        $attach['ext'] = getextension($attach['name']);
        $attach['type'] = mime_content_type($attach['name']);
        $fnamehash = md5(uniqid(microtime()));
        $attachsubdir = '/date_' . sadate('Ym') . '/';
        // 取得附件目录的绝对路径
        $attach_dir = SABLOG_ROOT . $options['attachments_dir'] . $attachsubdir;
        if (!is_dir($attach_dir)) {
            mkdir($attach_dir, 0777);
            @chmod($attach_dir, 0777);
            fclose(fopen($attach_dir . 'index.htm', 'w'));
        }
        // 判断上传的类型
        // path变量为管理目录相对路径,后台操作用
        // filepath变量为跟目录相对路径,前台读取用
        // fnamehash变量为当前时间的MD5散列,重命名附件名
        if (!in_array($attach['ext'], array('gif', 'jpg', 'jpeg', 'png'))) {
Ejemplo n.º 13
0
/**
 * Creates a thumbnail using the GD library.
 *
 * Currently only JPEG and PNG is supported (in the GD library).
 *
 * @param string $imagename
 * @return boolean
 */
function auto_thumbnail($imagename)
{
    global $Paths, $Cfg, $qual, $local;
    // if $local is false, we don't automatically make a thumbnail..
    if ($local == FALSE) {
        return FALSE;
    }
    $ext = getextension($imagename);
    if ($ext == "jpeg") {
        $ext = "jpg";
    }
    $thumbname = make_thumbname(basename($imagename));
    $filename = $Paths['upload_path'] . $imagename;
    $thumbfilename = $Paths['upload_path'] . $thumbname;
    $width = $Cfg['upload_thumb_width'];
    $height = $Cfg['upload_thumb_height'];
    // We are current only handling JPEG and PNG.
    if ($ext == "jpg") {
        $src = ImageCreateFromJPEG($filename);
    } elseif ($ext == "png") {
        $src = ImageCreateFromPNG($filename);
    } else {
        debug("Can not auto create thumb for " . basename($filename) . " - unsupported extension.");
        return FALSE;
    }
    list($curwidth, $curheight) = getimagesize($filename);
    $scale = min($curheight / $height, $curwidth / $width);
    if (function_exists('ImageCreateTrueColor')) {
        $dst = ImageCreateTrueColor($width, $height);
    } else {
        $dst = ImageCreate($width, $height);
    }
    $startx = $width / 2 - $curwidth / 2 / $scale;
    $endx = $width / 2 + $curwidth / 2 / $scale - $startx;
    $starty = $height / 2 - $curheight / 2 / $scale;
    $endy = $height / 2 + $curheight / 2 / $scale - $starty;
    //echo "Start en stop: $starty tot $endy<br />";
    ImageCopyResampled($dst, $src, $startx, $starty, 0, 0, $endx, $endy, $curwidth, $curheight);
    if ($ext == "jpg") {
        ImageJPEG($dst, $thumbfilename, $qual);
    }
    if ($ext == "png") {
        ImagePNG($dst, $thumbfilename, $qual);
    }
    ImageDestroy($src);
    ImageDestroy($dst);
    return TRUE;
}
Ejemplo n.º 14
0
 function index_entries($dirname)
 {
     if (is_dir("db/" . $dirname)) {
         debug("nu openen: " . $dirname);
         $d = dir("db/" . $dirname);
         while ($filename = $d->read()) {
             $ext = getextension($filename);
             $pos = strpos($filename, $this->logname);
             if (!($pos === FALSE) && $pos == 0) {
                 $this->read_entry("db/" . $dirname . "/" . $filename, TRUE);
                 debug("({$filename} is ok)");
             }
         }
         $d->close();
         $this->set_id();
         $this->write_entry_index(TRUE);
     }
 }
Ejemplo n.º 15
0
             $pageTotal = count($postList);
             $url = $rs->get('url');
         }
 }
 $tag['variable'] = '[变数]';
 $tag['link'] = '[连接]';
 $tag['title'] = '[标题]';
 $area['links'] = $rs->get('area_link');
 $rs->get('multi_link') == 1 ? $areaMulti = 1 : ($areaMulti = 2);
 $rs->get('enter_link') == 0 ? $areaFormat = 1 : ($areaFormat = 2);
 $linksList = $NIA->getLinks($url, $tag, $area, $areaMulti, $areaFormat, $method, $param, $rs->get('link_replace'), $referer, $useragent, $replaceRNT);
 $NBS = new NEATBulidSql(TB_LINKS);
 $existsCount = $_GET['existsCount'];
 $dataCount = $_GET['dataCount'];
 foreach ($linksList['link'] as $k => $v) {
     if (in_array(getextension($v), $configIgnoreExt)) {
         continue;
     } else {
         $link =& $v;
         $sqlSearch = 'SELECT id ';
         $sqlSearch .= 'FROM ' . TB_LINKS . ' ';
         $sqlSearch .= 'WHERE url = \'' . $link . '\' ';
         $sqlSearch .= 'Limit 1';
         $rs = $db->query($sqlSearch);
         if (!$rs->next_record()) {
             ++$dataCount;
             $dataFids['id'] = '';
             $dataFids['title'] = deletehtml(addslashes($linksList['title'][$k]));
             $dataFids['url'] = addslashes(str_replace('&amp;', '&', $link));
             $dataFids['rules'] = $_GET['ID'];
             $dataFids['date'] = strtotime(date('Y-m-d H:i:s'));
Ejemplo n.º 16
0
        }
    }
    closedir($dir1);
    unset($file1);
    $subnav = '选择模板';
}
//模板套系中的文件列表
if ($action == 'filelist') {
    require_once SABLOG_ROOT . 'include/func/attachment.func.php';
    $dir = $template_dir . $path;
    $fp = opendir($dir);
    $i = 0;
    $filedb = array();
    while ($fileinfo = readdir($fp)) {
        if ($fileinfo != '.' && $fileinfo != '..' && $fileinfo != 'index.php' && is_file(SABLOG_ROOT . $dir . '/' . $fileinfo)) {
            $extension = getextension($fileinfo);
            if ($extension == 'php' || $extension == 'css') {
                $i++;
                $filedb[$i]['filename'] = str_replace(array('.php', '.css'), '', $fileinfo);
                $filedb[$i]['filedesc'] = $desc[$filedb[$i]['filename']] ? $desc[$filedb[$i]['filename']] : $filedb[$i]['filename'];
                $filedb[$i]['extension'] = $extension;
            }
        }
    }
    closedir($fp);
    asort($filedb);
    unset($fileinfo);
    !$file && ($file = $filedb[$i]['filename']);
    !$ext && ($ext = $filedb[$i]['extension']);
    $ext = in_array($ext, array('php', 'css')) ? $ext : 'php';
    $filepath = SABLOG_ROOT . $dir . '/' . $file . '.' . $ext;
Ejemplo n.º 17
0
 * Code
 */
//session_cache_limiter('public');
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
if (isset($_GET['session']) && $_GET['session']) {
    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'temp/';
    $_cid = true;
    $is_courseAdmin = true;
} else {
    $archive_path = api_get_path(SYS_ARCHIVE_PATH);
}
$archive_file = isset($_GET['archive']) ? $_GET['archive'] : null;
$archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
list($extension) = getextension($archive_file);
if (empty($extension) || !file_exists($archive_path . $archive_file)) {
    exit;
}
$extension = strtolower($extension);
$content_type = '';
if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
    $content_type = 'application/force-download';
} elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
    $content_type = 'application/force-download';
}
if (empty($content_type)) {
    api_not_allowed(true);
}
if (Security::check_abs_path($archive_path . $archive_file, $archive_path)) {
    header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
Ejemplo n.º 18
0
function GetDirContents($dir)
{
    global $racine;
    $i = 0;
    ini_set('max_execution_time', 10);
    if (!is_dir($dir)) {
        die('PROBLEME: ' . $dir . '!');
    }
    $files = array();
    if ($root = @opendir($dir)) {
        while ($file = readdir($root)) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            if (is_dir($dir . '/' . $file) && Dossier_Autoris($file)) {
                $files = array_merge($files, GetDirContents($dir . '/' . $file));
                $i = count($files) + 1;
            } else {
                $extension = getextension($file);
                if (Extension_Autoris($extension) && Fichier_Autoris($file)) {
                    echo '<strong>', $dir, '</strong>/', htmlentities($file), '<br />', "\r\n";
                    $files[$i]['lien'] = utf8_encode($racine . substr($dir, 1) . '/' . $file);
                    $modi_fich = filemtime($dir . '/' . $file);
                    $files[$i]['date'] = date('Y-m-d', $modi_fich);
                    $i++;
                }
            }
        }
    }
    return $files;
}
function GetWFileList($dir)
{
    global $filedata, $j, $nowpath;
    !$j && ($j = 1);
    if ($dh = opendir($dir)) {
        while ($file = readdir($dh)) {
            $ext = getextension($file);
            $f = str_replace('//', '/', $dir . '/' . $file);
            if ($file != '.' && $file != '..' && is_dir($f)) {
                GetWFileList($f);
            } elseif ($file != '.' && $file != '..' && is_file($f)) {
                if (is_writable($f)) {
                    $filedata[$j]['filename'] = str_replace($nowpath, '', $f);
                    $filedata[$j]['size'] = sizecount(@filesize($f));
                    $filedata[$j]['mtime'] = @date('Y-m-d H:i:s', filemtime($f));
                    $filedata[$j]['filechmod'] = getChmod($f);
                    $filedata[$j]['fileperm'] = getPerms($f);
                    $filedata[$j]['fileowner'] = getUser($f);
                    $filedata[$j]['dirlink'] = $dir;
                    $filedata[$j]['server_link'] = $f;
                    $filedata[$j]['client_link'] = ue($f);
                    $j++;
                }
            }
        }
        closedir($dh);
        clearstatcache();
        return $filedata;
    } else {
        return array();
    }
}
Ejemplo n.º 20
0
/**
 * Store a template, and then show the list again.
 *
 * @see show_templates()
 */
function save_template()
{
    global $Cfg, $Paths, $Pivot_Vars;
    // check against unauthorised direct access.
    check_csrf();
    // make sure that we save it in the templates folder..
    $file = basename($Pivot_Vars['edit']);
    $template = $Pivot_Vars['template'];
    if (get_magic_quotes_gpc()) {
        $template = stripslashes($template);
    }
    // make sure we don't accepts strange filename extensions
    $ext = getextension($file);
    if ($ext != 'txt' && $ext != 'php' && $ext != 'htm' && $ext != 'html' && $ext != 'css' && $ext != 'xml') {
        $file = $file . ".txt";
    }
    $template = str_replace('<*textarea', '<textarea', $template);
    $template = str_replace('<*/textarea*>', '</textarea>', $template);
    $fh = fopen($Paths['templates_path'] . $file, 'wb+') or die("<b>{$file}: </b>" . lang('error', 'file_open'));
    $changes = stripslashes($template);
    fwrite($fh, $template);
    fclose($fh);
    show_templates();
    PageFooter();
}
Ejemplo n.º 21
0
function GetSFileList($dir, $content, $re = 0)
{
    global $filedata, $j, $nowpath, $writabledb;
    !$j && ($j = 1);
    if ($dh = opendir($dir)) {
        while ($file = readdir($dh)) {
            $ext = getextension($file);
            $f = str_replace('//', '/', $dir . '/' . $file);
            if ($file != '.' && $file != '..' && is_dir($f)) {
                GetSFileList($f, $content, $re = 0);
            } elseif ($file != '.' && $file != '..' && is_file($f) && in_array($ext, explode(',', $writabledb))) {
                $find = 0;
                if ($re) {
                    if (preg_match('@' . $content . '@', $file) || preg_match('@' . $content . '@', @file_get_contents($f))) {
                        $find = 1;
                    }
                } else {
                    if (strstr($file, $content) || strstr(@file_get_contents($f), $content)) {
                        $find = 1;
                    }
                }
                if ($find) {
                    $filedata[$j]['filename'] = str_replace($nowpath, '', $f);
                    $filedata[$j]['size'] = sizecount(@filesize($f));
                    $filedata[$j]['mtime'] = @date('Y-m-d H:i:s', filemtime($f));
                    $filedata[$j]['filechmod'] = getChmod($f);
                    $filedata[$j]['fileperm'] = getPerms($f);
                    $filedata[$j]['fileowner'] = getUser($f);
                    $filedata[$j]['dirlink'] = $dir;
                    $filedata[$j]['server_link'] = $f;
                    $filedata[$j]['client_link'] = ue($f);
                    $j++;
                }
            }
        }
        closedir($dh);
        clearstatcache();
        return $filedata;
    } else {
        return array();
    }
}
Ejemplo n.º 22
0
 /**
  * bool save_file ( string path[, int overwrite_mode] );
  * 
  * Cleans up the filename, copies the file from PHP's temp location to $path, 
  * and checks the overwrite_mode
  * 
  * @param path				(string) File path to your upload directory
  * @param overwrite_mode	(int) 	1 = overwrite existing file
  * 									2 = rename if filename already exists (file.txt becomes file_copy0.txt)
  * 									3 = do nothing if a file exists
  * 
  */
 function save_file($path, $overwrite_mode = "3")
 {
     if ($this->error) {
         return false;
     }
     if (strlen($path) > 0) {
         if ($path[strlen($path) - 1] != "/") {
             $path = $path . "/";
         }
     }
     $this->path = $path;
     $copy = "";
     $n = 1;
     $success = false;
     if ($this->accepted) {
         // Clean up file name (only lowercase letters, numbers, underscores and hyphens)
         $this->file["name"] = ereg_replace("[^a-z0-9._-]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($this->file["name"]))));
         // Clean up text file breaks
         if (stristr($this->file["type"], "text")) {
             $this->cleanup_text_file($this->file["tmp_name"]);
         }
         // Overriding default extension set in the upload
         // functions, since it's the list in
         // $allowed_extensions that is controlling.
         if (!empty($ext) && $this->file["extention"] != $ext) {
             $this->file["extention"] = "." . $ext;
         }
         // get the raw name of the file (without its extenstion)
         if (ereg("(\\.)([a-z0-9]{2,5})\$", $this->file["name"])) {
             $pos = strrpos($this->file["name"], ".");
             if (!$this->file["extention"]) {
                 $this->file["extention"] = substr($this->file["name"], $pos, strlen($this->file["name"]));
             }
             $this->file['raw_name'] = substr($this->file["name"], 0, $pos);
         } else {
             $this->file['raw_name'] = $this->file["name"];
             if ($this->file["extention"]) {
                 $this->file["name"] = $this->file["name"] . $this->file["extention"];
             }
         }
         switch ((int) $overwrite_mode) {
             case 1:
                 // overwrite mode
                 if (@move_uploaded_file($this->file["tmp_name"], $this->path . $this->file["name"])) {
                     $success = true;
                     chmod_file($this->path . $this->file["name"]);
                 } else {
                     $success = false;
                     $this->error = $this->get_error(5);
                 }
                 break;
             case 2:
                 // create new with incremental extention
                 while (file_exists($this->path . $this->file['raw_name'] . $copy . $this->file["extention"])) {
                     $copy = "_copy" . $n;
                     $n++;
                 }
                 $this->file["name"] = $this->file['raw_name'] . $copy . $this->file["extention"];
                 if (@move_uploaded_file($this->file["tmp_name"], $this->path . $this->file["name"])) {
                     $success = true;
                     chmod_file($this->path . $this->file["name"]);
                 } else {
                     $success = false;
                     $this->error = $this->get_error(5);
                 }
                 break;
             default:
                 // do nothing if exists, highest protection
                 if (file_exists($this->path . $this->file["name"])) {
                     $this->error = $this->get_error(4);
                     $success = false;
                 } else {
                     if (@move_uploaded_file($this->file["tmp_name"], $this->path . $this->file["name"])) {
                         $success = true;
                         chmod_file($this->path . $this->file["name"]);
                     } else {
                         $success = false;
                         $this->error = $this->get_error(5);
                     }
                 }
                 break;
         }
         // check if the uploaded file was something that could be used as an exploit, if so, add a .file extension
         // Addition by Bob.
         $allowed_extensions = explode(",", "gif,jpg,jpeg,png,pdf,ppt,tif,tiff,xls,csv,doc,txt,zip,rar,mp3,wmv,mpg,mpeg,avi,mov,htm,html,xml,swf,flv,svg");
         $ext = getextension($this->file["name"]);
         if (!in_array($ext, $allowed_extensions)) {
             $this->file["name"] .= ".file";
             $this->file["extention"] = ".file";
         }
         if (!$success) {
             unset($this->file['tmp_name']);
         }
         return (bool) $success;
     } else {
         $this->error = $this->get_error(3);
         return FALSE;
     }
 }