Uso de PHP para agregar Facebook Open Graph Acción Leer

I’m trying to get Facebook to publish a read action using PHP. I’ve coded it totally wrong and need a little help:

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
?>

<?php

curl -F 'access_token=MY ACCESS TOKEN'
     -F 'article=echo 'echo curPageURL();'
        'https://graph.facebook.com/me/news.reads'

?>

The second part is that bit I can’t translate into PHP properly. I’ve no idea where to start as I’m a novice with PHP and only just learning the Open Graph API.

Etiquetado , , , | Deja un comentario

Error en la consulta, Identificación de recursos lo que es #9?

I have following code..

$query = "SELECT quote, author FROM quotes ORDER BY id DESC";
$resut = mysql_query($query, $connection) or die(mysql_error());

echo $result; //for debuggin purpose

while($result_set =  mysql_fetch_array($result)) {
    echo '<div class="pullquote">';
    echo $result_set['quote'];
    echo ' - ';
    echo $result_set['author'];
    echo '</div>';
}

and this doesn’t works! The table is not empty FYI, all I see in the output is:

Identificación de recursos #9

I am not being able to figure out what this Resource id #9 medio.
As I tested SELECT quote, author FROM quotes ORDER BY id DESC in phpmyadmin, that just works fine and produces desired result, but not in here. I wonder what is wrong with the code or something?

If I do following,

$array = mysql_fetch_assoc($result);
var_dump ($array);

Devuelve, bool(false). What does that mean here?

Etiquetado | Deja un comentario

Insertar valor para el usuario en la tabla de mensajes en los que el usuario la división = division.divisionid

Can anyone shed any light on how I insert a table entry in my messages table for each user.ID where the users.MM_Division = division.divisionid

I want to include the user ID value in the messages.messagesuserid

I think I need a while loop but I’m not sure how I implement it when dealing with a insert query.

En la actualidad, en 1 message row is inserted into the messages table on the messageuserid value posts as NULL

Gracias

Aquí está mi código:

session_start();

$colname_division = "-1";
if ((isset($_GET['divisionid'])) && ($_GET['divisionid'] != "")) {
      $colname_division = $_GET['divisionid'];

mysql_select_db($database_connect, $connect);
$query_users = sprintf("SELECT users.*, division.* FROM users INNER JOIN division ON division.divisionid = users.MM_Division WHERE divisionid = %s", GetSQLValueString($colname_users, "int"));
$users = mysql_query($query_users, $connect) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);

// MESSAGE USERS DIVISION ARCHIVED
    $messageinsertSQL = sprintf("INSERT INTO messages (message, messageuserid) VALUES ('The division " . $row_division['division'] . " has been archived by " . $_SESSION['MM_Username'] . " please select a new division', '" . $row_users['ID'] . "')",GetSQLValueString($_GET['divisionid'], "int"));
    mysql_select_db($database_connect, $connect);
    $Result4 = mysql_query($messageinsertSQL, $connect) or die(mysql_error());

// REDIRECT
    $updateGoTo = "../divisions.php";
        if (isset($_SERVER['QUERY_STRING'])) {
            $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
            $updateGoTo .= $_SERVER['QUERY_STRING'];
        }
    header(sprintf("Location: %s", $updateGoTo));

    mysql_free_result($division);
    exit;
}
Etiquetado , , , | Deja un comentario

SSH Conexión a Amazon EC2 Instancia a través de PHP

Trying to connect to an Amazon EC2 instance using a .pem file, PHP, and phpseclib.

I have tried what’s mentioned in this post:
ssh access to ec2 from php

Sin embargo, Sigo recibiendo “Error 111. Connection refused in…”

When I connect from my own machine using ssh and the same .pem file, there are no errors.

Here is the code from the original post that I am using:

include('Net/SSH2.php');
include('Crypt/RSA.php');

$key = new Crypt_RSA();

$key->loadKey(file_get_contents('/pathtokey.pem'));

$ssh = new Net_SSH2('ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com');
if (!$ssh->login('user', $key)) {
exit('Login Failed');
}
Etiquetado , , | Deja un comentario

PHP MySQL session_set_save_handler condición de carrera

I have written a simple session_set_save_handler using a MySQL innoDB table as the storage backend. MySQL is 5.5.

Code looks like so (very simplified, but hopefully illustrates the flow of code), Estoy usando Redbean ORM for interacting with the database, but the commands should be clear in showing what was being written, read or deleted.:

class MySession{

    private $_database;  

    public function  __construct($database){
       //database object is injected using dependency injection then assigned to private var

       //Hook up handlers
       session_set_save_handler(
        array($this, "open"),
        array($this, "close"),
        array($this, "read"),
        array($this, "write"),
        array($this, "destroy"),
        array($this, "garbageCollection"));
       }

       //Register the shutdown function
       register_shutdown_function('session_write_close'); 

       //start
       session_start();

       //Regenerate session id
       //(NOTE: in production code, the id is regenerated every 10 minutes,
       //but regenerating allows us to trigger the race condition for demonstration.
       session_regenerate_id(TRUE);

    public function open($savePath, $sessionName){
        $this->_database->exec('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
        $this->_database->begin(); //Begin Transaction
        return true;
    }   

    public function close(){
        $this->_database->commit(); //Commit the transaction
        return true;
    }

    public function read($id){

        $this->_database->exec('SELECT * FROM session WHERE identifier = ? LOCK IN SHARE MODE', array($id));
        $session = $this->_database->findOne('session', 'identifier = ?', array($id));
        return $session->data;
    }

    public function write($id, $sessionData){

        $this->_database->exec('SELECT * FROM session WHERE identifier = ? FOR UPDATE', array($id));
        $session = $this->_database->findOne('session', 'identifier = ?', array($id));

        //We need to create a new session
        if ($session == NULL){
            $session = $this->_database->dispense('session');
        }

        $this->_database->store($session);
        return TRUE;
    }

    public function destroy($id){
        $this->_database->exec('SELECT * FROM session WHERE identifier = ? FOR UPDATE', array($id));
        $session = $this->_database->findOne('session', 'identifier = ?', array($id));

        if ($session != NULL){
            $this->_database->trash($session);
        }
        return TRUE;
    }

    public function garbageCollection($maxlifetime){
        $old = ... //Calculate the time for expired sessions

        $this->_database->exec("DELETE from session WHERE last_activity < ?", array($old));
        return TRUE;
    }
}

The problem is that even with the locking in place, if I send multiple requests to the application (por ejemplo, el uso de AJAX), the race condition still occurs and the data stored in the session is lost. I have pinned it down to session_regenerate_id(TRUE), which deletes the previous session to being the cause of the issue. Sin embargo, even with the row locking, the issue still occurs.

I have looked at this página, as well as some código from that author, but that uses MyISAM tables which implements table locking.

Can anyone shed some light as to why the locking is not making a difference and perhaps offer some solutions to this problem?

Etiquetado , , , , | Deja un comentario

Agregar código personalizado a HML Tema WordPress Niño Sin Cambio Archivo de plantilla?

I am working with a WordPress child theme, and I’d like to insert a custom line of HTML code. Normalmente, I’d simply put this extra HTML code in header.php, and while I know that I can copy the parent header.php and edit it in the child theme as the child header.php, I don’t want to do this because I will have to go back and re-update the header.php file when I eventually update the parent theme.

Is the best approach to simply use a functions.php file in the child theme and call the wp_head hook to insert the text? I don’t like the idea of the text being in the <head></head> area because it really should be in the <body></body>, but I will ultimately position the code with .css anyway.

Etiquetado | Deja un comentario

Para un sitio web de revisión, que el lenguaje?

I am thinking of building a review website and i was thinking about using php. What language would be good for a website like ratemyprofessor? would ruby be better?

Etiquetado , , | Deja un comentario

php mysql get resultado no es tan amplia, pero como texto

I want to get text result like:

+----+-------+----------------------------------+----+
| id | login | pwd                              | su |
+----+-------+----------------------------------+----+
|  1 | root  | c4ca4238a0b923820dcc509a6f75849b |  1 |
+----+-------+----------------------------------+----+
1 row in set (0.00 sec)

en PHP (cadena).

Ejemplo en php:

$query = mysql_query("SELECT * FROM users");
for (; $row = mysql_fetch_assoc($query); $data[] = $row);

I get array of arrays ($datos):

$data =
   0 => (id=>1, login=>root..)

But i want to get this as cadena:

+----+-------+----------------------------------+----+
| id | login | pwd                              | su |
+----+-------+----------------------------------+----+
|  1 | root  | c4ca4238a0b923820dcc509a6f75849b |  1 |
+----+-------+----------------------------------+----+
1 row in set (0.00 sec)

By the way for queryinsert into users set login =sp’, pwd = 1, su = 0″, this string must beQuery OK, 1 row affected, 2 advertencias (0.18 segundo)”.

Like sql terminal though php!

Etiquetado , , | Deja un comentario

El envío de una petición POST sin presentar un formulario HTML

Me pregunto, is it possible to send an HTTP POST in PHP without using an HTML form. Can this be done internally using PHP? Sino, maybe using JavaScript or jQuery?

Etiquetado , | Deja un comentario

How to keep the Chinese or other foreign language as they are instead of converting them into codes?

DOMDocument seems to convert Chinese characters into codes, por ejemplo,,

你的乱发 will become ä½ çš„ä¹±å‘

How can I keep the Chinese or other foreign language as they are instead of converting them into codes?

Below is my simple test,

$dom = new DOMDocument();
$dom->loadHTML($html);

If I add this below before loadHTML(),

$html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");

Me,

你的乱发

Even though the coverted codes will be displayed as Chinese characters, 你的乱发 still are not 你的乱发 what I am after….

Etiquetado , , , , | Deja un comentario
2207 páginas