public function getSingleton() { if (!self::$singleton) { if (!(self::$singleton = $this->createQuery("r")->fetchOne())) { $scrips = new Scripts(); $scrips->save(); self::$singleton = $scrips; } } return self::$singleton; }
public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function check_file($node) { global $context; global $footprints; $key = substr($node, strlen($context['path_to_root'])); // no extension to check if (strpos($key, '.') === FALSE) { } elseif (!strncmp($node, 'scripts/staging', 16)) { } elseif (!strcmp($key, 'footprints.php')) { } elseif (!strncmp(substr($key, -9), 'index.php', 9) && ($content = Safe::file_get_contents($node)) && !strcmp($content, Safe::mkdir_index_content())) { } elseif (!strncmp($key, 'temporary/cache_i18n_locale_', 28)) { } elseif (!strncmp(substr($key, -4), '.php', 4)) { // one of the parameter files created by yacs if (preg_match('/parameters\\/(agents|control|feeds|files|hooks|letters|root|scripts|services|skins|users|virtual_.+)\\.include\\.php$/i', $key)) { } elseif (isset($footprints[$key])) { $expected = $footprints[$key]; $actual = Scripts::hash($node); if ($expected[0] != $actual[0] || $expected[1] != $actual[1]) { $context['text'] .= sprintf(i18n::s('ERROR: File %s is missing or corrupted.'), $key) . BR . "\n"; } } else { $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n"; } // not a safe file } elseif (!preg_match('/\\.(bak|bat|css|done|dtd|fdb|flv|gif|ico|jpeg|jpg|js|jsmin|htc|htm|html|mo|off|on|pdf|png|po|pot|reg|sh|sql|swf|tgz|txt|xml|zip)$/i', $key)) { $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n"; } }
public function setUp() { $this->setHost('localhost'); $this->setPort(4444); $this->setBrowser('firefox'); $this->setBrowserUrl('http://localhost:8080/'); $this->mysqli = new mysqli('localhost', 'root', '', 'phpback_test'); Scripts::setInstance($this); }
public function testCategoryCreation() { Scripts::LoginAdmin(); $this->byLinkText('System Settings')->click(); $this->byLinkText('Categories')->click(); $this->fillFields(array('name' => 'Redcat', 'description' => 'Redcat is a category')); //TODO: NEED to refactor id's //$this->byLinkText('Add Category')->click(); }
function minify_filter_external_js() { $scripts = Scripts::newInstance()->getScripts(); $registered = Scripts::newInstance()->registered; foreach ($registered as $file) { $exists = array_search($file['url'], $scripts); if (false !== $exists) { if (false === strpos($file['url'], osc_base_url())) { unset($scripts[$exists]); } else { osc_remove_script($file['key']); } } } return $scripts; }
public function testDisableBanUser() { Scripts::LoginAdmin(); $this->byLinkText('Users Management')->click(); $this->byLinkText('Banned List ')->click(); $this->byLinkText('Disable ban')->click(); $passdisbann = RedBean::load('users', 3); $this->assertEquals($passdisbann->banned, '0'); }
$url = 'http://' . $context['reference_server'] . '/scripts/fetch.php?script=' . $file; if (!($content = http::proceed($url))) { $context['text'] .= sprintf(i18n::s('Impossible to read %s.'), $url) . BR . "\n"; $errors++; continue; } // ensure enough execution time Safe::set_time_limit(30); // save it in the staging store if (!Safe::file_put_contents('scripts/staging/' . $file, $content)) { $context['text'] .= '<p>' . sprintf(i18n::s('Impossible to write to %s.'), 'scripts/staging/' . $file) . "</p>\n"; $errors++; continue; } // ensure we have an exact copy by comparing hashes $staging_hash = Scripts::hash('scripts/staging/' . $file); if ($attributes[1] != $staging_hash[1]) { $context['text'] .= i18n::s('File has been corrupted!') . BR . "\n"; $errors++; continue; } // update statistics $staging_files++; } // errors have been encountered if ($errors) { $context['text'] .= i18n::s('Errors have been encountered, and you cannot proceed with the network update.') . "</p>\n"; // forward to the index page $menu = array('scripts/' => i18n::s('Server software')); $context['text'] .= Skin::build_list($menu, 'menu_bar'); // server is up to date
public function SetScript($script) { $this->use_script = $script; if ($this->use_script) { Scripts::Add($this->js()); } else { Scripts::Del($this->js()); } }
<?php if (!defined("__MAGIC__")) { exit; } Scripts::Add($this->path_view('write.js')); /* * view data 불러오기 * 우선순위 * 1.POST로 넘어온 미리보기 데이터 * 2.데이터베이스에 있는 데이터 * 3.기본 데이터 * */ // 1.데이터베이스에 있는 데이터 불러오기 $view = Widget::Inst()->Action('data_explode', $this->wg_no); $data = array(); // 위젯너비 $data['wg_width'] = GV::String('wg_width'); if (!$data['wg_width']) { $data['wg_width'] = $view['wg_width']; } if (!$data['wg_width']) { $data['wg_width'] = $this->Config('wg_width'); } // 위젯너비 단위 $data['wg_width_unit'] = GV::String('wg_width_unit'); if (!$data['wg_width_unit']) { $data['wg_width_unit'] = $view['wg_width_unit']; } if (!$data['wg_width_unit']) {
/** * Print the HTML tags to make the script load */ function osc_load_scripts() { Scripts::newInstance()->printScripts(); if (OC_ADMIN) { osc_run_hook('admin_scripts_loaded'); } else { osc_run_hook('scripts_loaded'); } }
<?php if (!defined("__MAGIC__")) { exit; } Scripts::Add($this->path_view('widget.js')); /* * view data 불러오기 * 우선순위 * 1.POST로 넘어온 미리보기 데이터 * 2.데이터베이스에 있는 데이터 * 3.기본 데이터 * */ // 데이터베이스에 있는 데이터 불러오기 $view = Widget::Inst()->Action('data_explode', $this->wg_no); $data = array(); // 위젯너비 $data['wg_width'] = GV::String('wg_width'); if (!$data['wg_width']) { $data['wg_width'] = $view['wg_width']; } if (!$data['wg_width']) { $data['wg_width'] = $this->Config('wg_width'); } // 위젯너비 단위 $data['wg_width_unit'] = GV::String('wg_width_unit'); if (!$data['wg_width_unit']) { $data['wg_width_unit'] = $view['wg_width_unit']; } if (!$data['wg_width_unit']) {
$context['text'] .= '<p>' . sprintf(i18n::s('Check the provided %s file to ensure prerequisites are fulfilled.'), '<a href="' . i18n::s('readme.txt') . '">' . i18n::s('readme.txt') . '</a>') . "</p>\n"; // link to the configuration page if (!count($context['error'])) { // report on checks $context['text'] .= '<h2>' . i18n::s('Ready to start the installation') . '</h2>'; // splash screen $context['text'] .= i18n::s("<p>At the moment no configuration file has been found. You will now have to pass through several steps in order to achieve the setup of your server:</p>\n<ul>\n<li>Configure parameters related to the database.</li>\n<li>Load extension hooks.</li>\n<li>Create tables in the database.</li>\n<li>Add one user profile and populate the database.</li>\n<li>Configure the theme of your server.</li>\n</ul>\nIn normal conditions this will take only some minutes. If you have any problems, please consult <a href=\"http://www.yacs.fr/\">www.yacs.fr</a> for additional support.<p>Thank you for having selected the YACS solution.</p>") . "\n"; // add a button to start the installation process $context['text'] .= '<form method="get" action="control/configure.php" id="main_form">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Start the installation process'), NULL, NULL, 'confirmed') . '</p>' . "\n" . '</form>' . "\n"; // a place holder for cookies activation $context['text'] .= '<p id="ask_for_cookies" style="display: none; color: red; text-decoration: blink;"></p>'; // the script used to check that cookies are activated Page::insert_script('document.cookie = \'CookiesEnabled=1\';' . "\n" . 'if((document.cookie == "") && document.getElementById) {' . "\n" . ' $("#ask_for_cookies").update("' . i18n::s('You must enable cookies to manage this server. Change settings of your browser accordingly, then revisit this page afterwards.') . '");' . "\n" . ' $("#ask_for_cookies").style.display = "block";' . "\n" . ' $("#confirmed").disabled = true;' . "\n" . '}' . "\n"); // purge the scripts/run_once directory on first installation include_once $context['path_to_root'] . 'scripts/scripts.php'; Scripts::purge_run_once(); } // on-going installation } elseif ($missing) { // splash screen $context['text'] .= '<p>' . i18n::s('Some configuration files are missing. Please follow the link to complete the installation process.') . "</p>\n"; // to the control panel $context['text'] .= '<p><a href="control/">' . i18n::s('Control Panel') . "</a></p>\n"; // end of the installation } elseif (!file_exists('parameters/switch.on') && !file_exists('parameters/switch.off')) { // create the switch $content = '---------------------------------------------' . "\n" . 'YACS will process requests if this file is named switch.on,' . "\n" . 'and will redirect everything to control/closed.php if its name is changed to switch.off.' . "\n" . "\n" . 'Associates can use the script control/switch.php to stop and restart remotely.' . "\n" . '---------------------------------------------' . "\n"; if (!Safe::file_put_contents('parameters/switch.on', $content)) { // not enough rights to write the file Logger::error(i18n::s('ERROR: YACS cannot create the file parameters/switch.on to activate the server.')); // allow for a manual update
<?php if (!defined("__MAGIC__")) { exit; } Styles::Add($this->path_view('jquery.mobile-1.1.0.min.css')); Scripts::Add($this->path_view('jquery.mobile-1.1.0.min.js'));
static function Del($src, $source = '') { if (!$src && $source == '') { return; } $html = self::createHtml($src, $source); if (FALSE !== ($key = array_search($html, self::$js))) { unset(self::$js[$key]); } } static function Get() { return self::$js; } } /* * magic/js/ 폴더의 파일은 모두 인크루드함 */ $core_js = array(); $dir = dir(Path::MB_js()); while ($name = $dir->read()) { if (is_file(Path::MB_js($name))) { $core_js[] = Path::MB_js($name); } } asort($core_js); foreach ($core_js as $v) { Scripts::Add($v); } unset($v); unset($core_js);
/** * delete reference files * * @param string the directory to start with * @see scripts/build.php */ function delete_reference($path) { global $context; $path_translated = str_replace('//', '/', $context['path_to_reference'] . $path); if ($handle = Safe::opendir($path_translated)) { while (($node = Safe::readdir($handle)) !== FALSE) { if ($node[0] == '.') { continue; } // make a real name $target = str_replace('//', '/', $path . '/' . $node); $target_translated = str_replace('//', '/', $path_translated . '/' . $node); // delete sub directory content if (is_dir($target_translated)) { delete_reference($target); } elseif (Scripts::hash($context['path_to_reference'] . $target)) { $context['text'] .= sprintf(i18n::s('Deleting %s'), substr($target, 1)) . BR . "\n"; Safe::unlink($target_translated); global $deleted_nodes; $deleted_nodes++; } // ensure we have enough time Safe::set_time_limit(30); } Safe::closedir($handle); } }
public function get_script() { if (!is_null($this->scriptid)) { return Scripts::get_by_id($this->scriptid); } }
<?php if (!defined("__MAGIC__")) { exit; } Scripts::Add(Path::MB('js/plugin/external/jquery.cookie.js')); Scripts::Add(Path::MB('js/plugin/external/jquery.hotkeys.js')); Scripts::Add(Path::MB('js/plugin/jquery.jstree.js'));
$context['page_title'] = i18n::s('Update file permissions'); // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('control/chmod.php')); } elseif (!Surfer::is_associate() && !(file_exists($context['path_to_root'] . 'parameters/switch.on') || file_exists($context['path_to_root'] . 'parameters/switch.off'))) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // forward to the index page $menu = array('control/' => i18n::s('Control Panel')); $context['text'] .= Skin::build_list($menu, 'menu_bar'); // do the action } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'confirm') { // list running scripts $context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n"; // locate script files starting at root $scripts = Scripts::list_scripts_at(NULL); if (is_array($scripts)) { $context['text'] .= BR . sprintf(i18n::s('%d scripts have been found.'), count($scripts)) . "\n"; } $context['text'] .= "</p>\n"; // chmod each file $context['text'] .= '<p>' . i18n::s('Updating file permissions...') . BR . "\n"; // analyse each script $count = 0; foreach ($scripts as $file) { // this will be filtered by umask anyway Safe::chmod($context['path_to_root'] . $file, $context['file_mask']); $count++; // avoid timeouts if (!($count % 50)) { Safe::set_time_limit(30);
} // offer to upgrade $context['text'] .= '<p>' . Skin::build_link('scripts/stage.php', i18n::s('Update the software')) . "</p>\n"; } // get the page from the php documentation, if any include_once 'phpdoc.php'; $item = PhpDoc::get('index'); if ($item) { // the list of things to do $context['page_tools'][] = Skin::build_link(Scripts::get_url('todo'), i18n::s('To do'), 'basic'); // the list of testers $context['page_tools'][] = Skin::build_link(Scripts::get_url('testers'), i18n::s('Testers'), 'basic'); // the list of authors $context['page_tools'][] = Skin::build_link(Scripts::get_url('authors'), i18n::s('Authors'), 'basic'); // the list of licenses $context['page_tools'][] = Skin::build_link(Scripts::get_url('licenses'), i18n::s('Licenses'), 'basic'); // splash message $text = '<p>' . i18n::s('Click on any link below to access the documentation extracted from each script (phpDoc).') . "</p>\n"; // tree of links to documentation pages $text .= Codes::beautify($item['content']); // link to some other server } else { $text = '<p>' . i18n::s('The complete documentation is available at the following server:') . '</p>'; // link to the existing reference server, or to the original server if (!isset($context['reference_server']) || !$context['reference_server']) { $context['reference_server'] = i18n::s('www.yacs.fr'); } $text .= '<p>' . Skin::build_link('http://' . $context['reference_server'] . '/', $context['reference_server'], 'external') . "</p>\n"; } // documentation box $context['text'] .= Skin::build_box(i18n::s('On-line Documentation'), $text);
/** * visualize differences for some attribute * * @param string name of the target attribute * @param string previous value * @return string HTML showing differences */ function &diff($name, $value) { global $context; // previous text $value = Codes::beautify($value); // target attribute does not exist if (!isset($this->item[$name])) { $output = '<ins>' . $value . '</ins>'; return $output; } // current text $current = Codes::beautify($this->item[$name]); // highlight differences include_once $context['path_to_root'] . 'scripts/scripts.php'; $output =& Scripts::hdiff($value, $current); return $output; }
/** * dynamically generate the page * * @see skins/index.php */ function send_body() { global $context; // only associates can proceed if (!Surfer::is_associate()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n"; // forward to the index page $menu = array('scripts/' => i18n::s('Server software')); echo Skin::build_list($menu, 'menu_bar'); // ask for confirmation } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') { // the splash message echo '<p>' . i18n::s('This tool will include most of the running reference PHP scripts. Any syntax error should be spotted easily.') . '</p>'; // the submit button echo '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Yes, I want to validate scripts'), NULL, NULL, 'confirmed') . '</p></form>'; // set the focus on the button Page::insert_script('$("#confirmed").focus();'); // this may take some time echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>'; // just do it } else { // the splash message echo '<p>' . i18n::s('All reference scripts are included, to show evidence of possible syntax errors.') . "</p>\n"; // list running scripts echo '<p>' . i18n::s('Listing files...') . BR . "\n"; // locate script files starting at root $scripts = Scripts::list_scripts_at(NULL); if (is_array($scripts) && count($scripts)) { echo BR . sprintf(i18n::s('%d scripts have been found.'), count($scripts)) . "\n"; natsort($scripts); } echo "</p>\n"; // including scripts echo '<p>' . i18n::s('Including reference scripts...') . BR . "\n"; // strip as much output as possible $_SERVER['REQUEST_METHOD'] = 'HEAD'; // we will finalize this page later on global $finalizing_fuse; $finalizing_fuse = FALSE; // take care of dependancies include_once '../behaviors/behavior.php'; include_once '../services/codec.php'; include_once '../users/authenticator.php'; // analyse each script $included_files = 0; $links_to_be_checked_manually = array(); foreach ($scripts as $file) { // ensure we have enough time to process this script Safe::set_time_limit(30); // skip run once scripts if (strpos($file, 'run_once/')) { continue; } // don't include ourself if ($file == 'scripts/validate.php') { continue; } // process only reference scripts if (!Scripts::hash($file)) { continue; } // check file content if (!($handle = Safe::fopen($file, 'rb'))) { echo sprintf(i18n::s('%s has no readable content.'), $file) . BR . "\n"; continue; } // look at the beginning of the file if (!($header = fread($handle, 16384))) { echo sprintf(i18n::s('%s has no readable content.'), $file) . BR . "\n"; fclose($handle); continue; } fclose($handle); // skip scripts that generate content asynchronously if (stripos($header, 'send_body') || stripos($header, 'page::content')) { $links_to_be_checked_manually[$file] = '(asynchronous)'; continue; } // skip scripts that would redefine our skin if (stripos($header, 'extends skin_skeleton')) { $links_to_be_checked_manually[$file] = '(skin)'; continue; } // log script inclusion on development host if ($context['with_debug'] == 'Y') { logger::remember('scripts/validate.php: inclusion of ' . $file, '', 'debug'); } // include the script and display any error $included_files += 1; $validate_stamp = time(); echo sprintf(i18n::s('inclusion of %s'), $file) . "\n"; Safe::chdir($context['path_to_root'] . dirname($file)); include_once $context['path_to_root'] . $file; $duration = time() - $validate_stamp; if ($duration) { echo ' (' . $duration . 's.)'; } echo BR; } // memory status $used_memory = ''; if (is_callable('memory_get_usage')) { $used_memory = ' (' . memory_get_usage() . ' bytes)'; } // report of included files if ($included_files > 1) { echo '<p>' . sprintf(i18n::s('%d files have been included.'), $included_files) . $used_memory . '</p>'; } // list files to be checked manually if (count($links_to_be_checked_manually)) { echo '<p>' . i18n::s('Following scripts have to be included separately:') . BR . "\n"; ksort($links_to_be_checked_manually); foreach ($links_to_be_checked_manually as $file => $label) { echo Skin::build_link($file, $file, 'basic') . ' ' . $label . BR . "\n"; } echo sprintf(i18n::s('%d files to be checked manually.'), count($links_to_be_checked_manually)) . '</p>' . "\n"; } // display the execution time $time = round(get_micro_time() - $context['start_time'], 2); echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>'; // forward to the referential building echo '<form method="get" action="' . $context['url_to_root'] . 'scripts/build.php"><p>' . "\n" . Skin::build_submit_button(i18n::s('If no error has popped up, build the reference set >>')) . "\n" . '</p></form>' . "\n"; // this may take some time echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>'; // clear text some scripts could have added $context['debug'] = ''; $context['extra'] = ''; $context['navigation'] = ''; $context['suffix'] = ''; $context['text'] = ''; $context['page_details'] = ''; $context['page_footer'] = ''; $context['page_menu'] = array(); $context['page_tags'] = ''; $context['page_tools'] = ''; // now we will finalize this page global $finalizing_fuse; unset($finalizing_fuse); } }
function classified_is_fineuploader() { return Scripts::newInstance()->registered['jquery-fineuploader'] && method_exists('ItemForm', 'ajax_photos'); }
session_start(); header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies. require_once '../config.php'; function __autoload($class_name) { include "../" . APP_CLASSES . "{$class_name}.class.php"; } $html = new Frontend(); $report = new Report(); $alerts = new Alerts(); $scripts = new Scripts(); $_SESSION['display'] = isset($_GET['display']) ? $_GET['display'] : true; if ($_SESSION['display']) { echo '<div class="container-fluid"><div class="row"><div class="col-xs-12 text-center"><h3>Running Cleanse</h3></div></div><div class="row"><hr /><div class="col-xs-10 col-xs-offset-1">'; } /////////////////// // Start Script // /////////////////// if (isset($_GET['clean'])) { switch ($_GET['clean']) { case 'logs': $scripts->clean_log_tables(); break; case 'reindex': $scripts->fix_reindex_error(); break;
public function testDeleteFlagComment() { Scripts::LoginUser(); Scripts::CreateComment(); Scripts::LogoutUser(); Scripts::LoginAdmin(); $this->url('/admin/ideas'); $this->byName('Delete votes')->click(); $this->assertNotContains('Flagged ', $this->byTag('body')->text()); }
<?php if (!defined("__MAGIC__")) { exit; } // 쿠키 사용을 위해서 Scripts::Add(Path::Root('magic/js/plugin/external/jquery.cookie.js'));
<?php if (!defined("__MAGIC__")) { exit; } Scripts::Add($this->path_view('cheditor.js'));
$context['page_title'] = i18n::s('Documentation:') . ' ' . $script; } else { $context['page_title'] = i18n::s('View PHP documentation'); } // no script has been provided -- help web crawlers if (!$script) { Safe::header('Status: 404 Not Found', TRUE, 404); Logger::error(i18n::s('No script has been provided')); // the script has to be there } elseif (!$row) { Safe::header('Status: 404 Not Found', TRUE, 404); Logger::error(i18n::s('Script does not exist')); // display script content } else { $context['text'] = Codes::beautify($row['content']); // referrals, if any $context['components']['referrals'] =& Skin::build_referrals(Scripts::get_url($script)); // update the menu bar if ($script != 'todo' && $script != 'authors' && $script != 'testers' && $script != 'licenses') { // browsing is safe $context['page_tools'][] = Skin::build_link(Scripts::get_url($script, 'browse'), i18n::s('Browse the source of this script')); // protect from spammers and robots if (Surfer::is_logged()) { $context['page_tools'][] = Skin::build_link(Scripts::get_url($script, 'fetch'), i18n::s('Fetch the script file')); } } // back to the index $context['page_tools'][] = Skin::build_link('scripts/', i18n::s('Server software')); } // render the skin render_skin();
public static function setInstance($element) { self::$instance = $element; }
<?php if (!defined("__MAGIC__")) { exit; } /* * 해당 레이아웃에서 사용할 css/js set */ Scripts::Add(Layout::Inst('index')->path_view('script.js'));