Пример #1
0
function gravarPermissoes()
{
    include '../dao/ConnectionHolder.php';
    $idUsuario = $_POST["idUsuario"];
    if (!$idUsuario) {
        finalize("idUsuario não fornecido!");
    }
    $idList = $_POST["list"];
    if (!$idList) {
        finalize("Lista de permissões vazia!");
    }
    try {
        $connection = ConnectionHolder::getConnection();
        // PROBLEMA!!
        // O postgres não trabalha com o conceito de transação, commit e rollback,
        // ao invés disso, deve ser enviada uma query, sendo todo o script sql,
        // e será executado todo, ou nada.
        // Fonte: http://stackoverflow.com/questions/9704557/php-pgsql-driver-and-autocommit
        // Apaga as permissoes existentes para o usuário
        $query = "DELETE FROM permissoes WHERE idusuario = " . $idUsuario . "; ";
        // Insere as operações recebidas por POST
        foreach ($idList as $id) {
            $query .= "INSERT INTO permissoes (idoperacaomodulo, idusuario) " . "VALUES (" . $id . ", " . $idUsuario . "); ";
        }
        $resultSet = pg_query($connection, $query);
        if (!$resultSet) {
            finalize("Query error");
        }
        done();
    } catch (Exception $e) {
        finalize("Exception: " . $e->getMessage());
    }
}
Пример #2
0
function alterarCRM()
{
    include '../dao/Cliforn.php';
    include '../dao/ClifornDAO.php';
    $clifornDAO = new ClifornDAO();
    $cliforn = $clifornDAO->selectRegistro($_POST["id"]);
    if (!$cliforn) {
        finalize("Cliente/Fornecedor não encontrado para alteração!");
    }
    if ($_POST["tipo"] == "F") {
        $cliforn->setNome($_POST["nome"]);
        $cliforn->setSexo($_POST["sexo"]);
        $cliforn->setDatanascimento($_POST["datanascimento"]);
        $cliforn->setCpf($_POST["cpf"]);
        $cliforn->setRg($_POST["rg"]);
    } else {
        $cliforn->setRazaosocial($_POST["razaosocial"]);
        $cliforn->setFantasia($_POST["fantasia"]);
        $cliforn->setCnpj($_POST["cnpj"]);
        $cliforn->setIe($_POST["ie"]);
    }
    $cliforn->setAtivo($_POST["ativo"] == "true");
    if ($clifornDAO->alterar($cliforn)) {
        done();
    }
    finalize("Erro ao alterar usuário!");
}
Пример #3
0
function error($code, $msg)
{
    global $background_log, $task_id, $instance, $status_path;
    $log_line = date("Y-m-d h:i:s") . " - {$task_id} - {$instance} - {$code} - {$msg}\n";
    file_put_contents($background_log, $log_line, FILE_APPEND);
    if ($status_path !== "") {
        update_status($code, $msg);
    }
    done();
}
Пример #4
0
function it(\string $phrase, \Closure $callback)
{
    global $__current;
    $__current['it_phrase'] = $phrase;
    $return_value = $callback(function ($is_ok) {
        return done($is_ok);
    });
    $__current['it_phrase'] = 'XxX';
    return $return_value;
}
Пример #5
0
function doit()
{
    global $HTTP_POST_VARS;
    if ($HTTP_POST_VARS['field_username'] != "") {
        $passwordhash = query_password($HTTP_POST_VARS['field_username']);
    } else {
        $passwordhash = query_password($HTTP_POST_VARS['field_email'], false);
    }
    if (is_array($passwordhash)) {
        send_mail($passwordhash);
    }
    done();
}
Пример #6
0
function build_query()
{
    global $appid, $service;
    if (empty($_REQUEST['query']) || !in_array($_REQUEST['type'], array_keys($service))) {
        done();
    }
    $q = '?query=' . rawurlencode($_REQUEST['query']);
    # if(!empty($_REQUEST['zip'])) $q.="&zip=".$_REQUEST['zip'];
    if (!empty($_REQUEST['start'])) {
        $q .= "&start=" . $_REQUEST['start'];
    }
    $q .= "&appid={$appid}";
    return $q;
}
Пример #7
0
 /**
  * The main function. It checks the command line arguments and calls different class behaviours.
  *
  * @return integer the exit code
  */
 public function run()
 {
     // No arguments; display the help
     if ($this->argc == 1) {
         // Show the usage
         echo $this->getUsage();
         echo "\n";
         return 0;
     }
     // Exactly one argument with value 'test'; run the tests
     if ($this->argc == 2 && $this->argv[1] === 'test') {
         echo "Running the tests...\n";
         $result = $this->runTests();
         // Forcibly call die(1) when any of the tests using function it() (file: TestFrameworkInATweet.php) fails
         done();
         // No problem. Continue
         echo "All tests completed successfully.\n";
         return $result;
     }
     // Exactly one argument with value 'source'; display the golfed code source
     if ($this->argc == 2 && $this->argv[1] === 'source') {
         $code = $this->getTheGolfedCode();
         printf("<?php // %d bytes\n", strlen($code));
         echo $code;
         echo "\n";
         return 0;
     }
     // Exactly one argument with value 'help'; display the program's usage
     if ($this->argc == 2 && $this->argv[1] === 'help') {
         echo $this->getUsage();
         return 2;
     }
     // Everything else: run the golfed code with the provided command line
     try {
         return $this->runTheGolfedCode($this->argc, $this->argv);
     } catch (InvalidArgumentException $e) {
         // The code cannot handle the arguments provided in the command line
         // Either their values are invalid or the number of arguments doesn't match
         echo $e->getMessage() . "\n";
         echo "\n";
         // Show the help again and exit
         echo $this->getUsage();
         return 3;
     } catch (Exception $e) {
         // Generic exception; this is a problem in the code.
         // There is nothing the user can do
         printf("Unhandled exception '%s' with message: %s.\nCannot continue.\n", get_class($e), $e->getMessage());
         return 4;
     }
 }
Пример #8
0
function verificarLogin()
{
    include '../dao/Usuarios.php';
    include '../dao/UsuariosDAO.php';
    $login = $_POST["login"];
    $senha = $_POST["senha"];
    $usuariosDAO = new UsuariosDAO();
    $usuarios = $usuariosDAO->selectRegistroPorLogin($login);
    if (!$usuarios) {
        finalize(NULL);
    }
    if (strcmp($usuarios->getSenha(), $senha) != 0) {
        finalize(NULL);
    }
    iniciarSessao($usuarios);
    done();
}
Пример #9
0
function alterarUsuario()
{
    include '../dao/Usuarios.php';
    include '../dao/UsuariosDAO.php';
    $usuariosDAO = new UsuariosDAO();
    $usuarios = $usuariosDAO->selectRegistro($_POST["id"]);
    if (!$usuarios) {
        finalize("Usuário não encontrado para alteração!");
    }
    $usuarios->setLogin($_POST["login"]);
    $usuarios->setNome($_POST["nome"]);
    $usuarios->setEmail($_POST["email"]);
    $usuarios->setSenha($_POST["senha"]);
    $usuarios->setAtivo($_POST["ativo"] == "true");
    if ($usuariosDAO->alterar($usuarios)) {
        done();
    }
    finalize("Erro ao alterar usuário!");
}
Пример #10
0
function buscarCRMList()
{
    include '../dao/Cliforn.php';
    include '../dao/ClifornDAO.php';
    $clifornDAO = new ClifornDAO();
    $clifornList = $clifornDAO->selectListaTodosRegistros();
    if (!$clifornList) {
        done();
    }
    $list['success'] = 1;
    $list['data'] = array();
    foreach ($clifornList as $cli) {
        $cpfcnpj = $cli->getCnpj();
        $nome = $cli->getRazaosocial();
        if ($cli->getTipo() == "F") {
            $cpfcnpj = $cli->getCpf();
            $nome = $cli->getNome();
        }
        $list['data'][] = array("id" => $cli->getId(), "nome" => $nome, "estado" => "Hm?", "cidade" => "Que?", "cpfcnpj" => $cpfcnpj);
    }
    echo json_encode($list);
}
Пример #11
0
$sql_last = mysqli_query($bd, "SELECT * FROM `BOOKS` ORDER BY `Id` DESC LIMIT 25");
if (mysqli_num_rows($sql_last) > 0) {
    $last = mysqli_fetch_array($sql_last);
    do {
        echo '<article class="box post post-excerpt">
							<header>
								
								<h2><a href="' . $home_url . 'books/' . $last['URL'] . '">' . $last['Title'] . '</a></h2>
								
							</header>
							<div class="info">
									<span class="date"><span class="day">' . $last['Yaer'] . '</span></span>
								
								<ul class="stats">
									<li><a href="#" class="icon fa-book ">' . reading($last['Id']) . '</a></li>
									<li><a href="#" class="icon fa-check">' . done($last['Id']) . '</a></li>
									<li><a href="#" class="icon fa-comment">' . comment($last['Id']) . '</a></li>
									<li>' . author($last['AUTHOR_ID']) . '</li>
								</ul>
							</div>
							<table style="width:100%">
								<tr>
									<td style="max-width:30%;vertical-align: top;"><a href="' . $home_url . 'books/' . $last['URL'] . '" class="image featured"><img src="' . $home_url . 'images/books/' . $last['Image'] . '" alt="" /></a></td>
									
									<td style="padding-left:1em">' . $last['Description'] . '</td>
								</tr>
							</table>
							
							
						</article>
';
Пример #12
0
            case 'Cache':
                #echo "Cache: <a href=\"{$value->Url}\">{$value->Url}</a> [{$value->Size}]<br />\n";
                break;
            case 'FileSize':
                break;
            case 'FileFormat':
                break;
            case 'Height':
                break;
            case 'Width':
                break;
            case 'PublishDate':
                break;
            case 'ModificationDate':
                #echo "<b>$key:</b> ".strftime('%X %x',(int)$value)."<br />\n";
                break;
            default:
                if (stristr($key, 'url')) {
                    echo "<a href=\"{$value}\">{$value}</a><br />\n";
                } else {
                    echo "<b>{$key}:</b> {$value}<br />";
                }
                break;
        }
    }
    echo "<hr />\n";
}
next_prev($res, $first, $last);
#echo "<br /><br />Page generated in <b>".(microtime(true)-$st_timer)."</b> seconds<br />\n";
done();
Пример #13
0
function checkOK($field)
{
    if (stristr($field, "\\r") || stristr($field, "\\n")) {
        done(450, "Invalid input parameter.");
    }
}
Пример #14
0
}
$user = $_REQUEST['user'];
$pass = $_REQUEST['pass'];
$field = 'cust_' . $_REQUEST['field'];
if ($_SERVER['REMOTE_ADDR'] != $localaddr) {
    writeToFile($_SERVER['REMOTE_ADDR'] . " user: {$user}, field: {$field}, pass length: " . strlen($pass));
}
$db_server = 'localhost';
$db_name = 'smf';
$db_user = '******';
$db_passwd = 'your_db_pass';
$db_prefix = 'smf_';
$mysqli = new mysqli($db_server, $db_user, $db_passwd, $db_name);
$stmt = $mysqli->prepare("SELECT `member_name`, `passwd`, `real_name` FROM `smf_members` WHERE `is_activated` = '1' AND `id_member` = (SELECT `id_member` FROM `smf_themes` WHERE `value` = ? AND `variable` = ?) LIMIT 1") or done('MySQL Error');
$stmt->bind_param("ss", $user, $field);
$stmt->execute();
// bind result variables
$stmt->bind_result($member_name, $pass_hash, $display_name);
$success = $stmt->fetch();
$stmt->close();
$mysqli->close();
if (!$success) {
    done('Name not registered, must put in profile on forum: URL_TO_YOUR_FORUM');
}
// hash password
$sha_passwd = sha1(strtolower($member_name) . htmlspecialchars_decode($pass));
if ($sha_passwd != $pass_hash) {
    done('Incorrect Password, make sure you use your forum password.');
}
done($display_name, "YES\n%s");
Пример #15
0
function test_clearSimpleCache($cache)
{
    $cacheAPI = new cacheAPI($cache);
    $tiko = new tikoCacheController($cacheAPI);
    // It should fetch requiredCacheParameters from cache
    // Since there are no required parameters, the item should now also be retrieved by cache.
    $tiko->removeCacheForURL();
    // Now, we load a new tiko instance
    $cacheAPI = new cacheAPI($cache);
    $tiko = new tikoCacheController($cacheAPI);
    // It should fetch requiredCacheParameters from cache
    // Since there are no required parameters, the item should now also be retrieved by cache.
    // But, *since it is removed*, it should not be found. Let's check
    $result = $cacheAPI->getItem();
    if ($result !== null) {
        fail("CLEARING OF CACHE FOR URL FAILED. CACHE IS ");
        var_dump($cache);
    } else {
        done("CLEARING OF CACHE FOR URL WORKED");
    }
}
function update()
{
    extract($_REQUEST);
    if (isset($done)) {
        done($done);
    }
    if (!isset($ndate_year)) {
        $ndate_year = date("Y");
    }
    if (!isset($ndate_month)) {
        $ndate_month = date("m");
    }
    if (!isset($ndate_day)) {
        $ndate_day = date("d");
    }
    if (!isset($nhour)) {
        $nhour = date("H");
    }
    if (!isset($nminute)) {
        $nminute = date("i");
    }
    $date = "{$ndate_year}-{$ndate_month}-{$ndate_day}";
    $time = "{$nhour}:{$nminute}";
    if (!empty($ndesc)) {
        $sql = "\n\t\t\tINSERT INTO cubit.todo_sub (\n\t\t\t\tdatetime, description, done, main_id\n\t\t\t) VALUES (\n\t\t\t\t'{$date} {$time}', '{$ndesc}', '0', '{$id}'\n\t\t\t)";
        db_exec($sql) or errDie("Unable to add todo item.");
    }
    return view();
}
Пример #17
0
function sair()
{
    fecharSessao();
    done();
}
Пример #18
0
/** calculate the similarity between two words 
	only do the top 20 - 40 most similar words
**/
function calculateSimilarity()
{
    // variable declarations
    $w1 = array();
    $pos;
    $id;
    $sim;
    $information1;
    $information2;
    $numerator;
    $similarity;
    $r;
    $i = 0;
    $result2;
    //get word 1. excluding stop words, proper nouns and words that only occur once.
    /*Batch 1: < 645 - >= 300
    	Batch 2: < 300  >= 25*/
    $query = "SELECT id, word.word, pos, information, sentence_frequency \n\t\tfrom word, word_idf \n\t\tWHERE pos IN ('JJ', 'JJR', 'JJS', 'NN', 'NNS', 'RB', 'RBS', 'RP', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ') \n\t\tAND word.id = word_id\n\t\tAND sentence_frequency >= 25\n\t\tAND word.id <= 40000\n\t\tAND word.id >= 3518\n\t\tAND sentence_frequency < 300\n\t  AND sentence_frequency >= 2\n\t\tORDER BY sentence_frequency desc, word_id asc;";
    $result1 = mysql_query($query);
    while ($w1 = mysql_fetch_array($result1)) {
        $pos = $w1['pos'];
        $id = $w1['id'];
        $information1 = $w1['information'];
        if (!stopword($w1['word'] && !done($id))) {
            echo $w1['sentence_frequency'], ", ", $id, ": ", $w1['word'], " ", $pos, " ";
            // get dep numerator
            $query = "SELECT SUM(w1.information + w2.information) as numerator, w2.dep_id as word2, word.information as information2 from word,\n\t\t\t\t\t\t(SELECT gov_id, relation_id, information from dependency WHERE relation_id != 11 AND information > 0 AND dep_id = " . $id . ") as w1\n\t\t\t\t\t\tJOIN \n\t\t\t\t\t\t(SELECT gov_id, relation_id, information, dep_id from dependency WHERE relation_id != 11 AND information > 0 AND dep_id != " . $id . " AND dep_pos = '" . $pos . "') as w2\n\t\t\t\t\t\tON\n\t\t\t\t\t\t(w1.relation_id = w2.relation_id AND w1.gov_id = w2.gov_id) WHERE word.id = w2.dep_id GROUP BY w2.dep_id ORDER BY numerator desc;";
            $r = mysql_query($query) or die("<b>A fatal MySQL error occured</b>\n<br/> Query: " . $query . "\n<br/> Error: (" . mysql_errno() . ") " . mysql_error());
            echo "g:", mysql_num_rows($r), " d:";
            //clear any previous result
            //$query = "DELETE FROM similarity where word1_id = $id;";
            //$result2 = mysql_query($query) or die("<b>A fatal MySQL error occured</b>\n<br/> Query: " . $query . "\n<br/> Error: (" . mysql_errno() . ") ". mysql_error());
            $i = 0;
            while ($sim = mysql_fetch_array($r)) {
                $i += 1;
                if ($i <= 100) {
                    //calculate similarity
                    $similarity = $sim['numerator'] / ($information1 + $sim['information2']);
                    if ($similarity > 0) {
                        $query = "INSERT IGNORE INTO similarity (word1_id, word2_id, lin_similarity) VALUES (" . $id . ", " . $sim['word2'] . ", " . $similarity . ");";
                        $result2 = mysql_query($query) or die("<b>A fatal MySQL error occured</b>\n<br/> Query: " . $query . "\n<br/> Error: (" . mysql_errno() . ") " . mysql_error());
                    } else {
                        break;
                    }
                }
            }
            // get gov numerator
            $query = "SELECT SUM(w1.information + w2.information) as numerator, w2.gov_id as word2, word.information as information2 from word,\n\t\t\t(SELECT dep_id, relation_id, information from dependency WHERE relation_id != 11 AND information > 0 AND gov_id = " . $id . ") as w1\n\t\t\tJOIN \n\t\t\t(SELECT dep_id, relation_id, information, gov_id from dependency WHERE relation_id != 11 AND information > 0 AND gov_id != " . $id . " AND gov_pos = '" . $pos . "') as w2\n\t\t\tON\n\t\t\t(w1.relation_id = w2.relation_id AND w1.dep_id = w2.dep_id) WHERE w2.gov_id=word.id GROUP BY w2.gov_id ORDER BY numerator desc;";
            $r = mysql_query($query) or die("<b>A fatal MySQL error occured</b>\n<br/> Query: " . $query . "\n<br/> Error: (" . mysql_errno() . ") " . mysql_error());
            echo mysql_num_rows($r), "\n";
            $i = 0;
            while ($sim = mysql_fetch_array($r)) {
                $i += 1;
                if ($i <= 100) {
                    //calculate similarity
                    $similarity = $sim['numerator'] / ($information1 + $sim['information2']);
                    if ($similarity > 0) {
                        $query = "INSERT INTO similarity (word1_id, word2_id, lin_similarity) VALUES (" . $id . ", " . $sim['word2'] . ", " . $similarity . ") ON DUPLICATE KEY UPDATE lin_similarity = lin_similarity + VALUES(lin_similarity);";
                        $result2 = mysql_query($query) or die("<b>A fatal MySQL error occured</b>\n<br/> Query: " . $query . "\n<br/> Error: (" . mysql_errno() . ") " . mysql_error());
                    }
                } else {
                    break;
                }
            }
        }
    }
}
            remind($conn, 'kaffee');
            break;
        case "muell_done":
            done($conn, 'muell');
            break;
        case "pfand_done":
            done($conn, 'pfand');
            break;
        case "geschirr_ein_done":
            done($conn, 'ein');
            break;
        case "geschirr_aus_done":
            done($conn, 'aus');
            break;
        case "entkalken_done":
            done($conn, 'kaffee');
            break;
    }
    header("Refresh:2");
    echo 'Aktion wurde ausgeführt.<br><br>';
    print_r($_POST);
    exit;
}
?>





<!DOCTYPE html>
<html lang="de">
Пример #20
0
<?php

echo '<style>@media screen and (min-width: 1024px)
{
	#content {margin-left:14em;}
	
}</style>';
echo "<article class='box post post-excerpt'>\n\t\t\t\t\t\t\t<header><h2>{$result['Title']}</h2>\n\t\t\t\t\t\t\t" . '<a href="#" class="icon fa-book" style="margin-right:1.5em;color:#666"> ' . reading($result['Id']) . '</a>
							<a href="#" class="icon fa-check" style="margin-right:1.5em;color:#666"> ' . done($result['Id']) . '</a>
							<a href="#" class="icon fa-comment" style="margin-right:1.5em;color:#666"> ' . comment($result['Id']) . '</a>
							' . author($result['AUTHOR_ID']) . '
							' . cat($result['CATEGORY_ID']) . '
							' . "</header>";
echo '<table style="width:100%">
								<tr>
									<td style="max-width:30%;vertical-align: top;"><a href="' . $home_url . 'books/' . $result['URL'] . '" class="image featured"><img src="' . $home_url . 'images/books/' . $result['Image'] . '" alt="" /></a></td>
									
									<td style="padding-left:1em">' . htmlspecialchars_decode($result['Description']) . '</td>
								</tr>
							</table>';
if (!empty($_SESSION["user"])) {
    if (read($result["Id"], $_SESSION["user"]) == 'N') {
        echo '<p align="center"><a href="' . $home_url . 'online/' . $result["URL"] . '"><button type="button" class="btn btn-success">ЧИТАТЬ ОНЛАЙН</button></a></p>';
    }
    if (read($result["Id"], $_SESSION["user"]) == 'D') {
        echo '<p align="center"><a href="' . $home_url . 'online/' . $result["URL"] . '"><button type="button" class="btn btn-success">ОТКРЫТЬ</button></a></p>';
    }
    if (read($result["Id"], $_SESSION["user"]) == 'Y') {
        echo '<p align="center"><a href="' . $home_url . 'online/' . $result["URL"] . '"><button type="button" class="btn btn-primary">ПРОДОЛЖИТЬ ЧТЕНИЕ</button></a></p>';
    }
} else {
Пример #21
0
    if (isset($_POST["skip"])) {
        $cursor->skip($_POST["skip"] * 1);
    }
    if (isset($_POST["sort"])) {
        $val = jsonDecode($_POST["sort"]);
        $cursor->sort($val);
    }
    if ($subcommand == "explain") {
        $result = $cursor->explain();
    } else {
        if ($subcommand == "validate") {
            if ($cursor->hasNext()) {
                $cursor->getNext();
            }
            $result = $cursor->valid();
        } else {
            if ($subcommand == "count") {
                $result = $cursor->count();
            } else {
                $result = $cursor;
                $result = array();
                while ($cursor->hasNext()) {
                    $result[] = $cursor->getNext();
                }
            }
        }
    }
    done($result);
}
// ------------------------------------------- DONE
error("Unknown command.");