Exemple #1
0
 static function get($params)
 {
     $params2 = array();
     if (is_string($params)) {
         $params = parse_str($params, $params2);
         $params = $params2;
     }
     if (isset($params['content_id'])) {
         $params['rel_type'] = 'content';
         $params['rel_id'] = mw()->database_manager->escape_string($params['content_id']);
     }
     $table = MODULE_DB_COMMENTS;
     $params['table'] = $table;
     $comments = db_get($params);
     if (is_array($comments)) {
         $i = 0;
         foreach ($comments as $item) {
             if (isset($item['created_by']) and intval($item['created_by']) > 0 and ($item['comment_name'] == false or $item['comment_name'] == '')) {
                 $comments[$i]['comment_name'] = user_name($item['created_by']);
             }
             $i++;
         }
     }
     return $comments;
 }
function get_quotes($params = array())
{
    if (is_string($params)) {
        $params = parse_params($params);
    }
    $params['table'] = "ez_quotes";
    return db_get($params);
}
Exemple #3
0
 public function LoadRoles()
 {
     $rs = db_get()->Execute('system_user_loadroles', $this->__get['Id']);
     while ($row = $rs->Fetch()) {
         $this->__get['Roles'][$row['RoleId']] = $row['Name'];
     }
     unset($rs, $row);
     return true;
 }
 public function execute($fetchas = "")
 {
     if ($fetchas != "") {
         $this->fetchas = $fetchas;
     }
     if (!isset($this->query) || $this->query == "") {
         $this->query = $this->build_query();
     }
     $res = db_get($this->query, $this->fetchas);
     return $res;
 }
function db_get_template($tpl_name, &$tpl_source, &$smarty_obj)
{
    global $db;
    global $thulit;
    $set = db_get("select id from data where name_id='" . $tpl_name . "' and node_type='template'");
    if ($arr = $set->fetchRow()) {
        $tpl_source = get_value($arr['id'], $thulit['lang']);
        return true;
    } else {
        return false;
    }
}
Exemple #6
0
 function __construct($class_name = NULL)
 {
     if ($class_name == NULL) {
         $this->new_class = true;
     } else {
         $this->new_class = false;
         //conn to database
         $db_vals = db_get("Classes", "*", "class_name", sprintf("%s", $class_name));
         $this->class_name = $class_name;
         $this->subject = $db_vals['subject'];
     }
 }
Exemple #7
0
 function get($id)
 {
     $id = alphaID($id, true);
     if (false !== ($paste = db_get($id))) {
         // check to see if this paste has expired
         $expired = $this->has_expired($paste);
         if ($expired === false) {
             return $paste;
         }
         return $expired;
     }
     return NCRYPT_DOES_NOT_EXIST;
 }
 public function login($username, $password)
 {
     if (value_exists("Registered_User", "username", $username)) {
         $db_val = db_get("Registered_User", "password", "username", $username);
         if (strcmp($password, $db_val['password']) == 0) {
             $role = $this->admin ? "admin" : "registered_user";
             return $role;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Exemple #9
0
function pl_unsubscribe()
{
    $p = sanitize(['email' => STR, 'groupid' => INT]);
    $who = $p['email'];
    $what = $p['groupid'];
    if (empty($who) || empty($what)) {
        return fails('empty input');
    }
    $db = db_connect();
    // test for existence
    $res = db_get('select * from subscriptions where email="' . $who . '" and groupid="' . $what . '"');
    if (count($res) > 0) {
        $db->exec('delete from subscriptions where email="' . $who . '" and groupid="' . $what . '"');
        return passes('removed ' . count($res) . ' entries');
    }
    return fails('nothing found');
}
 public function dbGet($params = array())
 {
     if (empty($params) && $this->id > 0) {
         $params = array("id" => $this->id);
     }
     if (empty($params)) {
         return false;
     }
     $query = "SELECT " . implode(",", $this->params) . " FROM " . $this->schema . $this->table . " WHERE ";
     foreach ($params as $key => $val) {
         $query .= $key . "=" . dbize($val);
     }
     $dbvals = db_get($query, "row");
     if ($dbvals != NULL) {
         $this->setFromArray($dbvals[0]);
     }
     $this->afterDbGet();
 }
 public function build_query()
 {
     // Check for existing table
     $tab = db_get("SELECT 1 FROM " . $this->table);
     if ($tab == NULL || !isset($tab[1])) {
         //echo "TABLE does not exist, continue";
     } else {
         if ($this->debug) {
             echo $this->table . " already exists";
         }
         return false;
     }
     if (!empty($this->columns)) {
         $colstring = "";
         $primaryKeyAdded = false;
         // Add the column names & types to the query string
         foreach ($this->columns as $name => $type) {
             if ($colstring != "") {
                 $colstring .= ",";
             }
             // If this is the primary key field, add the constraints
             if ($this->primaryKeyField != "" && strtolower($name) == strtolower($this->primaryKeyField)) {
                 $colstring .= primary_key_clause($name);
                 $primaryKeyAdded = true;
             } else {
                 $colstring .= $name . " " . $type;
             }
         }
         // Add primary key field, if one is set and it wasn't in the column list
         if ($this->primaryKeyField != "" && !$primaryKeyAdded) {
             $colstring = primary_key_clause($this->primaryKeyField) . ", " . $colstring;
         }
         if (!empty($this->unique_constraints)) {
             foreach ($this->unique_constraints as $constriant_name => $fields) {
                 $colstring .= ", CONSTRAINT " . $constraint_name . " UNIQUE (" . implode(",", $fields) . ")";
             }
         }
         // Create the query
         $query = "CREATE TABLE " . $this->table_with_schema() . "(" . $colstring . ")";
         $this->query = $query;
         return $this->query;
     }
     return "";
 }
Exemple #12
0
 function save($data)
 {
     if (is_admin() == false) {
         error('Must be admin');
     }
     if (isset($data['shipping_country'])) {
         if ($data['shipping_country'] == 'none') {
             error('Please choose country');
         }
         if (isset($data['id']) and intval($data['id']) > 0) {
         } else {
             $check = db_get('shipping_country=' . $data['shipping_country']);
             if ($check != false and is_array($check[0]) and isset($check[0]['id'])) {
                 $data['id'] = $check[0]['id'];
             }
         }
     }
     $data = mw()->database_manager->save($this->table, $data);
     return $data;
 }
 public function testSaveCustomFields()
 {
     $my_product_id = 3;
     $custom_field = array('field_name' => 'My test price', 'field_value' => 10, 'field_type' => 'price', 'content_id' => $my_product_id);
     // adding a custom field "price" to product
     $new_id = save_custom_field($custom_field);
     $are_values_here = db_get('table=custom_fields_values&custom_field_id=' . $new_id);
     $field = get_custom_field_by_id($new_id);
     $to_delete = array('id' => $new_id);
     $delete = delete_custom_field($to_delete);
     $field2 = get_custom_field_by_id($new_id);
     //check if values are deleted
     $are_values_gone = db_get('table=custom_fields_values&custom_field_id=' . $new_id);
     $this->assertEquals($field['name'], 'My test price');
     $this->assertEquals($field['value'], 10);
     $this->assertEquals(intval($new_id) > 0, true);
     $this->assertEquals(intval($delete) > 0, true);
     $this->assertEquals($field2, false);
     $this->assertEquals(is_array($are_values_here), true);
     $this->assertEquals(is_array($are_values_gone), false);
 }
Exemple #14
0
<?php

debug_backtrace() || die("Direct access not permitted.");
?>

<?php 
$pdo = db_connect();
$rows = db_get('scl_students');
$plug_path = plugin_path('school_management_vor');
require 'imageResize.php';
$db_ids = array();
foreach ($rows as $row) {
    $db_ids[] = $row['image'];
}
$accs = db_get('vor_admin');
$db_accs = array();
foreach ($accs as $acc) {
    $db_accs[] = $acc['image'];
}
$image_id_dir = $plug_path . 'images/scl_students/';
$image_acc_dir = 'img/admin/';
$stored_id_images = glob($image_id_dir . '*.jpg');
$stored_acc_images = glob($image_acc_dir . '*.jpg');
$def_image = array_search('img/admin/default_image.png', $stored_acc_images);
unset($stored_acc_images[$def_image]);
if (!empty($stored_id_images)) {
    $stored_image_m = array();
    foreach ($stored_id_images as $stored_image) {
        $stored_image_m[] = basename($stored_image);
    }
    foreach ($stored_image_m as $stored_image_h) {
function display_site($site, $parent = null)
{
    global $db;
    global $thulit;
    if (!isset($site)) {
        die("??? \$site nie je definovane ???");
    }
    $set = db_get("select * from data where name_id='" . $site . "' and node_type='site'");
    if ($arr = $set->fetchRow()) {
        display($arr, $parent);
    }
}
Exemple #16
0
    function index($params, $config)
    {
        $current_page = $current_page = 1;
        $post_params = $params;
        if (isset($post_params['id'])) {
            $paging_param = 'current_page' . crc32($post_params['id']);
            unset($post_params['id']);
        }
        $cat_from_url = url_param('category');
        $posts_parent_related = false;
        if (isset($params['current_page'])) {
            // $params['current_page'] = $params['current_page'];
        } elseif (isset($params['curent-page'])) {
            $params['current_page'] = $params['curent-page'];
        } elseif (isset($params['current-page'])) {
            $params['current_page'] = $params['current-page'];
        } elseif (isset($params['curent-page'])) {
            $params['current_page'] = $params['curent-page'];
        }
        if (isset($params['paging_param'])) {
            if (isset($params[$params['paging_param']])) {
                $current_page = $current_page = $params['current_page'] = $params[$params['paging_param']];
                $paging_param = $params['paging_param'];
            }
        }
        if (isset($params['current_page'])) {
            $current_page = $params['current_page'] = $params['current_page'];
        } else {
            $current_page_from_url = url_param($paging_param);
            if ($current_page_from_url != false) {
                $current_page = $current_page_from_url;
            }
        }
        if (isset($post_params['data-page-number'])) {
            $post_params['current_page'] = $post_params['data-page-number'];
            unset($post_params['data-page-number']);
        }
        if (isset($post_params['data-category-id'])) {
            $post_params['category'] = $post_params['data-category-id'];
            unset($post_params['data-category-id']);
        }
        if (isset($params['data-paging-param'])) {
            $paging_param = $params['data-paging-param'];
        }
        $show_fields = false;
        if (isset($post_params['data-show'])) {
            $show_fields = $post_params['data-show'];
        }
        if (isset($post_params['show'])) {
            $show_fields = $post_params['show'];
        }
        $set_content_type_from_opt = get_option('data-content-type', $params['id']);
        $show_fields1 = get_option('data-show', $params['id']);
        if ($show_fields1 != false and is_string($show_fields1) and trim($show_fields1) != '') {
            $show_fields = $show_fields1;
        }
        if ($show_fields != false and is_string($show_fields)) {
            $show_fields = explode(',', $show_fields);
        }
        if (isset($post_params['limit'])) {
            $post_params['limit'] = $post_params['limit'];
        }
        if (isset($post_params['data-limit'])) {
            $post_params['limit'] = $post_params['data-limit'];
        }
        if (!isset($post_params['data-limit'])) {
            $posts_limit = get_option('data-limit', $params['id']);
            if ($posts_limit != false) {
                $post_params['limit'] = $posts_limit;
            }
        }
        $posts_parent_category = $posts_parent_category_cfg = get_option('data-category-id', $params['id']);
        if ($posts_parent_category == '') {
            $posts_parent_category = false;
        }
        $set_category_for_posts = false;
        $posts_limit = get_option('data-limit', $params['id']);
        if ($posts_limit != false) {
            $post_params['data-limit'] = $post_params['limit'] = $posts_limit;
        }
        $cfg_page_id = $cfg_page_id_force = get_option('data-page-id', $params['id']);
        if ($cfg_page_id == false and isset($post_params['data-page-id'])) {
            $cfg_page_id = intval($post_params['data-page-id']);
        } else {
            if ($cfg_page_id == false and isset($post_params['content_id'])) {
                $cfg_page_id = intval($post_params['content_id']);
            } else {
                if ($cfg_page_id == false and isset($post_params['content-id'])) {
                    $cfg_page_id = intval($post_params['content-id']);
                } elseif ($cfg_page_id == false and isset($post_params['current_page'])) {
                    $cfg_page_id = 'current_page';
                }
            }
        }
        if ($posts_parent_category == false and isset($post_params['category_id'])) {
            $posts_parent_category = $post_params['category_id'];
        }
        if ($posts_parent_category == false and isset($post_params['related'])) {
            if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                $posts_parent_category = $posts_parent_related = CATEGORY_ID;
            }
        }
        if ($posts_parent_category_cfg == 'related') {
            $posts_parent_related = true;
            $posts_parent_category = $posts_parent_related = CATEGORY_ID;
        }
        if ($posts_parent_category == false and $cfg_page_id == 'current_page') {
            if (defined('PAGE_ID') and PAGE_ID > 0) {
                $cfg_page_id = PAGE_ID;
            }
        }
        if ($posts_parent_category_cfg == false) {
            if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                $posts_parent_category = CATEGORY_ID;
            }
        }
        if ($cfg_page_id == false and isset($post_params['related']) and $post_params['related'] != false and (!isset($post_params['parent']) or $post_params['parent'] == false)) {
            if (defined('PAGE_ID') and PAGE_ID > 0) {
                $cfg_page_id = PAGE_ID;
                $post_params['parent'] = $cfg_page_id;
            }
        }
        if (isset($post_params['most_ordered'])) {
            //
            $str0 = 'table=cart&limit=30&rel_type=content&fields=rel_id&order_by=id desc';
            $orders = db_get($str0);
            if (!empty($orders)) {
                $ids = array();
                foreach ($orders as $order) {
                    $ids[] = $order['rel_id'];
                }
                $post_params['ids'] = $ids;
            }
        }
        if (isset($post_params['recently_viewed'])) {
            if (defined("MAIN_PAGE_ID") and defined("CONTENT_ID")) {
                $str0 = 'table=stats_pageviews&limit=30&main_page_id=' . MAIN_PAGE_ID . '&page_id=[neq]' . CONTENT_ID . '&fields=page_id&order_by=id desc&no_cache=true';
                $orders = db_get($str0);
                if (!empty($orders)) {
                    $ids = array();
                    foreach ($orders as $order) {
                        $ids[] = $order['page_id'];
                    }
                    $post_params['ids'] = $ids;
                }
            }
        }
        if ($posts_parent_related == false) {
            if (intval($cfg_page_id_force) or !isset($params['global'])) {
                if ($cfg_page_id != false and intval($cfg_page_id) > 0) {
                    $sub_categories = array();
                    $page_categories = false;
                    if (intval($cfg_page_id) != 0 and $cat_from_url == false) {
                        $str0 = 'table=categories&limit=1000&data_type=category&what=categories&' . 'parent_id=0&rel_id=' . $cfg_page_id;
                        $page_categories = db_get($str0);
                        $str0 = 'table=categories&limit=1000&data_type=category&what=categories&' . 'parent_id=0&rel_id=' . $cfg_page_id;
                        $page_categories = db_get('table=categories&limit=1&data_type=category&' . 'parent_id=0&rel_id=' . $cfg_page_id);
                        if (is_array($page_categories)) {
                            foreach ($page_categories as $item_cat) {
                                $sub_categories[] = $item_cat['id'];
                                $more = get_category_children($item_cat['id']);
                                if ($more != false and is_array($more)) {
                                    foreach ($more as $item_more_subcat) {
                                        $sub_categories[] = $item_more_subcat;
                                    }
                                }
                            }
                        }
                    }
                    if ($posts_parent_category != false and intval($posts_parent_category) > 0 and $cat_from_url == false) {
                        if ($page_categories != false and is_array($page_categories) and !empty($page_categories)) {
                            // $sub_categories = array();
                            foreach ($page_categories as $item_cat) {
                                if (intval($item_cat['id']) == intval($posts_parent_category)) {
                                    $sub_categories[] = $item_cat['id'];
                                }
                            }
                        } elseif ($posts_parent_category_cfg != false) {
                            $post_params['category'] = $posts_parent_category_cfg;
                        }
                        if (is_array($sub_categories) and !empty($sub_categories) and isset($post_params['related']) and $post_params['related'] != false) {
                            $post_params['category'] = $sub_categories;
                        } elseif ($cfg_page_id != false) {
                            $post_params['parent'] = $cfg_page_id;
                        }
                    } else {
                        $post_params['parent'] = $cfg_page_id;
                        if (($cfg_page_id == PAGE_ID or $cfg_page_id == MAIN_PAGE_ID) and (!isset($post_params['category']) or $post_params['category'] == false) and $cat_from_url != false) {
                            $post_params['category'] = $cat_from_url;
                        }
                    }
                } elseif ($cat_from_url != false) {
                    $post_params['category'] = $cat_from_url;
                } elseif ($posts_parent_category != false and intval($posts_parent_category) > 0 and $cfg_page_id != false) {
                    $post_params['category'] = $posts_parent_category;
                }
            }
            if ($posts_parent_category_cfg != false and intval($posts_parent_category_cfg) > 0 and $cfg_page_id_force != false and intval($cfg_page_id_force) > 0) {
                $post_params['category'] = $posts_parent_category_cfg;
            }
        } else {
            $post_params['category'] = $posts_parent_related;
        }
        $tn_size = array('150');
        $tn = $tn_size;
        if (isset($post_params['data-thumbnail-size'])) {
            $temp = explode('x', strtolower($post_params['data-thumbnail-size']));
            if (!empty($temp)) {
                $tn_size = $temp;
            }
        } else {
            $cfg_page_item = get_option('data-thumbnail-size', $params['id']);
            if ($cfg_page_item != false) {
                $temp = explode('x', strtolower($cfg_page_item));
                if (!empty($temp)) {
                    $tn_size = $temp;
                }
            }
        }
        if (!isset($tn[0]) or $tn[0] == 150) {
            $tn[0] = 350;
        }
        if (!isset($tn[1])) {
            $tn[1] = $tn[0];
        }
        $character_limit = 120;
        $cfg_character_limit = get_option('data-character-limit', $params['id']);
        if ($cfg_character_limit != false and trim($cfg_character_limit) != '') {
            $character_limit = intval($cfg_character_limit);
        } else {
            if (isset($params['description-length'])) {
                $character_limit = intval($params['description-length']);
            }
        }
        $title_character_limit = 200;
        $cfg_character_limit1 = get_option('data-title-limit', $params['id']);
        if ($cfg_character_limit1 != false and trim($cfg_character_limit1) != '') {
            $title_character_limit = intval($cfg_character_limit1);
        } else {
            if (isset($params['title-length'])) {
                $title_character_limit = intval($params['title-length']);
            }
        }
        if ($show_fields == false) {
            //$show_fields = array('thumbnail', 'title', 'description', 'read_more');
        }
        if (is_array($show_fields)) {
            $show_fields = array_trim($show_fields);
        }
        if (isset($current_page) and intval($current_page) > 0) {
            $post_params['current_page'] = intval($current_page);
        }
        if (!isset($post_params['global'])) {
            if (!isset($post_params['content_type'])) {
                $post_params['content_type'] = 'post';
            }
        }
        if (isset($params['is_shop'])) {
            $post_params['content_type'] = 'product';
            unset($post_params['is_shop']);
        }
        if (!isset($post_params['content_type']) and !isset($post_params['global'])) {
            $post_params['content_type'] = 'post';
        }
        if (!isset($params['order_by']) and isset($params['order-by'])) {
            $params['orderby'] = $post_params['orderby'] = $params['order-by'];
        }
        if (isset($params['subtype_value'])) {
            $post_params['subtype_value'] = $params['subtype_value'];
        }
        $schema_org_item_type = false;
        $schema_org_item_type_tag = false;
        if (isset($post_params['content_type']) and $post_params['content_type'] == 'page') {
            $schema_org_item_type = 'WebPage';
        } else {
            if (isset($post_params['content_type']) and $post_params['content_type'] == 'post') {
                if (isset($post_params['subtype']) and $post_params['subtype'] != $post_params['content_type']) {
                    $schema_org_item_type = $post_params['subtype'];
                } else {
                    $schema_org_item_type = 'Article';
                }
            }
        }
        if ($schema_org_item_type != false) {
            $schema_org_item_type = ucfirst($schema_org_item_type);
            $schema_org_item_type_tag = ' itemtype="http://schema.org/' . $schema_org_item_type . '" ';
            $schema_org_item_type_tag = 'http://schema.org/' . $schema_org_item_type;
        }
        $ord_by = get_option('data-order-by', $params['id']);
        if ($ord_by != false and trim($ord_by) != '') {
            $post_params['orderby'] = $ord_by;
        }
        $date_format = get_option('date_format', 'website');
        if ($date_format == false) {
            $date_format = "Y-m-d H:i:s";
        }
        if (isset($params['title'])) {
            unset($post_params['title']);
        }
        $post_params['is_active'] = 1;
        $post_params['is_deleted'] = 0;
        if ((!isset($post_params['parent']) and !isset($post_params['category']) or isset($post_params['category']) and empty($post_params['category'])) and $cat_from_url != false and trim($cat_from_url) != '') {
            $post_params['category'] = $cat_from_url;
        }
        if (isset($params['content_type']) and $params['content_type'] == 'all') {
            unset($post_params['content_type']);
            unset($post_params['subtype']);
        }
        if (isset($params['search-parent'])) {
            $sub_content = get_content_children($params['search-parent']);
            if (!empty($sub_content)) {
                $post_params['ids'] = $sub_content;
                unset($post_params['parent']);
            }
        }
        if (isset($params['data-id'])) {
            unset($post_params['data-id']);
        }
        if ($posts_parent_related == false) {
            if (isset($post_params['category']) and is_string($post_params['category'])) {
                $sub_categories = array();
                $sub_categories[] = $post_params['category'];
                $more = get_category_children($post_params['category']);
                if ($more != false and is_array($more)) {
                    foreach ($more as $item_more_subcat) {
                        $sub_categories[] = $item_more_subcat;
                    }
                }
                //$post_params['category']
                $post_params['category'] = $sub_categories;
                //$post_params['category'] = $post_params['category'];
            } else {
                if (isset($post_params['category']) and is_array($post_params['category']) and empty($post_params['category']) and isset($post_params['related']) and $post_params['related'] != false) {
                    if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                        $post_params['category'] = CATEGORY_ID;
                    }
                }
            }
        }
        if (defined('POST_ID') and isset($posts_parent_category) and $posts_parent_category != false or isset($post_params['related'])) {
            $post_params['exclude_ids'] = POST_ID;
        }
        if (!isset($params['order_by'])) {
            //            if(isset($post_params['content_type']) and $post_params['content_type'] == 'page'){
            //                $post_params['order_by'] = 'position asc';
            //            } else {
            //
            //            }
            $post_params['order_by'] = 'position desc';
        }
        if (isset($params['search_in_fields']) and $params['search_in_fields'] != false) {
            $post_params['search_in_fields'] = $params['search_in_fields'];
        }
        $content = get_content($post_params);
        if ($posts_parent_related != false and empty($content) and isset($post_params['category'])) {
            unset($post_params['category']);
            $content = get_content($post_params);
        }
        $data = array();
        if (!empty($content)) {
            foreach ($content as $item) {
                $iu = get_picture($item['id'], $for = 'post', $full = false);
                if ($iu != false) {
                    $item['image'] = $iu;
                } else {
                    $item['image'] = false;
                }
                if ($item['image'] != false) {
                    $item['tn_image'] = thumbnail($item['image'], $tn[0], $tn[1]);
                } else {
                    $item['tn_image'] = false;
                }
                $item['content'] = htmlspecialchars_decode($item['content']);
                if (isset($item['created_at']) and trim($item['created_at']) != '') {
                    $item['created_at'] = date($date_format, strtotime($item['created_at']));
                }
                if (isset($item['updated_at']) and trim($item['updated_at']) != '') {
                    $item['updated_at'] = date($date_format, strtotime($item['updated_at']));
                }
                $item['link'] = content_link($item['id']);
                $item['full_description'] = '';
                if (!isset($item['description']) or $item['description'] == '') {
                    if (isset($item['content']) and $item['content'] != '') {
                        $item['description'] = character_limiter(strip_tags($item['content']), $character_limit);
                        $item['full_description'] = strip_tags($item['content']);
                    } elseif (isset($item['content_body']) and $item['content_body'] != '') {
                        $item['full_description'] = strip_tags($item['content']);
                        $item['description'] = character_limiter(strip_tags($item['content_body']), $character_limit);
                    }
                } else {
                    $item['full_description'] = trim($item['description']);
                    $item['description'] = character_limiter(strip_tags($item['description']), $character_limit);
                }
                if (isset($item['title']) and $item['title'] != '') {
                    $item['full_title'] = $item['title'];
                    $item['title'] = character_limiter($item['title'], $title_character_limit);
                }
                if (isset($post_params['content_type']) and $post_params['content_type'] == 'product') {
                    $item['prices'] = get_custom_fields("field_type=price&for=content&for_id=" . $item['id']);
                } else {
                    $item['prices'] = false;
                }
                if (isset($item['prices']) and is_array($item['prices']) and !empty($item['prices'])) {
                    $vals2 = array_values($item['prices']);
                    $val1 = array_shift($vals2);
                    $item['price'] = $val1;
                } else {
                    $item['price'] = false;
                }
                if (isset($show_fields) and is_array($show_fields) and !empty($show_fields)) {
                    if (!in_array('title', $show_fields)) {
                        $item['title'] = false;
                    }
                    if (!in_array('description', $show_fields)) {
                        $item['description'] = false;
                    }
                    if (!in_array('created_at', $show_fields)) {
                        $item['created_at'] = false;
                    }
                    if (!in_array('read_more', $show_fields)) {
                        $item['read_more'] = false;
                    }
                    if (!in_array('thumbnail', $show_fields)) {
                        $item['thumbnail'] = false;
                    }
                }
                $data[] = $item;
            }
        } else {
            if (isset($params['is_shop'])) {
                print lnotif('Your products module is empty');
            } elseif (isset($params['global'])) {
                print lnotif('Your content module is empty');
            } else {
                print lnotif('Your posts module is empty');
            }
        }
        $post_params_paging = $post_params;
        $post_params_paging['page_count'] = true;
        $cfg_data_hide_paging = get_option('data-hide-paging', $params['id']);
        if ($cfg_data_hide_paging === false) {
            if (isset($post_params['hide_paging']) and trim($post_params['hide_paging']) != 'false') {
                $post_params['hide-paging'] = $post_params['hide_paging'];
                unset($post_params['hide_paging']);
            }
            if (isset($post_params['hide-paging']) and trim($post_params['hide-paging']) != 'false') {
                $cfg_data_hide_paging = 'y';
                unset($post_params['hide-paging']);
            }
        }
        if ($cfg_data_hide_paging != 'y') {
            $pages_of_posts = get_content($post_params_paging);
            $pages_count = intval($pages_of_posts);
        } else {
            $pages_count = 0;
        }
        $paging_links = false;
        if (intval($pages_count) > 1) {
            //$paging_links = mw()->content_manager->paging_links(false, $pages_count, $paging_param, $keyword_param = 'keyword');
        }
        $read_more_text = get_option('data-read-more-text', $params['id']);
        $add_cart_text = get_option('data-add-to-cart-text', $params['id']);
        if ($add_cart_text == false or $add_cart_text == "Add to cart") {
            $add_cart_text = _e("Add to cart", true);
        }
        if (!isset($params['return'])) {
            $module_template = get_option('data-template', $params['id']);
            if ($module_template == false and isset($params['template'])) {
                $module_template = $params['template'];
            }
            if ($module_template != false) {
                if (strtolower($module_template) == 'none') {
                    if (isset($params['template'])) {
                        $module_template = $params['template'];
                    }
                }
                $template_file = module_templates($config['module'], $module_template);
            } else {
                $template_file = module_templates($config['module'], 'default');
            }
            if ($template_file == false) {
                $template_file = module_templates($config['module'], 'default');
            }
            if (isset($template_file) and is_file($template_file) != false) {
                include $template_file;
                ?>
                <?php 
                if (isset($params['ajax_paging']) or isset($params['ajax-paging'])) {
                    ?>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            mw.$('#<?php 
                    print $params['id'];
                    ?>
').find('a[data-page-number]').unbind('click');
                            mw.$('#<?php 
                    print $params['id'];
                    ?>
').find('a[data-page-number]').click(function (e) {
                                var pn = $(this).attr('data-page-number');
                                mw.$('#<?php 
                    print $params['id'];
                    ?>
').attr('paging_param', 'current_page');
                                mw.$('#<?php 
                    print $params['id'];
                    ?>
').attr('current_page', pn)
                                mw.reload_module('#<?php 
                    print $params['id'];
                    ?>
');
                                return false;
                            });
                        });
                    </script>
                <?php 
                }
                ?>
                <?php 
                if (isset($params['is_shop'])) {
                    ?>
                    <script type="text/javascript">
                        mw.require("shop.js");
                    </script>
                <?php 
                }
                ?>
            <?php 
            } else {
                print lnotif('No default template for ' . $config['module'] . ' is found');
            }
        }
    }
Exemple #17
0
 public function testSelectOnlyfields()
 {
     $content = db_get('content', 'limit=2&fields=id,position&order_by=id desc');
     foreach ($content as $item) {
         $this->assertTrue(true, count($item) == 2);
         $this->assertTrue(true, isset($item['id']));
         $this->assertTrue(true, isset($item['position']));
     }
 }
Exemple #18
0
$pt_opts = array();
$pt_opts['link'] = "{title}";
$pt_opts['list_tag'] = " ";
$pt_opts['list_item_tag'] = "option";
$pt_opts['include_categories'] = "true";
$pt_opts['for'] = "content";
$pt_opts['categories_active_ids'] = $posts_parent_page;
$pt_opts['remove_ids'] = $params['id'];
$pt_opts['active_code_tag'] = '   selected="selected"  ';
pages_tree($pt_opts);
?>

<?php 
if (isset($params['include_global_categories']) and $params['include_global_categories'] == true and isset($params['include_global_categories'])) {
    $str0 = 'table=categories&limit=1000&data_type=category&' . 'parent_id=0&rel_id=0&rel=content';
    $fors = db_get($str0);
    if ($fors != false and is_array($fors) and !empty($fors)) {
        foreach ($fors as $cat) {
            $cat_params = $params;
            $pt_opts = array();
            $pt_opts['link'] = "{title}";
            $pt_opts['list_tag'] = " ";
            $pt_opts['list_item_tag'] = "option";
            $pt_opts['parent'] = $cat['id'];
            $pt_opts['include_first'] = 1;
            category_tree($pt_opts);
        }
    }
}
?>
</select>
        $parent_page = $params['content-id'];
    }
}
if ($posts_parent_category == false) {
    if (isset($params['category'])) {
        $posts_parent_category = $params['category'];
    }
}
if ($posts_parent_category != false) {
    $add_post_q .= ' parent-category-id="' . intval($posts_parent_category) . '" ';
}
if (!isset($params['global']) and $posts_parent_page != false and $posts_parent_category != false and intval($posts_parent_category) > 0) {
    $str0 = 'table=categories&limit=1000&data_type=category&what=categories&' . 'parent_id=0&rel_id=' . $posts_parent_page;
    $page_categories = db_get($str0);
    $sub_cats = array();
    $page_categories = db_get($str0);
    if (is_array($page_categories)) {
        foreach ($page_categories as $item_cat) {
            $sub_cats[] = $item_cat['id'];
            $more = get_category_children($item_cat['id']);
            if ($more != false and is_array($more)) {
                foreach ($more as $item_more_subcat) {
                    $sub_cats[] = $item_more_subcat;
                }
            }
        }
    }
    if (is_array($sub_cats) and in_array($posts_parent_category, $sub_cats)) {
        $add_post_q .= ' selected-category-id=' . intval($posts_parent_category);
    }
}
Exemple #20
0
 public function Count($timeStamp = 0)
 {
     return db_get()->Execute('system_session_count', $timeStamp)->Fetch();
 }
Exemple #21
0
 public function login($username, $password)
 {
     session_start();
     if (value_exists("Registered_User", "username", $username)) {
         $db_val = db_get("Registered_User", "password", "username", $username);
         //making sure user is not blocked
         $db_conn = db_conn();
         $query_string = "SELECT * from Registered_User where username='******'";
         $results = mysqli_query($db_conn, $query_string);
         $isBlocked = true;
         while ($result = $results->fetch_assoc()) {
             if ($result['blocked_date'] == NULL) {
                 //if not blocked
                 $isBlocked = false;
             } else {
                 $isBlocked = true;
                 $_SESSION['errorMessage'] = 'This user is blocked!';
                 return null;
                 // do not let the user login
             }
         }
         mysqli_close($db_conn);
         if (strcmp($password, $db_val['password']) == 0) {
             echo $this->admin;
             $role = $this->admin ? "admin" : "registered_user";
             return $role;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Exemple #22
0
 public function isBlocked()
 {
     $db_val = db_get("Document", "blocked", "doc_id", $this->doc_id);
     $blocked_bool = $db_val["blocked"];
     return $blocked_bool;
 }
Exemple #23
0
	<th>jméno</th>
	<th>vydat stravenek</th>
	<th>celková hodnota (<?php 
echo $hodnota_stravenky;
?>
Kč/ks)</th>
	<th>příspěvek zaměstnance (45%)</th>
	<th>převzal</th>
</tr>
<?php 
$total_vydat = 0;
$total_prispevek = 0;
$employees = db_get_many("employees", "id", "active=1 AND stravenky=1", "name");
for ($i = 0; $i < count($employees); $i++) {
    $emp = $employees[$i];
    $name = db_get("employees", "name", $emp);
    $cur_tots = month_totals($_GET["year"], $_GET["month"], $emp, false);
    $vydat = $cur_tots["stravenky"];
    $hodnota = ceil($vydat * $hodnota_stravenky);
    $prispevek = ceil($vydat * $hodnota_stravenky * 0.45);
    $total_vydat += $vydat;
    $total_prispevek += $prispevek;
    echo "<tr>";
    echo "<td>" . $name . "</td>";
    echo "<td>" . $vydat . "</td>";
    echo "<td>" . $hodnota . "</td>";
    echo "<td>" . $prispevek . "</td>";
    echo "<td><div class=\"signature\"></div></td>";
    echo "</tr>";
}
?>
Exemple #24
0
<?php 
include "header.htm";
?>

<?php 
auth_header();
?>

<div class="content">
<h1>
Cestovní příkaz
</h1>

<h2>
<?php 
$employeename = db_get("employees", "name", $_GET["employee"]);
echo $employeename;
?>
 -
<?php 
echo monthname($_GET["month"]) . " " . $_GET["year"];
?>
</h2>

<table>
<tr>
	<th>datum</th>
	<th>odjezd/příjezd</th>
	<th>stravné</th>
</tr>
 /**
  * Handles the reception of SLO responses and sending of new SLO requests.
  * Deletes information for handled SLO request and finally deletes the session
  * the original SLO request was sent to.
  *
  * @param  array $message
  * @return void
  *
  *
  */
 public function handleslo(array $message)
 {
     $me = $this->getCurrentMD('entityID');
     $inresponseto = $message['_InResponseTo'];
     $req = db_get('REQ-' . $inresponseto);
     if ($remote = nvl($req, 'entity')) {
         db_del($req['type'] . '-' . $req['sessionindex'], sha1($remote));
     }
     $sloinfo = db_get('SLO-' . $req['ID']);
     $success = 'urn:oasis:names:tc:SAML:2.0:status:Success';
     if ($status = nvl2($message, 'samlp:Status', 'samlp:StatusCode')) {
         if ($status['_Value'] != $success || nvl2($status, 'samlp:StatusCode', '_Value')) {
             $sloinfo['success'] = false;
             db_put('SLO-' . $req['request '], $sloinfo);
         }
     }
     foreach ((array) nvl($sloinfo, 'sessions') as $session => $dummy) {
         foreach (array('IDP', 'SP') as $type) {
             $responses = db_get($type . '-' . $session, '*');
             foreach ($responses as $hashedentity => $info) {
                 if ($info['entity'] == $sloinfo['Issuer']) {
                     db_del($type . '-' . $session, $hashedentity);
                     continue;
                 }
                 $id = ID();
                 $info['ID'] = $id;
                 $info['type'] = $type;
                 debug("REQ id+", $id);
                 db_put("REQ-{$id}", serialize($info));
                 $response = $this->sendLogoutRequest($info);
                 if (!$response) {
                     $res = false;
                 } else {
                     $status = $response['samlp:Status']['samlp:StatusCode'];
                     $res = $status['_Value'] != $success || nvl2($status, 'samlp:StatusCode', '_Value');
                 }
                 if (!$res && $sloinfo['success']) {
                     $sloinfo['success'] = false;
                     db_put('SLO-' . $req['ID'], serialize($sloinfo));
                 }
             }
             db_del('REQ-' . $inresponseto);
         }
         delete_corto_session($session);
     }
     db_del('SLO-' . $req['ID']);
     $this->sendLogoutResponse($sloinfo);
 }
Exemple #26
0
 public function isBlocked()
 {
     $db_val = db_get("Forum_Post", "blocked", "post_id", $this->post_id);
     $blocked_bool = $db_val["blocked"];
     return $blocked_bool;
 }
 /**
  * Delete action.
  *
  * @return void
  */
 public function delete()
 {
     $id = FormUtil::getPassedValue('id', null, 'GET');
     $submit = FormUtil::getPassedValue('submit', null, 'GET');
     $article = db_get("select where id = {$id}");
     $article->delete();
     $this->notifyHooks('example.ui_hooks.general.process_delete', $article, $id);
 }
<?php

require_once "sql.php";
?>

<?php 
if ($_GET["from_id"]) {
    $name = db_get("employees", "name", $_GET["from_id"]);
    $plusminus = db_get("employees", "plusminus", $_GET["from_id"]);
    $dovolene = db_get("employees", "dovolene", $_GET["from_id"]);
    $active = db_get("employees", "active", $_GET["from_id"]);
    $stravenky = db_get("employees", "stravenky", $_GET["from_id"]);
}
?>

<?php 
include "header.htm";
?>

<form action="employee_edit.php" method="GET">

<input type="hidden" name="goto" value="-2">

<input type="hidden" name="id" value="<?php 
echo $_GET["id"];
?>
">

<p>
Jméno pracovníka:
<input type="text" name="name" value="<?php 
Exemple #29
0
function get_visits_for_sid($sid)
{
    return;
    $table = MODULE_DB_USERS_ONLINE;
    $q = false;
    $results = false;
    $data = array();
    $data['table'] = $table;
    $data['session_id'] = $sid;
    $data['limit'] = 10;
    $data['order_by'] = "visit_date desc,visit_time desc";
    return db_get($data);
}
<?php

require_once "sql.php";
?>

<?php 
if ($_GET["from_id"]) {
    $date = db_get("vacancies", "date", $_GET["from_id"]);
} else {
    $date = date("Y-m-d");
}
?>

<?php 
include "header.htm";
?>

<form action="vacancy_edit.php" method="GET">

<input type="hidden" name="goto" value="-2">

<input type="hidden" name="id" value="<?php 
echo $_GET["id"];
?>
">

<p>
Datum svátku (yyyy-mm-dd):
<input type="text" name="date" value="<?php 
echo $date;
?>