Exemple #1
0
$clip = new NWC2Clip('php://stdin');
echo $clip->GetClipHeader() . "\n";
$nothingToDo = TRUE;
foreach ($clip->Items as $item) {
    $nothingToDo = FALSE;
    $o = new NWC2ClipItem($item);
    $oType = $o->GetObjType();
    if (!in_array($oType, array("Note", "Chord", "Rest", "RestChord"))) {
        // not an item of interest, pass it thru
        echo $item;
    } elseif ($gobbleTime > 0) {
        // run down the gobble clock, don't print the item
        $gobbleTime -= timeTaken($o);
    } elseif ($passTime > 0) {
        $passTime -= timeTaken($o);
        echo $item;
    } elseif ($oType == "Rest" || !timeTaken($o)) {
        // don't filter on rests or grace notes
        echo $item;
    } else {
        $o =& filterPart($action, $part, $o);
        echo $o->ReconstructClipText() . "\n";
    }
    unset($o);
}
echo NWC2_ENDCLIP . "\n";
if ($nothingToDo) {
    abort("This tool requires a selection.\nPlease select something in your staff before executing this tool.");
}
unset($clip);
exit(NWC2RC_SUCCESS);
Exemple #2
0
 if ($oType == "Bar" && !$o->GetTaggedOpt("Color")) {
     $bar++;
     while ($go = array_shift($currentGroup)) {
         echo $go->ReconstructClipText() . "\n";
     }
     // now flush the current group
     $groupNum = 0;
     $placeInTime = 0;
 }
 if (!isset($currentGroupTimes)) {
     echo $item;
 } else {
     array_push($currentGroup, $o);
     // save the item
     if (in_array($oType, array("Note", "Chord", "Rest", "RestChord"))) {
         $placeInTime += timeTaken($o);
     }
     if (!isset($currentGroupTimes[$groupNum])) {
         report("Bar is too long at bar {$bar} from start\n");
     } elseif ($placeInTime >= $currentGroupTimes[$groupNum]) {
         tryToBeam(&$currentGroup);
         while ($go = array_shift($currentGroup)) {
             echo $go->ReconstructClipText() . "\n";
         }
         // now flush the current group
         $groupNum++;
         // and increment our group number
         // following is a test for when notes or chords exceed groupings
         if ($placeInTime > $currentGroupTimes[$groupNum - 1] && isset($currentGroupTimes[$groupNum])) {
             while ($placeInTime >= $currentGroupTimes[$groupNum] && isset($currentGroupTimes[$groupNum + 1])) {
                 $groupNum++;
Exemple #3
0
            // Skip "PRAGMA .." queries by SQLITE.
            if (strpos($query['sql'], "PRAGMA ") === 0) {
                continue;
            }
            $queries[] = array('query' => $query['sql'], 'params' => $query['params'], 'types' => $query['types'], 'duration' => sprintf("%0.2f", $query['executionMS']));
            $querycount++;
            $querytime += $query['executionMS'];
        }
        $twig = $app['twig.loader'];
        $templates = hackislyParseRegexTemplates($twig);
        $route = $request->get('_route');
        $route_params = $request->get('_route_params');
        $log = $app['log']->getMemorylog();
        // echo "<pre>\n" . util::var_dump($log, true) . "</pre>\n";
        $servervars = array('cookies <small>($_COOKIES)</small>' => $request->cookies->all(), 'headers' => makeValuepairs($request->headers->all(), '', '0'), 'query <small>($_GET)</small>' => $request->query->all(), 'request <small>($_POST)</small>' => $request->request->all(), 'session <small>($_SESSION)</small>' => $request->getSession()->all(), 'server <small>($_SERVER)</small>' => $request->server->all(), 'response' => makeValuepairs($response->headers->all(), '', '0'), 'statuscode' => $response->getStatusCode());
        echo $app['twig']->render('debugbar.twig', array('timetaken' => timeTaken(), 'memtaken' => getMem(), 'memtaken' => getMaxMem(), 'querycount' => $querycount, 'querytime' => sprintf("%0.2f", $querytime), 'queries' => $queries, 'servervars' => $servervars, 'templates' => $templates, 'log' => $log, 'route' => "/" . $route, 'route_params' => $route_params, 'editlink' => $app['editlink'], 'paths' => getPaths($app['config'])));
    });
}
$app->after(function (Request $request, Response $response) use($app) {
    $end = !empty($app['end']) ? $app['end'] : false;
    if ($end == "frontend") {
        $html = $response->getContent();
        // Insert our 'generator' after the last <meta ..> tag.
        $app['extensions']->insertSnippet('aftermeta', '<meta name="generator" content="Bolt">');
        $html = $app['extensions']->processSnippetQueue($html);
        $response->setContent($html);
    }
});
/**
 * Error page.
 */
Exemple #4
0
 /**
  * Set configuration item
  */
 public static function setConfig($key, $value)
 {
     global $PIVOTX;
     $config = self::getOfflineConfiguration($PIVOTX['paths']['db_path']);
     $clear_cache = false;
     if ($key == 'online') {
         if ($value == '') {
             $value = false;
         } else {
             $value = true;
             if (!$config['online']) {
                 $clear_cache = true;
             }
         }
     }
     $config[$key] = $value;
     if ($clear_cache) {
         $deletecounter = wipeSmartyCache();
         $message = sprintf(__('deleted %s cache files in %s seconds.'), $deletecounter, timeTaken());
         debug($message);
     }
     self::writeConfiguration($PIVOTX['paths']['db_path'], $config);
 }
 /**
  * Performs a query. Either pass the query to e executed as a parameter,
  *
  * @param string query
  */
 function query($query = "")
 {
     global $PIVOTX, $timetaken;
     // If there's no DB connection yet, set one up if we can.
     if (!$this->connection()) {
         return false;
     }
     // perhaps use the cached query
     if ($query == "") {
         $query = $this->cached_query;
     }
     // Set the last_query
     $this->last_query = $query;
     $now = timeTaken('int');
     // execute it.
     $this->sql_result = @$this->sql_doquery($query, $this->sql_link);
     // If we're profiling, we use the following to get an array of all queries.
     // We also debug queries that took relatively long to perform.
     if ($PIVOTX['config']->get('debug')) {
         $querytimetaken = round(timeTaken('int') - $now, 4);
         if (timeTaken('int') - $now > 0.4) {
             debug("\nStart: " . $now . " - timetaken: " . $querytimetaken);
             debug(htmlentities($query) . "\n\n");
             debug_printbacktrace();
         }
         $query = preg_replace("/\\s+/", " ", $query);
         // If debug is enabled, we add a small comment to the query, so that it's
         // easier to track where it came from
         if (function_exists('debug_backtrace')) {
             $trace = debug_backtrace();
             $comment = sprintf(" -- %s - %s():%s ", basename($trace[0]['file']), $trace[1]['function'], $trace[0]['line']);
             $query .= $comment;
         }
         //echo "<pre>\n"; print_r($query); echo "</pre>";
         $GLOBALS['query_log'][] = $query . " -- {$querytimetaken} sec. ";
     }
     if ($this->sql_result === false) {
         // If an error occured, we output the error.
         $this->error('', $this->last_query, $this->sql_errno($this->sql_link));
         $this->num_affected_rows = 0;
         return false;
     } else {
         // Count the num of results, and raise the total query count.
         $timetaken['query_count']++;
         $timetaken['sql'] += timetaken('int') - $now;
         $this->num_affected_rows = $this->affected_rows();
         return true;
     }
 }
/**
 * Indexes tags in entries in the PivotX database and returns true
 * if there are more entries to index.
 *
 * @param int $start Code for first entry to index
 * @param int $stop Code for last entry to index
 * @param int $time Indexing time.
 * @return boolean
 */
function writeTagIndex($start, $stop, $time)
{
    global $PIVOTX, $output;
    $entries = $PIVOTX['db']->db_lowlevel->date_index;
    $count = 0;
    $date = date('Y-m-d-H-i');
    foreach ($entries as $key => $value) {
        if ($count++ < $start) {
            continue;
        }
        if ($count > $stop) {
            break;
        }
        $entry = $PIVOTX['db']->read_entry($key);
        // rules: index if all are true:
        // - ( status == 'publish' )or(( status == 'timed')&&( publish_date <= date ))
        // - at least one category is in array of 'not hidden' categories..
        // check status and date
        if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= $date) {
            if ($count % 50 == 0) {
                $output .= sprintf(__("%1.2f sec: Processed %d entries...") . "<br />\n", timeTaken('int') + $time, $count);
            }
            writeTags($entry['keywords'], '', $key);
        }
    }
    // decide if we need to do some more.
    if (count($entries) > $stop) {
        return true;
    }
}
Exemple #7
0
/**
 * Display the 'Empty Cache' page.
 */
function pageEmptyCache()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Empty Cache'));
    $PIVOTX['template']->assign('heading', __("Clear PivotX's internal cache for stored files."));
    $deletecounter = wipeSmartyCache();
    $html = sprintf(__('deleted %s cache files in %s seconds.'), $deletecounter, timeTaken());
    $html = '<p>' . $html . '</p>';
    $PIVOTX['template']->assign("html", $html);
    renderTemplate('generic.tpl');
}
Exemple #8
0
 /**
  * Rebuild the search index
  */
 public static function ext_rebuildSearchIndex()
 {
     global $output, $PIVOTX;
     $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
     $output = "";
     // initialise the threshold.. Initially it's set to 10 * the rebuild_threshold,
     // roughly assuming we index 10 entries per second.
     if ($PIVOTX['config']->get('rebuild_threshold') > 4) {
         $chunksize = 10 * $PIVOTX['config']->get('rebuild_threshold');
     } else {
         $chunksize = 100;
     }
     @set_time_limit(0);
     include_once "modules/module_search.php";
     $start = isset($_POST['start']) ? $_POST['start'] : 0;
     $time = isset($_POST['time']) ? $_POST['time'] : 0;
     $stop = $start + $chunksize;
     if ($start == 0) {
         $PIVOTX['db']->clearIndex('search');
     }
     $continue = createSearchIndex($start, $stop, $time);
     writeSearchIndex(FALSE);
     $time += timeTaken('int');
     $result = array();
     $result['func'] = 'rebuildSearchIndex';
     $result['start'] = $stop;
     $result['time'] = $time;
     if ($continue) {
         $result['done'] = false;
     } else {
         $result['done'] = true;
         $status = sprintf(__('Finished! Generating index for %s entries took %s seconds '), $PIVOTX['db']->get_entries_count(), $time);
         $output .= sprintf("<br />\n<b>%s</b><br />\n", $status);
     }
     $result['text'] = $output;
     echo json_encode($result);
 }
 /**
  * Create the code for the debugbar and returns it..
  *
  * @return string
  */
 function getDebugCode()
 {
     global $PIVOTX, $version, $codename, $timetaken;
     // The debugbar will not work on IE6 or IE7.. Check for those browsers and return a notice.
     if (preg_match('|MSIE ([0-9].[0-9]{1,2})|', $_SERVER['HTTP_USER_AGENT'], $browserversion)) {
         if ($browserversion[1] < 8) {
             return "<!-- The PivotX debug bar is not supported on IE6 or IE7. -->";
         }
     }
     $debugcode = "";
     $debugversion = strip_tags($version . ($codename != "" ? ": " . $codename : ""));
     list($dummy, $host) = explode("://", $PIVOTX['paths']['canonical_host']);
     $path = $PIVOTX['paths']['pivotx_url'];
     // Build the text for 'Modifiers'
     $modifiers = array();
     $modifiers[] = "<strong>Modifiers:</strong>";
     // Note: 'Modifiers' left untranslated. I don't think we should translate this.
     foreach ($this->modifier as $key => $value) {
         $modifiers[] = sprintf('%-8s => %s', $key, getDefault($value, "<em>(empty)</em>"));
     }
     // Add the templates to template_log, but skip the first one (since it's always 'maintemplate')
     $smarty_debug_info = array_slice($PIVOTX['template']->_smarty_debug_info, 1);
     foreach ($smarty_debug_info as $template) {
         if (strpos($template['filename'], "db:") === false) {
             $GLOBALS['template_log'][] = "- " . $template['filename'];
         }
     }
     $modifiers[] = "\n<strong>" . __("Templates") . ":</strong>";
     $modifiers[] = "Main: " . $this->maintemplate;
     if (!empty($GLOBALS['template_log'])) {
         $modifiers[] = implode("\n", $GLOBALS['template_log']);
     }
     $str = __("Note: '%s' is enabled, which affects the performance of this site.");
     $str = preg_replace("/^([^:]*)/i", "<strong>\$1</strong>", $str);
     if ($PIVOTX['config']->get('smarty_force_compile')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Force compile templates')), 80);
     }
     if ($PIVOTX['config']->get('no_cached_include')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Disallow cached includes')), 80);
     }
     $str = __("Note: '%s' is enabled.");
     $str = preg_replace("/^([^:]*)/i", "<strong>\$1</strong>", $str);
     if ($PIVOTX['config']->get('minify_frontend')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Minify Frontend')), 80);
     }
     if ($PIVOTX['config']->get('smarty_cache')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Use output caching')), 80);
     }
     // Add the paths to the modifiers tab.
     $modifiers['paths'] = "\n<strong>" . __("Paths") . ":</strong> (\$PIVOTX['paths']['<em>pathname</em>'])";
     foreach ($PIVOTX['paths'] as $key => $value) {
         $modifiers['paths'] .= sprintf("\n%-16s => %s", $key, $value);
     }
     // Set the correct classes, if we want the bar at the bottom..
     if ($PIVOTX['config']->get("debug_bottom")) {
         $boxclass = " pxdb-box-bottom";
         $barclass = "class='pxdb-bar-bottom'";
     } else {
         $boxclass = "";
         $barclass = "";
     }
     // Build the text for the server tab.
     $server_log = array();
     $server_log = $this->getDebugCodeServerHelper('$_GET', $_GET, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_POST', $_POST, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_REQUEST', $_REQUEST, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_FILES', $_FILES, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_SERVER', $_SERVER, $server_log, 21);
     $server_log = $this->getDebugCodeServerHelper('$_COOKIE', $_COOKIE, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_SESSION', $_SESSION, $server_log, 13);
     $debugcode .= sprintf("<script type=\"text/javascript\">!window.jQuery && document.write('<script src=\"%s\"><\\/script>')</script>", $PIVOTX['paths']['jquery_url']);
     $debugcode .= sprintf("<script type=\"text/javascript\" src=\"%stemplates_internal/assets/debugbar.js\"></script>", $path);
     $debugcode .= sprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%stemplates_internal/assets/debugbar.css\" />", $path);
     $debugcode .= sprintf("        <div id=\"pxdb-bar\" %s>\n            <div id=\"pxdb-bar-logo\"><img src=\"%stemplates_internal/assets/m_pivotx.png\" width=\"90\" height=\"18\" alt=\"PivotX\" /></div>\n            <div id=\"pxdb-bar-version\">v %s</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-timetaken\">%s sec.</div>\n            <div class=\"pxdb-bar-divider\">|</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-modifiers\"><a href=\"#\">Modifiers</a></div>\n            <div class=\"pxdb-bar-divider\">|</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-log\"><a href=\"#\">Debug log</a></div>\n            <div class=\"pxdb-bar-divider\">|</div>", $barclass, $path, $debugversion, timeTaken('int'));
     if ($PIVOTX['db']->db_type == "sql") {
         $debugcode .= sprintf("        <div class=\"pxdb-bar-section\" id=\"pxdb-bar-queries\"><a href=\"#\">%s Queries</a> (%s sec.)</div>\n                <div class=\"pxdb-bar-divider\">|</div>", $timetaken['query_count'], $timetaken['sql']);
     }
     $debugcode .= sprintf("        <div class=\"pxdb-bar-section\" id=\"pxdb-bar-server\"><a href=\"#\">%s</a></div>\n                <div class=\"pxdb-bar-divider\">|</div>\n                <div class=\"pxdb-bar-section\" id=\"pxdb-bar-open\">&nbsp;</div>\n                <div class=\"pxdb-bar-section\" id=\"pxdb-bar-close\">&nbsp;</div>\n            </div>", $host);
     $debugcode .= sprintf("<div id=\"pxdb-box-modifiers\" class=\"pxdb-box%s\">\n            <pre>\n%s\n            </pre>\n            </div>", $boxclass, implode("\n", $modifiers));
     // If $query_log is filled, output the executed queries..
     if (count($GLOBALS['query_log']) > 0) {
         sort($GLOBALS['query_log']);
         $debugcode .= sprintf("<div id=\"pxdb-box-queries\" class=\"pxdb-box%s\">\n                <pre>\n%s\n                </pre>\n                </div>", $boxclass, implode("\n", $GLOBALS['query_log']));
         // perhaps also log to file
         if ($PIVOTX['config']->get('log_queries') && $PIVOTX['config']->get('debug_logfile')) {
             debug_printr($GLOBALS['query_log']);
         }
     }
     if (empty($GLOBALS['debug_log'])) {
         $GLOBALS['debug_log'] = "<div class='timetaken'>" . __("No debug output.") . "</div>";
     }
     $GLOBALS['debug_log'] .= sprintf("\n\n <a href=\"%s#bottom\" onclick=\"void(debugwin = window.open('%s#bottom', 'debugwin', 'status=yes, scrollbars=yes, resizable=yes, width=700, height=300')); return false;\">%s</a>", $PIVOTX['paths']['pivotx_url'] . "modules/module_debug.php", $PIVOTX['paths']['pivotx_url'] . "modules/module_debug.php", __("View debug logs"));
     // If $debug_log is filled, output it here..
     $debugcode .= sprintf("<div id=\"pxdb-box-log\" class=\"pxdb-box%s\">\n%s\n            </div>", $boxclass, nl2br($GLOBALS['debug_log']));
     // If $server_log is filled, output it here..
     $debugcode .= sprintf("<div id=\"pxdb-box-server\" class=\"pxdb-box%s\">\n                <pre>\n%s\n                </pre>\n                </div>", $boxclass, implode("\n", $server_log));
     /*
     
                 if ($PIVOTX['config']->get('debug_cachestats')) {
                     debug_printr($PIVOTX['cache']->stats());
                 }
     */
     return $debugcode;
 }
Exemple #10
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();
}