コード例 #1
0
ファイル: cog_variants.php プロジェクト: sdrinf/cog
 function get()
 {
     global $g_mv_tests, $g_log_id;
     if (isset($_SESSION["_mv_" . $this->test])) {
         return $_SESSION["_mv_" . $this->test]["var"];
     }
     if (beginsWith($this->test, "man")) {
         return 0;
     }
     $r = array_filter($g_mv_tests, function ($c) {
         return $c["test"] == $this->test && $c["goal"] == $this->goal;
     });
     // reindex array
     $r = array_values($r);
     if (count($r) == 0) {
         internal_error("No variants found for test: " . $this->test . " ,goal: " . $this->goal);
     }
     if ($r[0]["completed"] != null) {
         $res = $r[0];
     } else {
         // assign the user randomly
         shuffle($r);
         $res = $r[0];
     }
     $_SESSION["_mv_" . $this->test] = ["var" => $res["variation"], "start_log_id" => $g_log_id];
     return $res["variation"];
 }
コード例 #2
0
 private function getContent($url)
 {
     if (beginsWith(URL\takeDomain($url), 'blockchain.info') && beginsWith(URL\takePath($url), '/q/addressbalance/')) {
         return $this->addressBalanceRequest(withoutPrefix(URL\takePath($url), '/q/addressbalance/'));
     } else {
         if ($url == 'http://blockchain.info/q/addressbalance/peanuts') {
             return 'Checksum does not validate';
         } else {
             if (beginsWith($url, 'http://blockchain.info/tobtc?currency=USD')) {
                 return '0.00778083';
             } else {
                 if ($url == 'http://api.easyjquery.com/ips/?ip=99.99.99.99') {
                     return '{"Country": "US"}';
                 } else {
                     if ($url == 'https://freegeoip.net/json/99.99.99.99') {
                         return '{"ip":"99.99.99.99","country_code":"US","country_name":"United States",' . '"region_code":"","region_name":"","city":"","zipcode":"","latitude":38,' . '"longitude":-97,"metro_code":"","areacode":""}';
                     } else {
                         if ($url == 'https://freegeoip.net/json/175.156.249.231') {
                             return "404 page not found";
                         } else {
                             throw new Exception("Mock 'get' function couldn't handle following URL: {$url}");
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 public function add_js($file, $module_name)
 {
     if (beginsWith($file, 'http://') || beginsWith($file, 'https://') || beginsWith($file, '//')) {
         $this->js[] = $file;
     } else {
         $this->js[] = get_url('/' . PATH_TO_MODULES . '/' . $module_name . '/' . $file);
     }
 }
コード例 #4
0
ファイル: cog_webhandler.php プロジェクト: sdrinf/cog
 function map($url)
 {
     foreach ($this->urlmaps as $k => $v) {
         // add regex prefix, and suffix
         if (!beginsWith($k, "^")) {
             $k = "^" . $k;
         }
         if (!endsWith($k, "\$")) {
             $k = $k . "\$";
         }
         if (ereg($k, $url, $this->regparams)) {
             return $v;
         }
     }
     return null;
 }
コード例 #5
0
 public function load($db_row = array())
 {
     if (!empty($db_row)) {
         $this->id = $db_row['id'];
         return $this->load_from_id($db_row);
     }
     if (is_int((int) $this->id) && (int) $this->id > 0) {
         $this->id = (int) $this->id;
         return $this->load_from_id();
     } else {
         if (beginsWith($this->id, 'http')) {
             return $this->load_from_url();
         } else {
             return $this->load_from_name();
         }
     }
 }
コード例 #6
0
 function testSignupProcess()
 {
     $this->createHomepageWidgets();
     $this->get('/');
     $this->clickLink("//a[contains(@href, 'signup')]");
     $this->get('/account/signup');
     $this->followRedirects(true);
     $this->submitForm($this->getForm(), array('username' => 'sammy', 'email' => '*****@*****.**', 'password1' => 'luckystars', 'password2' => 'luckystars', 'memorydealers-updates' => 'on'));
     $u = User::loadFromUsername('sammy');
     assertEqual('*****@*****.**', $u->email);
     $subscriptions = current(DB\simpleSelect('subscriptions', 'user_id = ?', array($u->id)));
     assertFalse(empty($subscriptions), 'Expected to find record in subscriptions table for user');
     assertTrue($subscriptions['chipin'] == false || $subscriptions['chipin'] == 0);
     assertTrue($subscriptions['memorydealers'] == true || $subscriptions['memorydealers'] == 1);
     $this->logout();
     $this->login('sammy', 'luckystars');
     $this->get('/dashboard/');
     assertTrue(beginsWith($this->getCurrentPath(), '/dashboard'));
 }
コード例 #7
0
function getBalanceInSatoshis($address)
{
    $client = new HttpClient();
    $response = $client->get(balanceLookupURL($address));
    if ($response->statusCode == 200 && isInteger($response->content)) {
        return intval($response->content);
    } else {
        $e = strtolower($response->content);
        preg_match('@<title>(.*)</title>@', $response->content, $matches);
        $title = at($matches, 1);
        if ($e == 'checksum does not validate' || beginsWith($e, 'illegal character') || in_array($e, array('input to short', 'input too short'))) {
            throw new InvalidAddress("{$address} appears to be an invalid Bitcoin address");
        } else {
            if (contains($e, 'cloudflare') && !empty($title)) {
                throw new NetworkError("CloudFlare-reported problem at blockchain.info: " . withoutPrefix($title, "blockchain.info | "));
            } else {
                if (contains(strtolower($title), 'under maintenance')) {
                    throw new NetworkError("Blockchain.info appears to be under maintenance");
                } else {
                    if (contains($e, "maximum concurrent requests reached")) {
                        throw new NetworkError("Maximum concurrent requests to Blockchain.info reached");
                    } else {
                        if (!empty($title)) {
                            throw new NetworkError("Unknown error when attempting to check address-balance " . "for ({$address}) via blockchain.info: {$title}");
                        } else {
                            if (trim($e) == '') {
                                throw new NetworkError("Blockchain.info returned empty/content-less response");
                            } else {
                                if ($e == 'lock wait timeout exceeded; try restarting transaction') {
                                    throw new NetworkError("Blockchain.info responded with error message about lock timeout");
                                } else {
                                    throw new \Exception("Unexpected result received from blockchain.info when " . "attempting to get balance of address {$address}: {$response->content}");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #8
0
ファイル: checker.php プロジェクト: gitter-badger/OpenMS
################### doxygen errors in .doxygen-files  ##########################
if ($user == "all" && in_array("doxygen_errors", $tests)) {
    $file = file("{$bin_path}/doc/doxygen/doxygen-error.log");
    foreach ($file as $line) {
        $line = trim($line);
        if (ereg("(.*/[a-zA-Z0-9_]+\\.doxygen):[0-9]+:", $line, $parts)) {
            realOutput("Doxygen errors in '" . $parts[1] . "'", $user, "");
            print "  See 'OpenMS/doc/doxygen/doxygen-error.log'\n";
        }
    }
}
########################### warnings TOPP test  #################################
if (in_array("topp_output", $tests)) {
    $file_warnings = array();
    foreach ($test_log as $name => $warnings) {
        if (beginsWith($name, "TOPP_")) {
            $name = substr($name, 5);
            $name = substr($name, 0, strpos($name, '_'));
            $topp_file = "src/topp/" . $name . ".cpp";
            if (in_array($topp_file, $files_todo)) {
                if (!isset($file_warnings[$topp_file])) {
                    $file_warnings[$topp_file] = array();
                }
                $file_warnings[$topp_file] = array_merge($file_warnings[$topp_file], $warnings);
            }
        }
    }
    //print errors/warnings bundled for each TOPP tool
    foreach ($file_warnings as $file => $warnings) {
        realOutput("Error/warnings in TOPP tool test of '{$file}'", $user, $file);
        $warnings = array_unique($warnings);
コード例 #9
0
             $tagfound[$tags[$j]] = 1;
         }
         // server side index
         if (array_key_exists($tags[$j], $idx)) {
             $idx[$tags[$j]][] = count($geo);
         } else {
             $idx[$tags[$j]] = array(count($geo));
         }
     }
 }
 // filter the tags hstore
 if ($row[1] !== null) {
     $hstore = json_decode('{' . str_replace('"=>"', '":"', $row[1]) . '}', true);
     foreach ($hstore as $j => $val) {
         //if( beginsWith($j,'name:') ||  beginsWith($j,'tiger:')  ||  beginsWith($j,'nist:') ) continue;
         if (beginsWith($j, 'tiger:') || beginsWith($j, 'nist:')) {
             continue;
         }
         $type[$j] = $val;
         if (array_key_exists($j, $tagfound)) {
             $tagfound[$j]++;
         } else {
             $tagfound[$j] = 1;
         }
         // server side index
         if (array_key_exists($j, $idx)) {
             $idx[$j][] = count($geo);
         } else {
             $idx[$j] = array(count($geo));
         }
     }
コード例 #10
0
 /**
  * Get the path info, which is everything that follows the application
  * node in the URL. (without query info).
  * The returned pathinfo will not start or end with '/'.
  *
  * @return String
  */
 public static function getPathInfo()
 {
     $appRoot = self::getAppRoot();
     // Get the URL path (everything until the '?')
     $path = MapUtil::get($_SERVER, 'CONTEXT_PREFIX');
     // CONTEXT_PREFIX is aparently new to apache 2.3.13
     // If undefined, fall back to previous method. This one, though, is known
     // to have a problem when the URL is root. ('/').
     if ($path === null || $path === "") {
         $path = isset($_SERVER['SCRIPT_URL']) ? $_SERVER['SCRIPT_URL'] : $_SERVER['PHP_SELF'];
     }
     $pathInfo = substr($path, strlen($appRoot));
     if (beginsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 1);
     }
     if (endsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 0, -1);
     }
     return $pathInfo;
 }
コード例 #11
0
 protected function CalculateObjectDescriptionForAssociation($strAssociationTableName, $strTableName, $strReferencedTableName, $blnPluralize)
 {
     // Strip Prefixes (if applicable)
     $strTableName = $this->StripPrefixFromTable($strTableName);
     $strAssociationTableName = $this->StripPrefixFromTable($strAssociationTableName);
     $strReferencedTableName = $this->StripPrefixFromTable($strReferencedTableName);
     // Starting Point
     $strToReturn = QConvertNotation::CamelCaseFromUnderscore($strReferencedTableName);
     if ($blnPluralize) {
         $strToReturn = $this->Pluralize($strToReturn);
     }
     // Let's start with strAssociationTableName
     // Rip out trailing "_assn" if applicable
     $strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
     // remove instances of the table names in the association table name
     $strTableName2 = str_replace('_', '', $strTableName);
     // remove underscores if they are there
     $strReferencedTableName2 = str_replace('_', '', $strReferencedTableName);
     // remove underscores if they are there
     if (beginsWith($strAssociationTableName, $strTableName . '_')) {
         $strAssociationTableName = trimOffFront($strTableName . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strTableName2 . '_')) {
         $strAssociationTableName = trimOffFront($strTableName2 . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strReferencedTableName . '_')) {
         $strAssociationTableName = trimOffFront($strReferencedTableName . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strReferencedTableName2 . '_')) {
         $strAssociationTableName = trimOffFront($strReferencedTableName2 . '_', $strAssociationTableName);
     } elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
         $strAssociationTableName = "";
     }
     if (endsWith($strAssociationTableName, '_' . $strTableName)) {
         $strAssociationTableName = trimOffEnd('_' . $strTableName, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strTableName2)) {
         $strAssociationTableName = trimOffEnd('_' . $strTableName2, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName)) {
         $strAssociationTableName = trimOffEnd('_' . $strReferencedTableName, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName2)) {
         $strAssociationTableName = trimOffEnd('_' . $strReferencedTableName2, $strAssociationTableName);
     } elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
         $strAssociationTableName = "";
     }
     // Change any double "__" to single "_"
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     // If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
     if ($strAssociationTableName == "_" || $strAssociationTableName == "") {
         return sprintf("%s%s%s", $this->strAssociatedObjectPrefix, $strToReturn, $this->strAssociatedObjectSuffix);
     }
     // Otherwise, add "As" and the predicate
     return sprintf("%s%sAs%s%s", $this->strAssociatedObjectPrefix, $strToReturn, QConvertNotation::CamelCaseFromUnderscore($strAssociationTableName), $this->strAssociatedObjectSuffix);
 }
コード例 #12
0
ファイル: updateoislinks.php プロジェクト: AmsterdamData/CKAN
    if (strtolower(substr($txt, 0, strlen($begin))) == strtolower($begin)) {
        return true;
    }
    return false;
}
//error_reporting(0);
?>
<html>
<head>
<title>AODS Link-updater</title>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>

    <?php 
$count = 0;
$ckan = new CKAN("");
$ckan->getDatasets();
foreach ($ckan->datasets as $key => $set) {
    foreach ($set->res_url as $i => $url) {
        if (beginsWith($url, "http://os.amsterdam")) {
            $ckan->changeResource($set->name, $i, str_replace("http://os.amsterdam", "http://ois.amsterdam", $url), $set->res_description[$i]);
        }
    }
}
?>
  
</body>
</html>

コード例 #13
0
     }
 } else {
     $monobook['nsclass'] = 'mediawiki ns-1 ltr';
     /* Special page */
     $monobook['content_actions']['nstab-main']['wiki'] = ':' . substr($ID, strlen($monobook['discussion-location']));
     $monobook['content_actions']['nstab-main']['text'] = $lang['monobook_article'];
     $monobook['content_actions']['nstab-main']['accesskey'] = 'v';
     if ($monobook['discussion'] == 1) {
         $monobook['content_actions']['talk']['class'] = "selected";
         $monobook['content_actions']['talk']['wiki'] = ':' . $ID;
         //Etienne : Discussion, not found in the lang.php files
         //$monobook['content_actions']['talk']['text'] = "Discussion";
         $monobook['content_actions']['talk']['text'] = $lang['monobook_discussion'];
     }
 }
 if (beginsWith($ID, "wiki:user:"******"edit") {
     $monobook['content_actions']['edit']['class'] = "selected";
 }
 $monobook['content_actions']['edit']['href'] = DOKU_BASE . DOKU_SCRIPT . "?id=" . $ID . "&amp;do=edit&amp;rev=" . $_REQUEST['rev'];
 $monobook['content_actions']['edit']['accesskey'] = 'e';
 if ($INFO['writable']) {
     if ($INFO['exists']) {
         $monobook['content_actions']['edit']['text'] = $lang['btn_edit'];
         $monobook['content_actions']['edit']['accesskey'] = 'e';
コード例 #14
0
ファイル: sql2graph.php プロジェクト: gitter-badger/OpenMS
function parseSQLFile($filename, &$tables, &$edges)
{
    //init
    $tables = array();
    $edges = array();
    //parse file
    $file = file($filename);
    for ($i = 0; $i < count($file); ++$i) {
        $line = trim($file[$i]);
        //node
        if (beginsWith($line, "CREATE TABLE")) {
            $parts = explode(" ", $line);
            $current_table = $parts[2];
            $tables[$current_table] = array();
            $j = $i + 1;
            $line = trim($file[$j]);
            //table
            while (!beginsWith($line, "CREATE TABLE") && !beginsWith($line, "ALTER TABLE") && $line != "") {
                //primary key
                if (beginsWith($line, "PRIMARY KEY")) {
                    $parts = explode(" ", $line);
                    $tables[$current_table][rp($parts[3])][] = "P";
                } elseif (beginsWith($line, "KEY")) {
                    $parts = explode(" ", $line);
                    $tables[$current_table][rp($parts[2])][] = "I";
                } else {
                    $parts = explode(" ", $line);
                    if ($parts[0] != ")") {
                        $tables[$current_table][$parts[0]] = array();
                    }
                }
                ++$j;
                $line = trim($file[$j]);
            }
        } elseif (beginsWith($line, "ALTER TABLE")) {
            $parts = explode("`", $line);
            $from = $parts[1];
            $j = $i + 1;
            while (beginsWith(trim($file[$j]), "ADD CONSTRAINT")) {
                $parts = explode(" ", $file[$j]);
                $to = $parts[9];
                $tables[$from][rp($parts[7])][] = "F";
                $edges[] = array($from, $to);
                ++$j;
            }
        }
    }
}
コード例 #15
0
ファイル: utils.php プロジェクト: redhog/DemoWave
function varsToSearch($prefix, $vars)
{
    $search = array();
    foreach ($vars as $key => $value) {
        if (beginsWith($key, $prefix) && $value != "") {
            $key = substr($key, strlen($prefix));
            $subkeyarray = false;
            if (endsWith($key, '_lower')) {
                $key = substr($key, 0, strlen($key) - strlen('_lower'));
                $subkey = 'lower';
            } else {
                if (endsWith($key, '_upper')) {
                    $key = substr($key, 0, strlen($key) - strlen('_upper'));
                    $subkey = 'upper';
                } else {
                    if (endsWith($key, '_list')) {
                        $keyvalue = explode('__', substr($key, 0, strlen($key) - strlen('_list')));
                        $key = $keyvalue[0];
                        $value = $keyvalue[1];
                        $subkey = 'list';
                        $subkeyarray = true;
                    } else {
                        if (endsWith($key, '_multimatch')) {
                            $key = substr($key, 0, strlen($key) - strlen('_multimatch'));
                            if (empty($value)) {
                                $value = array();
                            } else {
                                $value = explode(",", $value);
                            }
                            $subkey = 'list';
                        } else {
                            $subkey = 'value';
                        }
                    }
                }
            }
            if (!isset($search[$key])) {
                $search[$key] = array();
            }
            if ($subkeyarray) {
                if (!isset($search[$key][$subkey])) {
                    $search[$key][$subkey] = array();
                }
                $search[$key][$subkey][] = $value;
            } else {
                $search[$key][$subkey] = $value;
            }
        }
    }
    return $search;
}
コード例 #16
0
ファイル: index.php プロジェクト: jkinner/ringside
function getComments($file_path)
{
    $source = file_get_contents($file_path);
    $tokens = token_get_all($source);
    foreach ($tokens as $token) {
        if (is_string($token)) {
            // simple 1-character token
            // ignore code tokens
        } else {
            // token array
            list($id, $text) = $token;
            switch ($id) {
                case T_CLASS:
                    return;
                    break;
                case T_DOC_COMMENT:
                    // This is the only case we care about
                    if (!beginsWith($text, '/*************************************')) {
                        echo '<ul>';
                        $head = getTag($text, '/**');
                        $author = getTag($text, '@author');
                        $return = getTag($text, '@return');
                        $a = getTags($text, '@param');
                        // Print the results
                        if ($head && strlen(trim($head)) > 0) {
                            echo "<li><STRONG>Header:</STRONG> {$head}</li>";
                        }
                        if ($return && strlen($return) > 0) {
                            echo "<li><STRONG>Return Value:</STRONG> {$return}</li>";
                        }
                        if ($author && strlen($author) > 0) {
                            echo "<li><STRONG>Author:</STRONG> {$author}</li>";
                        }
                        echo '<ul>';
                        foreach ($a as $s) {
                            echo "<li>{$s}</li>";
                        }
                        echo '</ul>';
                        echo '</ul>';
                    }
                    break;
                default:
                    // anything else -> ignore
                    break;
            }
        }
    }
}
コード例 #17
0
ファイル: users.php プロジェクト: redhog/DemoWave
        return "<option value='{$value}'>{$comment}</option>";
    }
}
?>

<h1><?php 
E_("Search for users");
?>
</h1>
<form action="<?php 
echo $_SERVER["SCRIPT_NAME"] . '?' . queryString(queryConstruct());
?>
" method="get" enctype="multipart/form-data">
 <?php 
foreach ($_GET as $key => $value) {
    if (!beginsWith($key, 'users_search_')) {
        echo "<input name='{$key}' value='{$value}' type='hidden'>\n";
    }
}
?>
 <table>
  <tr> 
   <?php 
echo drawSearchField(T_('Id'), 'users_search_id', false, 'bound', 10);
?>
   <?php 
echo drawSearchField(T_('User name'), 'users_search_username', false, 'match', 10);
?>
  </tr>
  <tr> 
   <?php 
コード例 #18
0
 include APPLICATION_INCPATH . 'htmlheader.inc.php';
 $sql = "SELECT name FROM `{$dbDashboard}`";
 $result = mysql_query($sql);
 if (mysql_error()) {
     trigger_error(mysql_error(), E_USER_WARNING);
 }
 echo "<h2>" . icon('dashboard', 32) . " ";
 echo $strInstallDashboardComponents . "</h2>";
 echo "<p align='center'>" . sprintf($strComponentMustBePlacedInDashboardDir, "<var>dashboard_NAME</var>") . "</p>";
 while ($dashboardnames = mysql_fetch_object($result)) {
     $dashboard[$dashboardnames->name] = $dashboardnames->name;
 }
 $path = APPLICATION_PLUGINPATH;
 $dir_handle = @opendir($path) or trigger_error("Unable to open dashboard directory {$path}", E_USER_ERROR);
 while ($file = readdir($dir_handle)) {
     if (beginsWith($file, "dashboard_") && endsWith($file, ".php")) {
         //echo "file name ".$file."<br />";
         if (empty($dashboard[substr($file, 10, strlen($file) - 14)])) {
             //echo "file name ".$file." - ".substr($file, 10, strlen($file)-14)."<br />";
             //$html .= "echo "<option value='{$row->id}'>$row->realname</option>\n";";
             $html .= "<option value='" . substr($file, 10, strlen($file) - 14) . "'>" . substr($file, 10, strlen($file) - 14) . " ({$file})</option>";
         }
     }
 }
 closedir($dir_handle);
 if (empty($html)) {
     echo "<p align='center'>{$strNoNewDashboardComponentsToInstall}</p>";
     echo "<p align='center'><a href='manage_dashboard.php'>{$strBackToList}</a></p>";
 } else {
     echo "<form action='{$_SERVER['PHP_SELF']}' method='post'>\n";
     echo "<table align='center' class='vertical'><tr><td>\n";
コード例 #19
0
ファイル: searchreferendums.php プロジェクト: redhog/DemoWave
        $args = queryString(queryConstruct(array(), array('search_referendums_show')));
    } else {
        $status = "heading_collapsed";
        $args = queryString(queryConstruct(array('search_referendums_show' => '1'), array()));
    }
    $title = T_("Search for referendums");
    echo "<h2 class='{$status}'><a href='{$_SERVER["SCRIPT_NAME"]}?{$args}'>{$title}</a></h2>";
    if (array_get($_GET, 'search_referendums_show', '')) {
        ?>
   <form action="<?php 
        echo $_SERVER["SCRIPT_NAME"];
        ?>
" method="get" enctype="multipart/url-encoded">
    <?php 
        foreach ($_GET as $key => $value) {
            if (!beginsWith($key, 'referendum_search_')) {
                echo "<input name='{$key}' value='{$value}' type='hidden'>\n";
            }
        }
        ?>
    <table>
     <tr> 
      <?php 
        echo drawSearchField(T_('Id'), 'referendum_search_referendum', false, 'bound', 10);
        echo drawSearchField(T_('Total'), 'referendum_search_area', false, 'bound', 10, 'vote-sum');
        ?>
     </tr>
     <tr>
      <?php 
        echo drawSearchField(T_('Title'), 'referendum_search_title', false, 'match', 10);
        echo drawSearchField(T_('Current'), 'referendum_search_sum', false, 'bound', 10, 'current-vote-sum');
コード例 #20
0
<?php

if (isset($DOKU_TPL) == FALSE) {
    $DOKU_TPL = DOKU_TPL;
}
if (isset($DOKU_TPLINC) == FALSE) {
    $DOKU_TPLINC = DOKU_TPLINC;
}
if (file_exists(DOKU_PLUGIN . 'displaywikipage/code.php')) {
    include_once DOKU_PLUGIN . 'displaywikipage/code.php';
}
if (file_exists(DOKU_PLUGIN . 'referrers/code.php')) {
    include_once DOKU_PLUGIN . 'referrers/code.php';
}
@(include dirname(__FILE__) . '/string_fn.php');
if (beginsWith(getenv("REMOTE_ADDR"), 'xxx')) {
    echo "<html><body><h3>You have been blocked from this server.</h3></body></html>";
} else {
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
    echo $conf['lang'];
    ?>
"
 lang="<?php 
    echo $conf['lang'];
    ?>
" dir="<?php 
    echo $lang['direction'];
    ?>
">
コード例 #21
0
     $text = pg_escape_string(array_get($_POST, 'new_referendum_text', ''));
     $sql .= "insert into referendum_type_category (referendum, add, path, breakpoint, type, text)\n\t     select\n\t      currval('referendum_id_seq'),\n\t      '{$add}',\n\t      '{$path}',\n\t      '{$breakpoint}',\n\t      '{$type}',\n\t      '{$text}';";
 } else {
     if ($category_type == 'text') {
         $text = pg_escape_string($_POST['new_referendum_text']);
         $sql .= "insert into referendum_type_text (referendum, text)\n\t     select\n\t      currval('referendum_id_seq'),\n\t      '{$text}';";
     } else {
         if ($category_type == 'law') {
             $para_nr = (int) $_POST['new_referendum_paragraphs'];
             $para_ids = array();
             $para_root = array();
             for ($para = 0; $para < $para_nr; $para++) {
                 if ($_POST["new_referendum_{$para}_path"] != '') {
                     $path = $_POST["new_referendum_{$para}_path"];
                     $relative = false;
                     if (beginsWith($path, 'n')) {
                         list($relative, $path) = explode('.', $path, 2);
                         sscanf($relative, "n%d", &$relative);
                     }
                     $para_ids[$para] = array('relative' => $relative, 'path' => $path, 'id' => $para, 'type' => $_POST["new_referendum_{$para}_type"], 'title' => $_POST["new_referendum_{$para}_title"], 'text' => $_POST["new_referendum_{$para}_text"], 'sub' => array(), 'next' => array());
                     $para_root[$para] =& $para_ids[$para];
                 }
             }
             for ($para = 0; $para < $para_nr; $para++) {
                 if (isset($para_ids[$para])) {
                     if ($para_ids[$para]['relative'] !== false) {
                         if ($para_ids[$para]['path'] == '') {
                             $para_ids[$para_root[$para]['relative']]['next'][] =& $para_ids[$para];
                         } else {
                             $para_ids[$para_root[$para]['relative']]['sub'][] =& $para_ids[$para];
                         }
コード例 #22
0
<?php

if (!isAjax()) {
    include '_header.php';
}
if (isset($views_to_load)) {
    foreach ($views_to_load as $view) {
        if (beginsWith($view, ' ')) {
            // raw input (html)
            echo $view;
        } else {
            if (beginsWith($view, '.') || beginsWith($view, '/')) {
                include $view;
            } else {
                include 'views/' . $view;
            }
        }
    }
}
if (!isAjax()) {
    include '_footer.php';
}
コード例 #23
0
ファイル: laweditor.php プロジェクト: redhog/DemoWave
         } else {
             if (beginsWith($key, "law_edit_cancel_")) {
                 cancelParagraph(str_replace('_', '.', substr($key, strlen("law_edit_cancel_"))));
             } else {
                 if (beginsWith($key, "law_edit_title_")) {
                     $path = explode('_', substr($key, strlen("law_edit_title_")));
                     $node =& $_SESSION["laweditor"]['laws'];
                     foreach ($path as $item) {
                         $node =& $node['sub'][$item];
                     }
                     if (isset($node['edit'])) {
                         // Don't fill this in if the item just got cancelled
                         $node['edit']['title'] = $value;
                     }
                 } else {
                     if (beginsWith($key, "law_edit_text_")) {
                         $path = explode('_', substr($key, strlen("law_edit_text_")));
                         $node =& $_SESSION["laweditor"]['laws'];
                         foreach ($path as $item) {
                             $node =& $node['sub'][$item];
                         }
                         if (isset($node['edit'])) {
                             // Don't fill this in if the item just got cancelled
                             $node['edit']['text'] = $value;
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #24
0
 private function compile_js()
 {
     $this->js_complied = '';
     $js = '';
     foreach ($this->js as $file) {
         if (beginsWith($file, 'http://') || beginsWith($file, 'https://')) {
             $js .= file_get_contents($file);
         } else {
             $file = cwd() . $file;
             if (file_exists($file)) {
                 $js .= file_get_contents($file);
             }
         }
     }
     $id = md5($js) . '_' . var_get('CACHE_KEY', md5(time()));
     $path = UPLOAD_PATH . '/js/' . $id . '.js';
     if (!file_exists($path)) {
         file_put_contents($path, $js);
     }
     $this->js_complied = "\t" . '<script src="' . get_url('/' . $path) . '"></script>' . "\n";
 }
コード例 #25
0
ファイル: evaluate_ff.php プロジェクト: gitter-badger/OpenMS
$options = array("-in", "-log", "-ini_ff", "-out_ff", "-type", "-in_an", "-out_co", "-use_pp", "-ini_pp", "-ini_fl", "-delete", "-calibrate", "-eval_only", "--help");
####################################################################################################################################
################################################## Parameter handling ##############################################################
####################################################################################################################################
#wrong parameter count
for ($i = 1; $i < count($argv); ++$i) {
    #option
    if (beginsWith($argv[$i], "-")) {
        #not registered option or flag
        if (!in_array($argv[$i], $options)) {
            print "\nError: Unregistered option '" . $argv[$i] . "'!\n\n";
            printUsage();
            exit;
        }
        # no argument to an option
        if ($argv[$i] != "--help" && in_array($argv[$i], $options) && (!isset($argv[$i + 1]) || beginsWith($argv[$i + 1], "-"))) {
            print "\nError: No argument to option '" . $argv[$i] . "'!\n\n";
            printUsage();
            exit;
        }
    }
}
// no parameters
if ($argc == 1 || in_array("--help", $argv)) {
    if (!in_array("--help", $argv)) {
        print "\nNo options given. Aborting!\n\n";
    }
    printUsage();
    exit;
}
// eval_only - evaluation without feature finding
コード例 #26
0
function strBeginsWithOneInArray($str, $arr)
{
    foreach ($arr as $val) {
        if (beginsWith($str, $val)) {
            return true;
        }
    }
    return false;
}
コード例 #27
0
function parseTestFile($filename)
{
    $tests = array();
    $todo_tests = array();
    $in_test = false;
    $last_test = "";
    #load file
    $tmp = file($filename);
    foreach ($tmp as $line) {
        $line = trim($line);
        if (beginsWith($line, "START_SECTION(") || beginsWith($line, "START_SECTION (") || beginsWith($line, "START_SECTION\t(")) {
            # strip brackets
            $function = trim(substr($line, 13));
            //print "Function: $function \n";
            while ($function[0] == '(' && $function[strlen($function) - 1] == ')') {
                $function = trim(substr($function, 1, -1));
            }
            # ignore OPENMS_DLLAPI
            $function = str_replace("OPENMS_DLLAPI ", "", $function);
            # ignore extra function tests
            if (!beginsWith($function, "[EXTRA]")) {
                $tests[] = $function;
                $last_test = $function;
            }
            $in_test = true;
        } elseif (beginsWith($line, "END_SECTION")) {
            $in_test = false;
        } elseif ($in_test) {
            if (strpos($line, "TODO") !== FALSE || strpos($line, "????") !== FALSE) {
                $todo_tests[] = $function;
            }
        }
    }
    return array("todo" => $todo_tests, "tests" => $tests);
}
コード例 #28
0
function write_ini_file($path, $assoc_arr)
{
    $content = "";
    if ($path != "" && is_array($assoc_arr) && file_exists($path)) {
        foreach ($assoc_arr as $key => $elem) {
            if (is_array($elem)) {
                if ($key != '') {
                    $content .= "[" . $key . "]\r\n";
                }
                foreach ($elem as $key2 => $elem2) {
                    if (beginsWith($key2, 'Comment_') == 1 && beginsWith($elem2, ';')) {
                        $content .= $elem2 . "\r\n";
                    } else {
                        if (beginsWith($key2, 'Newline_') == 1 && $elem2 == '') {
                            $content .= $elem2 . "\r\n";
                        } else {
                            $content .= $key2 . " = " . $elem2 . "\r\n";
                        }
                    }
                }
            } else {
                $content .= $key . " = " . $elem . "\r\n";
            }
        }
        if (!($handle = fopen($path, 'w'))) {
            return -2;
        }
        if (!fwrite($handle, $content)) {
            return -2;
        }
        fclose($handle);
        return 1;
    } else {
        return -2;
    }
}
コード例 #29
0
ファイル: compatCheck.php プロジェクト: DBezemer/server
 function processLine($buffer)
 {
     $markerPos = strpos($buffer, PS2_START_MARKER);
     if ($markerPos === false) {
         return false;
     }
     $params = trim(substr($buffer, $markerPos + strlen(PS2_START_MARKER)));
     if (!beginsWith($params, 'array (') || !endsWith($params, ')')) {
         return false;
     }
     $explodedBuffer = explode(' ', $buffer);
     $ipAddress = substr($explodedBuffer[3], 1, -1);
     $parsedParams = eval('return ' . $params . ';');
     if (processPS2Request($ipAddress, $parsedParams)) {
         return true;
     }
     return false;
 }
コード例 #30
0
ファイル: save_users.php プロジェクト: redhog/DemoWave
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
if (in_array('usermanagement', $_SESSION['privs']) && isset($_POST['save_userenable'])) {
    foreach ($_POST as $name => $value) {
        if (beginsWith($name, 'userenable_vote_') && $value != 'unchanged') {
            $user = substr($name, strlen('userenable_vote_'));
            if ($value == 'true') {
                $sql = "select enable_user({$user}::bigint, id, null) from user_enabled_type where name ='vote'";
            } else {
                $sql = "select disable_user({$user}::bigint, id, null) from user_enabled_type where name ='vote'";
            }
            pg_query($dbconn, $sql) or die('Unable to update user: '******'userenable_usermanagement_') && $value != 'unchanged') {
                $user = substr($name, strlen('userenable_usermanagement_'));
                if ($value == 'true') {
                    $sql = "select enable_user({$user}::bigint, id, null) from user_enabled_type where name ='usermanagement'";
                } else {
                    $sql = "select disable_user({$user}::bigint, id, null) from user_enabled_type where name ='usermanagement'";
                }
                pg_query($dbconn, $sql) or die('Unable to update user: ' . pg_last_error());
                $messages .= "<div>User management status updated for {$user}</div>";
            }
        }
    }
}