Esempio n. 1
0
 */
session_start();
// 1. Determine request type
$request = $_POST['request'];
// 2. Call corresponding function
if ($request == "login") {
    login();
}
if ($request == "logout") {
    logout();
}
if ($request == "register") {
    register();
}
if ($request == "add-favorite") {
    addFavorite();
}
if ($request == "delete-favorite") {
    deleteFavorite();
}
function login()
{
    // Establish DB connection
    $con = new mysqli("localhost", "root", "cjftns119", "DevLog");
    // Get more fields
    $user_email = $_POST['u_email'];
    $user_pw = $_POST['u_pw'];
    $encrypted_pw = md5($user_pw);
    // Check if user exists first:
    $query = "SELECT * FROM dl_users WHERE u_email='{$user_email}'";
    $result = $con->query($query);
Esempio n. 2
0
 /**
  * Add a new favorite for the action user
  */
 function addFavorite()
 {
     global $GEDCOM;
     if (PGV_USER_ID && !empty($_REQUEST["gid"])) {
         $gid = strtoupper($_REQUEST["gid"]);
         $indirec = find_person_record($gid);
         if ($indirec) {
             $favorite = array();
             $favorite["username"] = PGV_USER_NAME;
             $favorite["gid"] = $gid;
             $favorite["type"] = "INDI";
             $favorite["file"] = $GEDCOM;
             $favorite["url"] = "";
             $favorite["note"] = "";
             $favorite["title"] = "";
             addFavorite($favorite);
         }
     }
 }
Esempio n. 3
0
 /**
  * Add a new favorite for the action user
  */
 function addFavorite()
 {
     global $GEDCOM;
     if (empty($this->uname)) {
         return;
     }
     if (!empty($_REQUEST["gid"])) {
         $gid = strtoupper($_REQUEST["gid"]);
         $indirec = find_other_record($gid);
         if ($indirec) {
             $favorite = array();
             $favorite["username"] = $this->uname;
             $favorite["gid"] = $gid;
             $favorite["type"] = "NOTE";
             $favorite["file"] = $GEDCOM;
             $favorite["url"] = "";
             $favorite["note"] = "";
             $favorite["title"] = "";
             addFavorite($favorite);
         }
     }
 }
Esempio n. 4
0
    if ($stmt = $conn->prepare("INSERT INTO `favorites`(`Users_user_id`, `favo_companyid`) VALUES (?,?)")) {
        $stmt->bind_param("ii", $user, $company);
        $stmt->execute();
        $stmt->store_result();
        if ($stmt->affected_rows != 1) {
            echo '
            <div class="alert alert-warning alert-modal" role="alert">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;  </button>
                Falha ao tentar adicionar empresa aos favoritos.</div>';
            return false;
        } else {
            echo '
            <div class="alert alert-success alert-modal" role="alert">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;  </button>
                Empresa adicionada aos favoritos.
            </div>';
            return true;
        }
    } else {
        echo '
        <div class="alert alert-danger alert-modal" role="alert">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;  </button>
            Falha na conexão: ' . $conn->error . '
        </div>';
    }
}
$check = alreadyFavorite($_GET['user'], $_GET['company']);
if ($check === false) {
    addFavorite($_GET['user'], $_GET['company']);
}
header('Content-type: application/json');
chdir('../../common');
require_once 'init.php';
chdir('../database');
require_once 'storeAccount.php';
chdir('../ajax/store');
if (isset($_GET['storeId']) and isset($_GET['productId'])) {
    $userId = $_SESSION['storesLogin'][$_GET['storeId']]['userId'];
    if (isset($userId)) {
        $userFavorites = getFavorites($userId);
        if (isset($userFavorites[0])) {
            $found = 'false';
            foreach ($userFavorites as $favorite) {
                if ($favorite . id == $_GET["productId"]) {
                    $found = 'true';
                    break;
                }
            }
            if ($found == 'false') {
                addFavorite($userId, $_GET["productId"]);
            }
        } else {
            addFavorite($userId, $_GET["productId"]);
        }
        echo json_encode(array("result" => "ok"));
    } else {
        echo json_encode(array("result" => "user must be logged in"));
    }
} else {
    echo json_encode(array("result" => "missing data"));
}
Esempio n. 6
0
 function init()
 {
     global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight, $GEDCOM, $pgv_lang, $CONTACT_EMAIL, $show_famlink, $pgv_changes;
     $bwidth = $Dbwidth;
     $pbwidth = $bwidth + 12;
     $pbheight = $bheight + 14;
     $show_famlink = $this->view != 'preview';
     $this->famid = safe_GET_xref('famid');
     $this->family = Family::getInstance($this->famid);
     if (empty($this->famrec)) {
         $ct = preg_match("/(\\w+):(.+)/", $this->famid, $match);
         if ($ct > 0) {
             $servid = trim($match[1]);
             $remoteid = trim($match[2]);
             include_once 'includes/classes/class_serviceclient.php';
             $service = ServiceClient::getInstance($servid);
             if (!is_null($service)) {
                 $newrec = $service->mergeGedcomRecord($remoteid, "0 @" . $this->famid . "@ FAM\n1 RFN " . $this->famid, false);
                 $this->famrec = $newrec;
             }
         }
         //-- if no record was found create a default empty one
         if (isset($pgv_changes[$this->famid . "_" . $GEDCOM])) {
             $this->famrec = "0 @" . $this->famid . "@ FAM\n";
             $this->family = new Family($this->famrec);
         } else {
             if (empty($this->family)) {
                 return false;
             }
         }
     }
     $this->famrec = $this->family->getGedcomRecord();
     $this->display = displayDetailsById($this->famid, 'FAM');
     //-- if the user can edit and there are changes then get the new changes
     if ($this->show_changes && PGV_USER_CAN_EDIT && isset($pgv_changes[$this->famid . "_" . $GEDCOM])) {
         $newrec = find_updated_record($this->famid);
         if (empty($newrec)) {
             $newrec = find_family_record($this->famid);
         }
         $this->difffam = new Family($newrec);
         $this->difffam->setChanged(true);
         $this->family->diffMerge($this->difffam);
         //$this->famrec = $newrec;
         //$this->family = new Family($this->famrec);
     }
     $this->parents = array('HUSB' => $this->family->getHusbId(), 'WIFE' => $this->family->getWifeId());
     //-- check if we can display both parents
     if ($this->display == false) {
         $this->showLivingHusb = showLivingNameById($this->parents['HUSB']);
         $this->showLivingWife = showLivingNameById($this->parents['WIFE']);
     }
     //-- add favorites action
     if ($this->action == 'addfav' && !empty($_REQUEST['gid']) && PGV_USER_NAME) {
         $_REQUEST['gid'] = strtoupper($_REQUEST['gid']);
         $indirec = find_family_record($_REQUEST['gid']);
         if ($indirec) {
             $favorite = array('username' => PGV_USER_NAME, 'gid' => $_REQUEST['gid'], 'type' => 'FAM', 'file' => $GEDCOM, 'url' => '', 'note' => '', 'title' => '');
             addFavorite($favorite);
         }
     }
     if (PGV_USER_CAN_ACCEPT) {
         if ($this->action == 'accept') {
             if (accept_changes($_REQUEST['famid'] . '_' . $GEDCOM)) {
                 $this->show_changes = false;
                 $this->accept_success = true;
                 //-- check if we just deleted the record and redirect to index
                 $famrec = find_family_record($_REQUEST['famid']);
                 if (empty($famrec)) {
                     header("Location: index.php?ctype=gedcom");
                     exit;
                 }
                 $this->family = new Family($famrec);
                 $this->parents = find_parents($_REQUEST['famid']);
             }
         }
         if ($this->action == 'undo') {
             $this->family->undoChange();
             $this->parents = find_parents($_REQUEST['famid']);
         }
     }
     //-- make sure we have the true id from the record
     $ct = preg_match("/0 @(.*)@/", $this->famrec, $match);
     if ($ct > 0) {
         $this->famid = trim($match[1]);
     }
     if ($this->showLivingHusb == false && $this->showLivingWife == false) {
         print_header($pgv_lang['private'] . " " . $pgv_lang['family_info']);
         print_privacy_error($CONTACT_EMAIL);
         print_footer();
         exit;
     }
     $this->title = $this->family->getFullName();
     if (empty($this->parents['HUSB']) || empty($this->parents['WIFE'])) {
         $this->link_relation = 0;
     } else {
         $this->link_relation = 1;
     }
 }
Esempio n. 7
0
                    print '<a href="' . urlStr($uri) . '">' . $page->getDescription() . '</a>';
                } else {
                    print $uri;
                }
                ?>
            <br/>

        <?php 
            }
            print '</div>';
        }
        print '</div>';
    }
}
if ($_GET['fav_action'] == 'add') {
    addFavorite($_GET['uri']);
}
if ($_GET['fav_action'] == 'del') {
    delFavorite($_GET['uri']);
}
$sort_a;
foreach (listFavorites() as $uri) {
    list($m, $s, $a) = explode('/', $uri, 3);
    $sort_a[$m][$s][$a] = 1;
}
showFav($sort_a);
//add favorites link
$local_page = getPage($local_uri);
if ($local_page->isVisible()) {
    $_GET['fav_action'] = 'add';
    $_GET['uri'] = $local_uri;
Esempio n. 8
0
 /**
  * Add a new favorite for the action user
  */
 function addFavorite()
 {
     global $GEDCOM;
     if (!PGV_USER_ID) {
         return;
     }
     if (!empty($_REQUEST["gid"])) {
         $gid = strtoupper($_REQUEST["gid"]);
         $mediarec = find_media_record($gid);
         if ($mediarec) {
             $favorite = array();
             $favorite["username"] = PGV_USER_NAME;
             $favorite["gid"] = $gid;
             $favorite["type"] = "OBJE";
             $favorite["file"] = $GEDCOM;
             $favorite["url"] = "";
             $favorite["note"] = "";
             $favorite["title"] = "";
             addFavorite($favorite);
         }
     }
 }
Esempio n. 9
0
 /**
  * Import users etc. from index files
  *
  */
 function import()
 {
     global $INDEX_DIRECTORY, $TBLPREFIX, $pgv_lang, $GEDCOMS, $GEDCOM, $gBitDb;
     if (file_exists($INDEX_DIRECTORY . "authenticate.php") == false) {
         $this->impSuccess = false;
         return;
     } else {
         require $INDEX_DIRECTORY . "authenticate.php";
         $countold = count($users);
         $gBitDb->query("DELETE FROM {$TBLPREFIX}users");
         foreach ($users as $username => $user) {
             if ($user["editaccount"] == "1") {
                 $user["editaccount"] = "Y";
             } else {
                 $user["editaccount"] = "N";
             }
             //-- make sure fields are set for v4.0 DB
             if (!isset($user["firstname"])) {
                 if (isset($user["fullname"])) {
                     $parts = explode(' ', trim($user["fullname"]));
                     $user["lastname"] = array_pop($parts);
                     $user["firstname"] = implode(" ", $parts);
                 } else {
                     $user["firstname"] = '';
                     $user["lastname"] = '';
                 }
             }
             if (!isset($user["comment"])) {
                 $user["comment"] = '';
             }
             if (!isset($user["comment_exp"])) {
                 $user["comment_exp"] = '';
             }
             if (!isset($user["sync_gedcom"])) {
                 $user["sync_gedcom"] = 'N';
             }
             if (!isset($user["relationship_privacy"])) {
                 $user["relationship_privacy"] = 'N';
             }
             if (!isset($user["max_relation_path"])) {
                 $user["max_relation_path"] = '2';
             }
             if (!isset($user["auto_accept"])) {
                 $user["auto_accept"] = 'N';
             }
             if ($user_id = create_user($user['username'], $user['password'])) {
                 set_user_setting($user_id, 'firstname', $user["firstname"]);
                 set_user_setting($user_id, 'lastname', $user["lastname"]);
                 set_user_setting($user_id, 'email', $user["email"]);
                 set_user_setting($user_id, 'theme', $user["theme"]);
                 set_user_setting($user_id, 'language', $user["language"]);
                 set_user_setting($user_id, 'contactmethod', $user["contactmethod"]);
                 set_user_setting($user_id, 'defaulttab', $user["defaulttab"]);
                 set_user_setting($user_id, 'comment', $user["comment"]);
                 set_user_setting($user_id, 'comment_exp', $user["comment_exp"]);
                 set_user_setting($user_id, 'pwrequested', $user["pwrequested"]);
                 set_user_setting($user_id, 'reg_timestamp', $user["reg_timestamp"]);
                 set_user_setting($user_id, 'reg_hashcode', $user["reg_hashcode"]);
                 set_user_setting($user_id, 'loggedin', $user["loggedin"]);
                 set_user_setting($user_id, 'sessiontime', $user["sessiontime"]);
                 set_user_setting($user_id, 'max_relation_path', $user["max_relation_path"]);
                 set_user_setting($user_id, 'sync_gedcom', $user["sync_gedcom"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'relationship_privacy', $user["relationship_privacy"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'auto_accept', $user["auto_accept"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'canadmin', $user["canadmin"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'visibleonline', $user["visibleonline"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'editaccount', $user["editaccount"] ? 'Y' : 'N');
                 set_user_setting($user_id, 'verified', $user["verified"] ? 'yes' : 'no');
                 set_user_setting($user_id, 'verified_by_admin', $user["verified_by_admin"] ? 'yes' : 'no');
                 foreach (array('gedcomid', 'rootid', 'canedit') as $var) {
                     if ($user[$var]) {
                         foreach (unserialize(stripslashes($user[$var])) as $gedcom => $id) {
                             set_user_gedcom_setting($user_id, $gedcom, $var, $id);
                         }
                     }
                 }
                 AddToLog("added user -> {$user['username']} <-");
             }
         }
         if ($countold == get_user_count()) {
             $this->impSuccess = true;
         } else {
             $this->impSuccess = false;
         }
     }
     if (file_exists($INDEX_DIRECTORY . "messages.dat") == false) {
         $this->msgSuccess = false;
     } else {
         $gBitDb->query("DELETE FROM {$TBLPREFIX}messages");
         $messages = array();
         $fp = fopen($INDEX_DIRECTORY . "messages.dat", "rb");
         $mstring = fread($fp, filesize($INDEX_DIRECTORY . "messages.dat"));
         fclose($fp);
         $messages = unserialize($mstring);
         foreach ($messages as $newid => $message) {
             $gBitDb->query("INSERT INTO {$TBLPREFIX}messages (m_id, m_from, m_to, m_subject, m_body, m_created) VALUES (?, ? ,? ,? ,? ,?)", array($newid, $message["from"], $message["to"], $message["subject"], $message["body"], $message["created"]));
         }
         $this->msgSuccess = true;
     }
     if (file_exists($INDEX_DIRECTORY . "favorites.dat") == false) {
         $this->favSuccess = false;
         print $pgv_lang["um_nofav"] . "<br /><br />";
     } else {
         $gBitDb->query("DELETE FROM {$TBLPREFIX}favorites");
         $favorites = array();
         $fp = fopen($INDEX_DIRECTORY . "favorites.dat", "rb");
         $mstring = fread($fp, filesize($INDEX_DIRECTORY . "favorites.dat"));
         fclose($fp);
         $favorites = unserialize($mstring);
         foreach ($favorites as $newid => $favorite) {
             $res = addFavorite($favorite);
             if (!$res || DB::isError($res)) {
                 $this->errorMsg = "<span class=\"error\">Unable to update <i>Favorites</i> table.</span><br />\n";
                 return;
             }
         }
         $this->favSuccess = true;
     }
     if (file_exists($INDEX_DIRECTORY . "news.dat") == false) {
         $this->newsSuccess = false;
     } else {
         $gBitDb->query("DELETE FROM {$TBLPREFIX}news");
         $allnews = array();
         $fp = fopen($INDEX_DIRECTORY . "news.dat", "rb");
         $mstring = fread($fp, filesize($INDEX_DIRECTORY . "news.dat"));
         fclose($fp);
         $allnews = unserialize($mstring);
         foreach ($allnews as $newid => $news) {
             $res = addNews($news);
             if (!$res) {
                 $this->errorMsg = "<span class=\"error\">Unable to update <i>News</i> table.</span><br />\n";
                 return;
             }
         }
         $this->newsSuccess = true;
     }
     if (file_exists($INDEX_DIRECTORY . "blocks.dat") == false) {
         $this->blockSuccess = false;
     } else {
         $gBitDb->query("DELETE FROM {$TBLPREFIX}blocks");
         $allblocks = array();
         $fp = fopen($INDEX_DIRECTORY . "blocks.dat", "rb");
         $mstring = fread($fp, filesize($INDEX_DIRECTORY . "blocks.dat"));
         fclose($fp);
         $allblocks = unserialize($mstring);
         foreach ($allblocks as $bid => $blocks) {
             $username = $blocks["username"];
             $gBitDb->query("INSERT INTO {$TBLPREFIX}blocks (b_id, b_username, b_location, b_order, b_name, b_config) VALUES (?, ? ,? , ?, ?, ?)", array($bid, $blocks["username"], $blocks["location"], $blocks["order"], $blocks["name"], serialize($blocks["config"])));
         }
         $this->blockSuccess = true;
     }
 }
Esempio n. 10
0
<?php

session_start();
include "carpoolingDAO.php";
$tripId = $_POST["tripId"];
$userid = $_SESSION["userId"];
addFavorite($userid, $tripId);
?>