Пример #1
0
function publish_update()
{
    global $config;
    $next_tag = safe_read($config['generator']['next_tag'], 32);
    if ($next_tag === FALSE) {
        return array('success' => FALSE, 'output' => 'No tag to publish');
    }
    $tag_dir = $config['generator']['data_dir'] . '/' . $next_tag;
    if (!file_exists($tag_dir)) {
        mkdir($tag_dir, 0755, TRUE);
    }
    $dp = opendir($config['generator']['tmp_dir']);
    while (($file = readdir($dp)) !== FALSE) {
        if ($file !== '.' && $file !== '..') {
            $tmp = $config['generator']['tmp_dir'] . '/' . $file;
            $production = $tag_dir . '/' . $file;
            if (rename($tmp, $production) == FALSE) {
                return array('success' => FALSE, 'output' => 'Failed moving ' . $tmp . ' to ' . $production);
            }
        }
    }
    closedir($dp);
    safe_write($config['generator']['current_tag'], 'w', $next_tag);
    return array('success' => TRUE, 'output' => 'Tag "' . $next_tag . '" has been published');
}
function sync($tmp)
{
    global $parent, $chunk_data_size, $total_data_size, $pipe, $pipes;
    if (!$parent) {
        $data = pack('d*', ...$tmp);
        safe_write($pipe, $data);
        return array_values(unpack('d*', safe_read($pipe, $total_data_size)));
    } else {
        $tmps = array();
        foreach ($pipes as $pipe) {
            $tmps[] = unpack('d*', safe_read($pipe, $chunk_data_size));
        }
        $tmps[] = $tmp;
        $tmp = array_merge(...$tmps);
        $data = pack('d*', ...$tmp);
        foreach ($pipes as $pipe) {
            safe_write($pipe, $data);
        }
        return $tmp;
    }
}
Пример #3
0
function sync(&$tmp)
{
    global $parent, $chunk_data_size, $total_data_size, $pipe, $pipes;
    if (!$parent) {
        array_unshift($tmp, 'd*');
        $data = call_user_func_array('pack', $tmp);
        safe_write($pipe, $data);
        $tmp = array_merge(array(), unpack('d*', safe_read($pipe, $total_data_size)));
    } else {
        $tmps = array(array('d*'));
        foreach ($pipes as $pipe) {
            $tmps[] = unpack('d*', safe_read($pipe, $chunk_data_size));
        }
        $tmps[] =& $tmp;
        $tmp = call_user_func_array('array_merge', $tmps);
        $data = call_user_func_array('pack', $tmp);
        foreach ($pipes as $pipe) {
            safe_write($pipe, $data);
        }
        array_shift($tmp);
    }
}
Пример #4
0
function save_captcha_code($session_id, $captcha_code, $news_id, $user_ip, $type)
{
    global $error1;
    $file = file(FNEWS_ROOT_PATH . 'sessions.php');
    array_shift($file);
    $current_time = time();
    $data = '<?php die (\'' . $error1 . '\'); ?>' . "\n";
    foreach ($file as $value) {
        $session = get_line_data('sessions', $value);
        if ($session['session_id'] == $session_id) {
            continue;
        }
        if ($session['last_visit'] + 600 >= $current_time && $session['ip'] != $user_ip) {
            $data .= $value;
        }
    }
    $data .= create_line_data('sessions', true, $session_id, $captcha_code, $news_id, $user_ip, $current_time, $type);
    safe_write('sessions.php', 'wb', $data);
}
Пример #5
0
                         $news_file[1] = implode('|<|', $article) . '|<|' . "\n";
                         $write = implode('', $news_file);
                         safe_write('news/news.' . $article['news_id'] . '.php', 'wb', $write);
                         break;
                     case 2:
                         // Delete posts
                         unlink(FNEWS_ROOT_PATH . 'news/news.' . $article['news_id'] . '.php');
                         break;
                     default:
                         break;
                 }
             } else {
                 $data .= $news;
             }
         }
         safe_write('news/toc.php', 'wb', $data);
     }
     $title = $ind1;
     echo make_redirect($ind2, '?id=categories', $ind336);
 } else {
     $catid = isset($VARS['category']) ? intval($VARS['category']) : 0;
     if (!category_exists($catid)) {
         trigger_error(sprintf($ind198, $catid), E_USER_WARNING);
     }
     $title = $ind314;
     echo '<form method="post" action="?id=categories">';
     echo get_form_security();
     $file = file(FNEWS_ROOT_PATH . 'users.php');
     array_shift($file);
     $user_array = array();
     foreach ($file as $user) {
Пример #6
0
                        } else {
                            $comment = str_replace("\n", '&nbsp;', $comment);
                        }
                        $comment = str_replace("\r", '', $comment);
                        $time = time();
                        $random = 'com' . mt_rand();
                        $file = file(FNEWS_ROOT_PATH . 'news/news.' . $id . '.php');
                        $file[] = $ip . '|<|' . ($com_validation && !$news_user ? 0 : 1) . '|<|' . $comment . '|<|' . $name . '|<|' . $email . '|<|' . $time . '|<|' . $random . '|<|' . "\n";
                        $article = get_line_data('news', $file[1]);
                        if (!$com_validation || $news_user) {
                            ++$article['numcomments'];
                        }
                        $file[1] = implode('|<|', $article) . '|<|' . "\n";
                        $data = implode('', $file);
                        safe_write('news/news.' . $id . '.php', 'wb', $data);
                        safe_write('flood.php', 'ab', $ip . '|<|' . $time . '|<|' . "\n");
                        echo <<<html
<script type="text/javascript">
//<![CDATA[
setTimeout ('window.location="{$next}"', 2000);
//]]>
</script>
html;
                        if ($com_validation && !$news_user) {
                            echo $com6a;
                        } else {
                            echo $com6 . ' <a href="' . $next . '">' . $com7 . '</a>';
                        }
                    } else {
                        echo $com8;
                    }