Exemplo n.º 1
0
function youtubeSearch($title)
{
    $trailers = array();
    $title = normalize($title);
    $trailerquery = $title . " trailer";
    $youtubeurl = "http://gdata.youtube.com/feeds/api/videos?client=" . YOUTUBE_CLIENT_ID . "&key=" . YOUTUBE_DEVELOPER_KEY . "&v=2&" . "q=" . urlencode($trailerquery) . "&start-index=1&max-results=10";
    $resp = httpClient($youtubeurl, true);
    if (!$resp['success']) {
        return $trailers;
    }
    $xml = simplexml_load_string($resp['data']);
    // obtain namespaces
    $namespaces = $xml->getNameSpaces(true);
    foreach ($xml->entry as $trailer) {
        $media = $trailer->children($namespaces['media']);
        $yt = $media->group->children($namespaces['yt']);
        $id = $yt->videoid;
        // API filtering code removed
        $trailers[] = array('id' => (string) $id, 'src' => (string) $trailer->content['src'], 'title' => (string) $trailer->title);
        if (count($trailers) >= 10) {
            break;
        }
    }
    return $trailers;
}
function slug($str, $separator = '-')
{
    $str = normalize($str);
    // replace non letter or digits by separator
    $str = preg_replace('#^[^A-z0-9]+$#', $separator, $str);
    return trim(strtolower($str), $separator);
}
Exemplo n.º 3
0
    /**
     * Overrides the method to render the child in a `<DIV.field>` wrapper:
     *
     * ```html
     * <div class="field [{normalized_field_name}][required]">
     *     [<label for="{element_id}" class="input-label [required]">{element_form_label}</label>]
     *     <div class="input">{child}</div>
     * </div>
     * ```
     *
     * @inheritdoc
     */
    protected function render_child($child)
    {
        $control_group_class = 'control-group';
        $name = $child['name'];
        if ($name) {
            $control_group_class .= ' control-group--' . normalize($name);
        }
        if ($child[self::REQUIRED]) {
            $control_group_class .= ' required';
        }
        $state = $child[Element::STATE];
        if ($state) {
            $control_group_class .= ' ' . $state;
        }
        $label = $child[Form::LABEL];
        if ($label) {
            if (!$label instanceof Element) {
                $label = $this->t($label, [], ['scope' => 'group.label', 'default' => $this->t($label, [], ['scope' => 'element.label'])]);
            }
            $label = '<label for="' . $child->id . '" class="controls-label">' . $label . '</label>' . PHP_EOL;
        }
        return <<<EOT
<div class="{$control_group_class}">
\t{$label}<div class="controls">{$child}</div>
</div>
EOT;
    }
Exemplo n.º 4
0
function slug($str, $separator = '-')
{
    $str = normalize($str);
    // replace non letter or digits by separator
    $str = preg_replace('/[^a-zA-Z0-9]+/', $separator, html_entity_decode($str, ENT_QUOTES));
    return trim(strtolower($str), $separator);
}
Exemplo n.º 5
0
Arquivo: chat.php Projeto: philum/cms
function plug_chat($p, $msg, $res = '')
{
    //$_SESSION['muse']='';
    $p = $p ? normalize($p) : 'public';
    ses('muse', $res ? ajxg($res) : ses('USE'));
    return chatform($p, $msg) . divd('cht' . $p, chatread($p));
}
Exemplo n.º 6
0
/**
 * @param string $key
 * @param mixed $default
 * @return mixed
 */
function env($key, $default = null)
{
    $value = getenv($key);
    if ($value === false) {
        return value($default);
    }
    return normalize($value);
}
Exemplo n.º 7
0
function rednm($d)
{
    if (strrpos($d, "/") !== false) {
        $d = substr($d, strrpos($d, "/") + 1);
    }
    //if(strrpos($d,".")!==false)$d=substr($d,0,strpos($d,"."));
    return normalize($d);
}
Exemplo n.º 8
0
function cameraTransform($C, $A)
{
    $w = normalize(addVector($C, scalarProduct($A, -1)));
    $y = array(0, 1, 0);
    $u = normalize(crossProduct($y, $w));
    $v = crossProduct($w, $u);
    $t = scalarProduct($C, -1);
    return array($u[0], $v[0], $w[0], 0, $u[1], $v[1], $w[1], 0, $u[2], $v[2], $w[2], 0, dotProduct($u, $t), dotProduct($v, $t), dotProduct($w, $t), 1);
}
Exemplo n.º 9
0
 /**
  * 
  */
 public function testNormalizeCase()
 {
     $test1 = 'slug-case-to-normal-case';
     $test2 = 'snake_case_to_normal_case';
     $test3 = 'camelCaseToNormalCase';
     $test4 = 'CamelCaseToNormalCase';
     $this->assertEquals(normalize($test1), 'Slug case to normal case');
     $this->assertEquals(normalize($test2), 'Snake case to normal case');
     $this->assertEquals(normalize($test3), 'Camel case to normal case');
     $this->assertEquals(normalize($test4), 'Camel case to normal case');
 }
Exemplo n.º 10
0
function mform_mr($d)
{
    $r = explode(",", $d);
    $n = count($r);
    for ($i = 0; $i < $n; $i++) {
        list($v, $type) = explode("=", $r[$i]);
        $vb = normalize($v);
        if ($type != 'button') {
            $rb[] = $vb;
        }
    }
    //$rb[]='day';
    return $rb;
}
Exemplo n.º 11
0
function testword()
{
    require "../includes/connect.php";
    require "../includes/string.php";
    //$name = str_replace($unwantedChars, "", $row['movieId']);
    //$hashtag = "#".$name;
    //rpp = tweetcount (max=  100)
    $tweetUrl = "http://tweets2csv.com/results.php?q=%23starwars&rpp=40&submit=Search";
    echo $tweetUrl . "<br>";
    $htmltext = file_get_contents($tweetUrl);
    $regex = "#<div class='user'>(.*)(\\s*)<div class='text'>(.*)<div class='description'>#";
    preg_match_all($regex, $htmltext, $matches, PREG_SET_ORDER);
    $wordArray = array();
    $unwantedChars = array('/', "\\", 'http', "@", "-", "<a");
    foreach ($matches as $tweet) {
        //'text'=>$tweet[3],
        //$newData = array("text"=>htmlentities($tweet[3]));
        //array_push($data["data"], $newData);
        //echo $tweet[3]."<br>";
        $words = explode(" ", $tweet[3]);
        foreach ($words as $word) {
            if (!contains($word, $unwantedChars) && !in_array(normalize($word), $stopwords)) {
                if (!isset($wordArray[$word])) {
                    $wordArray[$word] = 1;
                } else {
                    $wordArray[$word]++;
                }
            }
        }
    }
    $newFileName = '../words/starwars.txt';
    if (file_put_contents($newFileName, json_encode($wordArray)) != false) {
        echo "added";
    } else {
        echo "Cannot create file (" . basename($newFileName) . ")";
    }
    echo "<br>";
    //format (just split by / and :)
    /*$newFileName = '../sentiment/'.$name.".txt";
    			$appendContent = $sent['positive'].";".$sent['negative'].";".$sent['neutral'].";".$sent['tweetCount'].";".$updateDate."/";
    
    
    			//If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set.
    			if(file_put_contents($newFileName,$appendContent,  FILE_APPEND) !=false){
    			    echo "File created (".basename($newFileName).")";
    			}else{
    			    echo "Cannot create file (".basename($newFileName).")";
    			}*/
}
Exemplo n.º 12
0
function prepare_link($title, $slug)
{
    //if not allowed characters
    $link = normalize($title);
    //multiples whitespaces -> single whitespace
    $link = preg_replace("/[^a-zA-Z0-9-\\s]+/i", "", $link);
    $link = trim($link);
    $link = strtolower($link);
    //multiples whitespaces -> single minus sign
    $link = preg_replace("/\\s\\s+/i", " ", $link);
    $link = preg_replace("/--+/i", "-", $link);
    $link = preg_replace("/\\s/i", "-", $link);
    $link = '/' . $slug . '/' . $link;
    return $link;
}
Exemplo n.º 13
0
function downloadPoster($movieId, $posterUrl)
{
    //require("includes/connect.php");
    set_time_limit(3600);
    $filename = normalize($movieId);
    $file = '../poster/' . $filename . '.jpg';
    if (!empty($posterUrl)) {
        echo $file . "made <br>";
        if (!file_exists($file)) {
            copy($posterUrl, $file);
        } else {
            echo "already exists";
        }
    } else {
        echo "EMPTY <br>";
    }
}
Exemplo n.º 14
0
function addf_inject()
{
    calltar();
    $ra = msql_read('server', 'edition_typos', '');
    if ($ra) {
        $vra = array_keys_r($ra, 0, 'k');
    }
    $r = msql_read('', 'public_addfonts', '');
    if ($r) {
        $vr = array_shift($r);
    }
    $dir = 'fonts/';
    $diru = 'users/' . $_SESSION['qb'] . '/fonts/';
    if (!is_dir($diru)) {
        mkdir($diru);
    }
    if ($r) {
        foreach ($r as $k => $v) {
            $font = normalize($v[0]);
            if (!$vra[$font]) {
                $rb = array($font, '', '', '', '');
                for ($i = 1; $i < count($v); $i++) {
                    $f = $font . '.' . $vr[$i];
                    $rc[] = $dir . $f;
                    $ret .= addf_copy($v[$i], $dir . $f) . br();
                }
                //u
                //msql_modif('server','edition_typos',$rb,$dfb,'push','');
                //modif_vars('','public_addfonts',$k,'del');
                if ($rc) {
                    PclTarCreate($diru . $font . '.tar.gz', $rc, '', '', '');
                }
                $ret .= btn('txtblc', lka($diru . $font . '.tar.gz')) . ' ' . btn('txtx', 'saved') . br();
            } else {
                $ret .= $font . ' already_exists' . br();
            }
        }
    }
    //if($rb)msql_modif('server','edition_typos',$rb,$dfb,'add','');
    $ret .= lkc('txtbox', '/?admin=fonts&inject==', 'inject datas (admin/fonts)') . br();
    return $ret;
}
Exemplo n.º 15
0
function vernam_enkripsi($plain, $key)
{
    $n = strlen($plain);
    for ($i = 0; $i < $n; $i++) {
        $data[$i] = str_pad(decbin(ord($plain[$i])), 8, "0", STR_PAD_LEFT);
        $kunci[$i] = str_pad(decbin(ord($key[$i])), 8, "0", STR_PAD_LEFT);
        //echo 'biner data ='.str_pad(decbin(ord($plain[$i])), 8, "0", STR_PAD_LEFT).', biner kunci = '.str_pad(decbin(ord($key[$i])), 8, "0", STR_PAD_LEFT).' ';
        //opeasi xor
        for ($j = 0; $j < 8; $j++) {
            $hasil[$j] = ($data[$i][$j] + $kunci[$i][$j]) % 2;
        }
        $result[$i] = implode($hasil);
        //echo 'biner hasil = '.$result[$i];
        $chiper[$i] = chr(normalize(bindec($result[$i])));
        //echo ', biner chiper = '.$chiper[$i];
        //echo ' '.ord($plain[$i]).', key ='.ord($key[$i]).', hasil = '.bindec($result[$i]).', normalisasi ='.normalize(bindec($result[$i])).'<br/>';
    }
    $chiperKey = implode($chiper);
    return $chiperKey;
}
Exemplo n.º 16
0
function do_new($formatter, $options)
{
    global $DBInfo;
    if (!$options['value']) {
        $title = _("Create a new page");
        $formatter->send_header("", $options);
        $formatter->send_title($title, "", $options);
        $url = $formatter->link_url($formatter->page->urlname);
        if ($DBInfo->hasPage('MyNewPage')) {
            $p = $DBInfo->getPage('MyNewPage');
            $f = new Formatter($p, $options);
            $f->use_rating = 0;
            $f->send_page('', $options);
        }
        $msg = _("Page Name");
        $fixname = _("Normalize this page name");
        $btn = _("Create a new page");
        print <<<FORM
<div class='addPage'>
<form method='get' action='{$url}'>
<table style='border:0'><tr><th class='addLabel'><labe>{$msg}: </label></th><td><input type='hidden' name='action' value='new' />
    <input name='value' size='30' /></td></tr>
<tr><th class='addLabel'><input type='checkbox' name='fixname' checked='checked' /></th><td>{$fixname}</td></tr>
<td></td><td><input type='submit' value='{$btn}' /></td>
</tr></table>
    </form>
</div>
FORM;
        $formatter->send_footer();
    } else {
        $pgname = $options['value'];
        if ($options['fixname']) {
            $pgname = normalize($pgname);
        }
        $options['page'] = $pgname;
        $page = new WikiPage($pgname);
        $f = new Formatter($page, $options);
        do_edit($f, $options);
        return true;
    }
}
Exemplo n.º 17
0
 static function addToIndex($id)
 {
     $indexThese = array('title', 'creator', 'subject', 'publisher', 'contributor', 'identifier', 's:subtitle', 's:isbn', 's:tag');
     $prefix = Config::db('prefix', '');
     $title = Input::get('title');
     $input = Input::get('extend.metadata_wtf');
     $metadata = self::parse_wtf($input);
     if (empty($metadata['.']['title'])) {
         $metadata['.']['title'][] = $title;
     }
     $query = Query::table($prefix . 'wtfsearch')->where('post_id', '=', $id);
     $query->delete();
     foreach ($metadata['.'] as $k => $vals) {
         if (in_array($k, $indexThese)) {
             foreach ($vals as $val) {
                 $query->insert(array('post_id' => $id, 'meta_key' => $k, 'meta_value' => normalize($val)));
             }
         }
     }
     //var_dump($prefix, $metadata, $id);
     //die;
 }
Exemplo n.º 18
0
function putOutput($reply)
{
    global $plain_text_log;
    global $query_id;
    global $time_start;
    $time_output = microtime(true);
    $time = $time_output - $time_start;
    $reply = normalize(clean(trim(clean(html_entity_decode($reply)))));
    $numbs = $_GET["mobile"];
    $myid = "AUU";
    //Log
    $response_length = strlen($reply);
    $plain_text_log .= "{$reply}\n----------------\n";
    file_put_contents(dirname(__FILE__) . "/log/plainlog.txt", $plain_text_log, FILE_APPEND);
    $to_log = array("Qid" => $query_id, "T" => $time, "L" => $response_length, "R" => mysql_real_escape_string($reply));
    $log = serialize($to_log);
    //$to_log = "$query_id\t$time\t$response_length\n$reply\n\n";
    file_put_contents(LOG_DIR . "/response.log", $log . "\n", FILE_APPEND);
    if ($numbs != "test" && $numbs != "ashwin" && $numbs != "abhinav" && $numbs != "suhail" && $numbs != "vineeth" && $numbs != "shyam" && $numbs != "web") {
        //$text=urldecode($_GET['content']);
        //$to=urldecode($_GET['number']);
        //$sender=urldecode($_GET['sender']);
        $url = 'http://IP/mt/send.php?sender=9822818163&number=' . $numbs . '&content=' . urlencode($reply);
        $content = file_get_contents($url);
        //echo $content;
    } else {
        echo $reply;
        echo "<br><br>" . dirname(__FILE__);
    }
    //	$reply;
    /* @header("Content-Type: text/html; charset=ISO-8859-1;");
       ?><br />
       <font face="Courier New, Courier, monospace">
       <?php //echo str_replace("\n","<br>",$reply); ?>
       </font>
       <?php
       //echo "<br>----------------------------<br>".strlen($reply); */
    //exit();
}
Exemplo n.º 19
0
function downloadAllPosters()
{
    require "../includes/connect.php";
    set_time_limit(3600);
    $selectQuery = "SELECT * FROM movieinfo";
    $selectResult = mysqli_query($conn, $selectQuery) or die(mysqli_error($conn));
    while ($row = mysqli_fetch_array($selectResult)) {
        $id = $row['movieId'];
        $filename = normalize($id);
        $file = '../poster/' . $filename . '.jpg';
        //echo $filename."<br>";
        $posterUrl = $row['poster'];
        if (!empty($posterUrl)) {
            echo $file . "made <br>";
            if (!file_exists($file)) {
                copy($posterUrl, $file);
            } else {
                echo "already exists";
            }
        } else {
            echo "EMPTY <br>";
        }
    }
}
Exemplo n.º 20
0
/**
 * Accepts an array of directories and generates a list of Javascript files (.js) in those directories and
 * all subdirectories recursively.
 *
 * @param array $dirs - An array of directories as specified in the configuration file (i.e. $configFile).
 *
 * @return array - An array of directory paths to all Javascript files found by recursively searching the
 * specified array of directories.
 */
function listFiles($dirs)
{
    $baseDir = normalize(RELATIVE_APP_ROOT);
    $result = array();
    foreach ($dirs as $dir) {
        $path = $baseDir . $dir;
        if (is_file($path)) {
            $path = substr_replace($path, RELATIVE_APP_ROOT, 0, strlen($baseDir));
            array_push($result, $path);
        } else {
            $paths = glob($path . '/*', GLOB_ONLYDIR | GLOB_NOSORT);
            $paths = substr_replace($paths, '', 0, strlen($baseDir));
            $result = array_merge($result, listFiles($paths));
            $files = glob($path . '/*.js', GLOB_NOSORT);
            $files = substr_replace($files, RELATIVE_APP_ROOT, 0, strlen($baseDir));
            $result = array_merge($result, $files);
        }
    }
    return $result;
}
Exemplo n.º 21
0
if (isset($_REQUEST['media_id'])) {
    $media_id = basename($_REQUEST['media_id']);
}
if ($media_id != '*') {
    $media_id = strtolower(basename($media_id));
    $media_id = normalize($media_id);
    $_REQUEST['media_id'] = $media_id;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
$part_id = '';
if (isset($_REQUEST['part_id'])) {
    $part_id = basename($_REQUEST['part_id']);
}
if ($part_id != '*') {
    $part_id = strtolower(basename($part_id));
    $part_id = normalize($part_id);
    $_REQUEST['part_id'] = $part_id;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
$resultText = '';
$fCount = 0;
$updateDone = FALSE;
$doPreview = FALSE;
$loc4msg = '';
if (isset($_REQUEST['posx'])) {
    $loc4msg = $_REQUEST['posx'];
}
$resultMsg = '';
if (isset($_REQUEST['msg'])) {
    $resultMsg = stripslashes(urldecode($_REQUEST['msg']));
}
Exemplo n.º 22
0
        break;
    case "all":
        $subselect = "";
        break;
    case "none":
    default:
        $noaccess = 1;
}
if ($noaccess) {
    print Error($GLOBALS['I18N']->get('No Access'));
    return;
}
if ($_POST["change"]) {
    if (!$_POST["id"]) {
        # new one
        Sql_Query(sprintf('insert into %s (namelc,created) values("%s",now())', $tables["admin"], strtolower(normalize($_POST["loginname"]))));
        $id = Sql_Insert_Id();
    } else {
        $id = $_POST["id"];
    }
    if ($id) {
        reset($struct);
        while (list($key, $val) = each($struct)) {
            list($a, $b) = explode(":", $val[1]);
            if ($a != "sys" && $val[1]) {
                Sql_Query("update {$tables["admin"]} set {$key} = \"" . $_POST[$key] . "\" where id = {$id}");
            }
        }
        if (is_array($_POST["attribute"])) {
            while (list($key, $val) = each($_POST["attribute"])) {
                Sql_Query(sprintf('replace into %s (adminid,adminattributeid,value)
Exemplo n.º 23
0
/**
 * Get pagelinks from the wiki text
 *
 * @author   Won-Kyu Park <*****@*****.**>
 */
function get_pagelinks($formatter, $text)
{
    // split into chunks
    $chunk = preg_split("/({{{\n                        (?:(?:[^{}]+|\n                        {[^{}]+}(?!})|\n                        (?<!{){{1,2}(?!{)|\n                        (?<!})}{1,2}(?!}))|(?1)\n                        )++}}})/x", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $inline = array();
    // save inline nowikis
    if (count($chunk) > 1) {
        // protect inline nowikis
        $nc = '';
        $k = 1;
        $idx = 1;
        foreach ($chunk as $c) {
            if ($k % 2) {
                $nc .= $c . ' ';
            }
            $k++;
        }
        $text = $nc;
    }
    // check wordrule
    if (empty($formatter->wordrule)) {
        $formatter->set_wordrule();
    }
    preg_match_all("/(" . $formatter->wordrule . ")/", $text, $match);
    $words = array();
    foreach ($match[0] as $k => $v) {
        if (preg_match('/^\\!/', $v)) {
            continue;
        }
        if (preg_match('/^\\?/', $v)) {
            $words[] = substr($v, 1);
        } else {
            if (preg_match('/^\\[?wiki:[^`\'\\{\\]\\^\\*\\(]/', $v) || !preg_match('/^\\[?' . $formatter->urls . ':/', $v)) {
                $extended = false;
                $creole = false;
                $word = rtrim($v, '`');
                // XXX
                if (preg_match('/^\\[\\[(.*)\\]\\]$/', $word, $m)) {
                    // MediaWiki/WikiCreole like links
                    $creole = true;
                    $word = $m[1];
                } else {
                    if (preg_match('/^\\[(.*)\\]$/', $word, $m)) {
                        $word = $m[1];
                    }
                }
                if (preg_match('/^(wiki:)?/', $word, $m)) {
                    if (!empty($m[1])) {
                        $word = substr($word, 5);
                    }
                    $word = ltrim($word);
                    // ltrim wikiwords
                    if (preg_match("/^\"([^\"]*)\"\\s?/", $word, $m1)) {
                        $extended = true;
                        $word = $m1[1];
                    } else {
                        if (!empty($m[1]) and ($p = strpos($word, " ")) !== false) {
                            $word = substr($word, 0, $p);
                        }
                    }
                } else {
                    if ($creole and ($p = strpos($word, '|')) !== false) {
                        $word = substr($word, 0, $p);
                    }
                }
                if (!$extended and empty($formatter->mediawiki_style) and strpos($word, " ") !== false) {
                    $word = normalize($word);
                }
                if (preg_match("/^([^\\(:]+)(\\((.*)\\))?\$/", $word, $m)) {
                    if (isset($m[1])) {
                        $name = $m[1];
                    } else {
                        $name = $word;
                    }
                    // check macro
                    $myname = getPlugin($name);
                    if (!empty($myname)) {
                        // this is macro
                        continue;
                    }
                }
                $word = strtok($word, '#?');
                // trim anchor tag
                $words[] = $word;
            }
        }
    }
    return array_values(array_unique($words));
}
Exemplo n.º 24
0
 $upKind = '';
 if (isset($_REQUEST['ext'])) {
     $upKind = $_REQUEST['ext'];
 }
 if ($upKind == 'txt') {
     $array_estensioni_ammesse = array_merge_recursive($array_estensioni_ammesse, $EXTENSION_TEXT);
 }
 if ($upKind == 'img') {
     $array_estensioni_ammesse = array_merge_recursive($array_estensioni_ammesse, $EXTENSION_GRAPHIC);
 }
 $ftp_path = DCTL_PROJECT_PATH;
 $pathToUpload0 = $_REQUEST['PATH'];
 foreach ($_FILES as $k => $v) {
     if ($v['size'] > 0) {
         $pathToUpload = $pathToUpload0;
         $fileNameUpload = strtolower(normalize($v['name']));
         $fileNameTemp = $v['tmp_name'];
         $dirToUpload = dirname($pathToUpload) . SYS_PATH_SEP;
         $dirToUpload = str_ireplace($ftp_path, '', $dirToUpload);
         $dirToUpload = str_ireplace('..', '', $dirToUpload);
         $dirToUpload = str_ireplace('.', '', $dirToUpload);
         $dirToUpload = str_ireplace(SYS_PATH_SEP, SYS_PATH_SEP, $dirToUpload);
         $dirToUpload = $ftp_path . $dirToUpload;
         $fileToUpload = basename($pathToUpload);
         $isMedia = $fileToUpload == basename(DCTL_MEDIA_BIG);
         $ext = explode('.', $fileNameUpload);
         $extToUpload = $ext[count($ext) - 1];
         if (in_array($extToUpload, $array_estensioni_ammesse)) {
             if (is_dir($dirToUpload)) {
                 if ($isMedia) {
                     $fileToUpload .= SYS_PATH_SEP;
Exemplo n.º 25
0
$files = glob($input . '/src/main/resources/rulesets/*.xml');
sort($files);
$index = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<index>' . PHP_EOL . '  <site index="true" display="false">' . PHP_EOL . '    <name>Index</name>' . PHP_EOL . '    <path>index.rst</path>' . PHP_EOL . '  </site>' . PHP_EOL;
foreach ($files as $file) {
    echo 'Processing: ', $file, PHP_EOL;
    $name = pathinfo($file, PATHINFO_FILENAME);
    $path = $output . '/' . $name . '.rst';
    $cmd = sprintf('xsltproc %s/pmd.xsl %s > %s', escapeshellarg(dirname(__FILE__)), escapeshellarg($file), escapeshellarg($path));
    shell_exec($cmd);
    $sxml = simplexml_load_file($file);
    $index .= '    <site>' . PHP_EOL . '        <name>' . $sxml['name'] . '</name>' . PHP_EOL . '        <path>' . $name . '.rst</path>' . PHP_EOL . '    </site>' . PHP_EOL;
    $rules = array();
    foreach ($sxml->rule as $rule) {
        $rules[] = array('name' => normalize($rule['name']), 'desc' => normalize($rule->description), 'href' => $name . '.html#' . strtolower($rule['name']));
    }
    $sets[] = array('name' => normalize($sxml['name']), 'desc' => normalize($sxml->description), 'rules' => $rules);
}
$index .= '</index>';
file_put_contents($output . '/index.rst', generate_index($sets));
file_put_contents($output . '/.index.xml', $index);
exit(0);
function normalize($elem)
{
    return preg_replace('(\\s+)s', ' ', trim((string) $elem));
}
function generate_index(array $sets)
{
    $content = '================' . PHP_EOL . 'Current Rulesets' . PHP_EOL . '================' . PHP_EOL . PHP_EOL . 'List of rulesets and rules contained in each ruleset.' . PHP_EOL . PHP_EOL;
    foreach ($sets as $set) {
        $content .= sprintf('- `%s`__: %s%s', $set['name'], $set['desc'], PHP_EOL);
    }
Exemplo n.º 26
0
/**
 * function download_headers($type, $name, $size, $force_download = false)
 */
function download_headers($name, $type, $size, $force_download = true)
{
    if ($force_download) {
        /** SAVR 10/20/06
         * Was:
         * header("Cache-Control: public");
         */
        header("Cache-Control: public, must-revalidate");
        header("Pragma: hack");
    } else {
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");
    }
    // if
    header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Content-Type: {$type}");
    header("Content-Length: {$size}");
    // Prepare disposition
    $disposition = $force_download ? 'attachment' : 'inline';
    // http://www.ietf.org/rfc/rfc2183.txt
    $download_name = strtr($name, " ()<>@,;:\\/[]?=*%'\"", '--------------------');
    $download_name = normalize($download_name);
    header("Content-Disposition: {$disposition}; filename=\"{$download_name}\"");
    //header("Content-Disposition: $disposition; filename=$download_name");
    header("Content-Transfer-Encoding: binary");
}
Exemplo n.º 27
0
function normalize($o)
{
    if (!is_array($o)) {
        return $o;
    }
    unset($o["count"]);
    $keys = array_keys($o);
    if (count(array_unique(array_map("is_int", $keys))) != 1) {
        $i = 0;
        while (isset($o[$i])) {
            unset($o[$i]);
            $i++;
        }
    }
    foreach ($o as &$e) {
        $e = normalize($e);
        if (is_array($e) && count($e) == 1) {
            $e = $e[0];
        }
    }
    return $o;
}
Exemplo n.º 28
0
 /**
  * Function: title_from_excerpt
  * Generates an acceptable Title from the post's excerpt.
  *
  * Returns:
  *     The post's excerpt. iltered -> first line -> ftags stripped -> truncated to 75 characters -> normalized.
  */
 public function title_from_excerpt()
 {
     if ($this->no_results) {
         return false;
     }
     # Excerpts are likely to have some sort of markup module applied to them;
     # if the current instantiation is not filtered, make one that is.
     $post = $this->filtered ? $this : new Post($this->id);
     $excerpt = $post->excerpt();
     Trigger::current()->filter($excerpt, "title_from_excerpt");
     $split_lines = explode("\n", $excerpt);
     $first_line = $split_lines[0];
     $stripped = strip_tags($first_line);
     # Strip all HTML
     $truncated = truncate($stripped, 75);
     # Truncate the excerpt to 75 characters
     $normalized = normalize($truncated);
     # Trim and normalize whitespace
     return $normalized;
 }
Exemplo n.º 29
0
         update_field('field_54999fdb96120', $weighted_value, get_the_ID());
         if (get_the_ID() == 428) {
             echo "Scores for Cyclopean Ultor<br/>";
             echo "Raw Attack Score: " . normalize((int) get_field('lord_atk'), $min_max['max_atk'], $min_max['min_atk']) . "<br/>";
             echo "Raw Defense Score: " . normalize((int) get_field('lord_def'), $min_max['max_def'], $min_max['min_def']) . "<br/>";
             echo "Raw HP Score: " . normalize((int) get_field('lord_hp'), $min_max['max_hp'], $min_max['min_hp']) . "<br/>";
             echo "Raw Recovery Score: " . normalize((int) get_field('lord_rec'), $min_max['max_rec'], $min_max['min_rec']) . "<br/>";
             echo "Raw Hit Count Score: " . normalize((int) get_field('hit_count'), $min_max['max_hit_count'], $min_max['min_hit_count']) . "<br/>";
             echo "Raw BB Hit Score: " . normalize((int) get_field('bb_hits'), $min_max['max_bb_hits'], $min_max['min_bb_hits']) . "<br/>";
             echo "Raw BB Fill Score: " . normalize((int) get_field('bb_fill'), $min_max['max_bb_fill'], $min_max['min_bb_fill'], true) . "<br/>";
             echo "Raw SBB Hit Score: " . normalize((int) get_field('sbb_hits'), $min_max['max_sbb_hits'], $min_max['min_sbb_hits']) . "<br/>";
             echo "Raw SBB Fill Score: " . normalize((int) get_field('sbb_fill'), $min_max['max_sbb_fill'], $min_max['min_sbb_fill'], true) . "<br/>";
             echo "Raw Votes Score: " . normalize((int) $votes, $min_max['max_votes'], $min_max['min_votes']) . "<br/>";
             echo "Weighted: " . $weighted_value . "<br/>";
             echo "Stat Score: " . (normalize((int) get_field('lord_atk'), $min_max['max_atk'], $min_max['min_atk']) * $ATK_WEIGHT + normalize((int) get_field('lord_def'), $min_max['max_def'], $min_max['min_def']) * $DEF_WEIGHT + normalize((int) get_field('lord_hp'), $min_max['max_hp'], $min_max['min_hp']) * $HP_WEIGHT + normalize((int) get_field('lord_rec'), $min_max['max_rec'], $min_max['min_rec']) * $REC_WEIGHT) * $STAT_WEIGHT . "<br/>";
             echo "Skill Score: " . (normalize((int) get_field('hit_count'), $min_max['max_hit_count'], $min_max['min_hit_count']) * $HIT_CNT_WEIGHT + normalize((int) get_field('bb_fill'), $min_max['max_bb_fill'], $min_max['min_bb_fill'], true) * $BB_FILL_WEIGHT + normalize((int) get_field('sbb_fill'), $min_max['max_sbb_fill'], $min_max['min_sbb_fill'], true) * $SBB_FILL_WEIGHT + normalize((int) get_field('bb_hits'), $min_max['max_bb_hits'], $min_max['min_bb_hits']) * $BB_HIT_WEIGHT + normalize((int) get_field('sbb_hits'), $min_max['max_sbb_hits'], $min_max['min_sbb_hits']) * $SBB_HIT_WEIGHT) * $SKILL_WEIGHT . "<br/>";
         }
     }
 }
 wp_reset_postdata();
 //Set the updated rank of the unit
 $args = array('post_type' => 'unit', 'meta_key' => 'weighted_value', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'posts_per_page' => -1);
 $units = new WP_Query($args);
 if ($units->have_posts()) {
     $rank = 1;
     $count = wp_count_posts('unit')->publish;
     while ($units->have_posts()) {
         $units->the_post();
         update_field('field_54999c5b9611c', $rank, get_the_ID());
         if ($rank / $count < 0.09) {
             $tier = "Godly Tier";
Exemplo n.º 30
0
        nv.utils.windowResize(chart.update);
        chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
        return chart;
    });
</script>



<script>
/*
	,{
            "key" : "Tweet count" ,
            "bar": true,
             "color": "#ccf",
            "values" : [ <?php 
printSentiment(3, normalize($nameRow['name']));
?>
]
        }
*/
   var testdata = [
        {
            "key" : "Positive" ,
            "bar": true,
             "color": "blue",
            "values" : [ <?php 
printSentiment(0, normalizeCaseSen($movieInfoRow['name']));
?>
]
        },
        {