Example #1
0
 public function _log($typeID, $id = array(), $text = "", $data = array())
 {
     //save($id=array("contentID"=>"","commentID"=>"","meetingID"=>"","companyID"=>"","answerID"=>""),$text="",$userID="") {
     $timer = new timer();
     $f3 = \base::instance();
     $user = $f3->get("user");
     $userID = $user['ID'];
     //test_array($id);
     $values = array('typeID' => $typeID, 'userID' => $userID, 'contentID' => isset($id["contentID"]) ? $id["contentID"] : null, 'commentID' => isset($id["commentID"]) ? $id["commentID"] : null, 'meetingID' => isset($id["meetingID"]) ? $id["meetingID"] : null, 'companyID' => isset($id["companyID"]) ? $id["companyID"] : null, 'optionID' => isset($id["optionID"]) ? $id["optionID"] : null, 'fileID' => isset($id["fileID"]) ? $id["fileID"] : null, 'text' => $text, 'data' => json_encode($data), 'sessionID' => session_id());
     //test_array($values);
     if ($values['fileID'] != null && $values['contentID'] == null) {
         $values['contentID'] = $this->lookup($values['fileID'], 'mp_content_files')->contentID;
     }
     if ($values['optionID'] != null && $values['contentID'] == null) {
         $values['contentID'] = $this->lookup($values['optionID'], 'mp_content_poll_answers')->contentID;
     }
     if ($values['commentID'] != null && $values['contentID'] == null) {
         $values['contentID'] = $this->lookup($values['commentID'], 'mp_content_comments')->contentID;
     }
     if ($values['contentID'] != null && $values['meetingID'] == null) {
         $values['meetingID'] = $this->lookup($values['contentID'], 'mp_content')->meetingID;
     }
     if ($values['meetingID'] != null && $values['companyID'] == null) {
         $values['companyID'] = $this->lookup($values['meetingID'], 'mp_meetings')->companyID;
     }
     $art = new \DB\SQL\Mapper($this->f3->get("DB"), 'mp_logs');
     foreach ($values as $key => $value) {
         if (isset($art->{$key}) && $key != "ID") {
             $art->{$key} = $value;
         }
     }
     $art->save();
     $timer->_stop(__NAMESPACE__, __CLASS__, __FUNCTION__, func_get_args());
     return $values;
 }
Example #2
0
 function Set($f3)
 {
     if (!\Check::confirm('POST.password')) {
         $this->flash('Konfirmasi Password Tidak Cocok');
         $f3->reroute($f3->get('URI'));
     }
     $post = $f3->get('POST');
     $db_host = $post['DB_HOST'];
     $db_name = $post['DB_NAME'];
     $db_user = $post['DB_USER'];
     $db_pass = $post['DB_PASS'];
     $dsn = "mysql:host={$db_host};port=3306;dbname={$db_name}";
     $db = new \DB\SQL($dsn, $db_user, $db_pass);
     try {
         $db->begin();
         $db->exec(explode(';', $f3->read('installation/install.sql')));
         $user = new \DB\SQL\Mapper($db, 'user');
         $user->username = $post['username'];
         $user->password = \Bcrypt::instance()->hash($post['password']);
         $user->type = 1;
         $user->save();
         $key = bin2hex(openssl_random_pseudo_bytes(32));
         $data = "[globals]\nDEBUG=0\nAUTOLOAD=\"controller/;model/\"\nUI=\"view/\"\nAPP_KEY=\"{$key}\"\nDB_SET=\"{$dsn}\"\nDB_USER=\"{$db_user}\"\nDB_PASS=\"{$db_pass}\"";
         $f3->write('config/config.ini', $data);
         $f3->write('config/route.ini', $f3->read('installation/route.ini'));
         $db->commit();
         $this->flash('Success... Silahkan Hapus Folder Installation', 'success');
     } catch (Exception $e) {
         $db->rollback();
         $this->flash($e->getMessage());
         $f3->reroute('/');
     }
     $f3->reroute('/');
 }
function recommendations_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 50;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}recommendations`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT SELECT_OUTER.recid,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT tid,',',tag,',',description ORDER BY `order`,tgid,tag ASC SEPARATOR '||') AS tagblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT charid,',',charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT cid,',',category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT ratingid,',',rating_name,',',rating_image SEPARATOR '||' ) as rating\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\tSELECT R.recid,\r\n\t\t\t\t\t\t\t\t\t\tR.ratingid, Ra.rating as rating_name, IF(Ra.rating_image,Ra.rating_image,'') as rating_image,\r\n\t\t\t\t\t\t\t\t\t\tCat.cid, Cat.category,\r\n\t\t\t\t\t\t\t\t\t\tTG.description,TG.order,TG.tgid,T.label as tag,T.tid,\r\n\t\t\t\t\t\t\t\t\t\tCh.charid, Ch.charname\r\n\t\t\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\t\tSELECT R1.*\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}recommendations` R1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE R1.cache_tags IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t\t) AS R\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings` Ra ON ( Ra.rid = R.ratingid )\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}recommendation_relations`rRT ON ( rRT.recid = R.recid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags` T ON ( T.tid = rRT.relid AND rRT.type='T' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups` TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters` Ch ON ( Ch.charid = rRT.relid AND rRT.type = 'CH' )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories` Cat ON ( Cat.cid = rRT.relid AND rRT.type = 'CA' )\r\n\t\t\t\t\t\t\t\t)AS SELECT_OUTER\r\n\t\t\t\t\t\t\t\tGROUP BY recid ORDER BY recid ASC;");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}recommendations` SET \r\n\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t`cache_categories`\t= :categoryblock,\r\n\t\t\t\t\t`cache_rating`\t\t= :rating\r\n\t\t\t\tWHERE recid = {$item['recid']} ;", [':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock'])), ':rating' => json_encode(explode(",", $item['rating']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}
Example #4
0
function contests_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 50;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}contests`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT \r\n\t\t\t\t\t\t\t\tCon.conid,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT S.sid,',',S.title,',',U.uid,',',U.nickname ORDER BY charname ASC SEPARATOR '||') AS storyblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT Chara.charid,',',Chara.charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT C.cid,',',C.category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT T.tid,',',T.label,',',TG.description ORDER BY TG.order,TG.tgid,T.label ASC SEPARATOR '||') AS tagblock\r\n\t\t\t\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\tSELECT Con1.conid\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}contests`Con1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE Con1.cache_tags IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t) AS Con\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}contest_relations`rC ON ( rC.conid = Con.conid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories`S ON ( S.sid = rC.relid and rC.type='ST' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_authors`rSA ON ( rSA.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}users`U ON ( U.uid = rSA.aid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags`T ON ( T.tid = rC.relid AND rC.type = 'T' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups`TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters`Chara ON ( Chara.charid = rC.relid AND rC.type = 'CH' )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories`C ON ( C.cid = rC.relid AND rC.type = 'CA' )\r\n\t\t\t\t\t\t\t\t\tGROUP BY Con.conid;");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}contests` SET \r\n\t\t\t\t\t\t`cache_stories`\t\t= :storyblock,\r\n\t\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t\t`cache_categories`\t= :categoryblock\r\n\t\t\t\t\tWHERE conid = {$item['conid']} ;", [':storyblock' => json_encode(upgradetools::cleanResult($item['storyblock'])), ':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}
Example #5
0
function series_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 20;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}series`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT \r\n\t\t\t\t\t\t\t\tSERIES.seriesid, \r\n\t\t\t\t\t\t\t\tSERIES.tagblock, \r\n\t\t\t\t\t\t\t\tSERIES.characterblock, \r\n\t\t\t\t\t\t\t\tSERIES.authorblock, \r\n\t\t\t\t\t\t\t\tSERIES.categoryblock, \r\n\t\t\t\t\t\t\t\tCONCAT(rating,'||',max_rating_id) as max_rating\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\tSer.seriesid,\r\n\t\t\t\t\t\t\tMAX(Ra.rid) as max_rating_id,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT U.uid,',',U.nickname ORDER BY nickname ASC SEPARATOR '||' ) as authorblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT Chara.charid,',',Chara.charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT C.cid,',',C.category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT T.tid,',',T.label,',',TG.description ORDER BY TG.order,TG.tgid,T.label ASC SEPARATOR '||') AS tagblock\r\n\t\t\t\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\tSELECT Ser1.seriesid\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}series`Ser1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE Ser1.cache_authors IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t) AS Ser\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}series_stories`TrS ON ( Ser.seriesid = TrS.seriesid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories`S ON ( TrS.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings`Ra ON ( Ra.rid = S.ratingid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_tags`rST ON ( rST.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags`T ON ( T.tid = rST.tid AND rST.character = 0 )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups`TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters`Chara ON ( Chara.charid = rST.tid AND rST.character = 1 )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_categories`rSC ON ( rSC.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories`C ON ( rSC.cid = C.cid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_authors`rSA ON ( rSA.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}users` U ON ( rSA.aid = U.uid )\r\n\t\t\t\t\t\t\t\t\tGROUP BY Ser.seriesid\r\n\t\t\t\t\t\t\t) AS SERIES\r\n\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings`R ON (R.rid = max_rating_id);");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}series` SET \r\n\t\t\t\t\t\t`cache_authors`\t\t= :authorblock,\r\n\t\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t\t`cache_categories`\t= :categoryblock,\r\n\t\t\t\t\t\t`max_rating`\t\t= :max_rating\r\n\t\t\t\t\tWHERE seriesid = {$item['seriesid']} ;", [':authorblock' => json_encode(upgradetools::cleanResult($item['authorblock'])), ':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock'])), ':max_rating' => json_encode(explode(",", $item['max_rating']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}
Example #6
0
 public function cacheCategories($catID = 0)
 {
     // clear stats of affected categories
     $sql = "UPDATE `tbl_categories` SET `stats` = NULL";
     if ($catID > 0) {
         $sql .= " WHERE `cid` = {$catID};";
     }
     $this->exec($sql);
     $categories = new \DB\SQL\Mapper($this->db, $this->prefix . 'categories');
     $sql = "SELECT C.cid, C.category, COUNT(DISTINCT S.sid) as counted, \r\n\t\t\t\t\tGROUP_CONCAT(DISTINCT C1.category SEPARATOR '||' ) as sub_categories, \r\n\t\t\t\t\tGROUP_CONCAT(DISTINCT C1.stats SEPARATOR '||' ) as sub_stats\r\n\t\t\tFROM `tbl_categories`C \r\n\t\t\t\tINNER JOIN (SELECT leveldown FROM `tbl_categories` WHERE `stats` = '' ORDER BY leveldown DESC LIMIT 0,1) c2 ON ( C.leveldown = c2.leveldown )\r\n\t\t\t\tLEFT JOIN `tbl_stories_categories`SC ON ( C.cid = SC.cid )\r\n\t\t\t\tLEFT JOIN `tbl_stories`S ON ( S.sid = SC.sid )\r\n\t\t\t\tLEFT JOIN `tbl_categories`C1 ON ( C.cid = C1.parent_cid )\r\n\t\t\tGROUP BY C.cid";
     do {
         $items = $this->exec($sql);
         $change = FALSE;
         foreach ($items as $item) {
             if ($item['sub_categories'] == NULL) {
                 $sub = NULL;
             } else {
                 $sub_categories = explode("||", $item['sub_categories']);
                 $sub_stats = explode("||", $item['sub_stats']);
                 $sub_stats = array_map("json_decode", $sub_stats);
                 foreach ($sub_categories as $key => $value) {
                     $item['counted'] += $sub_stats[$key]->count;
                     $sub[$value] = $sub_stats[$key]->count;
                 }
             }
             $stats = json_encode(["count" => (int) $item['counted'], "cid" => $item['cid'], "sub" => $sub]);
             unset($sub);
             $categories->load(array('cid=?', $item['cid']));
             $categories->stats = $stats;
             $categories->save();
             $change = $change ?: $categories->changed();
         }
     } while ($change != FALSE);
 }
Example #7
0
 function show_all($f3)
 {
     $orm = new DB\SQL\Mapper($f3->get('DB'), 'INGREDIENT_OVERVIEW');
     $page = $f3->get('PARAMS.page');
     $record_count = $orm->count();
     $result_number = 20;
     $page_count = ceil($record_count / $result_number);
     if (!isset($page) || $page <= 0) {
         $f3->reroute("/ainesosa/listaa/sivu/1");
     } else {
         if ($page > $page_count) {
             $f3->reroute("/ainesosa/listaa/sivu/" . $page_count);
         }
     }
     $page--;
     $result = $orm->find(array(), array('limit' => $result_number, 'offset' => $page * $result_number));
     $allergy_arr = array();
     foreach ($result as $ingredient) {
         $id = $ingredient->id;
         $string_allergies = $ingredient->allergies;
         $allergy_arr[$id] = array_filter(explode(',', trim($string_allergies)));
     }
     $f3->set('allergies', Allergy::map_to_id($f3));
     $f3->set('result', $result);
     $f3->set('page_count', $page_count);
     $f3->set('cur_page', $page + 1);
     $f3->set('allergy_arr', $allergy_arr);
     $f3->set("content", "ingredient_list.htm");
     $f3->set("title", "Ainesosat");
     echo Template::instance()->render("layout.htm");
 }
Example #8
0
 public function userSession($uid)
 {
     $session = new \DB\SQL\Mapper($this->db, $this->prefix . "sessions");
     $session->load(array('session=?', $_SESSION['session_id']));
     $session->user = $uid;
     $session->save();
 }
Example #9
0
 function GetDbMapperInstance($table)
 {
     $id = $this->f3->get('REQUEST.id');
     $result = new DB\SQL\Mapper($this->f3->get('DB'), $table);
     if ($id) {
         $result->load(array('id=?', $id));
     }
     return $result;
 }
Example #10
0
 function photo_delete()
 {
     $return = "done";
     $ID = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : "";
     $art = new \DB\SQL\Mapper($this->f3->get("DB"), "dir_items_photos");
     $art->load("ID='{$ID}'");
     $art->erase();
     return $GLOBALS["output"]['data'] = $return;
 }
Example #11
0
 public function getPosts($f3)
 {
     $db = new \DB\SQL('mysql:host=' . $f3->get('db_host') . ';port=3306;dbname=' . $f3->get('db_server'), $f3->get('db_login'), $f3->get('db_password'));
     $mapper = new \DB\SQL\Mapper($db, 'post_view');
     if (!$f3->get('PARAMS.id')) {
         $f3->set('usersPosts', $mapper->find(array(), array('order' => 'login')));
     } else {
         $f3->set('usersPosts', $mapper->find(array("user_id=?", $f3->get('PARAMS.id'))));
     }
 }
Example #12
0
 public function update($table, $data, $where)
 {
     $handle = new \DB\SQL\Mapper($this->db, str_replace("tbl_", $this->prefix, $table));
     $handle->load($where);
     foreach ($data as $key => $value) {
         $handle->{$key} = $value;
     }
     $handle->save();
     unset($handle);
 }
Example #13
0
 public function save()
 {
     $v = new DB\SQL\Mapper(Events::$db, 'venues');
     if ($this->id) {
         $v->load('id=' . $this->id);
     }
     $v->name = $this->name;
     $v->address = $this->address;
     $v->postcode = $this->postcode;
     $v->info = $this->info;
     $v->save();
 }
Example #14
0
 function edit($f3)
 {
     $video = new DB\SQL\Mapper($f3->get('db'), 'videos');
     $video->load(array('id=?', $f3->get('PARAMS.videoID')));
     if ($f3->get('POST.delete') == '1') {
         $video->erase();
     } else {
         $video->startTime = $f3->get('POST.startTime');
         $video->endTime = $f3->get('POST.endTime');
         $video->save();
     }
     $f3->reroute('@channelList');
 }
Example #15
0
 static function get_menus()
 {
     $db = new DB\SQL('mysql:host=localhost;dbname=MealDB', 'root', '');
     $menuInst = new DB\SQL\Mapper($db, "MENU");
     $menus = array();
     $menuInst->load('');
     while (!$menuInst->dry()) {
         $id = $menuInst->id;
         $name = $menuInst->name;
         $menus[$id] = $name;
         $menuInst->next();
     }
     return $menus;
 }
Example #16
0
 private function ipIsAlreadyRegistered($ip, $gaddress)
 {
     $faucet = new DB\SQL\Mapper($this->db, 'faucet');
     $faucet->load(array('user_ip=?', $ip));
     if ($faucet->user_ip == null) {
         $faucet->load(array('gaddress=?', $gaddress));
         if ($faucet->gaddress == null) {
             $faucet->user_ip = $ip;
             $faucet->gaddress = $gaddress;
             $faucet->save();
             return false;
         }
     }
     return true;
 }
Example #17
0
 public function __construct($db, $id = 0)
 {
     parent::__construct($db, 'Item');
     if ($id != 0) {
         $this->load(['id = ?', $id]);
     }
 }
Example #18
0
File: User.php Project: srccn/hy
 public function __construct(DB\SQL $db)
 {
     if ($_SESSION['is_admin']) {
     } else {
     }
     parent::__construct($db, 'users');
 }
Example #19
0
function textblocks_copy($job, $step)
{
    // Copy the existing blocks
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $old = "{$fw['installerCFG.db3.dbname']}`.`{$fw['installerCFG.db3.prefix']}fanfiction_";
    $i = 0;
    $newdata = new \DB\SQL\Mapper($fw->db5, $fw['installerCFG.db5.prefix'] . "textblocks");
    $dataIn = $fw->db3->exec("SELECT message_id as id, message_name as label, message_title as title, message_text as content, 1 as as_page FROM `{$old}messages`;");
    foreach ($dataIn as $data) {
        $i++;
        $newdata->copyfrom($data);
        $newdata->save();
        $newdata->reset();
    }
    $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 2, `items` = :items WHERE `id` = :id ", [':items' => $i, ':id' => $step['id']]);
}
Example #20
0
 /**
  * Load by ID directly if a number is passed
  * @param  string|array  $filter
  * @param  array         $options
  * @param  integer       $ttl
  * @return mixed
  */
 function load($filter = NULL, array $options = NULL, $ttl = 0)
 {
     if (is_numeric($filter)) {
         return parent::load(array("id = ?", $filter), $options, $ttl);
     } elseif (is_array($filter)) {
         return parent::load($filter, $options, $ttl);
     }
     throw new \Exception('$filter must be an int or array');
 }
Example #21
0
 function order()
 {
     $return = "";
     $domain = $this->f3->get("domain");
     //$ID = (isset($_GET['ID'])) ? $_GET['ID'] : "";
     $f3 = \Base::instance();
     $list = $_POST['id'];
     $a = new \DB\SQL\Mapper($f3->get("DB"), "dir_categories");
     $sort = array();
     foreach ($list as $id => $parentId) {
         $a->load("ID='{$id}'");
         $a->parentID = $parentId;
         if (!$a->dry()) {
             $a->save();
         }
         $a->reset();
     }
     test_array($sort);
     return $GLOBALS["output"]['data'] = $return;
 }
Example #22
0
File: Article.php Project: srccn/hy
 public function __construct(DB\SQL $db, $table_name, $cols)
 {
     if ($_SESSION['userid']) {
         $userId = $_SESSION['userid'];
         $_POST['user_id'] = $userId;
         if ($_SESSION['is_admin']) {
             $this->filter = null;
         } else {
             $this->filter = 'user_id = ' . $userId;
         }
     }
     parent::__construct($db, $table_name, $cols);
 }
Example #23
0
 public function newsletter()
 {
     $f3 = \Base::instance();
     $db = $f3->get('DB.instance');
     // Getting info about request, $org = organisation, $nId = newsletter id.
     $org = $f3->get('PARAMS.org');
     $nId = (int) $f3->get('PARAMS.nId');
     $nmap = new \DB\SQL\Mapper($db, 'newsletters');
     $omap = new \DB\SQL\Mapper($db, 'organisations');
     if ($omap->load(array('id=? OR cname=?', $org, $org))) {
         // Organisation exists
         if ($nmap->load(array('id=? AND orgId=?', $nId, $omap->id))) {
             $nmap->views++;
             $nmap->save();
             // Render
             $f3->set('v_org', $omap);
             $f3->set('v_let', $nmap);
             $this->_render('public/newsletter.html');
         } else {
             /*
              * Newsletter does not exists
              *
              * Render a page that says so, and lists other newsletters made by the same company.
              */
             $f3->set('v_org', $nmap);
             $lastNews = $nmap->find(array('orgId=?', $omap->id));
             $f3->set('v_lastNews', $lastNews);
             $this->_render('public/newsletter_notfound.html');
         }
     } else {
         /*
          * Organisation does not exists, error page
          */
         $this->_render('public/organisation_notfound.html');
     }
 }
Example #24
0
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'categories');
 }
Example #25
0
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'users');
 }
Example #26
0
 function __construct($table)
 {
     $this->initializeDatabase();
     parent::__construct($this->db, $table);
 }
Example #27
0
function getUniqueUsername($username)
{
    $db = db();
    $users = new DB\SQL\Mapper($db, 'users');
    $user = $users->findone(array('user_name = ?', $username));
    if (!empty($user)) {
        $username = $username . rand(0, 1000000000000);
        return getUniqueUsername($username);
    } else {
        return $username;
    }
}
Example #28
0
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'catgroup');
 }
Example #29
0
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'messages');
 }
Example #30
0
File: Stream.php Project: XaaT/ttb
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'stream');
 }