Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_host = 'localhost';
- $db_name = "dados";
- $mysql_charset = "utf8";
- $db_username = "root";
- $db_password = "";
- // Initiate curl
- $ch = curl_init();
- // Disable SSL verification
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- // Will return the response, if false it print the response
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- // Set the url
- curl_setopt($ch, CURLOPT_URL, "http://graph.facebook.com/?id=https://gamaia.com.br/");
- // Execute
- $result = curl_exec($ch);
- // Closing
- curl_close($ch);
- // Will dump a beauty json :3
- var_dump(json_decode($result, true));
- $json = json_decode($result, true);
- echo " <br />Compartilhamento Atual:".$json["share"]["share_count"];
- //conexão com o host
- try{
- $PDO = new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset='.$mysql_charset, $db_username, $db_password);
- }catch(PDOException $e){
- echo($e->getMessage());
- }
- //selecionar tabela
- $stmt = $PDO->prepare("SELECT * FROM tab_produtos_promo WHERE idpromo = 1");
- $stmt->execute();
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- ################################################################
- #REDIRECIONAMENTO
- $url = $row['cmp_codigo'];
- header("location: http://localhost/gamaia_test/detalhes".$row['url']);
- $shared = $row['shared'];
- echo "<br ><br >Compartilhamento até o inicio: ".$shared;
- $atual = $json["share"]["share_count"] - $shared;
- echo "<br ><br >Atual da Pagina:".$atual;
- // Preços
- $preco = $row['cmp_preco_de'];
- $precoMin = $row['promo'];
- $desconto = $row['desconto'];
- // formula de calculo
- $precoAtual = $preco - ( $desconto * $atual );
- echo "<br ><br >".$preco." -> ".$precoAtual;
- if($precoAtual <= $precoMin){
- //If para remover o item após ultrapassar o preço minimo
- $stmt = $PDO->prepare("UPDATE tab_produtos SET cmp_estoque = 0");
- $stmt->execute();
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- echo "<br>Remover</br>";
- }
- else {
- $stmt = $PDO->prepare("UPDATE tab_produtos SET cmp_preco_por = :preco2");
- $stmt->bindParam(':preco2', $precoAtual);
- $stmt->execute();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement