Example #1
1
 /**
  * Truncates a string to the given length.  It will optionally preserve
  * HTML tags if $is_html is set to true.
  *
  * @param   string  $string        the string to truncate
  * @param   int     $limit         the number of characters to truncate too
  * @param   string  $continuation  the string to use to denote it was truncated
  * @param   bool    $is_html       whether the string has HTML
  * @return  string  the truncated string
  */
 public static function truncate($string, $limit, $continuation = '...', $is_html = false)
 {
     $offset = 0;
     $tags = array();
     if ($is_html) {
         // Handle special characters.
         preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] >= $limit) {
                 break;
             }
             $limit += static::length($match[0][0]) - 1;
         }
         // Handle all the html tags.
         preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] - $offset >= $limit) {
                 break;
             }
             $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1);
             if ($tag[0] != '/') {
                 $tags[] = $tag;
             } elseif (end($tags) == static::sub($tag, 1)) {
                 array_pop($tags);
             }
             $offset += $match[1][1] - $match[0][1];
         }
     }
     $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset));
     $new_string .= static::length($string) > $limit ? $continuation : '';
     $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
     return $new_string;
 }
Example #2
0
 public function createLinks()
 {
     $pager = $this->_getPager();
     $numPages = count($pager->getPages());
     $headBlock = Mage::app()->getLayout()->getBlock('head');
     $previousPageUrl = $pager->getPreviousPageUrl();
     $nextPageUrl = $pager->getNextPageUrl();
     if (Mage::helper('mstcore')->isModuleInstalled('Amasty_Shopby')) {
         $url = Mage::helper('core/url')->getCurrentUrl();
         $url = strtok($url, '?');
         $previousPageUrl = $url . '?p=' . ($pager->getCurrentPage() - 1);
         $nextPageUrl = $url . '?p=' . ($pager->getCurrentPage() + 1);
         if ($pager->getCurrentPage() == 2) {
             $previousPageUrl = $url;
         }
     }
     //we have html_entity_decode because somehow manento encodes '&'
     if (!$pager->isFirstPage() && !$pager->isLastPage() && $numPages > 2) {
         $headBlock->addLinkRel('prev', html_entity_decode($previousPageUrl));
         $headBlock->addLinkRel('next', html_entity_decode($nextPageUrl));
     } elseif ($pager->isFirstPage() && $numPages > 1) {
         $headBlock->addLinkRel('next', html_entity_decode($nextPageUrl));
     } elseif ($pager->isLastPage() && $numPages > 1) {
         $headBlock->addLinkRel('prev', html_entity_decode($previousPageUrl));
     }
     return $this;
 }
 function get_current_url($no_query_params = false)
 {
     global $post;
     $server_name_method = um_get_option('current_url_method') ? um_get_option('current_url_method') : 'SERVER_NAME';
     if (!isset($_SERVER['SERVER_NAME'])) {
         return '';
     }
     if (is_front_page()) {
         $page_url = home_url();
     } else {
         $page_url = 'http';
         if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
             $page_url .= "s";
         }
         $page_url .= "://";
         if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
             $page_url .= $_SERVER[$server_name_method] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
         } else {
             $page_url .= $_SERVER[$server_name_method] . $_SERVER["REQUEST_URI"];
         }
     }
     if ($no_query_params == true) {
         $page_url = strtok($page_url, '?');
     }
     return apply_filters('um_get_current_page_url', $page_url);
 }
Example #4
0
 function get_current_url($no_query_params = false)
 {
     global $post;
     $um_get_option = get_option('um_options');
     $server_name_method = $um_get_option['current_url_method'] ? $um_get_option['current_url_method'] : 'SERVER_NAME';
     $um_port_forwarding_url = isset($um_get_option['um_port_forwarding_url']) ? $um_get_option['um_port_forwarding_url'] : '';
     if (!isset($_SERVER['SERVER_NAME'])) {
         return '';
     }
     if (is_front_page()) {
         $page_url = home_url();
         if (isset($_SERVER['QUERY_STRING']) && trim($_SERVER['QUERY_STRING'])) {
             $page_url .= '?' . $_SERVER['QUERY_STRING'];
         }
     } else {
         $page_url = 'http';
         if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
             $page_url .= "s";
         }
         $page_url .= "://";
         if ($um_port_forwarding_url == 1 && isset($_SERVER["SERVER_PORT"])) {
             $page_url .= $_SERVER[$server_name_method] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
         } else {
             $page_url .= $_SERVER[$server_name_method] . $_SERVER["REQUEST_URI"];
         }
     }
     if ($no_query_params == true) {
         $page_url = strtok($page_url, '?');
     }
     return apply_filters('um_get_current_page_url', $page_url);
 }
Example #5
0
 function writeDbDeleteCheck($sql)
 {
     if (getUserConfig('dbsynchron') != "") {
         //check for delete items to play on sync
         if (substr($sql, 0, 12) == "delete from ") {
             $table = trim(strtok(substr($sql, 12), " "));
             if ($table != "junk_items") {
                 $where = strtok(" ");
                 $where = strtok("");
                 $del = create_db_connection();
                 $del->openselect("select id from " . $table . " where " . $where);
                 $delids = "";
                 while (!$del->eof()) {
                     if ($delids != "") {
                         $delids .= ",";
                     }
                     $delids .= $del->getvalue("id");
                     $del->movenext();
                 }
                 $del = create_db_connection();
                 $del->addnew("junk_items");
                 $del->setvalue("fromtable", $table);
                 $del->setvalue("delid", $delids);
                 $del->setvalue("operation", 3);
                 $del->update();
             }
         }
     }
 }
Example #6
0
 private static function strip_attributes_recursive($node, $bad_attributes, $bad_protocols)
 {
     if ($node->nodeType !== XML_ELEMENT_NODE) {
         return;
     }
     if ($node->hasAttributes()) {
         foreach ($node->attributes as $attribute) {
             $attribute_name = strtolower($attribute->name);
             if (in_array($attribute_name, $bad_attributes)) {
                 $node->removeAttribute($attribute_name);
                 continue;
             }
             // on* attributes (like onclick) are a special case
             if (0 === stripos($attribute_name, 'on')) {
                 $node->removeAttribute($attribute_name);
                 continue;
             }
             if ('href' === $attribute_name) {
                 $protocol = strtok($attribute->value, ':');
                 if (in_array($protocol, $bad_protocols)) {
                     $node->removeAttribute($attribute_name);
                     continue;
                 }
             }
         }
     }
     foreach ($node->childNodes as $child_node) {
         self::strip_attributes_recursive($child_node, $bad_attributes, $bad_protocols);
     }
 }
Example #7
0
 /**
  * Get the SQL for a "comment" column modifier.
  *
  * @param \Illuminate\Database\Schema\Blueprint  $blueprint
  * @param \Illuminate\Support\Fluent             $column
  * @return string|null
  */
 protected function modifyCollate(IlluminateBlueprint $blueprint, Fluent $column)
 {
     if (!is_null($column->collate)) {
         $characterSet = strtok($column->collate, '_');
         return " character set {$characterSet} collate {$column->collate}";
     }
 }
function phpwhois_cidr_conv($net)
{
    $start = strtok($net, '/');
    $n = 3 - substr_count($net, '.');
    if ($n > 0) {
        for ($i = $n; $i > 0; $i--) {
            $start .= '.0';
        }
    }
    $bits1 = str_pad(decbin(ip2long($start)), 32, '0', 'STR_PAD_LEFT');
    $net = pow(2, 32 - substr(strstr($net, '/'), 1)) - 1;
    $bits2 = str_pad(decbin($net), 32, '0', 'STR_PAD_LEFT');
    $final = '';
    for ($i = 0; $i < 32; $i++) {
        if ($bits1[$i] == $bits2[$i]) {
            $final .= $bits1[$i];
        }
        if ($bits1[$i] == 1 and $bits2[$i] == 0) {
            $final .= $bits1[$i];
        }
        if ($bits1[$i] == 0 and $bits2[$i] == 1) {
            $final .= $bits2[$i];
        }
    }
    return $start . " - " . long2ip(bindec($final));
}
Example #9
0
 /**
  * функция определяет ip адрес по глобальному массиву $_SERVER
  * ip адреса проверяются начиная с приоритетного, для определения возможного использования прокси
  * @return ip-адрес
  */
 protected function get_ip()
 {
     $ip = false;
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ipa[] = trim(strtok($_SERVER['HTTP_X_FORWARDED_FOR'], ','));
     }
     if (isset($_SERVER['HTTP_CLIENT_IP'])) {
         $ipa[] = $_SERVER['HTTP_CLIENT_IP'];
     }
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $ipa[] = $_SERVER['REMOTE_ADDR'];
     }
     if (isset($_SERVER['HTTP_X_REAL_IP'])) {
         $ipa[] = $_SERVER['HTTP_X_REAL_IP'];
     }
     // проверяем ip-адреса на валидность начиная с приоритетного.
     foreach ($ipa as $ips) {
         //  если ip валидный обрываем цикл, назначаем ip адрес и возвращаем его
         if ($this->is_valid_ip($ips)) {
             $ip = $ips;
             break;
         }
     }
     return $ip;
 }
Example #10
0
/**
 * The requested URL path.
 *
 * @return string
 */
function current_path()
{
    static $path;
    if (isset($path)) {
        return $path;
    }
    if (isset($_SERVER['REQUEST_URI'])) {
        // This request is either a clean URL, or 'index.php', or nonsense.
        // Extract the path from REQUEST_URI.
        $request_path = strtok($_SERVER['REQUEST_URI'], '?');
        $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\\/'));
        // Unescape and strip $base_path prefix, leaving q without a leading slash.
        $path = substr(urldecode($request_path), $base_path_len + 1);
        // If the path equals the script filename, either because 'index.php' was
        // explicitly provided in the URL, or because the server added it to
        // $_SERVER['REQUEST_URI'] even when it wasn't provided in the URL (some
        // versions of Microsoft IIS do this), the front page should be served.
        if ($path == basename($_SERVER['PHP_SELF'])) {
            $path = '';
        }
    } else {
        // This is the front page.
        $path = '';
    }
    // Under certain conditions Apache's RewriteRule directive prepends the value
    // assigned to $_GET['q'] with a slash. Moreover we can always have a trailing
    // slash in place, hence we need to normalize $_GET['q'].
    $path = trim($path, '/');
    return $path;
}
function tie_vedio()
{
    global $post, $tie_blog;
    $get_meta = get_post_custom($post->ID);
    if (!empty($get_meta["tie_video_self_url"][0])) {
        echo do_shortcode('[video src="' . $get_meta["tie_video_self_url"][0] . '"][/video]');
    } elseif (isset($get_meta["tie_video_url"][0]) && !empty($get_meta["tie_video_url"][0])) {
        $video_url = $get_meta["tie_video_url"][0];
        $video_link = @parse_url($video_url);
        if ($video_link['host'] == 'www.youtube.com' || $video_link['host'] == 'youtube.com') {
            parse_str(@parse_url($video_url, PHP_URL_QUERY), $my_array_of_vars);
            $video = $my_array_of_vars['v'];
            $video_code = '<iframe width="600" height="325" src="http://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>';
        } elseif ($video_link['host'] == 'www.vimeo.com' || $video_link['host'] == 'vimeo.com') {
            $video = (int) substr(@parse_url($video_url, PHP_URL_PATH), 1);
            $video_code = '<iframe width="600" height="325" src="http://player.vimeo.com/video/' . $video . '" width="' . $width . '" height="' . $height . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
        } elseif ($video_link['host'] == 'www.youtu.be' || $video_link['host'] == 'youtu.be') {
            $video = substr(@parse_url($video_url, PHP_URL_PATH), 1);
            $video_code = '<iframe width="600" height="325" src="http://www.youtube.com/embed/' . $video . '?rel=0" frameborder="0" allowfullscreen></iframe>';
        } elseif ($video_link['host'] == 'www.dailymotion.com' || $video_link['host'] == 'dailymotion.com') {
            $video = substr(@parse_url($video_url, PHP_URL_PATH), 7);
            $video_id = strtok($video, '_');
            $video_code = '<iframe frameborder="0" width="600" height="325" src="http://www.dailymotion.com/embed/video/' . $video_id . '"></iframe>';
        }
    } elseif (isset($get_meta["tie_embed_code"][0])) {
        $embed_code = $get_meta["tie_embed_code"][0];
        $video_code = htmlspecialchars_decode($embed_code);
    }
    if (isset($video_code)) {
        echo $video_code;
    }
}
Example #12
0
 public function SampleFunction($a, $b = NULL)
 {
     if ($a === $b) {
         bar();
     } elseif ($a > $b) {
         $foo->bar($arg1);
     } else {
         BazClass::bar($arg2, $arg3);
     }
     if (!$b) {
         echo $c;
     }
     if (!strtok($b)) {
         echo $d;
     }
     if (!isset($b)) {
         echo $d;
     }
     if (!($var === $b)) {
         echo $c;
     }
     $variable_name = 'foo';
     $_fn = function () {
     };
 }
Example #13
0
 function JDtoYMD($date, &$year, &$month, &$day)
 {
     $string = JDToGregorian($date);
     $month = strtok($string, " -/");
     $day = strtok(" -/");
     $year = strtok(" -/");
 }
Example #14
0
 /**
  * Tests the mapping of fields.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to test.
  *
  * @return string
  *   The view rendered as HTML.
  */
 protected function mappedOutputHelper($view)
 {
     $output = $view->preview();
     $rendered_output = \Drupal::service('renderer')->renderRoot($output);
     $this->storeViewPreview($rendered_output);
     $rows = $this->elements->body->div->div->div;
     $data_set = $this->dataSet();
     $count = 0;
     foreach ($rows as $row) {
         $attributes = $row->attributes();
         $class = (string) $attributes['class'][0];
         $this->assertTrue(strpos($class, 'views-row-mapping-test') !== FALSE, 'Make sure that each row has the correct CSS class.');
         foreach ($row->div as $field) {
             // Split up the field-level class, the first part is the mapping name
             // and the second is the field ID.
             $field_attributes = $field->attributes();
             $name = strtok((string) $field_attributes['class'][0], '-');
             $field_id = strtok('-');
             // The expected result is the mapping name and the field value,
             // separated by ':'.
             $expected_result = $name . ':' . $data_set[$count][$field_id];
             $actual_result = (string) $field;
             $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
         }
         $count++;
     }
     return $rendered_output;
 }
Example #15
0
 /**
  * generate docs
  */
 public function docs()
 {
     $docs = [];
     foreach (get_declared_classes() as $task) {
         if (!preg_match('~Robo\\\\Task.*?Task$~', $task)) {
             continue;
         }
         $docs[basename((new ReflectionClass($task))->getFileName(), '.php')][] = $task;
     }
     ksort($docs);
     $taskGenerator = $this->taskGenDoc('docs/tasks.md')->filterClasses(function (\ReflectionClass $r) {
         return !$r->isAbstract() or $r->isTrait();
     })->prepend("# Tasks");
     foreach ($docs as $file => $classes) {
         $taskGenerator->docClass("Robo\\Task\\{$file}");
         foreach ($classes as $task) {
             $taskGenerator->docClass($task);
         }
     }
     $taskGenerator->filterMethods(function (\ReflectionMethod $m) {
         if ($m->isConstructor() or $m->isDestructor() or $m->isStatic()) {
             return false;
         }
         return !in_array($m->name, ['run', '', '__call', 'getCommand']) and $m->isPublic();
         // methods are not documented
     })->processClassSignature(function ($c) {
         return "## " . preg_replace('~Task$~', '', $c->getShortName()) . "\n";
     })->processClassDocBlock(function ($c, $doc) {
         return preg_replace('~@method .*?\\wTask (.*?)\\)~', '* `$1)` ', $doc);
     })->processMethodSignature(function (\ReflectionMethod $m, $text) {
         return str_replace('#### *public* ', '* `', $text) . '`';
     })->processMethodDocBlock(function (\ReflectionMethod $m, $text) {
         return $text ? ' ' . strtok($text, "\n") : '';
     })->run();
 }
Example #16
0
function postfilter_abbr($formatter, $value, $options)
{
    global $DBInfo;
    $abbrs = array();
    if (!$DBInfo->local_abbr or !$DBInfo->hasPage($DBInfo->local_abbr)) {
        return $value;
    }
    $p = $DBInfo->getPage($DBInfo->local_abbr);
    $raw = $p->get_raw_body();
    $lines = explode("\n", $raw);
    foreach ($lines as $line) {
        $line = trim($line);
        if ($line[0] == '#' or $line == '') {
            continue;
        }
        $word = strtok($line, ' ');
        $abbrs[$word] = strtok('');
    }
    $dict = new SimpleDict($abbrs);
    $rule = implode('|', array_keys($abbrs));
    $chunks = preg_split('/(<[^>]*>)/', $value, -1, PREG_SPLIT_DELIM_CAPTURE);
    for ($i = 0, $sz = count($chunks); $i < $sz; $i++) {
        if ($chunks[$i][0] == '<') {
            continue;
        }
        $dumm = preg_replace_callback('/\\b(' . $rule . ')\\b/', array($dict, 'get'), $chunks[$i]);
        $chunks[$i] = $dumm;
    }
    return implode('', $chunks);
}
Example #17
0
function preXml($xml)
{
    $xml = preg_replace('/(>)(<)(\\/*)/', "\$1\n\$2\$3", $xml);
    $token = strtok($xml, "\n");
    $result = '';
    // holds formatted version as it is built
    $pad = 0;
    // initial indent
    $matches = array();
    // returns from preg_matches()
    while ($token !== false) {
        if (preg_match('/.+<\\/\\w[^>]*>$/', $token, $matches)) {
            $indent = 0;
        } elseif (preg_match('/^<\\/\\w/', $token, $matches)) {
            $pad -= 4;
        } elseif (preg_match('/^<\\w[^>]*[^\\/]>.*$/', $token, $matches)) {
            $indent = 4;
        } else {
            $indent = 0;
        }
        $line = str_pad($token, strlen($token) + $pad, ' ', STR_PAD_LEFT);
        $result .= $line . "\n";
        $token = strtok("\n");
        $pad += $indent;
    }
    return htmlspecialchars($result);
}
Example #18
0
function &tree($treeStr)
{
    $treeTok = strtok($treeStr, ", ");
    if (!$treeTok || $treeTok == "#") {
        return array();
    }
    $root = treeNode($treeTok, null);
    $result = array(&$root);
    $queue = array(&$root);
    while (count($queue) != 0) {
        $parent =& $queue[0];
        array_shift($queue);
        $treeTok = strtok(", ");
        if ($treeTok && $treeTok != "#") {
            unset($node);
            $node = treeNode($treeTok, $parent["name"]);
            $queue[] =& $node;
            $parent["children"][] =& $node;
        }
        $treeTok = strtok(", ");
        if ($treeTok && $treeTok != "#") {
            unset($node);
            $node = treeNode($treeTok, $parent["name"]);
            $queue[] =& $node;
            $parent["children"][] =& $node;
        }
    }
    return $result;
}
Example #19
0
function ewiki_auth_query_http(&$data, $force_query = 0)
{
    global $ewiki_plugins, $ewiki_errmsg, $ewiki_author, $ewiki_ring;
    #-- fetch user:password
    if ($uu = trim($_SERVER["HTTP_AUTHORIZATION"])) {
        $auth_method = strtolower(strtok($uu, " "));
        if ($auth_method == "basic") {
            $uu = strtok(" ;,");
            $uu = base64_decode($uu);
            list($_a_u, $_a_p) = explode(":", $uu, 2);
        } else {
            #-- invalid response, ignore
        }
    } elseif (strlen($_a_u = trim($_SERVER["PHP_AUTH_USER"]))) {
        $_a_p = trim($_SERVER["PHP_AUTH_PW"]);
    }
    #-- check password
    $_success = ewiki_auth_user($_a_u, $_a_p);
    #-- request HTTP Basic authentication otherwise
    if (!$_success && $force_query || $force_query >= 2) {
        $realm = ewiki_t("RESTRICTED_ACCESS");
        $addmethod = "";
        if ($uu = $ewiki_config["login_notice"]) {
            $realm .= " " . $uu;
        }
        if ($uu = $ewiki_config["http_auth_add"]) {
            $addmethod = ", {$uu} realm=\"{$realm}\"";
        }
        header('HTTP/1.1 401 Authentication Required');
        header('Status: 401 Authentication Required');
        header('WWW-Authenticate: Basic realm="' . $realm . '"' . $addmethod);
    }
    #-- fin
    return $_success;
}
Example #20
0
function bible_verses($scriptures)
{
    $links = '';
    $scriptures = explode(';', $scriptures);
    foreach ($scriptures as $bookRefs) {
        $bookRefs = trim($bookRefs);
        // Genesis 1:26-28, 2:15-25, 3:1-20
        $temp = preg_match('/^([0-9]\\s)?[a-zA-Z]+\\s/', $bookRefs, $parts, PREG_OFFSET_CAPTURE);
        // Genesis OR 1 Kings
        $book = trim($parts[0][0]);
        $refs = explode(',', str_replace(' ', '', preg_replace('/^([0-9]\\s)?[a-zA-Z]+\\s/', '', $bookRefs)));
        // [1:26-28,2:15-25,3:1-20]
        $book_names = ['Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua', 'Judges', 'Ruth', '1 Samuel', '2 Samuel', '1 Kings', '2 Kings', '1 Chronicles', '2 Chronicles', 'Ezra', 'Nehemiah', 'Esther', 'Job', 'Psalm', 'Proverbs', 'Ecclesiastes', 'Song of Solomon', 'Isaiah', 'Jeremiah', 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos', 'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah', 'Malachi', 'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians', '2 Corinthians', 'Galatians', 'Ephesians', 'Philippians', 'Colossians', '1 Thessalonians', '2 Thessalonians', '1 Timothy', '2 Timothy', 'Titus', 'Philemon', 'Hebrews', 'James', '1 Peter', '2 Peter', '1 John', '2 John', '3 John', 'Jude', 'Revelation'];
        $book_abbreviations = ['Gen', 'Exod', 'Lev', 'Num', 'Deut', 'Josh', 'Judg', 'Ruth', '1Sam', '2Sam', '1Kgs', '2Kgs', '1Chr', '2Chr', 'Ezra', 'Neh', 'Esth', 'Job', 'Ps', 'Prov', 'Eccl', 'Song', 'Isa', 'Jer', 'Lam', 'Ezek', 'Dan', 'Hos', 'Joel', 'Amos', 'Obad', 'Jonah', 'Mic', 'Nah', 'Hab', 'Zeph', 'Hag', 'Zech', 'Mal', 'Matt', 'Mark', 'Luke', 'John', 'Acts', 'Rom', '1Cor', '2Cor', 'Gal', 'Eph', 'Phil', 'Col', '1Thess', '2Thess', '1Tim', '2Tim', 'Titus', 'Phlm', 'Heb', 'Jas', '1Pet', '2Pet', '1John', '2John', '3John', 'Jude', 'Rev'];
        $book_abbrev = $book_abbreviations[array_search($book, $book_names)];
        foreach ($refs as $key => $ref) {
            // $ref = 1:26-28
            if (strpos($ref, ':')) {
                $chapter = strtok($ref, ':');
                // 1
            }
            $verse = substr(strstr($ref, ':'), 1);
            // 26-28
            $links[] = '<a class="BibleRef" href="https://www.bible.com/bible/100/' . $book_abbrev . '.' . $chapter . '.' . $verse . '" target="_blank">' . ($key === 0 ? $book_abbrev . ' ' : '') . $chapter . ':' . $verse . '</a>';
        }
    }
    return implode(', ', $links);
}
Example #21
0
 public function set_route($route)
 {
     $route = strtok($route, '?');
     $route = explode('/', $route);
     array_shift($route);
     $this->route = $route;
 }
 static function issues_handler()
 {
     if (strtok($_SERVER["REQUEST_URI"], '?') == '/issues') {
         load_template(plugin_dir_path(__FILE__) . 'page-issues.php');
         exit;
     }
 }
 /**
  * Gets a portable column definition.
  *
  * The database type is mapped to a corresponding Doctrine mapping type.
  *
  * @param $tableColumn
  * @return array
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
     $dbType = strtolower($tableColumn['type']);
     $dbType = strtok($dbType, '(), ');
     if (isset($tableColumn['length'])) {
         $length = $tableColumn['length'];
         $decimal = '';
     } else {
         $length = strtok('(), ');
         $decimal = strtok('(), ') ? strtok('(), ') : null;
     }
     $type = array();
     $unsigned = $fixed = null;
     if (!isset($tableColumn['name'])) {
         $tableColumn['name'] = '';
     }
     $scale = null;
     $precision = null;
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
     $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
     switch ($dbType) {
         case 'char':
             $fixed = true;
             break;
         case 'float':
         case 'double':
         case 'real':
         case 'numeric':
         case 'decimal':
             if (preg_match('([A-Za-z]+\\(([0-9]+)\\,([0-9]+)\\))', $tableColumn['type'], $match)) {
                 $precision = $match[1];
                 $scale = $match[2];
                 $length = null;
             }
             break;
         case 'tinyint':
         case 'smallint':
         case 'mediumint':
         case 'int':
         case 'integer':
         case 'bigint':
         case 'tinyblob':
         case 'mediumblob':
         case 'longblob':
         case 'blob':
         case 'year':
             $length = null;
             break;
     }
     $length = (int) $length == 0 ? null : (int) $length;
     $def = array('type' => $type, 'length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => (bool) $fixed);
     $options = array('length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => (bool) $fixed, 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, 'notnull' => (bool) ($tableColumn['null'] != 'YES'), 'scale' => null, 'precision' => null, 'autoincrement' => (bool) (strpos($tableColumn['extra'], 'auto_increment') !== false), 'comment' => isset($tableColumn['comment']) ? $tableColumn['comment'] : null);
     if ($scale !== null && $precision !== null) {
         $options['scale'] = $scale;
         $options['precision'] = $precision;
     }
     return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
 }
Example #24
0
 public function processPackage($package)
 {
     if ($package instanceof AliasPackage || isset($this->matches[$package->getName()])) {
         return;
     }
     foreach ($this->tokens as $token) {
         if (!($score = $this->matchPackage($package, $token))) {
             continue;
         }
         if (false !== ($pos = stripos($package->getName(), $token))) {
             $name = substr($package->getPrettyName(), 0, $pos) . '<highlight>' . substr($package->getPrettyName(), $pos, strlen($token)) . '</highlight>' . substr($package->getPrettyName(), $pos + strlen($token));
         } else {
             $name = $package->getPrettyName();
         }
         $description = strtok($package->getDescription(), "\r\n");
         if (false !== ($pos = stripos($description, $token))) {
             $description = substr($description, 0, $pos) . '<highlight>' . substr($description, $pos, strlen($token)) . '</highlight>' . substr($description, $pos + strlen($token));
         }
         if ($score >= 3) {
             $this->output->writeln($name . '<comment>:</comment> ' . $description);
             $this->matches[$package->getName()] = true;
         } else {
             $this->lowMatches[$package->getName()] = array('name' => $name, 'description' => $description);
         }
         return;
     }
 }
 public function index()
 {
     $filename = "s.pdf";
     $content = shell_exec('pdftotext -raw ' . $filename . ' -');
     $separator = "\r\n";
     $line = strtok($content, $separator);
     $i = 0;
     $j = 0;
     while ($line !== false) {
         $i++;
         if ($line == 'Issue') {
             $j++;
             $data = new stdClass();
             $data->muhasil = strtok($separator);
             $data->jumlah = strtok($separator);
             $data->no_m1 = strtok($separator);
             $data->periode = strtok($separator);
             $data->nama = strtok($separator);
             $data->aims = strtok($separator);
             list($data->tanggal, $data->metode) = explode(' ', strtok($separator));
             while (($line = strtok($separator)) != 'Issue' && ord($line[0]) != 12) {
                 $data->rincian[] = $line;
             }
             var_dump($data);
             echo '<br/>------------------------------------<br/>';
         } else {
             $line = strtok($separator);
         }
     }
 }
 public function process()
 {
     $configuracao = Doctrine::getTable('Configuracao')->find(1);
     $this->document->pages[] = $page = $this->document->newPage(\Zend_Pdf_Page::SIZE_A4);
     //monta o cabecalho
     $color = array();
     $color["black"] = new Zend_Pdf_Color_Html("#000000");
     $fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $size = 12;
     $styleTitle = new Zend_Pdf_Style();
     $styleTitle->setFont($fontTitle, $size);
     $styleTitle->setFillColor($color["black"]);
     $page->setStyle($styleTitle);
     $page->drawText($configuracao->instituicao, Documento::DOCUMENT_LEFT, Documento::DOCUMENT_TOP, 'UTF-8');
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style = new Zend_Pdf_Style();
     $style->setFont($font, $size);
     $style->setFillColor($color["black"]);
     $page->setStyle($style);
     $text = wordwrap($this->text, 95, "\n", false);
     $token = strtok($text, "\n");
     $y = 665;
     while ($token != false) {
         if ($y < 100) {
             $this->document->pages[] = $page = $this->document->newPage(Zend_Pdf_Page::SIZE_A4);
             $page->setStyle($style);
             $y = 665;
         } else {
             $y -= 15;
         }
         $page->drawText($token, 60, $y, 'UTF-8');
         $token = strtok("\n");
     }
 }
Example #27
0
 /**
  * Minimizes the given URL to a maximum length
  *
  * @param string $url the url
  * @param int|null $max the maximum length
  * @param array $options
  * - placeholder
  * @return string the manipulated url (+ eventuell ...)
  */
 public function minimizeUrl($url, $max = null, array $options = [])
 {
     // check if there is nothing to do
     if (empty($url) || mb_strlen($url) <= (int) $max) {
         return $url;
     }
     // http:// etc has not to be displayed, so
     $url = $this->stripProtocol($url);
     // cut the parameters
     if (mb_strpos($url, '/') !== false) {
         $url = strtok($url, '/');
     }
     // return if the url is short enough
     if (mb_strlen($url) <= (int) $max) {
         return $url;
     }
     // otherwise cut a part in the middle (but only if long enough!)
     // TODO: more dynamically
     $placeholder = CHAR_HELLIP;
     if (!empty($options['placeholder'])) {
         $placeholder = $options['placeholder'];
     }
     $end = mb_substr($url, -5, 5);
     $front = mb_substr($url, 0, (int) $max - 8);
     return $front . $placeholder . $end;
 }
Example #28
0
/**
 * Set of functions used with the relation and pdf feature
 */
function PMA_transformation_getOptions($string)
{
    $transform_options = array();
    /* Parse options */
    for ($nextToken = strtok($string, ','); $nextToken !== false; $nextToken = strtok(',')) {
        $trimmed = trim($nextToken);
        if ($trimmed[0] == '\'' && $trimmed[strlen($trimmed) - 1] == '\'') {
            $transform_options[] = substr($trimmed, 1, -1);
        } else {
            if ($trimmed[0] == '\'') {
                $trimmed = ltrim($nextToken);
                while ($nextToken !== false) {
                    $nextToken = strtok(',');
                    $trimmed .= $nextToken;
                    $rtrimmed = rtrim($trimmed);
                    if ($rtrimmed[strlen($rtrimmed) - 1] == '\'') {
                        break;
                    }
                }
                $transform_options[] = substr($rtrimmed, 1, -1);
            } else {
                $transform_options[] = $nextToken;
            }
        }
    }
    // strip possible slashes to behave like documentation says
    $result = array();
    foreach ($transform_options as $val) {
        $result[] = stripslashes($val);
    }
    return $result;
}
Example #29
0
function WordIntoDB($url, $fileID, $db)
{
    $path = $url;
    $fp = fopen($path, 'r');
    $contents = stream_get_contents($fp);
    $contents = strip_tags($contents);
    $contents = strtolower($contents);
    $i = 0;
    $sep = " \n\t\"\\'!,.()''\"~!@#\$%^&*(),./<>\\+_=-|?;:[]{}`бу^1234567890";
    $acontents[$i++] = trim(strtok($contents, $sep));
    while ($token = strtok($sep)) {
        $acontents[$i++] = trim($token);
    }
    $count = array_count_values($acontents);
    ksort($count);
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
    }
    foreach ($count as $row => $times) {
        //echo $row."=>".$times."<br>";
        $word_id = $db->InsertWord($row);
        $db->InsertFileWords($fileID, $word_id, $times);
    }
    fclose($fp);
}
 /**
  * Gets the mime type for a blob
  *
  * @param GitPHP_Blob $blob blob
  * @return string mime type
  */
 public function GetMime($blob)
 {
     if (!$blob) {
         return false;
     }
     $data = $blob->GetData();
     if (empty($data)) {
         return false;
     }
     $descspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'));
     $proc = proc_open('file -b --mime -', $descspec, $pipes);
     if (is_resource($proc)) {
         fwrite($pipes[0], $data);
         fclose($pipes[0]);
         $mime = stream_get_contents($pipes[1]);
         fclose($pipes[1]);
         proc_close($proc);
         if ($mime && strpos($mime, '/')) {
             if (strpos($mime, ';')) {
                 $mime = strtok($mime, ';');
             }
             return $mime;
         }
     }
     return false;
 }