Ejemplo n.º 1
0
 function setCompileDir($compile_dir = '')
 {
     if (!empty($compile_dir)) {
         $comp_d = $this->compile_dir . $compile_dir;
         if (!file_exists($comp_d)) {
             pb_create_folder($comp_d);
         }
         $this->compile_dir = $comp_d;
     }
 }
Ejemplo n.º 2
0
 function lwrite($message = null, $pre = 'info')
 {
     if (empty($message)) {
         return;
     }
     if (empty($this->log_file)) {
         $this->log_file = DATA_PATH . 'logs/';
     }
     if (!is_dir($this->log_file)) {
         pb_create_folder($this->log_file);
     }
     $this->log_file = $this->log_file . $pre;
     if (!$this->fp) {
         $this->lopen();
     }
     $script_name = $_SERVER['PHP_SELF'];
     //		$script_name = basename($_SERVER['PHP_SELF']);
     //		$script_name = substr($script_name, 0, -4);
     $time = date('c');
     fwrite($this->fp, "{$time} - " . pb_getenv("REMOTE_ADDR") . " {$script_name}  {$message}\r\n");
     fclose($this->fp);
 }
Ejemplo n.º 3
0
require LIB_PATH . "db_mysql.inc.php";
uses("log");
$log = new Logs();
$db = new DB_Sql();
$conn = $db->connect($dbname, $dbhost, $dbuser, $dbpasswd);
$tpl_file = "db";
if (!($backupdir = $pdb->GetOne("SELECT valued FROM {$tb_prefix}settings WHERE variable='backup_dir'"))) {
    $backupdir = pb_radom(6);
    $db->query("REPLACE INTO {$tb_prefix}settings (variable, valued) values ('backup_dir', '{$backupdir}')");
}
require LIB_PATH . "func.db.php";
require LIB_PATH . "func.sql.php";
if (isset($_POST['do'])) {
    $do = trim($_POST['do']);
    if (!file_exists(DATA_PATH . "backup_" . $backupdir)) {
        pb_create_folder(DATA_PATH . "backup_" . $backupdir);
    }
    if ($do == "query" && !empty($_POST['sql_content'])) {
        if ($admin_runquery) {
            $result = sql_run($_POST['sql_content']);
            if ($result) {
                flash("success");
            } else {
                flash();
            }
        } else {
            flash("admin_runquery_forbidden");
        }
    }
    if ($do == "backup") {
        $filename = date('ymd') . '_' . pb_radom(6);
Ejemplo n.º 4
0
 function setCompileDir($compile_dir = '')
 {
     if (!$this->compile_sub_dirs) {
         if (!is_dir($this->compile_dir)) {
             pb_create_folder($this->compile_dir);
             @chmod($this->compile_dir, 0777);
         }
         return false;
     }
     $comp_d = $this->compile_dir . $compile_dir;
     if (!is_dir($comp_d)) {
         pb_create_folder($comp_d);
         @chmod($comp_d, 0777);
     }
     $smarty_cache = false;
     if (defined("SMARTY_CACHE")) {
         $smarty_cache = SMARTY_CACHE;
     }
     if ($this->caching || $smarty_cache) {
         if (!is_dir($this->cache_dir)) {
             pb_create_folder($this->cache_dir);
             @chmod($this->cache_dir, 0777);
         }
     }
     $this->compile_dir = $comp_d;
 }
Ejemplo n.º 5
0
     $authed = false;
     $attachment->if_thumb_large = false;
     if (!empty($_COOKIE[$cookiepre . 'admin'])) {
         $tAdminInfo = authcode($_COOKIE[$cookiepre . 'admin'], "DECODE");
         $tAdminInfo = explode("\n", $tAdminInfo);
         if (!empty($tAdminInfo)) {
             //check admin password
             $adminPasswd = $member->field("userpass", array("username" => $tAdminInfo['username']));
             if (pb_strcomp($tAdminInfo['userpass'], $adminPasswd)) {
                 $authed = true;
             }
         }
     }
     $targetPath = PHPB2B_ROOT . $attachment->attachment_dir . DS . "swfupload" . DS . gmdate("Y") . gmdate("m") . DS . gmdate("d") . DS;
     if (!is_dir($targetPath)) {
         pb_create_folder($targetPath);
     }
     $orignal_fileinfo = get_pathinfo($_FILES[$fileElementName]['name']);
     $new_file_name = gmdate("His") . pb_radom() . "." . $orignal_fileinfo['extension'];
     $targetFile = str_replace('//', '/', $targetPath) . $new_file_name;
     if ($authed && is_uploaded_file($_FILES[$fileElementName]['tmp_name'])) {
         move_uploaded_file($_FILES[$fileElementName]['tmp_name'], $targetFile);
         $return['url'] = $absolute_uri . $attachment_url . "swfupload/" . gmdate("Y") . gmdate("m") . "/" . gmdate("d") . "/" . $new_file_name;
         $return['name'] = $_FILES[$fileElementName]['name'];
         ajax_exit($return);
     }
     break;
 case "attachment":
     uses("attachment");
     //check permission
     $fileElementName = 'fileToUpload';
Ejemplo n.º 6
0
         $db->query($set_modes);
     }
     $tables = $db->table_names();
     if (!empty($tables)) {
         foreach ($tables as $names) {
             if (!function_exists("stripos")) {
                 function stripos($str, $needle)
                 {
                     return strpos(strtolower($str), strtolower($needle));
                 }
             }
             if (stripos($names['table_name'], $tb_prefix) === 0) {
                 $sqldump .= data2sql($names['table_name']);
             }
         }
         pb_create_folder(PHPB2B_ROOT . DS . "data" . DS . "backup_" . $backupdir);
         $file_path = PHPB2B_ROOT . DS . "data" . DS . "backup_" . $backupdir . DS . date('ymd') . '_' . pb_radom() . ".sql";
         if (trim($sqldump)) {
             file_put_contents($file_path, $sqldump);
             unset($sqldump);
         }
     }
     $db->free();
 }
 ob_start();
 $schema_path = "data/schemas/" . $app_lang . "/";
 $schema_common_path = "data/schemas/";
 if (!file_exists($schema_path)) {
     die(L("congratulate", "msg", $schema_path));
 }
 if (file_exists($schema_common_path . "mysql.sql")) {
Ejemplo n.º 7
0
 function writeCache($script, $cachenames = '', $cachedata = '', $prefix = 'cache_')
 {
     global $phpb2b_auth_key;
     if (!empty($this->lang_dirname)) {
         $app_lang = $this->lang_dirname;
     } else {
         $app_lang = $GLOBALS['app_lang'];
     }
     $mod_label = "Created";
     if (!empty($cachenames)) {
         if (is_array($cachenames) && !$cachedata) {
             foreach ($cachenames as $name) {
                 $cachedata .= $this->getCacheArray($name, $script);
             }
         } else {
             $cachedata .= $this->getCacheArray($cachenames);
         }
     }
     $dir = PHPB2B_ROOT . 'data' . DS . 'cache' . DS . $app_lang . DS;
     if (!is_dir($dir)) {
         pb_create_folder($dir);
     }
     $file_name = $dir . $prefix . $script . ".php";
     if (file_exists($file_name)) {
         $mod_label = "Modified";
     }
     $fpc = file_put_contents($file_name, "<?php\n/**\n * PHPB2B cache file, DO NOT change me!" . "\n * {$mod_label}: " . date("M j, Y, G:i") . "\n * Id: " . md5($prefix . $script . '.php' . $cachedata . $phpb2b_auth_key) . "\n */\n\n{$cachedata}\n?>");
     if (!$fpc) {
         exit(L("write_file_error_and_retry"));
     } else {
         return true;
     }
 }
Ejemplo n.º 8
0
 function check_dir($directory)
 {
     if (!is_dir($directory)) {
         if ($this->create_directory) {
             umask(0);
             pb_create_folder($directory);
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
Ejemplo n.º 9
0
function render($filename = null, $exit = false)
{
    global $smarty, $viewhelper, $theme_name, $time_start, $cache_id;
    $return = false;
    $htmlize = false;
    $allowed_file = array("index", "post", "industry", "area");
    $allowed_params = array("id");
    $file_info = pathinfo(pb_getenv('PHP_SELF'));
    $tmp_themename = '';
    $smarty->assign('position', $viewhelper->getPosition());
    $smarty->assign('page_title', $viewhelper->getTitle());
    $tpl_file = $theme_name . DS . $filename . $smarty->tpl_ext;
    if (in_array($file_info['filename'], $allowed_file)) {
        $dir_name = str_replace(array("\\", "//"), "/", $file_info['dirname']);
        $dir_name = explode("/", $dir_name);
        $dir_name = array_filter($dir_name);
        $i_count = count($dir_name);
        switch ($i_count) {
            case 1:
                $dir_name = '';
                break;
            default:
                $sub_dir = strrchr($file_info['dirname'], "/") . "/";
                $dir_name = $sub_dir;
                break;
        }
        $smarty->cache_dir = $smarty->cache_dir . $dir_name . DS;
        $smarty->cache_lifetime = 60 * 60;
        if (!is_dir($smarty->cache_dir)) {
            pb_create_folder($smarty->cache_dir);
        }
        if (!empty($cache_id)) {
            $cache_id = substr(md5($cache_id . $dir_name . $file_info['filename']), 0, 5);
        } else {
            $cache_id = substr(md5($dir_name . $file_info['filename']), 0, 5);
        }
    } else {
        $smarty->caching = false;
    }
    if ($theme_name == 'blue' || !$smarty->template_exists($tpl_file)) {
        $tmp_themename = 'default';
        $tpl_file = 'default' . DS . $filename . $smarty->tpl_ext;
    }
    $smarty->assign('ThemeName', $tmp_themename ? $tmp_themename : $theme_name);
    if (!empty($viewhelper->metaDescription)) {
        $smarty->assign("metadescription", $viewhelper->metaDescription);
    }
    if (!empty($viewhelper->metaKeyword)) {
        $smarty->assign("metakeywords", $viewhelper->metaKeyword);
    } elseif (!empty($viewhelper->metaDescription)) {
        $viewhelper->setMetaKeyword($viewhelper->metaDescription);
        $smarty->assign("metakeywords", $viewhelper->metaKeyword);
    }
    $return = $smarty->display($tpl_file, $cache_id);
    if ($exit) {
        exit;
    }
    if (!$htmlize) {
        return $return;
    }
    uses('htmlcache');
    $htmlcache = new Htmlcache();
    $htmls_path = APP_ROOT . $htmlcache->archiver_dir . DS;
    $htmls_path .= $dir_name;
    if (!in_array($file_info['filename'], $allowed_file)) {
        return;
    }
    switch ($file_info['filename']) {
        case "detail":
            $htmls_path .= "detail" . DS;
            $htmls_path .= date("Ymd") . DS;
            $file_name = $_GET['id'] . $htmlcache->file_ext;
            break;
        default:
            $file_name = $file_info['filename'] . $htmlcache->file_ext;
            break;
    }
    $htmlcache->setTargetPath($htmls_path);
    $htmlcache->write($file_name);
    return $return;
}
Ejemplo n.º 10
0
function render($filename = null, $exit = false)
{
    global $smarty, $viewhelper, $theme_name, $cache_id, $dir_name, $default_html_filename, $re_create_file;
    $return = false;
    $tmp_themename = '';
    $smarty->assign('position', $viewhelper->getPosition());
    $smarty->assign('page_title', $viewhelper->getTitle());
    $tpl = $theme_name . DS . $filename . $smarty->tpl_ext;
    if ($theme_name == 'blue' || !$smarty->template_exists($tpl)) {
        $tmp_themename = 'default';
        $tpl = 'default' . DS . $filename . $smarty->tpl_ext;
    }
    if (empty($filename)) {
        //Todo:auto select template default
    }
    $smarty->assign('ThemeName', $tmp_themename ? $tmp_themename : $theme_name);
    if (!empty($viewhelper->metaDescription)) {
        $smarty->assign("metadescription", $viewhelper->metaDescription);
    }
    if (!empty($viewhelper->metaKeyword)) {
        $smarty->assign("metakeywords", $viewhelper->metaKeyword);
    } elseif (!empty($viewhelper->metaDescription)) {
        $viewhelper->setMetaKeyword($viewhelper->metaDescription);
        $smarty->assign("metakeywords", $viewhelper->metaKeyword);
    }
    if ($smarty->caching) {
        $cache_id = $_GET['page'] . "|" . $_GET['id'] . "|" . $_GET['pos'];
    }
    if (defined("SMARTY_CACHE") && SMARTY_CACHE) {
        $smarty->caching = 1;
    }
    if ($smarty->caching) {
        $cache_id = substr(md5(pb_getenv('REQUEST_URI') . $cache_id), 0, 16);
    }
    $return = $smarty->display($tpl, $cache_id);
    //for the static homepage,since 1/1/2011
    if ($re_create_file) {
        if (!is_dir($dir_name)) {
            pb_create_folder($dir_name);
        }
        $content = ob_get_contents();
        file_put_contents($default_html_filename, $content);
    }
    if ($exit) {
        exit;
    }
    if (isset($htmlize) && !$htmlize) {
        return $return;
    }
    return $return;
}