Пример #1
0
 public function __construct()
 {
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $this->dao =& $dao;
 }
Пример #2
0
 /**
  * @param int $tablename name of table expressed as an integer,
  * 				e.g. MOD_enc::TABLE_NAME_REF_MEMBER
  * @param int $rownumber number of row in the table afore mentioned
  * @return void
  */
 public function __construct($tablename, $rownumber, $idMember, $keyMember)
 {
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $this->dao =& $dao;
     parent::__construct($tablename, $rownumber, $keyMember);
     $this->_idMember = $idMember;
 }
Пример #3
0
 /**
  * @param string $category optional value to set the page of the texts
  * 				 we're looking for (this needs an additional column in the
  * 				 words table)
  */
 public function __construct($category = null)
 {
     $this->_lang = PVars::get()->lang;
     $this->WordMemcache = new MOD_bw_memcache("words", "Sentence", "code");
     if (!empty($category)) {
         $this->_whereCategory = ' `category`=\'' . $category . '\'';
     }
     if (isset($_SESSION['IdLanguage'])) {
         $this->_langWrite = $_SESSION['IdLanguage'];
     } else {
         $this->_langWrite = 0;
     }
     $db_vars = PVars::getObj('config_rdbms');
     if (!$db_vars) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password);
     $this->_dao =& $dao;
     $R = MOD_right::get();
     if ($R->hasRight("Words", $this->_lang)) {
         $this->_offerTranslationLink = true;
     }
     // read translation mode from $_SESSION['tr_mode']
     if (array_key_exists("tr_mode", $_SESSION)) {
         $this->_trMode = $_SESSION['tr_mode'];
     } else {
         if (array_key_exists("tr_mode", $_SESSION)) {
             $this->_trMode = $_SESSION['tr_mode'];
         } else {
             if ($this->_offerTranslationLink) {
                 $this->_trMode = 'translate';
             } else {
                 $this->_trMode = 'browse';
             }
         }
     }
     switch ($this->_trMode) {
         case 'browse':
         case 'proofread':
             // not yet implemented
             break;
         case 'edit':
         case 'translate':
             if ($this->_offerTranslationLink) {
                 break;
             }
         default:
             if ($this->_offerTranslationLink) {
                 $this->_trMode = 'translate';
             } else {
                 $this->_trMode = 'browse';
             }
     }
 }
Пример #4
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // instantiate the dao
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $this->dao =& $dao;
     MOD_params::get()->loadParams();
 }
Пример #5
0
 /**
  * constructor...
  *
  * @return nothing
  */
 function __construct()
 {
     $this->baseuri = PVars::getObj('env')->baseuri;
     $this->IdTriggerer = 0;
     //TODO: set this to bot id
     $this->words = new MOD_words();
     $this->messages_model = new MessagesModel();
     $this->members_model = new MembersModel();
     // setup DB access
     $db_vars = PVars::getObj('config_rdbms');
     if (!$db_vars) {
         throw new PException('DB config error!');
     }
     $this->dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password);
 }
Пример #6
0
 private function __construct()
 {
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $this->dao =& $dao;
     global $_SYSHCVOL;
     if (isset($_SYSHCVOL['WhoIsOnlineDelayInMinutes'])) {
         $this->online_interval = $_SYSHCVOL['WhoIsOnlineDelayInMinutes'];
     } else {
         $this->online_interval = 5;
     }
 }
Пример #7
0
 /**
  * returns the handle from a TB user, given tb user id
  *
  * @param int $user_id id of user
  *
  * @access public
  * @return string
  */
 public static function getUserHandle($user_id)
 {
     // insanity lies in the details. Any design where you have to do
     // boilerplate code like this should be thrown out immediately
     // after design
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $result = $dao->query("SELECT handle FROM user WHERE id = " . intval($user_id));
     if ($result && ($fetched = $result->fetch(PDB::FETCH_OBJ))) {
         return $fetched->handle;
     }
     return '';
 }
Пример #8
0
    public function getLanguages()
    {
        $db_vars = PVars::getObj('config_rdbms');
        if (!$db_vars) {
            throw new PException('DB config error!');
        }
        $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password);
        $dbresult = $dao->query('
SELECT DISTINCT languages.*
FROM languages, words
WHERE languages.id = words.IdLanguage
AND words.code = \'WelcomeToSignup\'
ORDER BY FlagSortCriteria
        ');
        $langs = array();
        while ($row = $dbresult->fetch(PDB::FETCH_OBJ)) {
            $langs[] = $row;
        }
        return $langs;
    }
Пример #9
0
 /**
  * content of the middle column - this is the most important part
  */
 protected function column_col3()
 {
     echo '
     <h3>The hello universe middle column</h3>
     using the class HellouniverseSimplePage.<br>
     More beautiful in <a href="hellouniverse/advanced">hellouniverse/advanced</a>!<br>
     With tabs in <a href="hellouniverse/tab1">hellouniverse/tab1</a>!<br><br>';
     require_once SCRIPT_BASE . 'modules/i18n/lib/words2.lib.php';
     $db_vars = PVars::getObj('config_rdbms');
     if (!$db_vars) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password);
     $spoken_languages = array((object) array('id' => 6, 'ShortCode' => 'de'), (object) array('id' => 0, 'ShortCode' => 'en'));
     $print_strategy_map = array();
     $print_strategy_map['successful'] = new WordPrintStrategy_translateClickFullText();
     $print_strategy_map['obsolete'] = new WordPrintStrategy_translate();
     $print_strategy_map['missing_word'] = new WordPrintStrategy_translate();
     $print_strategy_map['missing_translation'] = new WordPrintStrategy_translateClickFullText();
     $words_gateway = new WordsGateway($dao);
     $translation_module = new TranslationModule($spoken_languages, $print_strategy_map, $words_gateway);
     echo $translation_module->translate('FindMembers', 'ww', array());
 }
Пример #10
0
require_once "reqs/common.php";
require_once "reqs/pdo.php";
require_once "reqs/auth.php";
checkLoggedIn();
$updata = array();
$updata["id"] = $_SESSION["user"];
$updata["password"] = param($_POST, 'password', '');
$updata["email"] = param($_POST, 'email', '');
$updata["first_name"] = param($_POST, 'first_name', '');
$updata["last_name"] = param($_POST, 'last_name', '');
$updata["phone"] = param($_POST, 'phone', '');
$updata["city"] = param($_POST, 'city', '');
$updata["state"] = param($_POST, 'state', '');
$updata["zipcode"] = param($_POST, 'zipcode', '');
$updata["avatar"] = param($_POST, 'avatar', '');
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
$user = $dbh->getUser($updata["id"]);
$currentemail = $user->email;
if ($updata["email"] != "" && $updata["email"] != $currentemail) {
    $exists = $site->checkEmail($updata["email"]);
    if ($exists === true) {
        errormsg("Email address already in use.");
    }
}
try {
    $ct = 0;
    $sql = "UPDATE users SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
Пример #11
0
 private function save()
 {
     if ($this->_callback && is_array($this->_callback)) {
         foreach ($this->_callback as $key => $callback) {
             if (!array_key_exists($key, $_POST)) {
                 continue;
             }
             foreach ($_POST as $k => $v) {
                 if (is_string($v)) {
                     $v = trim($v);
                     $v = stripslashes($v);
                 }
                 $this->_vars[$key][$k] = $v;
             }
             $this->_activeKey = $key;
             $callback = $this->_callback[$key];
             unset($this->_callback[$key]);
             break;
         }
         $ret = false;
         $db = PVars::getObj('config_rdbms');
         $dao = PDB::get($db->dsn, $db->user, $db->password);
         $c = new $callback[0]($dao);
         $cbRet = call_user_func(array(&$c, $callback[1]));
         if ($cbRet) {
             $ret = $cbRet;
         }
         $_SESSION['PostHandler'] = serialize($this);
         if ($ret) {
             $ret = parse_url($ret);
             $query = array();
             if (isset($ret['query'])) {
                 parse_str($ret['query'], $query);
             }
             if (is_array($query) && array_key_exists(session_name(), $query)) {
                 continue;
             }
             $query[session_name()] = session_id();
             $queries = array();
             foreach ($query as $k => $q) {
                 $queries[] = $k . '=' . $q;
             }
             $ret['query'] = implode('&', $queries);
             $ret = PFunctions::glueParsedUrl($ret);
             session_write_close();
             header('Location: ' . $ret);
             PPHP::PExit();
         }
         return TRUE;
     }
 }
Пример #12
0
// UNFINISHED
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
require_once "reqs/auth.php";
checkLoggedIn();
$updata = array();
$user = $_SESSION["user"];
$projectID = param($_POST, 'projectID', '');
if (empty($projectID)) {
    errormsg("The 'projectID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
$tasks = $dbh->getTasks($projectID);
$taskArr = array();
for ($i = 0; $i < count($tasks); $i++) {
    array_push($taskArr, $tasks[$i]->id);
}
$arr = implode(", ", $taskArr);
try {
    $ct = 0;
    if (!empty($arr)) {
        //rich and justin edit
        $sql = "DELETE FROM tasks WHERE id IN (" . $arr . ")";
        //errormsg($arr);
        $st = $db->prepare($sql);
Пример #13
0
$lastname = param($_POST, 'lastname', '');
$phone = param($_POST, 'phone', '');
$city = param($_POST, 'city', '');
$state = param($_POST, 'state', '');
$zipcode = param($_POST, 'zipcode', '');
$avatar = param($_POST, 'avatar', '');
if (empty($username)) {
    errormsg("Username required.");
}
if (empty($password)) {
    errormsg("Password required.");
}
if (empty($email)) {
    errormsg("Email required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
$exists = $site->checkName($username);
if ($exists === true) {
    errormsg("Username already exists.");
}
$exists = $site->checkEmail($email);
if ($exists === true) {
    errormsg("Email address already in use.");
}
$hashed = $site->hasher($username, $password);
try {
    $st = $db->prepare("\n\t\tINSERT INTO users \n\t\t(user_n, user_p, salt, email, first_name, last_name, phone, city, state, zipcode, avatar)\n\t\tVALUES (:user, :pass, :salt, :email, :firstname, :lastname, :phone, :city, :state, :zipcode, :avatar)\n\t");
    $st->execute(array(":user" => $username, ":pass" => $hashed["hash"], ":salt" => $hashed["salt"], ":email" => $email, ":firstname" => $firstname, ":lastname" => $lastname, ":phone" => $phone, ":city" => $city, ":state" => $state, ":zipcode" => $zipcode, ":avatar" => $avatar));
    $st = $db->prepare("SELECT LAST_INSERT_ID()");
Пример #14
0
 public static function getImage($paramIdMember = 0)
 {
     if ($paramIdMember == 0) {
         $IdMember = $_SESSION['IdMember'];
     } else {
         $IdMember = $paramIdMember;
     }
     if ($IdMember == 0) {
         return MOD_User::getDummyImage();
     }
     $db = PVars::getObj('config_rdbms');
     if (!$db) {
         throw new PException('DB config error!');
     }
     $dao = PDB::get($db->dsn, $db->user, $db->password);
     $localDao =& $dao;
     $result = $localDao->query("\nSELECT\n    FilePath\nFROM\n    membersphotos\nWHERE\n    IdMember = {$IdMember}  AND\n    SortOrder = 0\n            ");
     $record = $result->fetch(PDB::FETCH_OBJ);
     if (isset($record->FilePath)) {
         return $path = PVars::getObj('env')->baseuri . $record->FilePath;
     } else {
         $result = $localDao->query("\nSELECT\n    Gender,\n    HideGender\nFROM\n    members\nWHERE\n    id = {$IdMember}\n                ");
         $record = $result->fetch(PDB::FETCH_OBJ);
         return MOD_User::getDummyImage($record->Gender, $record->HideGender);
     }
 }
Пример #15
0
require_once "reqs/auth.php";
checkLoggedIn();
$updata = array();
$updata["id"] = param($_POST, 'projectID', '');
$updata["clientID"] = param($_POST, 'clientID', '');
$updata["teamID"] = param($_POST, 'teamID', '');
$updata["projectName"] = param($_POST, 'projectName', '');
$updata["projectDescription"] = param($_POST, 'projectDescription', '');
$updata["status"] = param($_POST, 'status', '');
$updata["updatedDate"] = param($_POST, 'updatedDate', '');
$updata["dueDate"] = param($_POST, 'dueDate', '');
$updata["startDate"] = param($_POST, 'startDate', '');
if (empty($updata["id"])) {
    errormsg("The 'projectID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "UPDATE projects SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key . " = :" . $key;
            $ct++;
        }
    }
    $sql .= " WHERE id = :id";
Пример #16
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = $_SESSION["user"];
$taskID = param($_GET, 'taskID', '');
$dbh = new PDB();
$db = $dbh->db;
$projectIDs = $dbh->getValidProjects($userID);
$projectID = param($_GET, 'projectID', $projectIDs);
if ($taskID !== '') {
    $tasks = $dbh->getTask($taskID);
} else {
    $tasks = $dbh->getTasks($projectID);
}
exitjson(array("tasks" => $tasks));
/*
if($st->rowCount() == 0){
	errormsg("Username or password incorrect.");
};
*/
Пример #17
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = $_SESSION["user"];
$dbh = new PDB();
$db = $dbh->db;
$projectIDs = $dbh->getValidProjects($userID);
$projectID = param($_GET, 'projectID', $projectIDs);
$projects = $dbh->getProjects($projectID);
exitjson(array("projects" => $projects));
/*
if($st->rowCount() == 0){
	errormsg("Username or password incorrect.");
};
*/
Пример #18
0
$updata["projectCreator"] = $_SESSION["user"];
$updata["projectName"] = param($_POST, 'projectName', '');
$updata["projectDescription"] = param($_POST, 'projectDescription', '');
$updata["status"] = param($_POST, 'status', '');
$updata["startDate"] = param($_POST, 'startDate', '');
$updata["dueDate"] = param($_POST, 'dueDate', '');
$updata["updatedDate"] = param($_POST, 'updatedDate', '');
$updata["teamID"] = param($_POST, 'teamID', '');
$updata["clientID"] = param($_POST, 'clientID', '');
if (empty($updata["projectName"])) {
    errormsg("The 'projectName' is required.");
}
if (empty($updata["status"])) {
    errormsg("The 'status' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "INSERT INTO projects (";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key;
            $ct++;
        }
    }
    $sql .= ") VALUES (";
Пример #19
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = param($_GET, 'userID', $_SESSION["user"]);
$dbh = new PDB();
$db = $dbh->db;
$user = $dbh->getUser($userID);
exitjson(array("user" => $user));
Пример #20
0
 /**
  * normally the $dao should be injected.
  * If it's not, this function creates a new one out of the blue..
  */
 protected function get_dao()
 {
     if (!($dbconfig = PVars::getObj('config_rdbms'))) {
         throw new PException('DB config error!');
     }
     return PDB::get($dbconfig->dsn, $dbconfig->user, $dbconfig->password);
 }
Пример #21
0
<?php

error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
$dbh = new PDB();
$db = $dbh->db;
if (!isset($_SESSION["user"])) {
    errormsg("Not logged in.");
}
$userID = $_SESSION["user"];
$userdata = $dbh->getUser($userID);
exitjson(array("user" => $userdata));
Пример #22
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = $_SESSION["user"];
$dbh = new PDB();
$db = $dbh->db;
$clientID = param($_GET, 'clientID', '');
if ($clientID == '') {
    $clients = $dbh->getClients($userID);
} else {
    $clients = $dbh->getClient($userID, $clientID);
}
exitjson(array("clients" => $clients));
Пример #23
0
$user = $_SESSION["user"];
$updata = array();
$updata["id"] = param($_POST, 'clientID', '');
$updata["clientName"] = param($_POST, 'clientName', '');
$updata["primaryContact"] = param($_POST, 'primaryContact', '');
$updata["phone"] = param($_POST, 'phone', '');
$updata["address"] = param($_POST, 'address', '');
$updata["city"] = param($_POST, 'city', '');
$updata["state"] = param($_POST, 'state', '');
$updata["zipcode"] = param($_POST, 'zipcode', '');
$updata["website"] = param($_POST, 'website', '');
$updata["email"] = param($_POST, 'email', '');
if (empty($updata["id"])) {
    errormsg("The 'clientID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "UPDATE clients SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key . " = :" . $key;
            $ct++;
        }
    }
    $sql .= " WHERE id = :id";
Пример #24
0
checkLoggedIn();
$updata = array();
$updata["id"] = param($_POST, 'taskID', '');
$updata["taskeeID"] = param($_POST, 'taskeeID', '');
$updata["taskName"] = param($_POST, 'taskName', '');
$updata["taskDescription"] = param($_POST, 'taskDescription', '');
$updata["specs"] = param($_POST, 'specs', '');
$updata["status"] = param($_POST, 'status', '');
$updata["priority"] = param($_POST, 'priority', '');
$updata["updatedDate"] = param($_POST, 'updatedDate', '');
$updata["dueDate"] = param($_POST, 'dueDate', '');
$updata["startDate"] = param($_POST, 'startDate', '');
if (empty($updata["id"])) {
    errormsg("The 'taskID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "UPDATE tasks SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key . " = :" . $key;
            $ct++;
        }
    }
    $sql .= " WHERE id = :id";
Пример #25
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$dbh = new PDB();
$db = $dbh->db;
$users = $dbh->getUserList();
exitjson(array("users" => $users));
Пример #26
0
$updata["status"] = param($_POST, 'status', '');
$updata["priority"] = param($_POST, 'priority', '');
$updata["startDate"] = param($_POST, 'startDate', '');
$updata["dueDate"] = param($_POST, 'dueDate', '');
$updata["taskeeID"] = param($_POST, 'taskeeID', $_SESSION["user"]);
$updata["projectID"] = param($_POST, 'projectID', '');
if (empty($updata["projectID"])) {
    errormsg("The 'projectID' is required.");
}
if (empty($updata["taskName"])) {
    errormsg("The 'taskName' is required.");
}
if (empty($updata["status"])) {
    errormsg("The 'status' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "INSERT INTO tasks (";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key;
            $ct++;
        }
    }
    $sql .= ") VALUES (";