Esempio n. 1
1
 function __construct($cmid = 0)
 {
     global $db;
     $this->_cmid = $cmid;
     if ($this->_cmid != 0) {
         $this->_dbo = DB_DataObject::Factory("phph_comments");
         if (PEAR::isError($this->_dbo)) {
             throw new Exception2("Bd wewn�rzny", $this->_dbo->getMessage());
         }
         $r = $this->_dbo->get($cmid);
         if (PEAR::isError($r)) {
             throw new Exception2("Bd wewn�rzny", $r->getMessage());
         }
         if ($r == 0) {
             throw new Exception2("Bd", "Komentarz nie istnieje", COMMENT_NOT_FOUND);
         }
         $this->_user = DB_DataObject::Factory("phph_users");
         if (PEAR::isError($this->_user)) {
             throw new Exception2("Bd wewn�rzny", $this->_user->getMessage());
         }
         $r = $this->_user->get($this->_dbo->user_id);
         if (PEAR::isError($r)) {
             throw new Exception2("Bd wewn�rzny", $r->getMessage());
         }
         if ($r == 0) {
             throw new Exception2("Bd sp�noci danych", "Uytkownik do kt�ego nalezy komentarz nie istnieje.<br />Skontakuj si�z administratorem, podajc numer komentarza ({$cmid}).", COMMENT_USER_NOT_FOUND);
         }
     }
 }
 public function lunchReport($idBrand, $idSocialNetwork, $idInteraction)
 {
     $report = DB_DataObject::Factory('MpBrandXSocialNetwork');
     // DB_DataObject::debugLevel(1);
     $report->idBrand = $idBrand;
     $report->idInteraction = $idInteraction;
     $report->idSocialNetwork = $idSocialNetwork;
     $find = $report->find();
     if ($find > 0) {
         while ($report->fetch()) {
             if ($report->status == 'L') {
                 $report->status = 'E';
                 $report->update();
             }
         }
     } else {
         $report->snID = "Aqui va algo";
         $report->ownedBrand = 'N';
         $report->status = 'E';
         $report->date = date('Y-m-d h:i:s');
         $l = $report->insert();
         // printVar($l);
     }
     $report->free();
     return 'ok';
 }
Esempio n. 3
0
 function get($table)
 {
     $d = DB_DAtaObject::Factory($table);
     if (method_exists($d, 'availableColumns')) {
         $cols = $d->availableColumns();
     } else {
         $re = $d->autoJoin();
         //echo '<PRE>';print_r($re);
         $cols = $re['cols'];
         $types = array();
         $tables = array();
         $schemas = array($table => $d->table());
         foreach ($cols as $name => $table_col) {
             list($tbl, $col) = explode('.', $table_col);
             if (!isset($schemas[$tbl])) {
                 $schemas[$tbl] = DB_DataObject::Factory($tbl)->table();
             }
             $types[$name] = $schemas[$tbl][$col];
             $tables[$name] = $tbl;
         }
         foreach ($re['join_names'] as $c => $f) {
             $cols[$c] = $f;
         }
     }
     foreach ($cols as $c => $f) {
         $ret[] = array('name' => $c, 'val' => $f, 'type' => isset($types[$c]) ? $this->typeToName($types[$c]) : -1, 'table' => isset($tables[$c]) ? $tables[$c] : "");
     }
     $this->jdata($ret);
 }
Esempio n. 4
0
function launchFacebook($terminoBuscar)
{
    $app_access_token = genToken();
    $resultFacebook = app_request("https://graph.facebook.com/v2.5/search?q=" . $terminoBuscar . "&type=page&limit=10&fields=id,name,picture.type(normal),likes&" . $app_access_token);
    //printVar($resultFacebook,$_SERVER['SERVER_NAME'].'/publication/search/results/resultFacebook.json');
    //printVar($_SERVER["DOCUMENT_ROOT"]);
    $fp = fopen($_SERVER["DOCUMENT_ROOT"] . '/publication/search/results/resultFacebook.json', 'w');
    $qpaso = fwrite($fp, json_encode($resultFacebook));
    fclose($fp);
    //printVar($qpaso,'que paso');
    $obj = DB_DataObject::Factory('MpBrand');
    $obj->name = $terminoBuscar;
    $find = $obj->find();
    if ($find > 0) {
        // echo 'entra al if';
        while ($obj->fetch()) {
            //DB_DataObject::debugLevel(1);
            $obj->picture = $resultFacebook['data'][0]['picture']['data']['url'];
            $obj->update();
        }
    } else {
    }
    $obj->free();
    //echo json_encode('');
}
Esempio n. 5
0
 function get()
 {
     $this->transObj = DB_DataObject::Factory('core_enum');
     $this->transObj->query('BEGIN');
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
     $this->modules = $this->modulesList();
     $this->etype();
     $this->defaults();
     foreach ($this->defaults as $k => $v) {
         $enum = DB_DataObject::factory('core_enum');
         $enum->setFrom(array('etype' => $this->etype->name, 'name' => $k, 'active' => 1));
         if ($enum->find(true)) {
             continue;
         }
         $enum->display_name = $v;
         $enum->insert();
     }
     $notify = DB_DataObject::factory('core_notify');
     $notify->selectAdd();
     $notify->selectAdd("\n            DISTINCT(evtype) AS evtype\n        ");
     $types = $notify->fetchAll();
     foreach ($types as $t) {
         $enum = DB_DataObject::factory('core_enum');
         $enum->setFrom(array('etype' => $this->etype->name, 'name' => $t->evtype, 'active' => 1));
         if ($enum->find(true)) {
             continue;
         }
         $enum->display_name = $t->evtype;
         $enum->insert();
     }
     $this->jok('DONE');
 }
 static function getUserLevel($uid)
 {
     global $db;
     $gl = 0;
     $q = $db->prepare("SELECT IFNULL(MAX(group_level), 0) AS gl FROM phph_groups WHERE group_id IN (SELECT group_id FROM phph_group_users WHERE user_id = ?)");
     if (PEAR::isError($q)) {
         die($q->getMessage());
     }
     $r = $db->execute($q, $uid);
     if (PEAR::isError($r)) {
         die($r->getMessage());
     }
     $row = $r->fetchRow();
     $gl = $row['gl'];
     $user = DB_DataObject::Factory("phph_users");
     if (PEAR::isError($user)) {
         die($user->getMessage());
     }
     $r = $user->get($uid);
     if (PEAR::isError($r)) {
         die($r->getMessage());
     }
     if ($r == 0) {
         return 0;
     }
     return max($gl, $user->user_level);
 }
Esempio n. 7
0
 function get($id)
 {
     $ev = DB_DataObject::Factory('Events');
     if (!$ev->get((int) $id)) {
         $this->jerr("invalid id");
     }
     // verify if not admin, then they should
     $g = DB_DataObject::Factory('core_group_member');
     if (is_a($g, 'DB_DataObject')) {
         $grps = $g->listGroupMembership($this->authUser);
         //var_dump($grps);
         $isAdmin = $g->inAdmin;
         if (!$isAdmin && $ev->person_id != $this->authUser->id) {
             $this->jerrAuth();
         }
     }
     echo '<PRE>' . htmlspecialchars(print_r($ev->toArray(), true)) . "</PRE>";
     // we have 2 bits of data available at present:
     // core_event_audit
     // the event file..
     $d = DB_DataObject::factory('core_event_audit');
     if (is_a($d, 'DB_DataObject')) {
         echo "<H2>Changed Data:</H2>";
         $d->event_id = $ev->id;
         foreach ($d->fetchAll() as $d) {
             echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
         }
     }
     echo "<HR><H2>Posted Data:</H2>";
     $logdir = DB_DAtaObject::Factory('Events')->logDir();
     if (!$logdir) {
         echo "not available (Pman[storedir] not configured)";
         exit;
     }
     $file = $logdir . date('/Y/m/d/', strtotime($ev->event_when)) . $ev->id . ".php";
     if (file_exists($file)) {
         echo '<PRE>' . htmlspecialchars(file_get_contents($file)) . '</PRE>';
     }
     $file = $logdir . date('/Y/m/d/', strtotime($ev->event_when)) . $ev->id . ".json";
     if (!file_exists($file)) {
         echo "not available (missing file) {$file}";
         exit;
     }
     echo '<PRE>' . htmlspecialchars(print_r(json_decode(file_get_contents($file)), true)) . '</PRE>';
     echo '<BR/><PRE>' . htmlspecialchars($ev->remarks) . '</PRE>';
     $json = json_decode($ev->remarks, JSON_PRETTY_PRINT);
     if (json_last_error() == JSON_ERROR_NONE) {
         echo "<HR><H2>JSON DECODE Data:</H2>";
         echo '<PRE>' . print_r($json, true) . '</PRE>';
     }
     $filesJ = json_decode(file_get_contents($file));
     echo '<br /><PRE>Download files</PRE>';
     foreach ($filesJ->FILES as $k => $f) {
         $ip = $ff->baseURL . "/Images/events/" . $ev->id . '/' . $f->tmp_name;
         echo '<a href="' . $ip . '/download">' . htmlspecialchars($k . ' - ' . $f->name) . '</a><br/>';
     }
     exit;
 }
Esempio n. 8
0
 function get($args, $opts)
 {
     //DB_DataObject::DebugLevel(1);
     $d = DB_DataObject::Factory('core_curr_rate');
     $d->loadRates();
     $hkd = $d->convert(1, 'USD', 'HKD');
     echo "1 USD is ~ {$hkd} HKD (should be about 7.75)\n ";
     die("done");
 }
Esempio n. 9
0
 function post()
 {
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
     $this->sessionState(0);
     // turn off the session..
     $img = DB_DataObject::Factory('images');
     $img->setFrom(array('onid' => 0, 'ontable' => 'ipshead'));
     $img->onUpload(false);
     require_once 'File/Convert.php';
     $fc = new File_Convert($img->getStoreName(), $img->mimetype);
     $csv = $fc->convert('text/csv');
     $this->importCsv($csv);
 }
Esempio n. 10
0
 function post()
 {
     $this->transObj = DB_DataObject::Factory('invhist_transfer');
     $this->transObj->query('BEGIN');
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
     $img = DB_DataObject::Factory('images');
     $img->setFrom(array('onid' => 0, 'ontable' => 'ipshead'));
     $img->onUpload(false);
     require_once 'File/Convert.php';
     $fc = new File_Convert($img->getStoreName(), $img->mimetype);
     $csv = $fc->convert('text/csv');
     $ret = $this->importCsv($csv);
     $this->jdata($ret['data'], false, isset($ret['extra']) ? $ret['extra'] : array());
 }
Esempio n. 11
0
 function get($app)
 {
     die("DISABLED");
     $b = DB_DataObject::Factory('Builder');
     $b->find();
     echo '<PRE>';
     $dir = "/home/gitlive/";
     $map = array('Clipping' => 'web.MediaOutreach/Pman/Clipping', 'PressRelease' => 'web.MediaOutreach/Pman/PressRelease', 'Ris' => 'web.Ris/Pman/Ris', 'TestApp' => false, 'Hex' => false, 'Example' => false, 'ExampleOld' => false, 'Deleted' => false, 'DealFlow' => 'web.Dealflow/Pman/DealFlow', 'Aviation' => 'web.Aviation/Pman/Aviation');
     $dirs = array();
     while ($b->fetch()) {
         //  print_r($b);
         $data = json_decode($b->json);
         $data->title = $data->name;
         $data->name = $data->{'|module'};
         if (empty($data->name)) {
             continue;
         }
         // {"id":"roo-file-1","name":"layout test.bjs","parent":"","title":false,"path":"/h
         //ome/alan/buildertest/layout test.bjs"
         $fn = $dir . "Pman." . trim($data->app) . '/' . $data->name . '.bjs';
         if (isset($map[trim($data->app)])) {
             if ($map[trim($data->app)] === false) {
                 continue;
             }
             $fn = $dir . $map[$data->app] . '/' . $data->name . '.bjs';
         }
         if (!file_exists(dirname($fn))) {
             print "<B>SKIP " . $fn . "</B>\n";
             continue;
         }
         $dirs[dirname($fn)] = true;
         echo "WRITE : " . $fn . "\n";
         //echo "                          " .htmlspecialchars(json_encode($data)) . "\n";
         file_put_contents($fn, json_encode($data));
     }
     print_r($dirs);
     foreach ($dirs as $d => $n) {
         chdir($d);
         $cmd = 'git pull 2>&1';
         echo $cmd . "\n" . `{$cmd}`;
         $cmd = 'git add --all 2>&1';
         echo $cmd . "\n" . `{$cmd}`;
         $cmd = "git commit -m 'add bjs' -a --author='Alan Knowles <*****@*****.**>' 2>&1";
         echo $cmd . "\n" . `{$cmd}`;
         $cmd = "git push  2>&1";
         echo $cmd . "\n" . `{$cmd}`;
     }
     exit;
 }
Esempio n. 12
0
 public function getall()
 {
     global $g;
     $data_obj = \DB_DataObject::Factory('mycms\\' . $this->m_type);
     if ($data_obj instanceof \DB_DataObject_Error) {
         $g['error']->push($data_obj->message);
         return;
     }
     $count = $data_obj->find();
     $rows = array();
     while ($data_obj->fetch()) {
         $rows[] = clone $data_obj;
     }
     return array('rows' => $rows, 'count' => $count);
 }
Esempio n. 13
0
 function makeCopy($roo)
 {
     $c = DB_DataObject::Factory($this->tableName());
     $c->setFrom($this);
     $c->name = "COPY of " . $this->name;
     $c->updated_dt = $this->sqlValue('NOW()');
     $id = $c->insert();
     $c = DB_DataObject::Factory($this->tableName());
     $c->get($id);
     // copy images.
     $i = DB_DataObject::factory('Images');
     $i->onid = $this->id;
     $i->ontable = $this->tableName();
     $i->find();
     while ($i->fetch()) {
         $new_image = DB_DataObject::factory('Images');
         $new_image->onid = $c->id;
         $new_image->ontable = $this->tableName();
         $new_image->createFrom($i->getStoreName(), $i->filename);
         $map[$i->id] = $new_image->id;
     }
     libxml_use_internal_errors(true);
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->loadHTML('<?xml encoding="UTF-8"><HTML><BODY>' . $this->bodytext . '</BODY></HTML>');
     $doc->formatOutput = true;
     //echo '<PRE>'; print_R($doc);
     $xpath = new DOMXpath($doc);
     foreach ($xpath->query('//img[@src]') as $img) {
         $href = $img->getAttribute('src');
         //var_dump($href);
         $matches = array();
         if (preg_match("/Images\\/([0-9]+)\\/([^#]+)\\#image\\-([0-9]+)\$/", $href, $matches)) {
             $oid = $matches[1];
             if (!isset($map[$oid])) {
                 //echo "skip no new id for $oid";
                 continue;
             }
             $nid = $map[$oid];
             $nstr = "/Images/{$nid}/{$matches[2]}/#image-{$nid}";
             $img->setAttribute('src', str_replace($matches[0], $nstr, $href));
         }
     }
     $cc = clone $c;
     $c->bodytext = $doc->saveHTML();
     $c->update($cc);
     libxml_use_internal_errors(false);
     $roo->jok("duplicated");
 }
Esempio n. 14
0
 public function insertAnalytics($pagina, $usuario, $pass, $idBrand)
 {
     $web = DB_DataObject::Factory('MpWeb');
     // DB_DataObject::debugLevel(1);
     $web->url = $pagina;
     $web->idBrand = $idBrand;
     $find = $web->find();
     if ($find > 0) {
         while ($web->fetch()) {
             $web->analyticsUser = $usuario;
             $web->analyticsPass = $pass;
             $web->update();
         }
     }
     $web->free();
 }
Esempio n. 15
0
 function get()
 {
     // must recieve a group..
     if (!isset($_GET['group_id']) || (int) $_GET['group_id'] < 0) {
         $this->jerr("NO GROUP");
     }
     if (!$this->hasPerm('Core.Groups', 'S')) {
         // listing groups..
         $this->jerr("PERMISSION DENIED");
     }
     $g = DB_DataObject::Factory('core_group');
     if (!$g->get($_GET['group_id'])) {
         $this->jerr("group is invalid");
     }
     //print_r($g);
     //   DB_DataObject::debugLevel(1);
     $p = DB_DataObject::factory('core_group_right');
     $p->group_id = (int) $_GET['group_id'];
     $p->find();
     $cur = array();
     while ($p->fetch()) {
         $cur[$p->rightname] = clone $p;
     }
     $e = -1;
     $ar = array();
     // echo "<PRE>"; print_r($p->defaultPermData() );
     foreach ($p->defaultPermData() as $k => $defdata) {
         if (empty($defdata[0])) {
             // no admin data available..
             continue;
         }
         if (!isset($cur[$k])) {
             // then there is no current access right for it..
             //DB_DataObject::debugLevel(1);
             $gr = DB_DataObject::factory('core_group_right');
             $gr->group_id = (int) $_GET['group_id'];
             $gr->rightname = $k;
             $gr->accessmask = $g->type == 2 ? '' : $defdata[1];
             // set to defaults.. unless it's a contact group.
             $gr->insert();
             $cur[$k] = clone $gr;
         }
         $ar[] = array('id' => $cur[$k]->id * 1, 'rightname' => $k, 'descript' => isset($defdata[2]) ? $defdata[2] : '', 'accessmask' => $cur[$k]->accessmask, 'FullMask' => $defdata[0], 'group_id' => (int) $_GET['group_id']);
     }
     $this->jdata($ar);
 }
Esempio n. 16
0
 static function set($name, $val)
 {
     $config = DB_DataObject::Factory('phph_config');
     if (PEAR::isError($config)) {
         return $config;
     }
     $r = $config->get($name);
     if (PEAR::isError($r)) {
         return $config;
     }
     $config->config_value = $val;
     if ($r == 0) {
         return $config->insert();
     } else {
         return $config->update();
     }
 }
Esempio n. 17
0
 public function traeHastag()
 {
     //DB_DataObject::debugLevel(5);
     //Crea una nueva instancia de $tabla a partir de DataObject
     $objDBO = DB_DataObject::Factory('DpHashtag');
     $objDBO->selectadd();
     $objDBO->selectadd('id,hashtag');
     //$objDBO -> orderBy("idTweet DESC");
     //$objDBO -> limit('1');
     $objDBO->find();
     $count = 0;
     while ($objDBO->fetch()) {
         $ret[$count]->id = $objDBO->id;
         $ret[$count]->hashtag = $objDBO->hashtag;
         $count++;
     }
     //$ret = $ret + 1;
     //Libera el objeto DBO
     $objDBO->free();
     return $ret;
 }
Esempio n. 18
0
 /**
  * initalizie the cfg aray
  *
  */
 function cfg()
 {
     static $loaded = false;
     if ($loaded) {
         return self::$cfg;
     }
     $loaded = true;
     $ff = HTML_FlexyFramework::get();
     // BC compatible.. if any of these are set, then we use them as the settings..
     $opts = array();
     foreach (array('Pman_Core_I18n', 'Pman_Core_I18N', 'Pman_I18N', 'Pman_I18n') as $pk) {
         if (isset($ff->{$pk})) {
             //var_dump($pk);
             $opts = $ff->{$pk};
             break;
         }
     }
     //echo '<PRE>';print_R($opts);//exit;
     // var_dump($opts);exit;
     $i = DB_DataObject::Factory('I18n');
     // load the cofiguration
     foreach ($opts as $k => $v) {
         if ($v == '*') {
             // everything..
             // self::$cfg[$k] = $i->availableCodes($k, false);
             continue;
         }
         self::$cfg[$k] = is_array($v) ? $v : explode(',', $v);
     }
     // available codes recursively calls this... -- so the above has to be set first..
     foreach ($opts as $k => $v) {
         if ($v == '*') {
             // everything..
             self::$cfg[$k] = '*';
             //$i->availableCodes($k, false);
             continue;
         }
     }
     return self::$cfg;
 }
Esempio n. 19
0
 private function getSubTreeR($cid)
 {
     global $db;
     $dbo = DB_DataObject::Factory("phph_categories");
     if (PEAR::isError($dbo)) {
         throw new Exception2("B³±d wewnêtrzny", $dbo->getMessage());
     }
     $r = $dbo->get($cid);
     if (PEAR::isError($r)) {
         throw new Exception2("B³±d wewnêtrzny", $r->getMessage());
     }
     if ($r == 0) {
         throw new Exception2("B³±d", "Kategoria nie istnieje", CATEGORY_NOT_FOUND);
     }
     $sub = array();
     $q = $db->prepare("SELECT category_id FROM phph_categories WHERE category_parent = ? ORDER BY category_order ASC");
     $res = $db->execute($q, array($cid));
     while ($row = $res->fetchRow()) {
         $sub[] = $this->getSubTreeR($row['category_id']);
     }
     return array('id' => $cid, 'name' => $dbo->category_name, 'sub' => $sub);
 }
Esempio n. 20
0
    function addComment($title, $text)
    {
        $session = Session::singletone();
        $dbo = DB_DataObject::Factory("phph_comments");
        if (PEAR::isError($dbo)) {
            throw new Exception2(_INTERNAL_ERROR, $dbo->getMessage());
        }
        $dbo->comment_title = $title;
        $dbo->comment_text = $text;
        $dbo->photo_id = $this->_pid;
        $dbo->comment_date = time();
        $dbo->user_id = $session->_uid;
        $dbo->insert();
        if ($this->_dbo->user_id != $session->_uid) {
            $user = new User($session->_uid);
            $to_name = $this->_user->user_login;
            $photo_title = $this->_dbo->photo_title;
            $author = $user->_dbo->user_login;
            $body = <<<EOT
Witaj {$to_name},

U¿ytkownik {$author} doda³ do Twojego zdjêcia "{$photo_title}" komentarz. Poni¿ej znajduje siê tre¶æ komentarza:

{$title}

{$text}

-- 
Ten email zosta³ wys³any automatycznie. Prosimy nie odpowiadaæ.
EOT;
            Utils::mail("Nowy komentarz do Twojego zdjêcia \"{$photo_title}\".", $body, $this->_user->user_email, $this->_user->user_name);
        }
    }
Esempio n. 21
0
 function logDeleteEvent($object)
 {
     DB_DataObject::Factory('Events')->logDeletedRecord($object);
     $this->addEvent("DELETE", $object);
 }
Esempio n. 22
0
 }
 if ($user_pass1 == "") {
     $err_pass1 = true;
     $err_pass2 = true;
     throw new Exception2(_ADMIN_CANT_CREATE_ACCOUNT, _ADMIN_ERROR_EMPTY_PASSWORD);
 }
 if ($user_email == "") {
     $err_email = true;
     throw new Exception2(_ADMIN_CANT_CREATE_ACCOUNT, _ADMIN_ERROR_EMPTY_EMAIL);
 }
 if ($user_pass1 != $user_pass2) {
     $err_pass1 = true;
     $err_pass2 = true;
     throw new Exception2(_ADMIN_CANT_CREATE_ACCOUNT, _ADMIN_ERROR_PASSWORDS_DO_NOT_MATCH);
 }
 $user = DB_DataObject::Factory('phph_users');
 if (PEAR::isError($user)) {
     throw new Exception2(_INTERNAL_ERROR, $user->getMessage());
 }
 $r = $user->get('user_login', $_POST['user_login']);
 if (PEAR::isError($r)) {
     throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
 }
 if ($r != 0) {
     throw new Exception2(_ADMIN_CANT_CREATE_ACCOUNT, _ADMIN_LOGIN_EXISTS);
 }
 $user->user_login = $user_login;
 $user->user_pass = md5($user_pass1);
 $user->user_email = $user_email;
 $user->user_registered = time();
 $user->user_activated = time();
Esempio n. 23
0
 function post()
 {
     //DB_DataObject::debugLevel(1);
     if (!empty($_REQUEST['getAuthUser'])) {
         $this->sendAuthUserDetails();
         exit;
     }
     if (!empty($_REQUEST['logout'])) {
         return $this->logout();
     }
     if (!empty($_REQUEST['passwordRequest'])) {
         //|| (strpos($_REQUEST['username'], '@') < 1)) {
         return $this->passwordRequest($_REQUEST['passwordRequest']);
     }
     if (!empty($_REQUEST['changePassword'])) {
         return $this->changePassword($_REQUEST);
     }
     // login attempt..
     $ff = HTML_FlexyFramework::get();
     $tbl = empty($ff->Pman['authTable']) ? 'core_person' : $ff->Pman['authTable'];
     $u = DB_DataObject::factory($tbl);
     // ratelimit
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         //DB_DataObject::DebugLevel(1);
         $e = DB_DataObject::Factory('Events');
         $e->action = 'LOGIN-BAD';
         $e->ipaddr = $_SERVER['REMOTE_ADDR'];
         $e->whereAdd('event_when > NOW() - INTERVAL 10 MINUTE');
         if ($e->count() > 5) {
             $this->jerror('LOGIN-RATE', "Login failures are rate limited - please try later");
         }
     }
     //$u->active = 1;
     // empty username = not really a hacking attempt.
     if (empty($_REQUEST['username'])) {
         //|| (strpos($_REQUEST['username'], '@') < 1)) {
         $this->jerror('LOGIN-EMPTY', 'You typed the wrong Username or Password (0)');
         exit;
     }
     $u->authUserName($_REQUEST['username']);
     if ($u->count() > 1 || !$u->find(true)) {
         $this->jerror('LOGIN-BAD', 'You typed the wrong Username or Password  (1)');
         exit;
     }
     if (!$u->active()) {
         $this->jerror('LOGIN-BAD', 'Account disabled');
     }
     // check if config allows non-owner passwords.
     // auth_company = "OWNER" // auth_company = "CLIENT" or blank for all?
     // perhaps it should support arrays..
     $ff = HTML_FlexyFramework::get();
     if (!empty($ff->Pman['auth_comptype']) && $ff->Pman['auth_comptype'] != $u->company()->comptype) {
         //print_r($u->company());
         $this->jerror('LOGIN-BADUSER', "Login not permited to outside companies");
         // serious failure
     }
     // note we trim \x10 -- line break - as it was injected the front end
     // may have an old bug on safari/chrome that added that character in certian wierd scenarios..
     if ($u->checkPassword(trim($_REQUEST['password'], ""))) {
         $u->login();
         // we might need this later..
         $this->addEvent("LOGIN", false, session_id());
         if (!empty($_REQUEST['lang'])) {
             $u->lang($_REQUEST['lang']);
         }
         // log it..
         $this->sendAuthUserDetails();
         exit;
         //exit;
     }
     $this->jerror('LOGIN-BAD', 'You typed the wrong Username or Password  (2)');
     // - " . htmlspecialchars(print_r($_POST,true))."'");
     exit;
 }
 $category->category_name = $category_name;
 if ($category_parent > 0) {
     $category->category_parent = $category_parent;
 } else {
     $category->category_parent = DB_DataObject_Cast::sql("NULL");
 }
 $r = $category->find();
 if (PEAR::isError($r)) {
     throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
 }
 $category->fetch();
 if ($r != 0 && ($action == "add" || $action == "edit" && $category->category_id != $cid)) {
     throw new Exception2($err, _ADMIN_CATEGORY_EXISTS);
 }
 if ($action == "edit") {
     $category = DB_DataObject::Factory('phph_categories');
     if (PEAR::isError($category)) {
         throw new Exception2(_INTERNAL_ERROR, $category->getMessage());
     }
     $r = $category->get($cid);
     if (PEAR::isError($r)) {
         throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
     }
     if ($r == 0) {
         throw new Exception2($err, _ADMIN_ERROR_CATEGORY_DOESNT_EXISTS);
     }
 } else {
     $category->category_created = time();
     $category->category_creator = $session->_uid;
 }
 $category->category_name = $category_name;
Esempio n. 25
0
 /**
  * translate (used by database building);
  * usage :
  * require_once 'Pman/Core/I18n.php';
  * $x = new Pman_Core_I18N();
  * $x->translate($this->authuser, 'c', 'US');
  * @param au - auth User
  * @param type = 'c' or 'l'
  * @param k - key to translate
  * 
  */
 function translate($au, $type, $k)
 {
     static $cache;
     if (empty($k)) {
         return '??';
     }
     $lang = !$au || empty($au->lang) ? 'en' : is_string($au) ? $au : $au->lang;
     // does it need caching?
     $i = DB_DataObject::Factory('I18n');
     return $i->translate($lang, $type, $k);
 }
Esempio n. 26
0
 function syncTemplate()
 {
     // possibly needs to be cleverer = if template is a dialog etc.?
     $m = $this->module();
     $t = DB_DataObject::Factory('cms_template');
     $t->view_name = $m->name;
     $t->template = $this->name . '.html';
     $t->lang = 'en';
     if (!$t->find(true)) {
         $t->updated = $t->sqlValue('NOW()');
         $t->insert();
         return;
     }
     $t->updated = $t->sqlValue('NOW()');
     $t->update();
 }
Esempio n. 27
0
    }
    $r = $user->get($uid);
    if (PEAR::isError($r)) {
        die($r->getMessage());
    }
    if ($r == 0) {
        header("Location: " . $session->addSID(Config::get("site_url") . "/admin/users.php"));
    }
    $name = $user->user_login;
    $field = "user_id";
    $id = $uid;
} else {
    if (!Permissions::checkPerm('change_groups_permissions')) {
        die("Permission denied.");
    }
    $group = DB_DataObject::Factory('phph_groups');
    if (PEAR::isError($group)) {
        die($group->getMessage());
    }
    $r = $group->get($gid);
    if (PEAR::isError($r)) {
        die($r->getMessage());
    }
    if ($r == 0) {
        header("Location: " . $session->addSID(Config::get("site_url") . "/admin/groups.php"));
    }
    $name = $group->group_name;
    $field = "group_id";
    $id = $gid;
}
$q = $db->prepare("SELECT permission FROM phph_permissions WHERE {$field} = ?");
 function actualizaRanking()
 {
     //DB_DataObject::debugLevel(1);
     $tableDB = DB_DataObject::Factory("VistaNestumRanking");
     $tableDB->query("insert into nestum_rankingcron (idUsuario,idFacebook,nombreCompleto,nombres,apellidos,total) select  idUsuario,idFacebook,concat(nombres,' ',apellidos),nombres,apellidos,total from vista_nestum_ranking ORDER BY total DESC");
     return $tableDB;
 }
Esempio n. 29
0
 function lastId($field)
 {
     //Crea una nueva instancia de $tabla a partir de DataObject
     $objDBO = DB_DataObject::Factory($this->__tempName);
     $objDBO->selectadd();
     $objDBO->selectadd($field);
     $objDBO->orderBy("{$field} DESC");
     $objDBO->find();
     $objDBO->fetch();
     $ret = $objDBO->{$field};
     $objDBO->free();
     return $ret;
 }
Esempio n. 30
0
 function applyDefs($g, $usecol)
 {
     $defs = $this->defaultPermData();
     //echo '<PRE>';print_r($defs);
     //$usecol = 1;
     foreach ($defs as $rightname => $defdata) {
         $gr = DB_DataObject::Factory('core_group_right');
         $gr->rightname = $rightname;
         $gr->group_id = $g->id;
         if (!$gr->find(true)) {
             $gr->accessmask = $defdata[$usecol];
             $gr->insert();
             continue;
         }
         $oldgr = clone $gr;
         $gr->accessmask = $gr->mergeMask($gr->accessmask, $defdata[$usecol]);
         if ($gr->accessmask == $oldgr->accessmask) {
             continue;
         }
         $gr->update($oldgr);
     }
 }