Ejemplo n.º 1
0
<?php

foreach ($_POST as $key => $value) {
    echo_log("{$key} = {$value}\r\n");
}
Ejemplo n.º 2
0
        break;
    case 'checkban':
        if (empty($_GET['username'])) {
            die('Bad request');
        }
        $status = m_checkban($_GET['username']);
        if (!$status) {
            $answer = array('username' => $_GET['username'], 'status' => 'not banned');
        } else {
            $answer = array('username' => $_GET['username'], 'status' => 'banned', 'info' => $status);
        }
        echo_log(json_encode($answer));
        break;
    case 'feedback':
        if (empty($jsonData['username']) || empty($jsonData['password'])) {
            die(echo_log(json_encode(array('error' => 'Bad request', 'errorMessage' => 'Bad request', 'cause' => 'Bad request'))));
        }
        if (!m_login($jsonData['username'], $jsonData['password'])) {
            die(json_encode(array('error' => 'Unauthorized', 'errorMessage' => 'Unauthorized', 'cause' => 'Wrong username/password')));
        }
        $logfile = "./feedback/" . $jsonData['username'] . "." . date('Y-m-d_H-i-s_') . explode(" ", microtime())[0] . ".log";
        if (file_put_contents($logfile, gzdecode(base64_decode($jsonData['log']))) || file_put_contents($logfile, base64_decode($jsonData['desc']) . "\n" . base64_decode($jsonData['log']) . "\n")) {
            $answer = array('username' => $jsonData['username'], 'status' => 'accepted');
        } else {
            $answer = array('username' => $jsonData['username'], 'status' => 'not accepted');
        }
        echo_log(json_encode($answer));
        break;
    default:
        die("I'm sorry, what?");
}
Ejemplo n.º 3
0
// And we can neither use INSERT / UPDATE because we cannot add the user_id
// to the unique constraint.
if ($re_register) {
    $retval = $PDOX->queryDie("UPDATE {$CFG->dbprefix}lti_key SET updated_at = NOW(), ack = :ACK,\n            new_secret = :SECRET, new_consumer_profile = :PROFILE\n            WHERE key_sha256 = :SHA and user_id = :UID", array(":SECRET" => $shared_secret, ":PROFILE" => $tc_profile_json, ":UID" => $_SESSION['id'], ":SHA" => $key_sha256, ":ACK" => $ack));
    if (!$retval->success) {
        lmsDie("Unable to UPDATE Registration key {$oauth_consumer_key} " . $retval->errorImplode);
    }
    echo_log("LTI2 Key {$oauth_consumer_key} updated.\n");
    // If we do not have a key, insert one, checking carefully for a failed insert
    // due to a unique constraint violation.  If this insert fails, it is likely
    // a race condition between competing INSERTs for the same key_id
} else {
    $retval = $PDOX->queryDie("INSERT INTO {$CFG->dbprefix}lti_key \n            (key_sha256, key_key, user_id, secret, consumer_profile)\n        VALUES\n            (:SHA, :KEY, :UID, :SECRET, :PROFILE)\n        ON DUPLICATE KEY\n            UPDATE secret = :SECRET, consumer_profile = :PROFILE\n        ", array(":SHA" => $key_sha256, ":KEY" => $oauth_consumer_key, ":UID" => $_SESSION['id'], ":SECRET" => $shared_secret, ":PROFILE" => $tc_profile_json));
    if (!$retval->success) {
        lmsDie("Unable to INSERT Registration key {$oauth_consumer_key} " . $retval->errorImplode);
    }
    echo_log("LTI2 Key {$oauth_consumer_key} inserted.\n");
}
if ($last_http_response == 201 || $last_http_response == 200) {
    echo '<p><a href="' . $launch_presentation_return_url . '">Continue to launch_presentation_url</a></p>' . "\n";
    exit;
}
echo "Registration failed, http code=" . $last_http_response . "\n";
// Check to see if they slid us the base string...
if ($responseObject != null && isset($responseObject->base_string)) {
    $base_string = $responseObject->base_string;
    if (strlen($base_string) > 0 && strlen($LastOAuthBodyBaseString) > 0 && $base_string != $LastOAuthBodyBaseString) {
        $compare = LTI::compareBaseStrings($LastOAuthBodyBaseString, $base_string);
        $OUTPUT->togglePre("Compare Base Strings (ours first)", htmlent_utf8($compare));
    }
}
Ejemplo n.º 4
0
    if (!$retval->success) {
        log_return_die("Unable to UPDATE Registration key {$oauth_consumer_key} " . $retval->errorImplode);
    }
    $return_url_lti_message = "LTI2 Key {$oauth_consumer_key} updated";
    // If we do not have a key, insert one, checking carefully for a failed insert
    // due to a unique constraint violation.  If this insert fails, it is likely
    // a race condition between competing INSERTs for the same key_id
} else {
    $key_sha256 = lti_sha256($oauth_consumer_key);
    $retval = $PDOX->queryDie("INSERT INTO {$CFG->dbprefix}lti_key \n            (key_sha256, key_key, user_id, secret, consumer_profile)\n        VALUES\n            (:SHA, :KEY, :UID, :SECRET, :PROFILE)\n        ON DUPLICATE KEY\n            UPDATE secret = :SECRET, consumer_profile = :PROFILE\n        ", array(":SHA" => $key_sha256, ":KEY" => $oauth_consumer_key, ":UID" => $_SESSION['id'], ":SECRET" => $shared_secret, ":PROFILE" => $tc_profile_json));
    if (!$retval->success) {
        log_return_die("Unable to INSERT Registration key {$oauth_consumer_key} " . $retval->errorImplode);
    }
    $return_url_lti_message = "LTI2 Key {$oauth_consumer_key} inserted";
}
echo_log("{$return_url_lti_message} \n");
if ($last_http_response == 201 || $last_http_response == 200) {
    if (strpos($launch_presentation_return_url, '?') > 0) {
        $launch_presentation_return_url .= '&';
    } else {
        $launch_presentation_return_url .= '?';
    }
    $launch_presentation_return_url .= "status=success";
    $launch_presentation_return_url .= "&lti_message=" . urlencode($return_url_lti_message);
    $launch_presentation_return_url .= "&tool_proxy_guid=" . urlencode($tc_tool_proxy_guid);
    echo '<p><a href="' . $launch_presentation_return_url . '">Continue to launch_presentation_url</a></p>' . "\n";
    exit;
}
echo "Registration failed, http code=" . $last_http_response . "\n";
// Check to see if they slid us the base string...
if ($responseObject != null && isset($responseObject->base_string)) {
Ejemplo n.º 5
0
function debut_droite($rubrique="", $return= false) {
	global $spip_ecran, $spip_display, $spip_lang_left;

	$res = '';

	if ($spip_display == 4) $res .= " -->";

	$res .= liste_articles_bloques();

	$res .= creer_colonne_droite($rubrique, true)
	. "</div>";

	$res .= "\n<div id='contenu'>";

	// touche d'acces rapide au debut du contenu : z
	// Attention avant c'etait 's' mais c'est incompatible avec
	// le ctrl-s qui fait "enregistrer"
	$res .= "\n<a id='saut' href='#saut' accesskey='z'></a>\n";

	if ($return) return $res; else echo_log('debut_droite',$res);
}
Ejemplo n.º 6
0
     echo '<pre class="alert alert-danger">' . "\n";
     $msg = "result_id=" . $row['result_id'] . "\n" . "grade=" . $row['grade'] . " server_grade=" . $row['server_grade'] . "\n" . "error=" . $status;
     echo_log("Problem Sending Grade: " . session_id() . "\n" . $msg . "\n" . "result_url=" . $row['reult_url'] . " service_key=" . $row['service_key'] . " sourcedid=" . $row['sourcedid']);
     echo "</pre>\n";
     $OUTPUT->togglePre("Error retrieving new grade at " . $count, $LastPOXGradeResponse);
     flush();
     echo "Problem sending grade " . $status . "<br/>\n";
     $fail++;
     continue;
 }
 // Check to see if the grade we sent is really there - Also updates our local table
 $server_grade = LTIX::gradeGet($row);
 if (is_string($server_grade)) {
     echo '<pre class="alert alert-danger">' . "\n";
     $msg = "result_id=" . $row['result_id'] . "\n" . "grade=" . $row['grade'] . " updated=" . $row['updated_at'] . "\n" . "server_grade=" . $row['server_grade'] . " retrieved=" . $row['retrieved_at'] . "\n" . "error=" . $server_grade;
     echo_log("Problem Updating Grade: " . session_id() . "\n" . $msg . "\n" . "result_url=" . $row['reult_url'] . " service_key=" . $row['service_key'] . " sourcedid=" . $row['sourcedid']);
     echo "</pre>\n";
     error_log("Error re-retrieving grade: " . session_id() . ' result_id=' . $row['result_id'] . "result_url=" . $row['reult_url'] . ' sourcedid=' + $row['sourcedid'] + ' service_key=' + $row['service_key']);
     $OUTPUT->togglePre("Error retrieving new grade at " . $count, $LastPOXGradeResponse);
     flush();
     $fail++;
     continue;
 } else {
     if ($server_grade != $row['grade']) {
     } else {
     }
 }
 if ($success % 10 == 0) {
     echo "Grade={$grade} ({$ets}) {$count} / {$total} <br/>\n";
     flush();
 }
Ejemplo n.º 7
0
function afficher_enfant_rub($id_rubrique, $bouton=false, $return=false) {
	global  $spip_lang_left,$spip_lang_right, $spip_display;

	$les_enfants = enfant_rub($id_rubrique);
	$n = strlen(trim($les_enfants));

	if (!$n && !$bouton) return "";

	if (!($x = strpos($les_enfants,"\n<div class='enfants'>",round($n/2)))) {
		$les_enfants2="";
	}else{
		$les_enfants2 = substr($les_enfants, $x);
		$les_enfants = substr($les_enfants,0,$x);
		if ($spip_display == 4) {
		  $les_enfants .= '</li></ul>';
		  $les_enfants2 = '<ul><li>' . $les_enfants2;
		}
	}

	$res =
	"<div class='gauche'>"
	. $les_enfants
	. "</div>"
	. "<div class='droite'>"
	. $les_enfants2
	. "</div>"
	. "&nbsp;"
	. "<div style='float:"
	. $spip_lang_right
	. ";position:relative;'>"
	. (!$bouton ? ''
		 : (!$id_rubrique
		    ? icone(_T('icone_creer_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav"), "secteur-24.gif", "creer.gif",$spip_lang_right, false)
		    : icone(_T('icone_creer_sous_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav&id_parent=$id_rubrique"), "rubrique-24.gif", "creer.gif",$spip_lang_right,false)))
	. "</div>";

	if ($return) return $res; else echo_log('afficher_enfant_rub',$res);
}
Ejemplo n.º 8
0
 /**
 +----------------------------------------------------------
 * 查找记录
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param array $options 表达式
 +----------------------------------------------------------
 * @return array
 +----------------------------------------------------------
 */
 public function select($options = array())
 {
     if (isset($options['page'])) {
         // 根据页数计算limit
         list($page, $listRows) = explode(',', $options['page']);
         $listRows = $listRows ? $listRows : (isset($options['limit']) && is_numeric($options['limit']) ? $options['limit'] : 20);
         $offset = $listRows * ((int) $page - 1);
         $options['limit'] = $offset . ',' . $listRows;
     }
     $sql = str_replace(array('%TABLE%', '%DISTINCT%', '%FIELDS%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%'), array($this->parseTable($options['table']), $this->parseDistinct(isset($options['distinct']) ? $options['distinct'] : false), $this->parseField(isset($options['field']) ? $options['field'] : '*'), $this->parseJoin(isset($options['join']) ? $options['join'] : ''), $this->parseWhere(isset($options['where']) ? $options['where'] : ''), $this->parseGroup(isset($options['group']) ? $options['group'] : ''), $this->parseHaving(isset($options['having']) ? $options['having'] : ''), $this->parseOrder(isset($options['order']) ? $options['order'] : ''), $this->parseLimit(isset($options['limit']) ? $options['limit'] : '')), $this->selectSql);
     $sql .= $this->parseLock(isset($options['lock']) ? $options['lock'] : false);
     if (ECHO_SQL) {
         echo_log($sql);
     }
     return $this->query($sql);
 }
Ejemplo n.º 9
0
  function importtable($json,$txt) {
   $t = array_keys(get_object_vars($json));
   $t=$t[0];
 //  echo_r ($t);
   $tablespreview = 0; //(1==2) || !(($t=='ApartSell')||($t=='ArendSell')||($t=='RoomsSell'));
   
   global $fieldid;
   $fieldid = array();
   
   $thistable = $json->$t;
 //  ajax_echo_r ($thistable); 
   
   if ($tablespreview) {
    echo "<hr><h3>".$t."</h3>";
   }
   
   
   
   switch ($t) {
    case ('Money'):
     $thissqltablename = 'money';
     
 //    echo "tablespreview: ".$tablespreview."<br>";
//     $sql_l_tr  ="DELETE `locationinfo`.* FROM `locationinfo`,`lands`  WHERE (`locationinfo`.`IsTemplate` = 0) AND (`locationinfo`.`ID`=`lands`.`LocationID`) ; ";
     $sql_b_tr  ="DELETE FROM `".$thissqltablename."`   WHERE `SourceID` = 0 ; ";
     
//     $r=$this->db->exec($sql_l_tr);
//     $mar=$r->rowsAffected;
//     echo_log ("lands->locationinfo items deleted: ".$mar);
     
     $r=$this->db->exec($sql_b_tr);
     $mar=$r->rowsAffected;
     echo_log ($thissqltablename." items deleted: ".$mar);
     
     if ($tablespreview) {
      echo "<table border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
      echo "<tr> ";
     }
     
     // -- print field name
     for ($j=0; $j<=sizeof($thistable->fields); $j++) {
      if ($tablespreview) {
       echo "<th  align=\"left\" bgcolor=\"#CCCCCC\" > <font color=\"#990000\"> ";
       echo($thistable->fields[$j]);
       echo "</font> </th>";
      }
      $fieldid[$thistable->fields[$j]] = $j;
     }
     $j=$j-1;
     
     $c  = 0;
     $ca = 0;
     
     $mar_b=0;
     do { // getting data
      $rowid = "row".$c;
      $result = $thistable->$rowid;
      
      $items=array();
      
      $items['DateAdded']        = _odbc_result($result, 'DateTime'         );
      $items['TypeID']           = _odbc_result($result, 'Type'             );
      $items['Value']            = _odbc_result($result, 'Value'            );
      $items['Content']          = _odbc_result($result, 'Content'          );
      $items['ProjectID']        = _odbc_result($result, 'ProjectID'        );
      $items['GroupID']          = _odbc_result($result, 'Group'            );
      $items['PlaceName']        = _odbc_result($result, 'PlaceName'        );
      $items['PlaceType']        = _odbc_result($result, 'PlaceType'        );
//      $items['DateEdited']       = 'NOW()';
      $items['SourceID']         = '0';
      
//      $items['DateCreated']      = convertfield($result, 'ZDATE'                  ,0);
      
      $keys   = "";
      $values = "";
      
      foreach ($items as $k => $v) {
       if ($keys) $keys.=", ";
       $keys.="`".$k."`";
       
       if ($values) $values.=", ";
       $values.="'".$v."'";
      }
      
      $sql_this_b="INSERT INTO `".$thissqltablename."` 
       (
      ".$keys."
       ) VALUES (
      ".$values."
       ) ; 
      ";
      
      $r=$this->db->exec($sql_this_b);
      $lastid_b=$r->lastInsertID;
      if ($r->rowsAffected<1) {
       echo((($tags_enabled)?"<p>":"").$sql_this_b.": ".mysql_error().(($tags_enabled)?"</p>":"\n"));
       break;
      } else {
       $mar_b += 1;
      }
      
      $c++;
      if ($tablespreview) {
       if ($c%2==0)
        echo("<tr bgcolor=\"#d0d0d0\">\n");
       else
        echo "<tr bgcolor=\"#eeeeee\">\n";
      }
      for ($i=1; $i<=sizeof($thistable->fields); $i++) {
       //        $thissql.="'".iconv("windows-1251", "UTF-8", odbc_result($result, $i))."'";
       if ($tablespreview) {
        echo("<td>");
        echo(_odbc_result($result, $i));
        echo "</td>";
       }
       if ($i%$j==0) {
        $nrows+=1; // counting no of rows    
       }
      }
  //    $res=odbc_fetch_row($result);
      if ($tablespreview) {
       echo "</tr>";
      }
     } while ($result);
     $thissql.=";";
     if ($tablespreview) {
      echo "</td> </tr>\n";
      echo "</table >\n<br>";
     }
//     echo (($tags_enabled)?"<p>":"")."locationinfo items added: ".$mar_l.(($tags_enabled)?"</p>":"<br>\r");
     echo (($tags_enabled)?"<p>":"").$thissqltablename." items added: "       .$mar_b.(($tags_enabled)?"</p>":"<br>\r");
     
    break;
    
    case ('Projects'):
     
     $thissqltablename = 'projects';
     
 //    echo "tablespreview: ".$tablespreview."<br>";
//     $sql_l_tr  ="DELETE `locationinfo`.* FROM `locationinfo`,`lands`  WHERE (`locationinfo`.`IsTemplate` = 0) AND (`locationinfo`.`ID`=`lands`.`LocationID`) ; ";
     $sql_b_tr  ="DELETE FROM `".$thissqltablename."`   WHERE `SourceID` = 0 ; ";
     
//     $r=$this->db->exec($sql_l_tr);
//     $mar=$r->rowsAffected;
//     echo_log ("lands->locationinfo items deleted: ".$mar);
     
     $r=$this->db->exec($sql_b_tr);
     $mar=$r->rowsAffected;
     echo_log ($thissqltablename." items deleted: ".$mar);
     
     if ($tablespreview) {
      echo "<table border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
      echo "<tr> ";
     }
     
     // -- print field name
     for ($j=0; $j<=sizeof($thistable->fields); $j++) {
      if ($tablespreview) {
       echo "<th  align=\"left\" bgcolor=\"#CCCCCC\" > <font color=\"#990000\"> ";
       echo($thistable->fields[$j]);
       echo "</font> </th>";
      }
      $fieldid[$thistable->fields[$j]] = $j;
     }
     $j=$j-1;
     
     $c  = 0;
     $ca = 0;
     
     $mar_b=0;
     do { // getting data
      $rowid = "row".$c;
      $result = $thistable->$rowid;
      
      $items=array();
      
      $items['ID']               = _odbc_result($result, 'ID'               );
      $items['Title']            = _odbc_result($result, 'ProjectName'      );
      $items['DateAdded']        = _odbc_result($result, 'DateStarted'      );
      $items['DateFinished']     = _odbc_result($result, 'DateFinished'     );
      $items['AddedBy']          = '1';
      $items['Description']      = _odbc_result($result, 'Description'      );
      $items['Cost']             = _odbc_result($result, 'Cost'             );
      $items['CustomerID']       = _odbc_result($result, 'Customer'         );
      $items['TypeID']           = _odbc_result($result, 'Type'             );
//      $items['DateEdited']       = 'NOW()';
      $items['SourceID']         = '0';
      
//      $items['DateCreated']      = convertfield($result, 'ZDATE'                  ,0);
      
      $keys   = "";
      $values = "";
      
      foreach ($items as $k => $v) {
       if ($keys) $keys.=", ";
       $keys.="`".$k."`";
       
       if ($values) $values.=", ";
       $values.="'".$v."'";
      }
      
      $sql_this_b="INSERT INTO `".$thissqltablename."` 
       (
      ".$keys."
       ) VALUES (
      ".$values."
       ) ; 
      ";
      
      $r=$this->db->exec($sql_this_b);
      $lastid_b=$r->lastInsertID;
      if ($r->rowsAffected<1) {
       echo((($tags_enabled)?"<p>":"").$sql_this_b.": ".mysql_error().(($tags_enabled)?"</p>":"\n"));
       break;
      } else {
       $mar_b += 1;
      }
      
      $c++;
      if ($tablespreview) {
       if ($c%2==0)
        echo("<tr bgcolor=\"#d0d0d0\">\n");
       else
        echo "<tr bgcolor=\"#eeeeee\">\n";
      }
      for ($i=1; $i<=sizeof($thistable->fields); $i++) {
       //        $thissql.="'".iconv("windows-1251", "UTF-8", odbc_result($result, $i))."'";
       if ($tablespreview) {
        echo("<td>");
        echo(_odbc_result($result, $i));
        echo "</td>";
       }
       if ($i%$j==0) {
        $nrows+=1; // counting no of rows    
       }
      }
  //    $res=odbc_fetch_row($result);
      if ($tablespreview) {
       echo "</tr>";
      }
     } while ($result);
     $thissql.=";";
     if ($tablespreview) {
      echo "</td> </tr>\n";
      echo "</table >\n<br>";
     }
//     echo (($tags_enabled)?"<p>":"")."locationinfo items added: ".$mar_l.(($tags_enabled)?"</p>":"<br>\r");
     echo (($tags_enabled)?"<p>":"").$thissqltablename." items added: "       .$mar_b.(($tags_enabled)?"</p>":"<br>\r");
     
    break;
    
    
    default:
     echo_log ('This table ('.$t.') is not supported by converter.');
    break;
    
   }
  }