function select_account()
{
    $accounts = get_auth_keys();
    //Show Account List
    if (count($accounts) < 1) {
        println("Please authenticate account.");
        println("eg) php auth_request.php");
        exit(1);
    }
    println("Please select the account.");
    foreach ($accounts as $screen_name => $token) {
        println(sprintf("@%s", $screen_name));
    }
    //input screen_name
    echo ">@";
    while (true) {
        //input
        $screen_name = strtolower(trim(read()));
        //authenticate user check
        if (!array_key_exists($screen_name, $accounts)) {
            println("Please select the authenticated account");
            echo ">@";
            continue;
        }
        break;
    }
    return ["screen_name" => $screen_name, "access_token" => $accounts[$screen_name]["access_token_key"], "access_token_secret" => $accounts[$screen_name]["access_token_secret"]];
}
Exemple #2
0
function hydrate_model($file)
{
    if (is_file($file) && strpos($file, '.php')) {
        preg_match_all('/class\\s(\\S+)\\s/', read($file), $match);
        require $file;
        foreach ($match[1] as $klass) {
            $re = new \ReflectionClass($klass);
            switch ($re->getParentClass()->getName()) {
                case 'Servant\\Mapper\\Database':
                    status('hydrate', $file);
                    $dsn = option('database.' . $klass::CONNECTION);
                    $db = \Grocery\Base::connect($dsn);
                    $columns = $klass::columns();
                    $indexes = $klass::indexes();
                    if (!isset($db[$klass::table()])) {
                        $db[$klass::table()] = $columns;
                    }
                    \Grocery\Helpers::hydrate($db[$klass::table()], $columns, $indexes);
                    break;
                case 'Servant\\Mapper\\MongoDB':
                    status('hydrate', $file);
                    $dsn_string = \Servant\Config::get($klass::CONNECTION);
                    $database = substr($dsn_string, strrpos($dsn_string, '/') + 1);
                    $mongo = $dsn_string ? new \Mongo($dsn_string) : new \Mongo();
                    $db = $mongo->{$database ?: 'default'};
                    \Servant\Helpers::reindex($db->{$klass::table()}, $klass::indexes());
                    break;
                default:
                    break;
            }
        }
    }
}
Exemple #3
0
 function __construct()
 {
     /* --------------------------------------------------------------
      * Swap information
      * -------------------------------------------------------------- */
     @preg_match_all('/^([^:]+)\\:\\s+(\\d+)\\s*(?:k[bB])?\\s*/m', read('/proc/meminfo'), $matches, PREG_SET_ORDER);
     if ($matches) {
         foreach ($matches as $item) {
             switch (strtolower($item[1])) {
                 case 'swaptotal':
                     $this->total = $item[2];
                     break;
                 case 'swapfree':
                     $this->free = $item[2];
                     break;
             }
         }
         if ($this->total) {
             $this->used = $this->total - $this->free;
             $this->percentage = $this->used / $this->total * 100;
         } else {
             $this->used = 0;
             $this->percentage = 0;
         }
     }
 }
function readon($server)
{
    echo "<span id=connect>Connected.<br></span>";
    while ($GLOBALS['connected']) {
        $line = read($server);
        $line = trim($line);
        if ($line != "") {
            if (strpos($line, ":!:ping:!:") !== false) {
                write(":!:pong:!:", $server);
            } else {
                if (strpos($line, ":!:hangup:!:") !== false) {
                    $GLOBALS['connected'] = false;
                } else {
                    if (strpos($line, ":!:players:!:") !== false) {
                        disPlayers(substr($line, 13));
                    } else {
                        if (strpos($line, ":!:info:!:") !== false) {
                            echo "<span id=info>" . substr($line, 10) . "</span><br>";
                        } else {
                            echo "<span id=gos>" . $line . "</span><br>";
                        }
                    }
                }
            }
        }
        checkSql($server);
        ob_flush();
        flush();
        echo " <script language=javascript>window.scroll(0,50000);</script>";
        sleep(1);
    }
}
function retornaPosts($cond = null)
{
    if ($cond) {
        $post = read('post', $cond);
    } else {
        $post = read('post');
    }
    return $post;
}
function setViews($topicoId)
{
    $topicoId = mysql_real_escape_string($topicoId);
    $readArtigo = read('up_posts', "WHERE id = '{$topicoId}'");
    foreach ($readArtigo as $artigo) {
    }
    $views = $artigo['visitas'];
    $views = $views + 1;
    $dataViews = array('visitas' => $views);
    update('up_posts', $dataViews, "id = '{$topicoId}'");
}
Exemple #7
0
/**
 * Creates Yes/No question dialog. It waits until user types either Y or N (non-case sensitive)
 * 
 * @param String $q the question
 *
 * @return String answer
 **/
function read_yn($q)
{
    $ans = '';
    while (1) {
        writeln($q . " [Y/N]");
        $ans = read();
        if (strtoupper($ans) == 'Y' || strtoupper($ans) == 'N') {
            break;
        }
    }
    return $ans;
}
Exemple #8
0
function setViews($topicoId)
{
    $con = mysqli_connect(HOST, USER, PASS, DBAS) or die(mysqli_error($con) . "Não foi possível fazer a conexão com o sistema");
    $topicoId = mysqli_real_escape_string($con, $topicoId);
    $readArtigo = read('post', "WHERE id = '{$topicoId}'");
    foreach ($readArtigo as $artigo) {
    }
    $views = $artigo['visitas'];
    $views = $views + 1;
    $dataViews = array('visitas' => $views);
    update('post', $dataViews, " WHERE id = '{$topicoId}'");
}
function write($newtext, $fn, $search)
{
    $file = file_get_contents($fn);
    $arr = explode($search . ':', $file);
    $oldtext = explode(";", $arr[1]);
    if ($oldtext[0] == "") {
        $oldtext[0] = " ";
        $str = str_replace(substr($oldtext[0], 0, 0), $newtext, $file);
    }
    $str = str_replace($oldtext[0], $newtext, $file);
    file_put_contents($fn, $str);
    return read($fn, $search);
}
Exemple #10
0
function controller()
{
    $id = $_REQUEST["id"];
    $action = $_REQUEST["action"];
    switch ($id) {
        case "recommand":
            include "model/recommand_data.php";
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "news":
            include "model/news_data.php";
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "local":
            include 'model/local_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "image":
            include 'model/image_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "entertainment":
            include 'model/entertainment_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        default:
            break;
    }
}
Exemple #11
0
 function __construct()
 {
     /* --------------------------------------------------------------
      * CPU load
      * -------------------------------------------------------------- */
     $parts = explode(" ", read('/proc/loadavg'));
     if ($parts) {
         $this->load = $parts[0];
         $this->load5 = $parts[1];
         $this->load15 = $parts[2];
     }
     /* --------------------------------------------------------------
      * CPU information
      * -------------------------------------------------------------- */
     $processors = preg_split('/\\s?\\n\\s?\\n/', read('/proc/cpuinfo'));
     if ($processors) {
         // only using first cpu for information
         $processor = reset($processors);
         $lines = explode("\n", $processor);
         foreach ($lines as $line) {
             list($key, $value) = explode(':', $line, 2);
             switch (strtolower(trim($key))) {
                 case 'processor':
                 case 'model name':
                     $this->name = $value;
                     break;
                 case 'clock':
                 case 'cpu mhz':
                     $this->frequency = $value;
                     break;
                 case 'bogomips':
                     if (!isset($this->frequency)) {
                         $this->frequency = $value;
                     }
                     break;
             }
         }
         $this->count = count($processors);
     }
     /* --------------------------------------------------------------
      * Raspberry Pi Temperature
      * -------------------------------------------------------------- */
     $temp = read('/sys/class/thermal/thermal_zone0/temp');
     if ($temp) {
         $this->temp = $temp / 1000;
     }
 }
Exemple #12
0
 function __construct()
 {
     /* --------------------------------------------------------------
      * Network adapters
      * -------------------------------------------------------------- */
     $lines = explode("\n", read('/proc/net/dev'));
     foreach ($lines as $line) {
         if (!strpos($line, ':')) {
             continue;
         }
         $parts = preg_split('/\\s+/', trim($line));
         $adapter = substr($parts[0], 0, -1);
         $state = read('/sys/class/net/' . $adapter . '/operstate');
         if ($state == 'unknown' || $state == '') {
             continue;
         }
         $this->{$adapter} = new stdClass();
         $this->{$adapter}->state = $state;
         $this->{$adapter}->speed = read('/sys/class/net/' . $adapter . '/speed');
         $this->{$adapter}->received = $parts[1];
         $this->{$adapter}->sent = $parts[9];
         $this->{$adapter}->total = $this->{$adapter}->sent + $this->{$adapter}->received;
         $this->{$adapter}->dropped = $parts[4] + $parts[12];
         $this->{$adapter}->errors = $parts[3] + $parts[11];
         /* --------------------------------------------------------------
          * ifconfig
          * -------------------------------------------------------------- */
         $ifconfig = array();
         exec('/sbin/ifconfig ' . $adapter, $ifconfig);
         if ($ifconfig) {
             foreach ($ifconfig as $line) {
                 if (preg_match('/inet\\saddr:\\s*(\\S*)/i', $line, $matches)) {
                     $this->{$adapter}->ip = $matches[1];
                 } else {
                     if (preg_match('/inet6\\saddr:\\s*(\\S*)/i', $line, $matches)) {
                         $this->{$adapter}->ipv6 = $matches[1];
                     } else {
                         if (preg_match('/HWaddr\\s*(\\S*)/i', $line, $matches)) {
                             $this->{$adapter}->mac = $matches[1];
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #13
0
function show(array $files, $context)
{
    foreach ($files as $file) {
        $data = read($file);
        $ok = phutil_is_utf8($data);
        if ($ok) {
            echo "OKAY";
        } else {
            echo "FAIL";
        }
        echo "  " . name($file) . "\n";
        if (!$ok) {
            $lines = explode("\n", $data);
            $len = count($lines);
            $map = array();
            $bad = array();
            foreach ($lines as $n => $line) {
                if (phutil_is_utf8($line)) {
                    continue;
                }
                $bad[$n] = true;
                for ($jj = max(0, $n - $context); $jj < min($len, $n + 1 + $context); $jj++) {
                    $map[$jj] = true;
                }
            }
            $width = strlen(max(array_keys($map)));
            // Set $last such that we print a newline on the first iteration thorugh
            // the loop.
            $last = -2;
            foreach ($map as $idx => $ignored) {
                if ($idx != $last + 1) {
                    printf("\n");
                }
                $last = $idx;
                $line = $lines[$idx];
                if (!empty($bad[$idx])) {
                    $line = show_problems($line);
                }
                printf("  % {$width}d  %s\n", $idx + 1, $line);
            }
            echo "\n";
        }
    }
    return 0;
}
Exemple #14
0
 function __construct()
 {
     /* --------------------------------------------------------------
      * System uptime
      * -------------------------------------------------------------- */
     $output = read('/proc/uptime');
     list($seconds) = explode(' ', $output);
     $minutes = (int) $seconds / 60;
     $seconds = $seconds % 60;
     $hours = (int) $minutes / 60;
     $minutes = $minutes % 60;
     $days = (int) $hours / 24;
     $hours = $hours % 24;
     $this->days = floor($days);
     $this->hours = floor($hours);
     $this->minutes = floor($minutes);
     $this->seconds = floor($seconds);
 }
 function index_action()
 {
     if (!checkfile('plugins', 0)) {
         $plugins = $this->plugin->GetPage(array('isshow' => 0));
         foreach ($plugins as $k => $v) {
             $v['isinstalled'] = 1;
             $pluginlist[] = $v;
         }
         $plugins = $this->_getAllPlugins();
         foreach ($plugins as $k => $v) {
             $v['isinstalled'] = 0;
             $pluginlist[] = $v;
         }
         write('plugins', $pluginlist);
     } else {
         $pluginlist = read('plugins');
     }
     include ROOT_PATH . '/views/admin/plugin.php';
 }
Exemple #16
0
function write($arr)
{
    $read = json_decode(read(), true);
    $arrkey = array_keys($arr);
    foreach ($arrkey as $temp) {
        if (is_array($arr[$temp])) {
            print_r($arr[$temp]);
            foreach ($arr[$temp] as $value) {
                $read[$temp][$value] += 1;
            }
        } else {
            if (array_key_exists($arr[$temp], $read[$temp])) {
                $read[$temp][$arr[$temp]] += 1;
            }
        }
    }
    if (!array_key_exists($arr['processorSpeed'], $read['processorSpeed'])) {
        $read['processorSpeed'] += array($arr['processorSpeed'] => 1);
    }
    file_put_contents("results.txt", json_encode($read));
}
function getAutor($autorId, $campo = NULL)
{
    $autorId = mysql_real_escape_string($autorId);
    $readAutor = read('up_users', "WHERE id = '{$autorId}'");
    if ($readAutor) {
        foreach ($readAutor as $autor) {
        }
        if (!$autor['foto']) {
            $gravatar = 'http://www.gravatar.com/avatar/';
            $gravatar .= md5(strtolower(trim($autor['email'])));
            $gravatar .= '?d=mm&s=180';
            $autor['foto'] = $gravatar;
        }
        if (!$campo) {
            return $autor;
        } else {
            return $autor[$campo];
        }
    } else {
        echo 'Erro ao ler autor';
    }
}
Exemple #18
0
if (!$_SESSION['autUser']) {
    header('Location: index.php');
} else {
    $userId = $_SESSION['autUser']['id'];
    $readAutUser = read('users', "WHERE id = '{$userId}'");
    if ($readAutUser) {
        foreach ($readAutUser as $autUser) {
        }
        if ($autUser['nivel'] < '1' || $autUser['nivel'] > '2') {
            header('Location: ' . BASE . '/pagina/perfil');
        }
    } else {
        header('Location: index.php');
    }
}
$readPremium = read('users', "WHERE nivel = '3' AND premium_end < date(NOW())");
if ($readPremium) {
    foreach ($readPremium as $premium) {
        $end = array('nivel' => '4', 'premium_end' => '0000-00-00 00:00:00');
        update('users', $end, "id = '{$premium['id']}'");
    }
}
require_once 'includes/header.php';
require_once 'includes/menu.php';
if (empty($_GET['exe'])) {
    require 'home.php';
} elseif (file_exists($_GET['exe'] . '.php')) {
    require $_GET['exe'] . '.php';
} else {
    echo '<div class="bloco"><span class="ms in">Desculpe, a página que você está tentando acessar é inválida!</ span></div>';
}
Exemple #19
0
            } elseif (!empty($_SESSION['return'])) {
                echo $_SESSION['return'];
                unset($_SESSION['return']);
            }
            ?>
    <form name="formulario" action="" method="post" class="form-horizontal" enctype="multipart/form-data">
    <fieldset>
  	<legend>Cadastrar Medidas em :<strong class="alert alert-error"> <?php 
            echo $postedit['titulo'];
            ?>
</strong></legend> 
          <div class="control-group">
  <label class="control-label" for="checkboxes">Cores Dispon&iacute;veis:</label>
  <div class="controls">
  <?php 
            $readColor = read('colors');
            foreach ($readColor as $color) {
                echo '<label class="checkbox inline span2" for="' . $color['color_name'] . '">';
                echo '<input type="checkbox" name="cores[]" id="' . $color['color_name'] . '" value="' . $color['color_hexadecimal'] . '">';
                echo '<span style="background-color:' . $color['color_hexadecimal'] . '">&nbsp;&nbsp;&nbsp;&nbsp;</span> ' . $color['color_name'];
                echo '</label>';
            }
            ?>
    
  </div>
</div> 
    <div class="control-group">
    <label class="control-label" for="sendForm"></label>
    <div class="controls">
    <input type="submit" value="Cadastrar" id="sendForm" name="sendForm" class="btn btn-success" />
    </div>
 echo '<tr>';
 echo '<td>' . $cat['nome'] . '</td>';
 echo '<td>' . lmWord($cat['content'], '35') . '</td>';
 echo '<td align="center"><img src="ico/' . $catTags . '" alt="Tags da categoria" title="' . $cat['tags'] . '" /></td>';
 echo '<td align="center">' . date('d/m/Y H:i', strtotime($cat['data'])) . '</td>';
 echo '<td align="center"><a href="index2.php?exe=posts/categorias-edit&edit=' . $cat['id'] . '" ';
 echo 'title="editar categoria ' . $cat['nome'] . '"><img src="ico/edit.png" alt="editar categoria ' . $cat['nome'] . '" ';
 echo 'title="editar categoria ' . $cat['nome'] . '" /></a></td>';
 echo '<td align="center"><a href="index2.php?exe=posts/categorias-subcreate&idpai=' . $cat['id'] . '&uri=' . $cat['url'] . '" ';
 echo 'title="Criar sub categoria"><img src="ico/new.png" alt="Criar sub categoria" ';
 echo 'title="Criar sub categoria" /></a></td>';
 echo '<td align="center"><a href="index2.php?exe=posts/categorias&delcat=' . $cat['id'] . '" ';
 echo 'title="deletar categoria ' . $cat['nome'] . '"><img src="ico/no.png" alt="deletar categoria ' . $cat['nome'] . '" ';
 echo 'title="deletar categoria ' . $cat['nome'] . '" /></a></td>';
 echo '</tr>';
 $readSubCat = read('up_cat', "WHERE id_pai = '{$cat['id']}'");
 if ($readSubCat) {
     foreach ($readSubCat as $catSub) {
         $catSubTags = $catSub['tags'] != '' ? 'ok.png' : 'no.png';
         echo '<tr class="subcat">';
         echo '<td>&raquo;&raquo; ' . $catSub['nome'] . '</td>';
         echo '<td>' . lmWord($catSub['content'], '35') . '</td>';
         echo '<td align="center"><img src="ico/' . $catSubTags . '" alt="Tags da categoria" title="' . $catSub['tags'] . '" /></td>';
         echo '<td align="center">' . date('d/m/Y H:i', strtotime($catSub['data'])) . '</td>';
         echo '<td align="center" colspan="2"><a href="index2.php?exe=posts/categorias-edit&edit=' . $catSub['id'] . '&uri=' . $cat['url'] . '" ';
         echo 'title="editar categoria ' . $catSub['nome'] . '"><img src="ico/edit.png" alt="editar categoria ' . $catSub['nome'] . '" ';
         echo 'title="editar categoria ' . $catSub['nome'] . '" /></a></td>';
         echo '<td align="center"><a href="index2.php?exe=posts/categorias&delsub=' . $catSub['id'] . '" ';
         echo 'title="deletar categoria ' . $catSub['nome'] . '"><img src="ico/no.png" alt="deletar categoria ' . $catSub['nome'] . '" ';
         echo 'title="deletar categoria ' . $catSub['nome'] . '" /></a></td>';
         echo '</tr>';
Exemple #21
0
    do {
        $nt[] += $notes['Symbol'];
    } while ($notes = mysqli_fetch_array($sql_notes));
}
$ex = explode(">", htmlspecialchars_decode($result['Text']));
$len = 0;
$i = 0;
echo $ex[0] . '>';
for ($k = 1; $k < count($ex); $k++) {
    $ex1 = explode("<", $ex[$k]);
    $ex1 = explode(" ", $ex1[0]);
    for ($m = 0; $m < count($ex1); $m++) {
        $i += mb_strlen($ex1[$m], "UTF-8");
    }
}
echo '<input type="hidden" id="smb" value="' . mb_strlen(htmlspecialchars_decode($result['Text']), "UTF-8") . '">';
echo htmlspecialchars_decode($result["Text"]);
echo '</div>
</article>';
if (read($result["Id"], $_SESSION["user"]) == 'Y') {
    ?>
<p align="center" style="margin-top:2em"><button type="button" class="btn btn-danger" onclick="BookDone()">КНИГА ПРОЧТЕНА</button></p>
<?php 
}
?>
<div id="modal_form"><!-- Сaмo oкнo --> 
      <span id="modal_close" onclick="close_modal()">X</span>
      <font id="modal_content"></font>
</div>
<div id="overlay"></div>
 function skip($bytes)
 {
     $data = read($bytes);
     return strlen($data);
 }
Exemple #23
0
		<form action='<?php 
htmlentities($_SERVER["PHP_SELF"]);
?>
' method='POST'>
			<textarea name='new_text'></textarea><br>
			<input type='hidden' value='Main' name='text'>
			<input type='submit'>
		</form>
		
		<div id='container'>
			<img src='images/home-main.jpg' class='home_img'/>
			<h3 class='home_img_overlay'> Your Business Here </h3>
		</div>

		<?php 
echo "<h2 id='mission'><pre>" . read($filename, 'Mission') . "</pre></h2>";
?>

		<form action='<?php 
htmlentities($_SERVER["PHP_SELF"]);
?>
' method='POST'>
			<textarea name='new_text'></textarea><br>
			<input type='hidden' value='Mission' name='text'>
			<input type='submit'>
		</form>

		


		
Exemple #24
0
        ?>
            <option value="<?php 
        echo $postedit['cat_id'];
        ?>
" ><?php 
        echo $cat['nome'];
        ?>
</option>
            <?php 
        $readCAtegoriaPai = read('cat', "WHERE id_pai IS NULL AND tipo = 'dropmenu'");
        if (!$readCAtegoriaPai) {
            echo '<option value="">N&atilde;o encontramos categoria &nbsp;&nbsp;</option>';
        } else {
            foreach ($readCAtegoriaPai as $pai) {
                echo ' <option value=""disabled="disabled">' . $pai['nome'] . '</option>';
                $readCategorias = read('cat', "WHERE id_pai = '{$pai['id']}'");
                if (!$readCategorias) {
                    echo ' <option value="" disabled="disabled">&raquo; &raquo; Cadastre uma sub Categoria aqui!</option>';
                } else {
                    foreach ($readCategorias as $cat) {
                        echo ' <option value="' . $cat['id'] . '"';
                        if ($cat['id'] == $postedit['categoria']) {
                            echo 'selected ="selected"';
                        }
                        echo '>&raquo; &raquo;' . $cat['nome'] . '</option>';
                    }
                }
            }
        }
        ?>
            
Exemple #25
0
?>

<div id="content">

<div class="single">
	<h1 class="pgtitulo"><?php 
echo $art['titulo'];
?>
</h1>
      
    <div class="content">
      <?php 
echo $art['content'];
?>
        <?php 
$readArtGb = read('up_posts_gb', "WHERE post_id = '{$art['id']}'");
if ($readArtGb) {
    echo '<ul class="gallery">';
    foreach ($readArtGb as $gb) {
        $gbnum++;
        echo '<li';
        if ($gbnum % 5 == 0) {
            echo ' class="last" ';
        }
        echo '>';
        getThumb($gb['img'], $art['titulo'] . '( imagem' . $gbnum . ')', $art['titulo'], '100', '65', $art['id'], '', '', '#');
        echo '</li>';
    }
    echo '</ul><!-- //gallery -->';
}
?>
function channel_read($chan_id, $len)
{
    $c = get_channel_by_id($chan_id);
    if ($c) {
        # First get any pending unread data from a previous read
        $ret = substr($c['data'], 0, $len);
        $c['data'] = substr($c['data'], $len);
        if (strlen($ret) > 0) {
            my_print("Had some leftovers: '{$ret}'");
        }
        # Next grab stderr if we have it and it's not the same file descriptor
        # as stdout.
        if (strlen($ret) < $len and is_resource($c[2]) and $c[1] != $c[2]) {
            # Read as much as possible into the channel's data buffer
            $read = read($c[2]);
            $c['data'] .= $read;
            # Now slice out however much the client asked for.  If there's any
            # left over, they'll get it next time.  If it doesn't add up to
            # what they requested, oh well, they'll just have to call read
            # again. Looping until we get the requested number of bytes is
            # inconsistent with win32 meterpreter and causes the whole php
            # process to block waiting on input.
            $bytes_needed = $len - strlen($ret);
            $ret .= substr($c['data'], 0, $bytes_needed);
            $c['data'] = substr($c['data'], $bytes_needed);
        }
        # Then if there's still room, grab stdout
        if (strlen($ret) < $len and is_resource($c[1])) {
            # Same as above, but for stdout.  This will overwrite a false
            # return value from reading stderr but the two should generally
            # EOF at the same time, so it should be fine.
            $read = read($c[1]);
            $c['data'] .= $read;
            $bytes_needed = $len - strlen($ret);
            $ret .= substr($c['data'], 0, $bytes_needed);
            $c['data'] = substr($c['data'], $bytes_needed);
        }
        # In the event of one or the other of the above read()s returning
        # false, make sure we have sent any pending unread data before saying
        # EOF by returning false.  Note that if they didn't return false, it is
        # perfectly legitimate to return an empty string which just means
        # there's no data right now but we haven't hit EOF yet.
        if (false === $read and empty($ret)) {
            if (interacting($chan_id)) {
                handle_dead_resource_channel($c[1]);
            }
            return false;
        }
        return $ret;
    } else {
        return false;
    }
}
Exemple #27
0
<?php

use Cake\Datasource\ConnectionManager;
use Cake\Utility\Hash;
ConnectionManager::config(Hash::merge(['default' => ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => env('DATABASE_DEFAULT_HOST') ?: 'localhost', 'username' => env('DATABASE_DEFAULT_USER') ?: 'my_app', 'password' => env('DATABASE_DEFAULT_PASS') ?: 'secret', 'database' => env('DATABASE_DEFAULT_NAME') ?: 'my_app', 'prefix' => false, 'encoding' => strtolower(str_replace('-', '', read('App.encoding'))), 'timezone' => read('App.timezone'), 'quoteIdentifiers' => false], 'test' => ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => env('DATABASE_TEST_HOST') ?: 'localhost', 'username' => env('DATABASE_TEST_USER') ?: 'my_app', 'password' => env('DATABASE_TEST_PASS') ?: 'secret', 'database' => env('DATABASE_TEST_NAME') ?: 'test_myapp', 'prefix' => false, 'encoding' => strtolower(str_replace('-', '', read('App.encoding'))), 'timezone' => read('App.timezone'), 'quoteIdentifiers' => false]], consume('Datasources')));
Exemple #28
0
<?php

// Defaults
$default = read(__DIR__ . '/default.php');
// Router
$router = read(__DIR__ . '/router.php');
// Load environment configuration
$environment = [];
if (file_exists(__DIR__ . '/../../env.php')) {
    $environment = read(__DIR__ . '/../../env.php');
}
if (file_exists(__DIR__ . '/env.php')) {
    $environment = read(__DIR__ . '/env.php');
}
$config = [];
if (isset($environment['env']['name'])) {
    $config = read(__DIR__ . '/' . $environment['env']['name'] . '.php');
}
return array_replace_recursive($default, $router, $config, $environment);
Exemple #29
0
        $read_from_table .= "]}";
        echo $read_from_table;
    } else {
        echo "0 results";
    }
}
session_start();
$servername = "ruochenwebtestcom.ipagemysql.com";
$username = "******";
$password = "******";
$dbname = "inventory_management";
//create connection
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
//create_input_table($conn);
//drop_input_table($conn,$dbname);
if (strcmp($_GET["purpose"], "add") == 0) {
    add($conn);
}
if (strcmp($_GET["purpose"], "read") == 0) {
    read($conn);
}
if (strcmp($_GET["purpose"], "delete") == 0) {
    delete($conn);
}
if (strcmp($_GET["purpose"], "update") == 0) {
    update($conn);
}
$conn->close();
Exemple #30
0
 <div class="pu">
    <?php 
$readpublicidade = read("publicidade", " WHERE pg ='noticias' LIMIT 6");
if (!$readpublicidade) {
    echo 'Publicidades:';
} else {
    echo '<ul>';
    foreach ($readpublicidade as $publi) {
        echo '<li>' . getTumb($publi["thumb"], $publi['nome'], $publi['nome'], 250, 135, '', '', $publi['link']) . '</li>';
    }
    echo '</ul>';
}
?>
	  
    
  </div><!-- publicidades -->