{
return (UsersNetItem::UsersNetItemDefaults($owner, $target));
}
+ function usersnet_save($owner_id, $json)
+ {
+ GLOBAL $G_dbpfx;
+ $ret = 99999;
+ $trans = FALSE;
+
+ do {
+ $friend = usersnet_friend_getid($json->friend);
+
+ if ($json->skill < 1 || $json->skill > 5 ||
+ $json->trust < 1 || $json->trust > 5 ||
+ $friend == FALSE) {
+ $ret = 1;
+ break;
+ }
+
+ $this->transaction('BEGIN');
+ $trans = TRUE;
+
+ // try to update
+ $net_sql = sprintf("
+ UPDATE %susersnet SET (friend, skill, trust, mtime) =
+ (%d, %d, %d, now())
+ FROM %susers as us
+ WHERE owner = %d AND us.login = '%s' AND target = us.code RETURNING *;",
+ $G_dbpfx,
+ $friend, $json->skill, $json->trust,
+ $G_dbpfx,
+ $owner_id, escsql($json->login));
+ if (($net_pg = $this->query($net_sql)) == FALSE || pg_numrows($net_pg) == 0) {
+ $net_sql = sprintf("
+ INSERT INTO %susersnet SELECT %d AS owner, us.code as target,
+ %d as friend, %d as skill, %d as trust
+ FROM %susers as us WHERE us.login = '%s' RETURNING *;",
+ $G_dbpfx, $owner_id,
+ $friend, $json->skill, $json->trust,
+ $G_dbpfx, $json->login);
+ if (($net_pg = $this->query($net_sql)) == FALSE) {
+ log_wr('insert query failed');
+ $ret = 2;
+ break;
+ }
+ if (pg_numrows($net_pg) != 1) {
+ log_wr(sprintf('insert numrow failed [%s] [%d]', $net_sql, pg_numrows($net_pg)));
+ $ret = 3;
+ break;
+ }
+ }
+ else {
+ if (pg_numrows($net_pg) != 1) {
+ log_wr('update numrow failed');
+ $ret = 4;
+ break;
+ }
+ }
+ $net_obj = pg_fetch_object($net_pg, 0);
+ $this->transaction('COMMIT');
+ return (0);
+ } while (0);
+
+ if ($trans)
+ $this->transaction('ROLLBACK');
+
+ return ($ret);
+ }
} // End class BriskDB
class LoginDBOld
Ciò è necessario per ottenere la password.<br><br>
Saluti e buone partite, mop.<br>',
'en' => 'EN mhtml [%s] [%s]'),
+ 'info_err' => array( 'it' => 'E\' occorso un errore (%d), riprova più tardi.',
+ 'en' => 'Some error occurs (%d), retry later.')
);
define('LICMGR_CHO_ACCEPT', 0);
if ($argz[0] == 'ping') {
log_wr("PING RECEIVED");
}
+ else if ($argz[0] == 'info') {
+ if ($argz[1] == 'save') {
+ if (!isset($post['info'])) {
+ return FALSE;
+ }
+
+ if (($ret = $brisk->info_save($user, $post['info'])) == TRUE) {
+ if ($ret == TRUE) {
+ echo "1";
+ return TRUE;
+ }
+ }
+ printf($mlang_indwr['info_err'][$G_lang], $ret);
+ return FALSE;
+ }
+ }
else if ($argz[0] == 'prefs') {
if ($argz[1] == 'save') {
if (!isset($post['prefs'])) {
target = $('info').getElementsByClassName('login_id')[0].innerHTML;
return info_show(target);
}
+
+function info_save()
+{
+ var info, jinfo, ret;
+
+ info = info_fld($('info'));
+ jinfo = info.dom2json();
+
+ ret = server_request('mesg', 'info|save','__POST__', 'info', JSON.stringify(jinfo));
+
+ if (ret == 1) {
+ $('info').style.visibility = 'hidden';
+ }
+ else {
+ alert(ret);
+ }
+}