Esempio n. 1
0
function m__space_use()
{
    $html = '空间占用情况:<span style=\\"color:red;\\">';
    if (!isset($_SESSION['space_size'])) {
        $_SESSION['space_size'] = num_bitunit(dir_size(dirname(__FILE__) . '/../'));
    }
    $html .= $_SESSION['space_size'];
    $html .= '</span>&nbsp;&nbsp;&nbsp;空间文件数量:<span style=\\"color:red;\\">';
    if (!isset($_SESSION['space_files'])) {
        $_SESSION['space_files'] = dir_files(dirname(__FILE__) . '/../');
    }
    $html .= $_SESSION['space_files'];
    $html .= '</span>';
    die('{"code":"0","msg":"' . $html . '"}');
}
 /**
  * Returns the number of assets in a given folder 
  *
  * @access	public
  * @param	string	An asset folder
  * @return	int
  */
 public function record_count($dir = 'images')
 {
     $CI =& get_instance();
     $assets_path = WEB_ROOT . $CI->config->item('assets_path') . $dir . '/';
     $files = dir_files($assets_path, false, false);
     return count($files);
 }
Esempio n. 3
0
    ?>

    <!-- archivos adjuntos -->
    <?php
    $ruta = 'uploads/'.$var_ticketid;

    $scanned_directory = ( file_exists( $ruta ) ) ? array_diff(scandir($ruta), array('..', '.')) : 0;
    if ( count($scanned_directory) == 0 )   @rmdir( $ruta );
    ?>
    <? if ( file_exists( $ruta ) ) { ?>
        <!-- Block -->
        <div class="block">
            <!-- Lightbox Gallery with Options Title --><div class="block-title"><h2>Archivos Adjuntos</h2></div><!-- END Lightbox Gallery with Options Title -->
            <!-- Lightbox Gallery with Options Content -->
            <?php
            $files  = dir_files( $ruta );
            if( count($files) > 0 )
            {
                ?>
                <div class="gallery" data-toggle="lightbox-gallery">
                    <div class="row">
                        <?php
                        foreach ( $files as $elem )
                        {
                            ?>
                            <div class="col-sm-2 gallery-image" style="text-align: center;">
                                <!-- <a href="<?php echo $ruta . '/'. $elem; ?>" class="gallery-link" title="<?php echo $elem; ?>"> -->
                                <?php
                                $ext = explode( '.', $elem );
                                if ( $ext[1] == 'pdf' )     echo '<img src="images/ico-upload-pdf.png"/>';
                                elseif ( $ext[1] == 'doc' ) echo '<img src="images/ico-upload-word.png"/>';
Esempio n. 4
0
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv=Content-Type content="text/html; charset=utf-8">
	<meta http-equiv=Content-Language content=zh-CN>
	<title>迅傲信息</title>
	<?php 
require_once '../../frame.php';
$debug_tag = false;
use_jquery();
require_role();
?>
</head>
<?php 
$dir = '/dbscript/';
$files = dir_files($dir, false);
if ($files === false) {
    die('执行失败');
}
$db = get_db();
$db->query("select file_name from db_migrate");
if ($db->move_first() === false) {
    die('执行成功,无新脚本');
}
do {
    $executed_files[] = $db->field_by_name('file_name');
} while ($db->move_next());
$doing_files = array_diff($files, $executed_files);
$done_files = array();
$fail_files = array();
$fail_scripts = array();
            }
        }
    }
}
foreach ($tracklist as $n => $track) {
    if ($n == 0) {
        continue;
    }
    // не трогаем первый трекер, это мастер
    // Remote tracker
    if (substr($track['path'], 0, 4) == 'http') {
        $files = api_get_files($track, $n);
        // Local tracker
    } else {
        foreach (array('clicks', 'postback') as $type) {
            $files = dir_files($track['path'] . '/cache/' . $type, $type);
            foreach ($files as $f) {
                rename($track['path'] . '/cache/' . $type . '/' . $f, _CACHE_PATH . '/' . $type . '/' . $f . '_' . $n);
            }
        }
    }
}
// Process clicks
$arr_files = array();
$process_at_once = 60 * 24 * 10;
$iCnt = 0;
if ($handle = opendir(_CACHE_PATH . '/clicks/')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && $entry != ".empty") {
            if (strpos($entry, '.') === 0 && strpos($entry, '+') === false && strpos($entry, '*') === false) {
                // Also check that there were at least 2 minutes from creation date
function download_clicks()
{
    global $tracklist;
    foreach ($tracklist as $n => $track) {
        if (substr($track['path'], 0, 4) == 'http') {
            // Remote tracker
            api_get_files($track, $n);
        } else {
            if ($n == 0) {
                continue;
            }
            // First tracker is master, don't touch
            // Local tracker
            foreach (array('clicks', 'postback') as $type) {
                $files = dir_files($track['path'] . '/cache/' . $type, $type);
                foreach ($files as $f) {
                    rename($track['path'] . '/cache/' . $type . '/' . $f, _CACHE_PATH . '/' . $type . '/' . $f . '_' . $n);
                }
            }
        }
    }
}
Esempio n. 7
0
    // Обновление кэша ссылок
} elseif ($act == 'links_update') {
    $links_cache = rq('links');
    $outs_path = _CACHE_PATH . '/outs';
    $errors = array();
    if (!is_dir($outs_path)) {
        mkdir($outs_path);
        chmod($outs_path, 0777);
    }
    foreach ($links_cache as $id => $link) {
        $path = $outs_path . '/.' . $id;
        if (file_put_contents($path, $link, LOCK_EX)) {
            chmod($path, 0777);
        } else {
            $errors[] = 'Ошибка записи в файл ' . $path;
        }
    }
    // Удаляем неактуальные кэши
    $files = dir_files($outs_path);
    foreach ($files as $f) {
        if (!array_key_exists(substr($f, 1), $links_cache)) {
            unlink($outs_path . '/' . $f);
        }
    }
    if (!empty($errors)) {
        $out = api_error(join("\n", $errors));
    } else {
        $out['data'] = 'success';
    }
}
echo json_encode($out);
/**
 * Рассылка информации по трекерам
 */
function send2trackers($name, $data)
{
    global $tracklist;
    $out = array('status' => 1);
    $error = array();
    switch ($name) {
        // Обновление правил
        case 'rules_update':
            $rules_cache = array();
            foreach ($data as $rule_name => $arr_items) {
                $i = 1;
                $arr_rules = array();
                foreach ($arr_items as $row) {
                    if ($row['parent_id'] > 0) {
                        $arr_rules[$arr_items[$row['parent_id']]['type']][] = array('value' => $arr_items[$row['parent_id']]['value'], 'rule_id' => $row['rule_id'], 'out_id' => $row['value'], 'order' => $i);
                        $i++;
                    }
                }
                $str_rules = serialize($arr_rules);
                $rules_cache[$rule_name] = $str_rules;
            }
            foreach ($tracklist as $track) {
                $type = substr($track['path'], 0, 4) == 'http' ? 'remote' : 'local';
                if ($type == 'local') {
                    $rules_path = $track['path'] . '/cache/rules';
                    if (!is_dir($rules_path)) {
                        mkdir($rules_path);
                        chmod($rules_path, 0777);
                    }
                    // Записываем новые хеши
                    foreach ($rules_cache as $rule_name => $str_rules) {
                        $path = $rules_path . '/.' . $rule_name;
                        if (file_put_contents($path, $str_rules, LOCK_EX)) {
                            chmod($path, 0777);
                        } else {
                            $error[] = 'Can\'t create file ' . $path;
                        }
                    }
                    // Удаляем неактуальные кэши
                    $files = dir_files($rules_path);
                    foreach ($files as $f) {
                        if (!array_key_exists(substr($f, 1), $rules_cache)) {
                            unlink($rules_path . '/' . $f);
                        }
                    }
                } else {
                    $url = $track['path'] . '/api.php?act=ping&key=' . $track['key'];
                    $answer_text = api_send($url);
                    $answer = json_decode($answer_text, true);
                    if ($answer['status'] == 1) {
                        $url = $track['path'] . '/api.php?act=rules_update&key=' . $track['key'];
                        $answer_text = api_send($url, array('rules' => $rules_cache));
                        $answer = json_decode($answer_text, true);
                        if ($answer['status'] != 1) {
                            if (empty($answer['error'])) {
                                $error[] = $answer['error'];
                            } else {
                                $error[] = 'Unknown error';
                            }
                        }
                    } else {
                        $str_error = 'Don\'t have access to host ' . $url;
                        if ($answer_text != '') {
                            $str_error .= ' Answer: ' . $answer_text;
                        }
                        $error[] = $str_error;
                    }
                }
            }
            break;
            // Обновление ссылок
        // Обновление ссылок
        case 'links_update':
            foreach ($tracklist as $track) {
                $type = substr($track['path'], 0, 4) == 'http' ? 'remote' : 'local';
                if ($type == 'local') {
                    $outs_path = $track['path'] . '/cache/outs';
                    if (!is_dir($outs_path)) {
                        mkdir($outs_path);
                        chmod($outs_path, 0777);
                    }
                    foreach ($data as $id => $link) {
                        $path = $outs_path . '/.' . $id;
                        if (file_put_contents($path, $link, LOCK_EX)) {
                            chmod($path, 0777);
                        } else {
                            $error[] = 'Can\'t create file ' . $path;
                        }
                    }
                    // Удаляем неактуальные кэши
                    $files = dir_files($outs_path);
                    foreach ($files as $f) {
                        if (!array_key_exists(substr($f, 1), $data)) {
                            unlink($outs_path . '/' . $f);
                        }
                    }
                } else {
                    $url = $track['path'] . '/api.php?act=ping&key=' . $track['key'];
                    $answer_text = api_send($url);
                    $answer = json_decode($answer_text, true);
                    if ($answer['status'] == 1) {
                        $url = $track['path'] . '/api.php?act=links_update&key=' . $track['key'];
                        $answer_text = api_send($url, array('links' => $data));
                        $answer = json_decode($answer_text, true);
                        if ($answer['status'] != 1) {
                            if (empty($answer['error'])) {
                                $error[] = $answer['error'];
                            } else {
                                $error[] = 'Unknown error';
                            }
                        }
                    } else {
                        $str_error = 'Don\'t have access to host ' . $url . '.';
                        if ($answer_text != '') {
                            $str_error .= ' Answer: ' . $answer_text;
                        }
                        $error[] = $str_error;
                    }
                }
            }
            break;
    }
    if (!empty($error)) {
        $out = array('status' => 0, 'error' => join("\n", $error));
    }
    return $out;
}
Esempio n. 9
0
function dir_files($dirname)
{
    $files = 0;
    if ($dir_handle = opendir($dirname)) {
        while ($filename = readdir($dir_handle)) {
            $subFile = $dirname . DIRECTORY_SEPARATOR . $filename;
            if ($filename == '.' || $filename == '..') {
                continue;
            } else {
                if (is_dir($subFile)) {
                    $files += dir_files($subFile);
                } else {
                    if (is_file($subFile)) {
                        $files++;
                    }
                }
            }
        }
        closedir($dir_handle);
    }
    return $files;
}
Esempio n. 10
0
        if ($content == '') {
            unlink($path);
            if (file_exists($path)) {
                $errors[] = 'Ошибка удаления файла ' . $path;
            }
        } else {
            if (file_put_contents($path, $content, LOCK_EX)) {
                chmod($path, 0777);
            } else {
                $errors[] = 'Ошибка записи в файл ' . $path;
            }
        }
    }
    // Удаляем неактуальные кэши, если это был полный список
    if ($full) {
        $files = dir_files($cache_path);
        foreach ($files as $f) {
            if (!array_key_exists(substr($f, 1), $cache)) {
                unlink($cache_path . '/' . $f);
            }
        }
    }
    if (!empty($errors)) {
        $out = api_error(join("\n", $errors));
    } else {
        $out['data'] = 'success';
    }
} elseif ($act == 'get_status') {
    $out['data'] = array('time' => date('Y-m-d H:i:s'), 'unix_time' => time(), 'timezone' => date_default_timezone_get());
} elseif ($act != 'ping') {
    $errors[] = 'Неизвестный метод ' . $act;
/**
 * Рассылка информации по трекерам
 */
function send2trackers($name, $data)
{
    global $tracklist;
    $out = array('status' => 1);
    $error = array();
    switch ($name) {
        case 'rule_update':
            // Обновление ОДНОГО правила
        // Обновление ОДНОГО правила
        case 'rules_update':
            // Обновление ВСЕХ правил
            $rules_cache = array();
            foreach ($data as $rule_name => $arr_items) {
                $i = 1;
                $arr_rules = array();
                foreach ($arr_items as $row) {
                    if ($row['parent_id'] > 0) {
                        $arr_rules[$arr_items[$row['parent_id']]['type']][] = array('value' => $arr_items[$row['parent_id']]['value'], 'rule_id' => $row['rule_id'], 'out_id' => $row['value'], 'order' => $i);
                        $i++;
                    }
                }
                $str_rules = empty($arr_rules) ? '' : serialize($arr_rules);
                $rules_cache[$rule_name] = $str_rules;
            }
            foreach ($tracklist as $track) {
                $type = substr($track['path'], 0, 4) == 'http' ? 'remote' : 'local';
                // Локальный трекер
                if ($type == 'local') {
                    $rules_path = $track['path'] . '/cache/rules';
                    dir_exists($rules_path);
                    // Записываем новые хеши
                    foreach ($rules_cache as $rule_name => $str_rules) {
                        $path = $rules_path . '/.' . $rule_name;
                        if (file_put_contents($path, $str_rules, LOCK_EX)) {
                            chmod($path, 0777);
                        } else {
                            $error[] = 'Can\'t create file ' . $path;
                        }
                    }
                    // Удаляем кэши, которые есть, но нам их не прислали в обновлениях
                    if ($name == 'rules_update') {
                        $files = dir_files($rules_path);
                        foreach ($files as $f) {
                            if (!array_key_exists(substr($f, 1), $rules_cache)) {
                                unlink($rules_path . '/' . $f);
                            }
                        }
                    }
                    // Удаленный трекер
                } else {
                    $url = $track['path'] . '/api.php?act=ping';
                    $answer_text = api_send($url);
                    $answer = json_decode($answer_text, true);
                    if ($answer['status'] == 1) {
                        // Полное или частичное обновление
                        $url = $track['path'] . '/api.php?act=rules_update' . ($name == 'rules_update' ? '&full=1' : '');
                        $answer_text = api_send($url, array('cache' => $rules_cache, 'key' => $track['key']));
                        $answer = json_decode($answer_text, true);
                        if ($answer['status'] != 1) {
                            if (empty($answer['error'])) {
                                $error[] = $answer['error'];
                            } else {
                                $error[] = 'Unknown error. Answer: ' . $answer_text;
                            }
                        }
                    } else {
                        $str_error = 'Don\'t have access to host ' . $url;
                        if ($answer_text != '') {
                            $str_error .= ' Answer: ' . $answer_text;
                        }
                        $error[] = $str_error;
                    }
                }
            }
            break;
        case 'out_update':
            // Обновление одной ссылки
        // Обновление одной ссылки
        case 'outs_update':
            // Обновление всех ссылок
            foreach ($tracklist as $track) {
                $type = substr($track['path'], 0, 4) == 'http' ? 'remote' : 'local';
                if ($type == 'local') {
                    $outs_path = $track['path'] . '/cache/outs';
                    dir_exists($outs_path);
                    foreach ($data as $id => $link) {
                        $path = $outs_path . '/.' . $id;
                        if (file_put_contents($path, $link, LOCK_EX)) {
                            chmod($path, 0777);
                        } else {
                            $error[] = 'Can\'t create file ' . $path;
                        }
                    }
                    // Удаляем неактуальные кэши
                    $files = dir_files($outs_path);
                    foreach ($files as $f) {
                        if (!array_key_exists(substr($f, 1), $data)) {
                            unlink($outs_path . '/' . $f);
                        }
                    }
                } else {
                    $url = $track['path'] . '/api.php?act=ping';
                    $answer_text = api_send($url);
                    $answer = json_decode($answer_text, true);
                    if ($answer['status'] == 1) {
                        $url = $track['path'] . '/api.php?act=outs_update' . ($name == 'outs_update' ? '&full=1' : '');
                        $answer_text = api_send($url, array('cache' => $data, 'key' => $track['key']));
                        $answer = json_decode($answer_text, true);
                        if ($answer['status'] != 1) {
                            if (empty($answer['error'])) {
                                $error[] = $answer['error'];
                            } else {
                                $error[] = 'Unknown error';
                            }
                        }
                    } else {
                        $str_error = 'Don\'t have access to host ' . $url . '.';
                        if ($answer_text != '') {
                            $str_error .= ' Answer: ' . $answer_text;
                        }
                        $error[] = $str_error;
                    }
                }
            }
            break;
    }
    if (!empty($error)) {
        $out = array('status' => 0, 'error' => join("\n", $error));
    }
    return $out;
}