mlsync.php 1.15 KB
Newer Older
Feu's avatar
Feu committed
1 2
<?php

Feu's avatar
Feu committed
3
$topdir = "./";
Feu's avatar
Feu committed
4
require_once($topdir. "include/mysql.inc.php");
Feu's avatar
Feu committed
5 6
require_once($topdir. "include/mysqlae.inc.php");

Feu's avatar
Feu committed
7
if ( $_SERVER["REMOTE_ADDR"] != "127.0.1.1" )
Feu's avatar
Feu committed
8
{
Feu's avatar
Feu committed
9
  echo "ERROR HTTPS REQUIRED";
Feu's avatar
Feu committed
10 11 12 13 14
  exit();
}

$db = new mysqlae ("rw");

Feu's avatar
Feu committed
15 16 17 18 19 20
if ( !$db->dbh )
{
  echo "ERROR DB UNAVAILABLE";
  exit();
}

Feu's avatar
Feu committed
21 22 23 24 25 26 27
$valid = new requete($db,
  "SELECT `key` ".
  "FROM `sso_api_keys` ".
  "WHERE `key` = '".mysql_real_escape_string($_REQUEST["key"])."'");

if ( $valid->lines != 1 )
{
Feu's avatar
Feu committed
28
  echo "ERROR KEY NOT VALID\n";
Feu's avatar
Feu committed
29 30 31 32 33 34
  exit();
}

if ( isset($_REQUEST["done"]) )
{
  $num = intval($_REQUEST["done"]);
35

Feu's avatar
Feu committed
36
  $req = new requete($db,"SELECT num_todo FROM ml_todo WHERE num_todo <= $num ORDER BY num_todo DESC LIMIT 1");
Feu's avatar
Feu committed
37 38 39 40 41 42 43 44 45 46 47

  if ($req->lines!= 1 )
  {
    echo "ERROR ACK NONE";
  }
  else
  {
    list($real) = $req->get_row();
    new requete($db,"DELETE FROM ml_todo WHERE num_todo <= $num");
    echo "ACK ".$real;
  }
48
  exit();
Feu's avatar
Feu committed
49 50 51 52 53 54 55
}

$req = new requete($db,"SELECT * FROM ml_todo ORDER BY num_todo");

while ( $row = $req->get_row() )
{
  echo $row["num_todo"]." ".$row["action_todo"]." ".$row["ml_todo"];
Feu's avatar
Feu committed
56
  if ( !is_null($row["email_todo"]) )
Feu's avatar
Feu committed
57 58 59 60
    echo " ".$row["email_todo"];
  echo "\n";
}

Ayolo's avatar
Ayolo committed
61
?>