Example #1
0
/**
 * Printing wiki editor.
 * Depending on where it is called , action will go to different destinations.
 * If it is called from comments section, the return will be in comments section
 *  in any other case it will be in edit view section.
 * @param $pageid. Current pageid
 * @param $content. Content to be edited.
 * @param $section. Current section, default null
 * @param $comesfrom. Information about where the function call is made
 * @param commentid. id comment of comment that will be edited.
 */

function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $section = null, $upload = false, $deleteuploads = array(), $comesfrom = 'editorview', $commentid = 0) {
    global $CFG, $OUTPUT, $PAGE;

    if ($comesfrom == 'editcomments') {
        $action = $CFG->wwwroot . '/mod/wiki/instancecomments.php?pageid=' . $pageid . '&id=' . $commentid . '&action=edit';
    } else if ($comesfrom == 'addcomments') {
        $action = $CFG->wwwroot . '/mod/wiki/instancecomments.php?pageid=' . $pageid . '&id=' . $commentid . '&action=add';
    } else {
        $action = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $pageid;
    }

    if (!empty($section)) {
        $action .= "&section=" . urlencode($section);
    }

    ///Get tags for every element we are displaying
    $tag = getTokens($editor, 'bold');
    $wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki'));
    $tag = getTokens($editor, 'italic');
    $wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki'));
    $tag = getTokens($editor, 'link');
    $wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki'));
    $tag = getTokens($editor, 'url');
    $wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiexternalurl', 'wiki'));
    $tag = getTokens($editor, 'list');
    $wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n' . $tag[0], '', '');
    $wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n' . $tag[1], '', '');
    $tag = getTokens($editor, 'image');
    $wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki'));
    $tag = getTokens($editor, 'header');
    $wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n' . $tag . ' ', ' ' . $tag . '\\n', get_string('wikiheader', 'wiki', 1));
    $wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n' . $tag . $tag . ' ', ' ' . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 2));
    $wiki_editor['h3'] = array('ed_h3.gif', get_string('wikiheader', 'wiki', 3), '\\n' . $tag . $tag . $tag . ' ', ' ' . $tag . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 3));
    $tag = getTokens($editor, 'line_break');
    $wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n' . $tag . '\\n', '', '');
    $tag = getTokens($editor, 'nowiki');
    $wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki'));

    $OUTPUT->heading(strtoupper(get_string('format' . $editor, 'wiki')), 3);

    $PAGE->requires->js('/mod/wiki/editors/wiki/buttons.js');

    echo $OUTPUT->container_start();
    foreach ($wiki_editor as $button) {
        echo "<a href=\"javascript:insertTags";
        echo "('" . $button[2] . "','" . $button[3] . "','" . $button[4] . "');\">";
        echo "<img width=\"23\" height=\"22\" src=\"$CFG->wwwroot/mod/wiki/editors/wiki/images/$button[0]\" alt=\"" . $button[1] . "\" title=\"" . $button[1] . "\" />";
        echo "</a>";
    }
    echo $OUTPUT->container_end();

    echo $OUTPUT->container_start();
    echo '<form method="post" id="mform1" action="' . $action . '">';
    echo $OUTPUT->container(print_textarea(false, 20, 60, 0, 0, "newcontent", $content, 0, true), false, 'wiki_editor');
    echo $OUTPUT->container_start();
    wiki_print_edit_form_default_fields($editor, $pageid, $version, $upload, $deleteuploads);
    echo $OUTPUT->container_end();
    echo '</form>';
    echo $OUTPUT->container_end();
}
Example #2
0
function getAccessToken(&$fb, $bucket, $tokenFile)
{
    // Read file from Google Storage
    $client = getClient();
    $storage = getStorageService($client);
    $tokensStr = getTokens($client, $storage, $bucket, $tokenFile);
    if (empty($tokensStr)) {
        quit("No more FB access tokens in storage -- login to app ASAP to generate a token");
    } else {
        $tokens = json_decode($tokensStr, true);
        // 'true' will turn this into associative array instead of object
        // Validate the token before use. User may have logged off facebook, or deauthorized this app.
        // shuffle the array to get random order of iteration
        shuffle($tokens);
        //var_dump($tokens);
        foreach ($tokens as $token) {
            $response = $fb->get('/me', $token);
            if (!$response->isError()) {
                // access_token is valid token
                return $token;
            }
        }
        quit("None of the tokens are valid");
    }
}
/**
 * 检查是否为指定的Token
 * @param string $token 要检查的token值
 * @param string $formName
 * @param boolean $fromCheck 是否检查来路,如果为true,会判断token中附加的session_id是否和当前session_id一至.
 * @param string $key 加密密钥
 * @return boolean
 */
function isToken($token, $formName, $key)
{
    $fromCheck = C('FROM_CHECK') == null ? false : C('From_Check');
    $key = tokenKeyDefault($key);
    if (empty($token)) {
        return false;
    }
    $tokens = getTokens();
    if (in_array($token, $tokens)) {
        //如果存在,说明是以使用过的token
        return false;
    }
    $source = decrypt($token, $key);
    if ($fromCheck) {
        return $source == $formName . session_id();
    } else {
        return strpos($source, $formName) === 0;
    }
}
Example #4
0
 * @return [boolean] True if write was successful
 */
function writeDocFile($namespace, $docs)
{
    $filename = TERMINUS_ROOT . '/docs/' . str_replace(array('Terminus\\', '\\'), array('', '/'), $namespace) . '.md';
    $rendered_doc = Utils\twigRender('doc.twig', $docs, array('namespace' => $namespace));
    file_put_contents($filename, $rendered_doc);
    return true;
}
$library_files = getFiles(TERMINUS_ROOT . '/php/Terminus/Models');
$tokenized_files = array();
foreach ($library_files as $filename) {
    $namespace = str_replace(array(TERMINUS_ROOT . '/php/', '.php', '/'), array('', '', '\\'), $filename);
    $tokenized_files[$namespace] = getTokens($filename);
}
$tokenized_files['Terminus\\Auth'] = getTokens(TERMINUS_ROOT . '/php/Terminus/Auth.php');
$file_functions = array();
foreach ($tokenized_files as $namespace => $tokens) {
    $file_functions[$namespace] = findTokenPatterns($tokens);
}
$documentation = array();
foreach ($file_functions as $namespace => $functions) {
    if (!empty($functions)) {
        $documentation[$namespace] = array();
        foreach ($functions as $name => $function) {
            $documentation[$namespace][$name] = parseDocs($function['T_DOC_COMMENT']);
        }
    }
}
foreach ($documentation as $namespace => $data) {
    writeDocFile($namespace, $data);
Example #5
0
function process_request($files, $chunks, $skin, $icons, $yui = false, $notcompress = false)
{
    global $js_header, $java;
    $files = explode(";", $files);
    $chunks = explode(";", $chunks);
    array_push($chunks, "__pro_feature");
    $js_list = array("./dhtmlxcommon.js", "../dhtmlxMessage/codebase/dhtmlxmessage.js");
    $css_list = array("../dhtmlxMessage/codebase/dhtmlxmessage_{$skin}.css");
    $manifest = array("Skin: " . $skin);
    for ($i = 0; $i < sizeof($files); $i++) {
        if ($files[$i] == "") {
            continue;
        }
        if (preg_match("/.*\\.js\$/", $files[$i])) {
            array_push($js_list, "." . $files[$i]);
        } else {
            array_push($css_list, "." . $files[$i]);
        }
    }
    $js_list = array_values(array_unique($js_list));
    $css_list = array_values(array_unique($css_list));
    $chunks = array_values(array_unique($chunks));
    $components = array();
    for ($i = 0; $i < sizeof($js_list); $i++) {
        $temp = explode("/", $js_list[$i]);
        if (sizeof($temp) > 2) {
            array_push($components, $temp[1]);
        }
    }
    $location = export_images(array_values(array_unique($components)), $skin);
    for ($i = 0; $i < sizeof($components); $i++) {
        $temp_name = "../" . $components[$i] . "/codebase/skins/" . strtolower($components[$i]) . "_" . $skin . ".css";
        if (file_exists($temp_name)) {
            array_push($css_list, $temp_name);
        }
    }
    $css_list = array_values(array_unique($css_list));
    $js_code = "";
    $css_code = "";
    $store_requested = false;
    array_push($manifest, "\n======== JS CODE =========");
    $dw_index = -1;
    $ch_index = -1;
    $ds_index = -1;
    for ($i = 0; $i < sizeof($js_list); $i++) {
        if (strpos($js_list[$i], "dhtmlxdataview.js") !== false) {
            $dw_index = $i;
        }
        if (strpos($js_list[$i], "dhtmlxchart.js") !== false) {
            $ch_index = $i;
        }
        if (strpos($js_list[$i], "datastore.js") !== false) {
            $ds_index = $i;
        }
    }
    if ($dw_index != -1 && $ch_index != -1) {
        $js_list[] = "corestore.js";
    } else {
        $dw_index = -1;
        $ch_index = -1;
        $ds_index = -1;
    }
    for ($i = 0; $i < sizeof($js_list); $i++) {
        if ($i == $dw_index || $i == $ch_index || $i == $ds_index) {
            continue;
        }
        if (strpos($js_list[$i], "datastore.js") !== false) {
            $store_requested = $js_list[$i];
            continue;
        }
        $check_path = str_replace("codebase", "sources", $js_list[$i]);
        if (is_file($check_path)) {
            $js_code .= "\r\n" . file_get_contents($check_path);
        } else {
            if (!is_file($js_list[$i])) {
                continue;
            }
            $js_code .= "\r\n" . file_get_contents($js_list[$i]);
        }
        array_push($manifest, $js_list[$i]);
    }
    if ($store_requested) {
        $check_path = str_replace("codebase", "sources", $store_requested);
        if (is_file($check_path)) {
            $js_code .= "\r\n" . file_get_contents($check_path);
            array_push($manifest, $store_requested);
        } else {
            if (is_file($store_requested)) {
                $js_code .= "\r\n" . file_get_contents($store_requested);
                array_push($manifest, $store_requested);
            }
        }
    }
    array_push($manifest, "\n======== CSS CODE ========");
    for ($i = 0; $i < sizeof($css_list); $i++) {
        if (!is_file($css_list[$i])) {
            continue;
        }
        $css_code .= "\r\n" . file_get_contents($css_list[$i]);
        array_push($manifest, $css_list[$i]);
    }
    $js_code = clearAreas($js_code, getTokens($js_code, "some file"), $chunks);
    if ($js_code != "") {
        $js_code .= "\ndhtmlx.skin='" . $skin . "';";
    }
    if (!$notcompress) {
        file_put_contents($location . "/temp.js", $js_code);
        print "<br>" . getcwd() . ":" . $java . "- {$java} - {$java}";
        print "--Execute: " . "java  -jar ./yui/compiler.jar --dhx_safe --js {$location}/temp.js > {$location}/temp2.js--<br>";
        exec("java  -jar ./yui/compiler.jar --dhx_safe --js {$location}/temp.js > {$location}/temp2.js");
        $new_js_code = file_get_contents($location . "/temp2.js");
        if ($new_js_code == "") {
            $js_code = replaceWhitespaces(replaceComments($js_code));
        } else {
            $js_code = $new_js_code;
        }
        //unlink($location."/temp.js");
        //unlink($location."/temp2.js");
    }
    $css_code = preg_replace('/"/', "'", $css_code);
    $css_code = str_replace("../imgs", "imgs/", $css_code);
    $css_code = str_replace("imgs//", "imgs/", $css_code);
    $css_code = str_replace("../../codebase/", "", $css_code);
    if (!$notcompress) {
        file_put_contents($location . "/temp.css", $css_code);
        exec("{$java}  -jar ./yui/yuicompressor-2.3.5/build/yuicompressor-2.3.5.jar {$location}/temp.css > {$location}/temp2.css");
        $new_css_code = file_get_contents($location . "/temp2.css");
        if ($new_css_code == "") {
            $css_code = replaceCssWhitespaces($css_code);
        } else {
            $css_code = $new_css_code;
        }
        unlink($location . "/temp.css");
        unlink($location . "/temp2.css");
    }
    file_put_contents($location . "/dhtmlx.js", $js_header . $js_code);
    file_put_contents($location . "/dhtmlx.css", $css_code);
    file_put_contents($location . "/manifest.txt", implode("\n", $manifest));
    return $location;
}
Example #6
0
}
if (isset($_SESSION['error_warning'])) {
    $error_warning = $_SESSION['error_warning'];
    unset($_SESSION['error_warning']);
} else {
    $error_warning = '';
}
$total_token = getTotalToken();
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
}
$numrows = 20;
$data = array('start' => ($page - 1) * $numrows, 'limit' => $numrows);
$tokens = getTokens($data);
$pagination = new Pagination();
$pagination->total = $total_token;
$pagination->page = $page;
$pagination->limit = $numrows;
$pagination->url = "token/page{page}.html";
$pagination = $pagination->render();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['selected'])) {
    foreach ($_POST['selected'] as $token_id) {
        $delete_query = deleteToken($token_id);
        if ($delete_query) {
            $_SESSION['success'] = $lang['success_delete'];
            header('Location:tokens.html');
        } else {
            $error_warning = $lang['error_query'];
        }
  function getValues($dataText, $beginDelimiter, $endDelimiter) {
    global $allBeginDelimiters;
    global $allEndDelimiters;
    global $loopCount;

    if ($dataText == null) {
      die("Data input to generate tokens is NULL in getValues");
    }
    $beginDelimiterCount = count($allBeginDelimiters);
    
    $textOfInterest = getTextOfInterest($dataText, $beginDelimiter, $endDelimiter);
    $tokensRowNum = 0;
    $loopCount = 0;
    while ($textOfInterest != null) {
      $loopCount = $loopCount + 1;
      if ($loopCount > 10000) {
        die ("Unterminated recursive call triggered!");
      }
      $tokens = getTokens($textOfInterest);
      $textTokens[$tokensRowNum++] = $tokens;
      $textOfInterest = getTextOfInterest(null, $beginDelimiter, $endDelimiter);
    }
    return $textTokens;
  }
Example #8
0
function macro_FastSearch($formatter, $value = "", &$opts)
{
    global $DBInfo;
    $default_limit = isset($DBInfo->fastsearch_limit) ? $DBInfo->fastsearch_limit : 30;
    if ($value === true) {
        $needle = $value = $formatter->page->name;
    } else {
        # for MoinMoin compatibility with [[FullSearch("blah blah")]]
        $needle = $value = preg_replace("/^('|\")([^\\1]*)\\1/", "\\2", $value);
    }
    $needle = _preg_search_escape($needle);
    $pattern = '/' . $needle . '/i';
    $fneedle = str_replace('"', "&#34;", $needle);
    # XXX
    $url = $formatter->link_url($formatter->page->urlname);
    $arena = 'fullsearch';
    $check1 = 'checked="checked"';
    $check2 = $check3 = '';
    if (in_array($opts['arena'], array('titlesearch', 'fullsearch', 'pagelinks'))) {
        $check1 = '';
        $arena = $opts['arena'];
        if ($arena == 'fullsearch') {
            $check1 = 'checked="checked"';
        } else {
            if ($arena == 'titlesearch') {
                $check2 = 'checked="checked"';
            } else {
                $check3 = 'checked="checked"';
            }
        }
    }
    if (!empty($opts['backlinks'])) {
        $arena = 'pagelinks';
        $check1 = '';
        $check3 = 'checked="checked"';
    }
    $msg = _("Fast search");
    $msg2 = _("Display context of search results");
    $msg3 = _("Full text search");
    $msg4 = _("Title search");
    $msg5 = _("Link search");
    $form = <<<EOF
<form method='get' action='{$url}'>
   <input type='hidden' name='action' value='fastsearch' />
   <input name='value' size='30' value='{$fneedle}' />
   <span class='button'><input type='submit' class='button' value='{$msg}' /></span><br />
   <input type='checkbox' name='context' value='20' />{$msg2}<br />
   <input type='radio' name='arena' value='fullsearch' {$check1} />{$msg3}
   <input type='radio' name='arena' value='titlesearch' {$check2} />{$msg4}
   <input type='radio' name='arena' value='pagelinks' {$check3} />{$msg5}<br />
   </form>
EOF;
    if (!isset($needle[0]) or !empty($opts['form'])) {
        # or blah blah
        $opts['msg'] = _("No search text");
        return $form;
    } else {
        if (validate_needle($needle) === false) {
            $opts['msg'] = sprintf(_("Invalid search expression \"%s\""), $needle);
            return $form;
        }
    }
    $DB = new Indexer_dba($arena, "r", $DBInfo->dba_type);
    if ($DB->db == null) {
        $opts['msg'] = _("Couldn't open search database, sorry.");
        $opts['hits'] = array();
        $opts['hit'] = 0;
        $opts['all'] = 0;
        return '';
    }
    $opts['form'] = $form;
    $sc = new Cache_text("searchkey");
    if ($arena == "pagelinks") {
        $words = array($value);
    } else {
        $words = getTokens($value);
    }
    // $words=explode(' ', strtolower($value));
    $idx = array();
    $new_words = array();
    foreach ($words as $word) {
        if ($sc->exists($word)) {
            $searchkeys = $sc->fetch($word);
        } else {
            $searchkeys = $DB->_search($word);
            $sc->update($word, $searchkeys);
        }
        $new_words = array_merge($new_words, $searchkeys);
        $new_words = array_merge($idx, $DB->_search($word));
    }
    $words = array_merge($words, $new_words);
    //
    $word = array_shift($words);
    $idx = $DB->_fetchValues($word);
    foreach ($words as $word) {
        $ids = $DB->_fetchValues($word);
        // FIXME
        foreach ($ids as $id) {
            $idx[] = $id;
        }
    }
    $init_hits = array_count_values($idx);
    // initial hits
    $idx = array_keys($init_hits);
    //arsort($idx);
    $all_count = $DBInfo->getCounter();
    $pages = array();
    $hits = array();
    foreach ($idx as $id) {
        $key = $DB->_fetch($id);
        $pages[$id] = $key;
        $hits['_' . $key] = $init_hits[$id];
        // HACK. prefix '_' to numerical named pages
    }
    $DB->close();
    if (!empty($_GET['q']) and isset($_GET['q'][0])) {
        return $pages;
    }
    $context = !empty($opts['context']) ? $opts['context'] : 0;
    $limit = isset($opts['limit'][0]) ? $opts['limit'] : $default_limit;
    $contexts = array();
    if ($arena == 'fullsearch' || $arena == 'pagelinks') {
        $idx = 1;
        foreach ($pages as $page_name) {
            if (!empty($limit) and $idx > $limit) {
                break;
            }
            $p = new WikiPage($page_name);
            if (!$p->exists()) {
                continue;
            }
            $body = $p->_get_raw_body();
            $count = preg_match_all($pattern, $body, $matches);
            // more precisely count matches
            if ($context) {
                # search matching contexts
                $contexts[$page_name] = find_needle($body, $needle, '', $context);
            }
            $hits['_' . $page_name] = $count;
            // XXX hack for numerical named pages
            $idx++;
        }
    }
    //uasort($hits, 'strcasecmp');
    //$order = 0;
    //uasort($hits, create_function('$a, $b', 'return ' . ($order ? '' : '-') . '(strcasecmp($a, $b));'));
    $name = array_keys($hits);
    array_multisort($hits, SORT_DESC, $name, SORT_ASC);
    $opts['hits'] = $hits;
    $opts['hit'] = count($hits);
    $opts['all'] = $all_count;
    if (!empty($opts['call'])) {
        return $hits;
    }
    $out = "<!-- RESULT LIST START -->";
    // for search plugin
    $out .= "<ul>";
    $idx = 1;
    while (list($page_name, $count) = each($hits)) {
        $page_name = substr($page_name, 1);
        $out .= '<!-- RESULT ITEM START -->';
        // for search plugin
        $out .= '<li>' . $formatter->link_tag(_rawurlencode($page_name), "?action=highlight&amp;value=" . _urlencode($needle), $page_name, "tabindex='{$idx}'");
        if ($count > 1) {
            $out .= ' . . . . ' . sprintf($count == 1 ? _("%d match") : _("%d matches"), $count);
            if (!empty($contexts[$page_name])) {
                $out .= $contexts[$page_name];
            }
        }
        $out .= "</li>\n";
        $out .= '<!-- RESULT ITEM END -->';
        // for search plugin
        $idx++;
        if (!empty($limit) and $idx > $limit) {
            break;
        }
    }
    $out .= "</ul>\n";
    $out .= "<!-- RESULT LIST END -->";
    // for search plugin
    return $out;
}
Example #9
0
 */
function writeDocFile($namespace, $docs)
{
    $filename = TERMINUS_ROOT . '/docs/' . str_replace(array('Terminus\\', '\\'), array('', '/'), $namespace) . '.md';
    $rendered_doc = Utils\twigRender('doc.twig', $docs, array('namespace' => $namespace));
    file_put_contents($filename, $rendered_doc);
    return true;
}
$library_files = array_merge(getFiles(TERMINUS_ROOT . '/php/Terminus/Models'), getFiles(TERMINUS_ROOT . '/php/Terminus/Outputters'));
$tokenized_files = array();
foreach ($library_files as $filename) {
    $namespace = str_replace(array(TERMINUS_ROOT . '/php/', '.php', '/'), array('', '', '\\'), $filename);
    $tokenized_files[$namespace] = getTokens($filename);
}
$tokenized_files['Terminus\\Auth'] = getTokens(TERMINUS_ROOT . '/php/Terminus/Auth.php');
$tokenized_files['Terminus\\Helpers\\Input'] = getTokens(TERMINUS_ROOT . '/php/Terminus/Helpers/Input.php');
$file_functions = array();
foreach ($tokenized_files as $namespace => $tokens) {
    $file_functions[$namespace] = findTokenPatterns($tokens);
}
$documentation = array();
foreach ($file_functions as $namespace => $functions) {
    if (!empty($functions)) {
        $documentation[$namespace] = array();
        foreach ($functions as $name => $function) {
            $documentation[$namespace][$name] = parseDocs($function['T_DOC_COMMENT']);
        }
    }
}
foreach ($documentation as $namespace => $data) {
    writeDocFile($namespace, $data);
Example #10
0
function process_request($files, $chunks, $skin, $yui = false)
{
    global $js_header;
    $files = explode(";", $files);
    $chunks = explode(";", $chunks);
    array_push($chunks, "__pro_feature");
    $js_list = array("./dhtmlxcommon.js");
    $css_list = array();
    $manifest = array("Skin: " . $skin);
    for ($i = 0; $i < sizeof($files); $i++) {
        if ($files[$i] == "") {
            continue;
        }
        if (preg_match("/.*\\.js\$/", $files[$i])) {
            array_push($js_list, "." . $files[$i]);
        } else {
            array_push($css_list, "." . $files[$i]);
        }
    }
    $js_list = array_values(array_unique($js_list));
    $css_list = array_values(array_unique($css_list));
    $chunks = array_values(array_unique($chunks));
    $components = array();
    for ($i = 0; $i < sizeof($js_list); $i++) {
        $temp = explode("/", $js_list[$i]);
        if (sizeof($temp) > 2) {
            array_push($components, $temp[1]);
        }
    }
    $location = export_images(array_values(array_unique($components)), $skin);
    for ($i = 0; $i < sizeof($components); $i++) {
        $temp_name = "../" . $components[$i] . "/codebase/skins/" . strtolower($components[$i]) . "_" . $skin . ".css";
        if (file_exists($temp_name)) {
            array_push($css_list, $temp_name);
        }
    }
    $css_list = array_values(array_unique($css_list));
    $js_code = "";
    $css_code = "";
    $jscore_code = "";
    array_push($manifest, "\n======== JS CODE =========");
    for ($i = 0; $i < sizeof($js_list); $i++) {
        if (strpos($js_list[$i], "dhtmlxdataview.js") !== false || strpos($js_list[$i], "dhtmlxchart.js") !== false) {
            if (sizeof($js_list) == 2) {
                if (!is_file($js_list[$i])) {
                    continue;
                }
                $js_code = "";
                $jscore_code = "\r\n" . file_get_contents($js_list[$i]);
                if (strpos($js_list[$i], "dhtmlxchart.js") !== false) {
                    $jscore_code .= "\r\n" . file_get_contents(str_replace("dhtmlxchart.js", "thirdparty/excanvas/excanvas.js", $js_list[$i]));
                }
                continue;
            } else {
                $jscore_code .= "\r\n" . file_get_contents("./core.js");
                continue;
            }
        }
        $check_path = str_replace("codebase", "sources", $js_list[$i]);
        if (is_file($check_path)) {
            $js_code .= "\r\n" . file_get_contents($check_path);
        } else {
            if (!is_file($js_list[$i])) {
                continue;
            }
            $js_code .= "\r\n" . file_get_contents($js_list[$i]);
        }
        array_push($manifest, $js_list[$i]);
    }
    array_push($manifest, "\n======== CSS CODE ========");
    for ($i = 0; $i < sizeof($css_list); $i++) {
        if (!is_file($css_list[$i])) {
            continue;
        }
        $css_code .= "\r\n" . file_get_contents($css_list[$i]);
        array_push($manifest, $css_list[$i]);
    }
    $js_code = clearAreas($js_code, getTokens($js_code, "some file"), $chunks);
    if ($js_code != "") {
        $js_code .= "\ndhtmlx.skin='" . $skin . "';";
    }
    if (!$yui) {
        $js_code = replaceWhitespaces(replaceComments($js_code));
    } else {
        file_put_contents($location . "/temp.js", $js_code);
        `java  -jar ./yui/yuicompressor-2.3.5/build/yuicompressor-2.3.5.jar {$location}/temp.js > {$location}/temp2.js`;
        $js_code = file_get_contents($location . "/temp2.js");
        unlink($location . "/temp.js");
        unlink($location . "/temp2.js");
    }
    $css_code = preg_replace('/"/', "'", $css_code);
    $css_code = str_replace("../imgs", "imgs/", $css_code);
    $css_code = str_replace("../../codebase/", "", $css_code);
    if (!$yui) {
        $css_code = preg_replace("#\\/\\*([^\\*]|\\*[^\\/])*\\*\\/#", "", $css_code);
        $css_code = preg_replace('/[ \\t]+/', " ", $css_code);
        $css_code = preg_replace("/\\{[\r\n]+/", "{", $css_code);
        $css_code = preg_replace("/;[\r\n]+/", ";", $css_code);
        $css_code = preg_replace("/[\r\n]+/", "\n", $css_code);
        $css_code = preg_replace("/\\/\\*.*\n/", "", $css_code);
        //$css_code=preg_replace("/\n/","\";str+=\"",$css_code);
        //$css_code=preg_replace("/\n/","\\n",$css_code);
        $css_code = preg_replace("/\\{ /", "{", $css_code);
        $css_code = preg_replace("/[; ]+\\}/", "}", $css_code);
    } else {
        file_put_contents($location . "/temp.css", $css_code);
        `java  -jar ./yui/yuicompressor-2.3.5/build/yuicompressor-2.3.5.jar {$location}/temp.css > {$location}/temp2.css`;
        $css_code = file_get_contents($location . "/temp2.css");
        unlink($location . "/temp.css");
        unlink($location . "/temp2.css");
    }
    file_put_contents($location . "/dhtmlx.js", $js_header . $js_code . $jscore_code);
    file_put_contents($location . "/dhtmlx.css", $css_code);
    file_put_contents($location . "/manifest.txt", implode("\n", $manifest));
    return $location;
}
Example #11
0
function allData($playerId)
{
    $games = getGameObject($playerId, false);
    $player = getPlayerObject($playerId);
    $playerStats = array("kills" => 4, "gamesPlayed" => 3);
    $news = getNews($playerId);
    $tokens = getTokens();
    if ($player !== false) {
        $ret = array("status" => "OK", "player" => $player, "news" => $news, "games" => $games, "tokens" => $tokens);
    } else {
        $ret = array("status" => "NO_PLAYER", "playerId" => $playerId);
    }
    print json_encode($ret);
}
Example #12
0
<?php

//ini_set('display_errors', 1);
session_start();
require_once "includes/twitteroauth/twitteroauth.php";
require_once "includes/htmlhelper.php";
require_once "includes/bibliohelper.php";
$contents = "No se encontraron resultados para '{$_REQUEST['searchtext']}'";
if ($_REQUEST['searchtext'] != "") {
    header("Cache-Control: no-cache");
    $_SESSION['tokens'] = getTokens();
    $titulos = getList(utf8_decode($_REQUEST['searchtext']));
    if (count($titulos) > 0) {
        $contents = "<table id='resultados' width='99%' cellspacing='0' cellpadding='0' border='0' summary='Listado de libros'><thead><tr><th width='50%' colspan='2'>{$_REQUEST['searchtext']}</th><th width='15%'>disponibilidad</th><th width='15%'>localización</th><th width='15%'>signatura</th><th width='5%'></th></tr></thead><tbody>";
        $contador = 0;
        foreach ($titulos as $key => $value) {
            $class = ++$contador % 2 == 1 ? "class='tr_odd'" : "";
            $contents .= "<tr {$class}><td><img src='img/progress.gif'/></td><td>{$value}</td><td></td><td></td><td></td><td class='ult'></td></tr>";
        }
        $contents .= "</tbody></table>";
    }
    echo $contents;
}
Example #13
0
function process_request($files, $chunks, $skin, $icons, $yui = false)
{
    global $js_header;
    global $java;
    $files = explode(";", $files);
    $chunks = explode(";", $chunks);
    array_push($chunks, "__pro_feature");
    $js_list = array("./dhtmlxcommon.js", "./message/message.js");
    $css_list = array("./message/message.css");
    $manifest = array("Skin: " . $skin);
    for ($i = 0; $i < sizeof($files); $i++) {
        if ($files[$i] == "") {
            continue;
        }
        if (preg_match("/.*\\.js\$/", $files[$i])) {
            array_push($js_list, "." . $files[$i]);
        } else {
            array_push($css_list, "." . $files[$i]);
        }
    }
    $js_list = array_values(array_unique($js_list));
    $css_list = array_values(array_unique($css_list));
    $chunks = array_values(array_unique($chunks));
    $components = array();
    for ($i = 0; $i < sizeof($js_list); $i++) {
        $temp = explode("/", $js_list[$i]);
        if (sizeof($temp) > 2) {
            array_push($components, $temp[1]);
        }
    }
    $location = export_images(array_values(array_unique($components)), $skin);
    for ($i = 0; $i < sizeof($components); $i++) {
        $temp_name = "../" . $components[$i] . "/codebase/skins/" . strtolower($components[$i]) . "_" . $skin . ".css";
        if (file_exists($temp_name)) {
            array_push($css_list, $temp_name);
        }
    }
    $css_list = array_values(array_unique($css_list));
    $js_code = "";
    $css_code = "";
    $store_requested = false;
    array_push($manifest, "\n======== JS CODE =========");
    for ($i = 0; $i < sizeof($js_list); $i++) {
        if (strpos($js_list[$i], "datastore.js") !== false) {
            $store_requested = $js_list[$i];
            continue;
        }
        /*	if (strpos($js_list[$i],"dhtmlxdataview.js")!==false || strpos($js_list[$i],"dhtmlxchart.js")!==false){
        				if (sizeof($js_list) == 2){
        					if (!is_file($js_list[$i])) continue;
        					$js_code="";
        					$js_code.="\r\n".file_get_contents($js_list[$i]);
        					if (strpos($js_list[$i],"dhtmlxchart.js")!==false)
        						$js_code.="\r\n".file_get_contents(str_replace("dhtmlxchart.js","thirdparty/excanvas/excanvas.js",$js_list[$i]));
        					continue;
        				} else {
        					if (!$core_included){
        						$js_code.="\r\n".file_get_contents("./corestore.js");
        						array_push($manifest,"core, dataview, chart");
        					}
        					$core_included = true;
        					continue;
        				}
        			}*/
        $check_path = str_replace("codebase", "sources", $js_list[$i]);
        if (is_file($check_path)) {
            $js_code .= "\r\n" . file_get_contents($check_path);
        } else {
            if (!is_file($js_list[$i])) {
                continue;
            }
            $js_code .= "\r\n" . file_get_contents($js_list[$i]);
        }
        array_push($manifest, $js_list[$i]);
    }
    if ($store_requested) {
        $check_path = str_replace("codebase", "sources", $store_requested);
        if (is_file($check_path)) {
            $js_code .= "\r\n" . file_get_contents($check_path);
            array_push($manifest, $store_requested);
        } else {
            if (is_file($store_requested)) {
                $js_code .= "\r\n" . file_get_contents($store_requested);
                array_push($manifest, $store_requested);
            }
        }
    }
    array_push($manifest, "\n======== CSS CODE ========");
    for ($i = 0; $i < sizeof($css_list); $i++) {
        if (!is_file($css_list[$i])) {
            continue;
        }
        $css_code .= "\r\n" . file_get_contents($css_list[$i]);
        array_push($manifest, $css_list[$i]);
    }
    $js_code = clearAreas($js_code, getTokens($js_code, "some file"), $chunks);
    if ($js_code != "") {
        $js_code .= "\ndhtmlx.skin='" . $skin . "';";
    }
    file_put_contents($location . "/temp.js", $js_code);
    exec("{$java}  -jar ./yui/compiler.jar --dhx_safe --js {$location}/temp.js > {$location}/temp2.js");
    $new_js_code = file_get_contents($location . "/temp2.js");
    if ($new_js_code == "") {
        $js_code = replaceWhitespaces(replaceComments($js_code));
    } else {
        $js_code = $new_js_code;
    }
    unlink($location . "/temp.js");
    unlink($location . "/temp2.js");
    $css_code = preg_replace('/"/', "'", $css_code);
    $css_code = str_replace("../imgs", "imgs/", $css_code);
    $css_code = str_replace("imgs//", "imgs/", $css_code);
    $css_code = str_replace("../../codebase/", "", $css_code);
    file_put_contents($location . "/temp.css", $css_code);
    exec("{$java}  -jar ./yui/yuicompressor-2.3.5/build/yuicompressor-2.3.5.jar {$location}/temp.css > {$location}/temp2.css");
    $new_css_code = file_get_contents($location . "/temp2.css");
    if ($new_css_code == "") {
        $css_code = replaceCssWhitespaces($css_code);
    } else {
        $css_code = $new_css_code;
    }
    unlink($location . "/temp.css");
    unlink($location . "/temp2.css");
    file_put_contents($location . "/dhtmlx.js", $js_header . $js_code);
    file_put_contents($location . "/dhtmlx.css", $css_code);
    file_put_contents($location . "/manifest.txt", implode("\n", $manifest));
    return $location;
}
<?php

require_once "praveenlib.php";
require_once "applib.php";
$keys = array("userId", "message");
$respjson = array("status" => "unprocessed", "errorCode" => 1);
if (checkPOST($keys)) {
    $userId = $_POST['userId'];
    $message = $_POST['message'];
    $ids = array();
    $ids[] = $userId;
    $tokenData = getTokens($ids);
    $tokens = $tokenData['tokens'];
    $title = "Server Notification";
    $respjson[] = sendPushNotification($tokens, $title, $message);
} else {
    $respjson["status"] = "insufficient Data";
    $respjson["errorCode"] = 2;
}
echo json_encode($respjson);
Example #15
0
 * @param string[] $docs      Documentation to add to file
 * @return bool    True if write was successful
 */
function writeDocFile($namespace, $docs)
{
    $template_helper = new \Terminus\Helpers\TemplateHelper(['command' => null]);
    $filename = TERMINUS_ROOT . '/docs/' . str_replace(array('Terminus\\', '\\'), array('', '/'), $namespace) . '.md';
    $rendered_doc = $template_helper->render(['template_name' => 'doc.twig', 'data' => $docs, 'options' => ['namespace' => $namespace]]);
    file_put_contents($filename, $rendered_doc);
    return true;
}
$library_files = array_merge(getFiles(TERMINUS_ROOT . '/php/Terminus/Models'), getFiles(TERMINUS_ROOT . '/php/Terminus/Outputters'), getFiles(TERMINUS_ROOT . '/php/Terminus/Helpers'));
$tokenized_files = array();
foreach ($library_files as $filename) {
    $namespace = str_replace(array(TERMINUS_ROOT . '/php/', '.php', '/'), array('', '', '\\'), $filename);
    $tokenized_files[$namespace] = getTokens($filename);
}
$file_functions = array();
foreach ($tokenized_files as $namespace => $tokens) {
    $file_functions[$namespace] = findTokenPatterns($tokens);
}
$documentation = array();
foreach ($file_functions as $namespace => $functions) {
    if (!empty($functions)) {
        $documentation[$namespace] = array();
        foreach ($functions as $name => $function) {
            $documentation[$namespace][$name] = parseDocs($function['T_DOC_COMMENT']);
        }
    }
}
foreach ($documentation as $namespace => $data) {
Example #16
0
#$indexer->test();
#exit;
$handle = opendir($DBInfo->text_dir);
if (!is_resource($handle)) {
    echo "Can't open {$DBInfo->text_dir}\n";
    exit;
}
$ii = 1;
while (($file = readdir($handle)) !== false) {
    if (is_dir($DBInfo->text_dir . "/" . $file)) {
        continue;
    }
    $pagename = $DBInfo->keyToPagename($file);
    print "* [{$ii}] {$pagename} ";
    $ii++;
    $words = getTokens($pagename);
    $k = get_key($pagename);
    print " - ({$k}) - ";
    print ' ' . count($words) . "\n";
    $words[] = "" . $k;
    $indexer->addWordCache($pagename, $words);
    if (count($indexer->wordcache) > 10000) {
        $indexer->flushWordCache(false);
    }
    #$indexer->addWords($pagename, $words);
}
$indexer->flushWordCache();
$indexer->packWords();
$indexer->close();
closedir($handle);
// vim:et:sts=4:sw=4:
Example #17
0
$handle = opendir($DBInfo->text_dir);
if (!is_resource($handle)) {
    echo "Can't open {$DBInfo->text_dir}\n";
    exit;
}
$ii = 1;
while (($file = readdir($handle)) !== false) {
    if (is_dir($DBInfo->text_dir . "/" . $file)) {
        continue;
    }
    $pagename = $DBInfo->keyToPagename($file);
    $p = $DBInfo->getPage($pagename);
    print "* [{$ii}] {$pagename} ";
    $ii++;
    if (!$p->exists()) {
        continue;
    }
    $raw = $p->_get_raw_body();
    $words = getTokens($raw);
    print ' ' . count($words) . "\n";
    $indexer->addWordCache($pagename, $words);
    if (count($indexer->wordcache) > 10000) {
        $indexer->flushWordCache(false);
    }
    #$indexer->addWords($pagename, $words);
}
$indexer->flushWordCache();
$indexer->packWords();
$indexer->close();
closedir($handle);
// vim:et:sts=4:sw=4: