Example #1
0
 function __construct()
 {
     parent::__construct();
     $this->model = new PbModel();
     $this->allowed_search = array("info" => "news", "offer" => "offer", "product" => "product", "yellow_page" => "company");
     if (isset($_GET['module'])) {
         $this->module = trim(strtolower($_GET['module']));
     }
     $this->option = $this->module;
     if (!empty($this->module) && !in_array($this->module, $this->allowed_search)) {
         flash();
     }
     $search_word = !empty($_GET['q']) ? htmlspecialchars(trim($_GET['q']), ENT_QUOTES) : '';
     switch ($this->module) {
         case "company":
             $this->condition[] = 'status=1';
             if (!empty($search_word)) {
                 $this->condition[] = "name LIKE '%{$search_word}%'";
             }
             $this->extra = ",name AS title,description AS content";
             break;
         case "offer":
             $condition[] = 'status=1';
             if (!empty($search_word)) {
                 $this->condition[] = "title LIKE '%{$search_word}%'";
             }
             $this->option = "offer";
             $this->module = "trade";
             break;
         case "product":
             $condition[] = 'status=1';
             if (!empty($search_word)) {
                 $this->condition[] = "name LIKE '%{$search_word}%'";
             }
             $this->extra = ",name AS title";
             break;
         default:
             $condition[] = 'status=1';
             if (!empty($search_word)) {
                 $this->condition[] = "title LIKE '%{$search_word}%'";
             }
             break;
     }
     $search_controller = new PbController();
     $this->model_name = htmlspecialchars($this->module, ENT_QUOTES);
     $this->model_name = strtolower($search_controller->pluralize(ucwords($this->model_name)));
     $this->view->setTemplateDir(PHPB2B_ROOT . "templates/wap/3g" . DS, 'wap');
     $this->view->setCompileDir(DATA_PATH . "templates_c" . DS . $this->lang . DS . "wap" . DS . "3g" . DS);
 }
Example #2
0
 public function getInstance()
 {
     if (self::$instance == NULL) {
         // If instance is not created yet, will create it.
         self::$instance = new PbController();
     }
     return self::$instance;
 }
Example #3
0
 function getUninstalled()
 {
     $uninstalled = $temp = array();
     $installed = $this->getInstalled();
     foreach ($installed as $key => $val) {
         $temp[] = $val['name'];
     }
     $template_dir = dir($this->payment_path);
     while ($entry = $template_dir->read()) {
         $tpldir = realpath($this->payment_path . $entry);
         $k = reset(explode(".", $entry));
         if (!in_array($entry, array('.', '..', '.svn')) && !in_array($k, $temp) && is_file($tpldir)) {
             //get info from tip
             $pay_controller = new PbController();
             $cfg = $pay_controller->getSkinData($tpldir);
             $uninstalled[] = array('name' => $k, 'title' => $cfg['Name'], 'description' => $cfg['Description'], 'available' => 0);
         }
     }
     return $uninstalled;
 }
Example #4
0
 function __construct()
 {
     parent::__construct();
     if (!empty($_GET['code'])) {
         $this->code = trim($_GET['code']);
     }
     if (!empty($_GET['msg'])) {
         $this->message = urldecode($_GET['msg']);
     }
     flash("offer");
 }
Example #5
0
 function add()
 {
     global $viewhelper;
     if (isset($_POST['do']) && !empty($_POST['data']['market']['name'])) {
         pb_submit_check("data");
         $this->market->setParams();
         $this->market->params['data']['market']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
         $this->market->params['data']['market']['area_id'] = PbController::getMultiId($_POST['area']['id']);
         $result = $this->market->Add();
         if ($result) {
             flash('thanks_for_adding_market');
         } else {
             pheader("location:add.php");
         }
     }
     $viewhelper->setPosition(L("added_market_info", "tpl"));
     render("market/add");
 }
Example #6
0
 function industry()
 {
     $tpl_file = "special/list";
     $mod = __FUNCTION__;
     global $viewhelper;
     $datas = cache_read($mod);
     $datas = PbController::getInstance()->array_multi2single($datas);
     $alphabet_sorts = array();
     foreach ($datas as $key => $val) {
         $letter = strtoupper(PbController::getInitial($val));
         $alphabet_sorts[$letter]['child'][$key]['id'] = $key;
         $alphabet_sorts[$letter]['child'][$key]['title'] = $val;
     }
     ksort($alphabet_sorts);
     setvar("alpha_datas", $alphabet_sorts);
     setvar("type", $mod);
     setvar("station_name", L("sub_" . $mod, "tpl"));
     unset($datas, $alphabet_sorts);
     $viewhelper->setTitle(L("sub_" . $mod, "tpl"));
     $membertypes = cache_read("type", "membertype");
     setvar("member_types", $membertypes);
     render($tpl_file);
 }
Example #7
0
 function __construct()
 {
     parent::__construct();
     $this->loadModel("expo");
 }
Example #8
0
    }
}
if (isset($_POST['save']) && !empty($_POST['data']['expo']['name'])) {
    $expo->setParams();
    if (isset($_POST['id'])) {
        $id = intval($_POST['id']);
    }
    if (!empty($_POST['data']['begin_time'])) {
        $expo->params['data']['expo']['begin_time'] = Times::dateConvert($_POST['data']['begin_time']);
    }
    if (!empty($_POST['data']['end_time'])) {
        $expo->params['data']['expo']['end_time'] = Times::dateConvert($_POST['data']['end_time']);
    }
    $expo->params['data']['expo']['status'] = 1;
    $expo->params['data']['expo']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
    $expo->params['data']['expo']['area_id'] = PbController::getMultiId($_POST['area']['id']);
    if (!empty($id)) {
        if (!empty($_FILES['pic']['name'])) {
            $attachment->insert_new = false;
            $attachment->rename_file = "fair-" . $id;
            $attachment->upload_process();
            $expo->params['data']['expo']['picture'] = $attachment->file_full_url;
        }
        $expo->params['data']['expo']['modified'] = $time_stamp;
        $result = $expo->save($expo->params['data']['expo'], "update", $id);
    } else {
        $expo->params['data']['expo']['created'] = $expo->params['data']['expo']['modified'] = $time_stamp;
        if (!empty($_FILES['pic']['name'])) {
            $attachment->rename_file = "fair-" . ($fair->getMaxId() + 1);
            $attachment->upload_process();
            $expo->params['data']['expo']['picture'] = $attachment->file_full_url;
Example #9
0
 function disSubNames($id, $sep = "»", $link = false, $do = null)
 {
     $ids = $this->disSubOptions($id);
     $tmp_controller = new PbController();
     if (is_null($sep)) {
         $sep = "»";
     }
     $r = array();
     $_PB_CACHE['industry'] = cache_read("industry");
     $datas = $tmp_controller->array_multi2single($_PB_CACHE['industry']);
     $tmp_ids = $ids;
     foreach ($ids as $key => $val) {
         if ($link) {
             $tmp = ltrim($key, "id");
             switch ($tmp) {
                 case 1:
                     $the_id = implode(",", $ids);
                     break;
                 case 2:
                     unset($tmp_ids["id1"]);
                     $the_id = implode(",", $tmp_ids);
                     break;
                 default:
                     $the_id = $val;
                     break;
             }
             if (!function_exists("smarty_function_the_url")) {
                 require SLUGIN_PATH . "function.the_url.php";
             }
             $r[] = "<a href='" . smarty_function_the_url(array("module" => $do, "action" => "lists", "do" => "search", "industryid" => $the_id)) . "' rel='special_link'>" . $datas[$val] . "</a>";
         } else {
             $r[] = $datas[$val];
         }
     }
     unset($_PB_CACHE);
     return implode($sep, $r);
 }
Example #10
0
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2149 $
 */
require "../libraries/common.inc.php";
require "session_cp.inc.php";
require LIB_PATH . "payment.class.php";
require LIB_PATH . "file.class.php";
require LIB_PATH . "cache.class.php";
uses("setting", "typeoption");
$cache = new Caches();
$typeoption = new Typeoption();
$file = new Files();
$payment = new Payments();
$pay_controller = new PbController();
$setting = new Settings();
$tpl_file = "payment";
setvar("AskAction", $typeoption->get_cache_type("common_option"));
$result = $payment->getpayments();
setvar("Items", $result);
setvar("payment_url", URL . 'plugins/' . $payment->payment_dir . '/');
$item = $setting->getValues(1);
if (isset($_POST['save'])) {
    $datas = $_POST['data']['payment'];
    if (isset($_POST['id'])) {
        $id = intval($_POST['id']);
    }
    if (!empty($_POST['data']['config'])) {
        $datas['config'] = serialize($_POST['data']['config']);
    }
Example #11
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
function smarty_block_getdata($params, $content, Smarty_Internal_Template $sTemplate, &$repeat)
{
    $conditions = $orderbys = array();
    $mysql_limit = $mysql_orderby = $image_col = $_seperate = '';
    $target = "_blank";
    extract($params);
    if (!isset($params['assign'])) {
        $assign = 'row';
    }
    if (!empty($params['name'])) {
        $assign = trim($params['name']);
    }
    $C = new PbController();
    $M = new PbModel();
    $M->condition = '';
    //Initial any last conditions
    $_table = $params['module'];
    switch ($params['module']) {
        case "offer":
        case "trade":
            $_table = "trade";
            break;
        case "fair":
        case "expo":
            $_table = "expo";
            break;
        case "announce":
            $_table = "announcement";
            break;
        case "ads":
            $_table = "adses";
            break;
        case "adword":
            $_table = "spread";
            break;
        case "price":
            $_table = "productprice";
            break;
        case "adses":
            break;
        default:
            break;
    }
    if (method_exists($sTemplate, 'get_template_vars')) {
        $_bindex = $sTemplate->getTemplateVars('_bindex');
    } else {
        $_bindex = $sTemplate->getVariable('_bindex')->value;
    }
    if (!$_bindex) {
        $_bindex = array();
    }
    if (isset($params['name'])) {
        if (!isset($_bindex[$params['name']])) {
            $_bindex[$params['name']] = 1;
        } else {
            $_bindex[$params['name']]++;
        }
    }
    $sTemplate->assign('_bindex', $_bindex);
    if (!isset($sTemplate->block_data)) {
        $sTemplate->block_data = array();
    }
    $iTags = count($sTemplate->_tag_stack);
    /**
     * set condition
     */
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    if (isset($_GET['pos'])) {
        $_pos = intval($_GET['pos']);
        $offset = ceil($_pos / $limit) * $row;
    }
    if (!empty($params['flag'])) {
        $conditions[] = "flag='" . $params['flag'] . "'";
    }
    if ($_table == "industry" or $_table == "area") {
        if (isset($params['parentid'])) {
            if (!empty($params['parentid'])) {
                $conditions['parentid'] = "parent_id='" . intval($params['parentid']) . "' OR id=" . intval($params['parentid']);
            } else {
                $conditions['parentid'] = "parent_id=0";
            }
        } else {
            $conditions['parentid'] = "parent_id=0";
        }
    }
    if (!empty($params['level'])) {
        if ($_table == "newstype") {
            $conditions[] = "level_id='" . $params['level'] . "'";
        } else {
            $conditions[] = "level='" . $params['level'] . "'";
        }
    }
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    if ($module == "friendlink") {
                        $image_col = "logo";
                    } else {
                        $image_col = "picture";
                    }
                    $conditions[] = "{$image_col}!=''";
                    break;
                case 'hot':
                    $orderbys[] = "hits DESC";
                    break;
                case 'commend':
                    $conditions[] = "if_commend='1'";
                    break;
                default:
                    break;
            }
        }
    }
    if (isset($params['exclude'])) {
        $conditions[] = $M->getExcludeIds($params['exclude']);
    }
    if (isset($params['include'])) {
        $conditions[] = $M->getIncludeIds($params['include']);
    }
    if (isset($params['orderby'])) {
        $orderbys[] = trim($params['orderby']);
    }
    if (!empty($row) && $row != 'all' && $row != -1) {
        $M->setLimitOffset($offset, $limit);
        $mysql_limit = $M->getLimitOffset();
    }
    if (!empty($params['limit'])) {
        $mysql_limit = " " . trim($params['limit']);
    }
    if (!empty($_GET['producttypeid'])) {
        $conditions[] = "type_id=" . intval($_GET['producttypeid']);
    }
    if (!empty($params['companyid'])) {
        $conditions[] = "company_id=" . intval($params['companyid']);
    }
    if (!empty($params['industryid'])) {
        $conditions[] = "industry_id=" . intval($params['industryid']);
    }
    if (!empty($params['typeid'])) {
        if ($_table == 'adses') {
            $conditions[] = "adzone_id=" . intval($params['typeid']);
        } else {
            $conditions[] = "type_id=" . intval($params['typeid']);
        }
    }
    if (empty($sTemplate->block_data[$iTags])) {
        # ************************************************************************
        # Main content
        $M->setCondition($conditions);
        $M->setOrderby($orderbys);
        $sql = sprintf("SELECT * FROM %s%s %s %s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition(), $M->getOrderby(), $mysql_limit);
        $sTemplate->block_data[$iTags] = $M->GetArray($sql);
        //如果没有数据,那就不用再执行了(repeat)
        if (!$sTemplate->block_data[$iTags]) {
            return $repeat = false;
        }
        if (isset($stat)) {
            $_total_count = $M->dbstuff->GetOne(sprintf("SELECT count(*) FROM %s%s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition()));
            $sTemplate->assign('total_count', $_total_count);
            $sTemplate->assign("paging", array('total' => $_total_count));
        }
        # End main content
        # ************************************************************************
    }
    if (!$sTemplate->block_data[$iTags]) {
        $repeat = false;
        return '';
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    $counts = count($sTemplate->block_data[$iTags]);
    if (list($key, $item) = each($sTemplate->block_data[$iTags])) {
        $_title = $_title_full = $_content = $_content_full = '';
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        if (!empty($item['url'])) {
            $url = $item['url'];
        } else {
            $url = smarty_function_the_url(array("do" => $module, "id" => $item['id'], "action" => 'detail'));
        }
        if ($module == "company") {
            $url = smarty_function_the_url(array("id" => $item['id'], "do" => "company", "userid" => $item['cache_spacename']));
        } elseif ($module == "tag") {
            $url = smarty_function_the_url(array("do" => "product", "action" => 'lists', "q" => $item['name']));
        }
        $item['url'] = $url;
        if (isset($item['title'])) {
            $_title = $item['name'] = $item['title'];
        } elseif (isset($item['name'])) {
            $_title = $item['title'] = $item['name'];
        } elseif (isset($item['subject'])) {
            $_title = $item['title'] = $item['subject'];
        } elseif (isset($item['word'])) {
            $_title = $item['title'] = $item['word'];
        }
        $_title_full = $_title;
        $item['title'] = $_title = strip_tags(pb_lang_split($_title));
        $_title_full = strip_tags(pb_lang_split($_title_full));
        if (!empty($titlelen)) {
            $_title = mb_substr($_title, 0, $titlelen);
        }
        if (isset($item['description'])) {
            $_content = $item['description'];
        } elseif (isset($item['content'])) {
            $_content = $item['content'];
        }
        if (isset($item['clicked'])) {
            $item['hits'] = $item['clicked'];
        }
        $_content_full = $_content;
        if (!empty($_content) && isset($infolen)) {
            $_content = mb_substr($_content, 0, $infolen);
        }
        if (isset($item['created'])) {
            $item['pubdate'] = df($item['created'], "m-d");
        } elseif (isset($item['submit_time'])) {
            $item['pubdate'] = df($item['submit_time']);
        }
        if (!empty($params['sep'])) {
            $_seperate = $params['sep'];
        }
        $item['content'] = $_content = strip_tags(pb_lang_split($_content));
        //		if($seperate) $_title = ($key==$counts-1)?$_title:$_title.$seperate;
        $item['link'] = '<a title="' . $_title_full . '" href="' . $url . '" target="' . $target . '">' . $_title . '</a>' . $_seperate;
        $media_url = '';
        if (!empty($item['picture'])) {
            $media_url = $item['picture'];
            if (!empty($media_url)) {
                $item['thumb'] = $item['src'] = pb_get_attachmenturl($media_url, '', 'small');
            }
        }
        if (!empty($item['source_url'])) {
            $media_url = $item['source_url'];
            if (!empty($media_url)) {
                $item['thumb'] = $item['src'] = $media_url;
            }
        }
        if (isset($item['highlight'])) {
            $item['style'] = parse_highlight($item['highlight']);
        }
        $sTemplate->assign($assign, $item);
        $repeat = true;
    } else {
        $repeat = false;
        reset($sTemplate->block_data[$iTags]);
        if (isset($params['name'])) {
            unset($_bindex[$params['name']]);
            $sTemplate->assign('_bindex', $_bindex);
        }
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $sTemplate->block_data[$iTags] = array();
    }
}
Example #12
0
 if (isset($_POST['id'])) {
     $id = $_POST['id'];
 }
 if (!empty($_POST['expire_time'])) {
     $vals['expire_time'] = Times::dateConvert($_POST['expire_time']);
 }
 $check_job_update = $g['job_check'];
 if ($check_job_update == "0") {
     $vals['status'] = 1;
     $message_info = 'msg_wait_success';
 } else {
     $vals['status'] = 0;
     $message_info = 'msg_wait_check';
 }
 $vals['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
 $vals['area_id'] = PbController::getMultiId($_POST['area']['id']);
 if (!empty($id)) {
     $vals['modified'] = $time_stamp;
     $result = $job->save($vals, "update", $id, null, "member_id=" . $the_memberid);
 } else {
     if ($g['max_job'] && $now_job_amount >= $g['max_job']) {
         flash('one_day_max');
     }
     $vals['created'] = $vals['modified'] = $time_stamp;
     $vals['company_id'] = $companyinfo['id'];
     $vals['member_id'] = $the_memberid;
     $vals['cache_spacename'] = $pdb->GetOne("SELECT space_name FROM {$tb_prefix}members WHERE id=" . $the_memberid);
     $result = $job->save($vals);
 }
 if (!$result) {
     flash();
Example #13
0
 function __construct()
 {
     parent::__construct();
     $this->loadModel("product");
 }
Example #14
0
         break;
     case "product":
         $condition[] = 'status=1';
         if (!empty($search_word)) {
             $condition[] = "name LIKE '%{$search_word}%'";
         }
         $extra = ",name AS title";
         break;
     default:
         $condition[] = 'status=1';
         if (!empty($search_word)) {
             $condition[] = "title LIKE '%{$search_word}%'";
         }
         break;
 }
 $search_controller = new PbController();
 $model_name = htmlspecialchars($do, ENT_QUOTES);
 $model_name = strtolower($search_controller->pluralize(ucwords($model_name)));
 if (!empty($_GET['id'])) {
     $id = intval($_GET['id']);
     $result = $pdb->GetRow("SELECT *" . $extra . " FROM " . $tb_prefix . $model_name . " WHERE id=" . $id);
     setvar("item", $result);
     $tpl_file = "wap/detail";
 } else {
     $model_common = new PbModel();
     $model_common->setCondition($condition);
     //pager
     $pagesize = 10;
     $page = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
     $total = $pdb->GetOne("SELECT count(id) FROM " . $tb_prefix . $model_name . $model_common->getCondition());
     $pagecount = ceil($total / $pagesize);
Example #15
0
function showLanguages($return_arr = false)
{
    global $app_lang, $charset;
    $return = $datas = array();
    $path = '../languages/';
    $handle = opendir($path);
    $setting_controller = new PbController();
    while (false !== ($file = readdir($handle))) {
        $dir = $path . $file;
        if (is_dir($dir) && !in_array($file, array('.', '..', '.svn'))) {
            $tmp = "<option value='" . $file . "'";
            if ($app_lang == $file) {
                $tmp .= " selected='selected'";
            } elseif (isset($_GET['app_lang']) && $_GET['app_lang'] == $file) {
                $tmp .= " selected='selected'";
            }
            $templet_file = PHPB2B_ROOT . "languages/" . $file . "/readme.txt";
            $data = $setting_controller->getSkinData($templet_file);
            $title = $data['Name'];
            if ($charset != "utf-8") {
                //only for gbk chinese convert
                $title = iconv('gbk', $charset, $title);
            }
            $tmp .= ">" . $title . "</option>";
            $return[] = $tmp;
            $datas[$file]['title'] = $title;
            if (is_file(PHPB2B_ROOT . "languages/" . $file . "/icon.gif")) {
                $datas[$file]['img'] = "languages/" . $file . "/icon.gif";
            }
        }
    }
    if ($return_arr) {
        return $datas;
    } elseif (!empty($return)) {
        return implode("\r\n", $return);
    } else {
        return false;
    }
    closedir($handle);
}
Example #16
0
<?php

/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2048 $
 */
define('CURSCRIPT', 'add');
require "../libraries/common.inc.php";
require "../share.inc.php";
uses("market");
$market = new Markets();
if (isset($_POST['do']) && !empty($_POST['data']['market']['name'])) {
    pb_submit_check("data");
    $market->setParams();
    $market->params['data']['market']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
    $market->params['data']['market']['area_id'] = PbController::getMultiId($_POST['area']['id']);
    $result = $market->Add();
    if ($result) {
        flash('thanks_for_adding_market');
    } else {
        pheader("location:add.php");
    }
}
$viewhelper->setPosition(L("added_market_info", "tpl"));
render("market/add");
Example #17
0
 if (isset($_POST['quote']['market_name'])) {
     if (!pb_strcomp($_POST['quote']['market_name'], $_POST['market_name'])) {
         $vals['market_id'] = $pdb->GetOne("SELECT id FROM {$tb_prefix}markets WHERE name='" . $_POST['quote']['market_name'] . "'");
     } else {
         $vals['market_id'] = $pdb->GetOne("SELECT id FROM {$tb_prefix}markets WHERE name='" . $_POST['market_name'] . "'");
     }
 }
 if (isset($_POST['quote']['product_name'])) {
     if (!pb_strcomp($_POST['quote']['product_name'], $_POST['product_name'])) {
         $vals['product_id'] = $pdb->GetOne("SELECT id FROM {$tb_prefix}products WHERE name='" . $_POST['quote']['product_name'] . "'");
     } else {
         $vals['product_id'] = $pdb->GetOne("SELECT id FROM {$tb_prefix}products WHERE name='" . $_POST['product_name'] . "'");
     }
 }
 $trend['x'] = PbController::convertTextToArray($_POST['trend_data']['x']);
 $trend['y'] = PbController::convertTextToArray($_POST['trend_data']['y']);
 $vals['trend_data'] = serialize($trend);
 $vals['area_id'] = $vals['area_id3'];
 if (!empty($vals['content'])) {
     $vals['content'] = stripcslashes($vals['content']);
 }
 if (!empty($id)) {
     $vals['modified'] = $time_stamp;
     $result = $marketquotes->save($vals, "update", $id);
 } else {
     $vals['created'] = $vals['modified'] = $time_stamp;
     $result = $marketquotes->save($vals);
 }
 if (!$result) {
     flash();
 } else {
Example #18
0
     $message_info = 'msg_wait_check';
 }
 if (isset($_POST['id'])) {
     $id = intval($_POST['id']);
 }
 if (!empty($_FILES['pic']['name'])) {
     $attach_id = empty($id) ? "product-" . $the_memberid . "-" . ($product->getMaxId() + 1) : "product-" . $the_memberid . "-" . $id;
     $attachment->rename_file = $attach_id;
     $attachment->upload_process();
     $product->params['data']['product']['picture'] = $attachment->file_full_url;
 }
 $form_type_id = 2;
 $product->params['data']['product']['tag_ids'] = $tag->setTagId($_POST['data']['tag']);
 $product->params['data']['product']['cache_companyname'] = $companyinfo['name'];
 $product->params['data']['product']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
 $product->params['data']['product']['area_id'] = PbController::getMultiId($_POST['area']['id']);
 if (!empty($id)) {
     $item_ids = $form->Add($id, $_POST['data']['formitem'], 1, $form_type_id);
     $product->params['data']['product']['modified'] = $time_stamp;
     $product->params['data']['product']['formattribute_ids'] = $item_ids;
     $result = $product->save($product->params['data']['product'], "update", $id, null, $conditions);
 } else {
     if ($g['max_product'] && $now_product_amount >= $g['max_product']) {
         flash('one_day_max');
     }
     $product->params['data']['product']['member_id'] = $the_memberid;
     $product->params['data']['product']['company_id'] = $company_id;
     $product->params['data']['product']['created'] = $product->params['data']['product']['modified'] = $time_stamp;
     $result = $product->save($product->params['data']['product']);
     $new_id = $product->table_name . "_id";
     $product_id = $product->{$new_id};
Example #19
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2214 $
 */
function smarty_function_get($params, &$smarty)
{
    $op = null;
    extract($params);
    global $tb_prefix, $pdb;
    if (empty($var)) {
        $var = "item";
    }
    if (!empty($from)) {
        switch ($from) {
            case "market":
                $num = 4;
                if (isset($params['row'])) {
                    $num = intval($params['row']);
                }
                $latest_commend_markets = $industry->GetArray("SELECT * FROM " . $tb_prefix . "markets WHERE if_commend='1' AND status='1' AND picture!='' ORDER BY id DESC LIMIT " . $num);
                $urls = $infos = $images = array();
                if (!empty($latest_commend_markets)) {
                    while (list($key, $val) = each($latest_commend_markets)) {
                        $urls[] = $industry->getPermaLink($val['id'], null, 'market');
                        $infos[] = pb_lang_split($val['name']);
                        $images[] = pb_get_attachmenturl($val['picture'], '', $size);
                    }
                    $items['url'] = implode("|", $urls);
                    $items['info'] = implode("|", $infos);
                    $items['image'] = implode("|", $images);
                    $return = $items;
                }
                break;
            case "area":
                if (class_exists("Areas")) {
                    $area = new Areas();
                } else {
                    uses("area");
                    $area = new Areas();
                }
                $return = $area->getLevelAreas();
                break;
            case "industry":
                //depth
                if (class_exists("Industries")) {
                    $industry = new Industries();
                    $obj_controller = new Industry();
                } else {
                    uses("industry");
                    $industry = new Industries();
                    $obj_controller = new Industry();
                }
                $return = $industry->getCacheIndustry();
                break;
            case "type":
                if (!empty($name)) {
                    //depth
                    if (class_exists("Industries")) {
                        $industry = new Industries();
                        $obj_controller = new PbController();
                    } else {
                        uses("industry");
                        $industry = new Industries();
                        $obj_controller = new PbController();
                    }
                    $name = $obj_controller->pluralize($name);
                    $industry->findIt($name);
                    $return = $industry->params['data'][1];
                    if (isset($multi)) {
                        $return = $obj_controller->flatten_array($return);
                    }
                    if (empty($var)) {
                        $var = "Items";
                    }
                }
                break;
            default:
                $return = cache_read($name, $key);
                break;
        }
    }
    if (!empty($sql)) {
        //replace table prefix
        $pdb->setFetchMode(ADODB_FETCH_ASSOC);
        $sql = str_replace("pb_", $tb_prefix, $sql);
        //for secure
        if (eregi('insert|update|delete|union|into|load_file|outfile|replace', $sql)) {
            trigger_error('no supported sql.');
        }
        //mysql_escape_string()
        $return = $industry->GetArray($sql);
    }
    if (isset($name)) {
        switch ($name) {
            case "language":
                global $G;
                $languages = unserialize($G['setting']['languages']);
                if (!empty($languages)) {
                    if (!isset($echo)) {
                        $smarty->assign($var, $languages);
                    } else {
                        foreach ($languages as $lang_key => $lang_val) {
                            $tmp = "<a href='" . URL . 'redirect.php?url=' . pb_getenv("REQUEST_URI") . "&app_lang=" . $lang_key . "' title='" . $lang_val['title'] . "'>";
                            if ($image && !empty($lang_val['img'])) {
                                $tmp .= "<img src='" . $lang_val['img'] . "' alt='" . $lang_val['title'] . "' />";
                            } else {
                                $tmp .= $lang_val['title'];
                            }
                            $tmp .= "</a>";
                            if ($sep) {
                                $tmp .= $sep;
                            }
                            if (isset($title_li) && $title_li == "list") {
                                $op .= "<li>" . $tmp . "</li>";
                            } else {
                                $op .= $tmp;
                            }
                        }
                    }
                }
                break;
            case "nav":
                $_nav = cache_read("nav");
                $navs = $_nav['navs'];
                if (!empty($exclude)) {
                    $_exclude_navs = explode(",", $exclude);
                    foreach ($_exclude_navs as $_exkey => $_exval) {
                        unset($navs[$_exval]);
                    }
                }
                if (empty($echo)) {
                    $smarty->assign($var, $navs);
                } else {
                    foreach ($navs as $nav) {
                        $op .= '<li id="mn_' . $nav['id'] . '" class="nav_item nav-item-' . $nav['id'];
                        $file_name = pb_getenv('REQUEST_URI');
                        if (strpos($file_name, $nav['url']) !== false && $nav['url'] != 'index.php') {
                            $op .= ' current_nav_item';
                        }
                        $op .= '"><a href="' . $nav['url'] . '" target="_self"><span>' . pb_lang_split($nav['name']) . '</span></a></li>';
                    }
                }
                break;
            default:
                if (is_file(CACHE_COMMON_PATH . "cache_" . $name . ".php")) {
                    require CACHE_COMMON_PATH . "cache_" . $name . ".php";
                }
                if (isset($_PB_CACHE)) {
                    $smarty->assign($var, $_PB_CACHE);
                }
                break;
        }
    }
    if (!empty($return)) {
        $smarty->assign($var, $return);
    }
    return $op;
}
Example #20
0
 }
 $vals['office_redirect'] = $_POST['member']['office_redirect'];
 $vals['email'] = $_POST['member']['email'];
 if (empty($_POST['member']['email'])) {
     unset($vals['email']);
 }
 if (!empty($_FILES['photo']['name'])) {
     $attachment->upload_dir = "profile" . DS . gmdate("Y") . gmdate("m") . DS . gmdate("d");
     $attachment->insert_new = false;
     $attachment->if_orignal = false;
     $attachment->if_watermark = false;
     $attachment->rename_file = "photo-" . $the_memberid;
     $attachment->upload_process();
     $vals['photo'] = $attachment->file_full_url;
 }
 $_POST['memberfield']['area_id'] = PbController::getMultiId($_POST['area']['id']);
 unset($vals['created']);
 unset($_POST['memberfield']['created']);
 $result = $member->save($vals, "update", $the_memberid);
 $memberfield->primaryKey = "member_id";
 $result = $memberfield->save($_POST['memberfield'], "update", $the_memberid);
 $member->clearCache($the_memberid);
 $member->updateMemberCaches($the_memberid);
 if (isset($_POST['personal']['resume_status'])) {
     $result = $pdb->Execute("REPLACE INTO {$tb_prefix}personals (member_id,resume_status,max_education) VALUE (" . $the_memberid . ",'" . $_POST['personal']['resume_status'] . "','" . $_POST['personal']['max_education'] . "')");
 }
 if (!$result) {
     flash('action_failed');
 } else {
     flash('success');
 }
Example #21
0
 function __construct()
 {
     parent::__construct();
     $this->loadModel("industry");
 }
Example #22
0
 function __construct()
 {
     parent::__construct();
 }
Example #23
0
 if (in_array($do, $allowed_search)) {
     $tpl_file = "search.list";
     switch ($do) {
         case "fair":
             $do = "expo";
             $option = "fair";
             break;
         case "offer":
             $option = "offer";
             $do = "trade";
             break;
         default:
             $option = $do;
             break;
     }
     $search_controller = new PbController();
     $model_name = htmlspecialchars($do, ENT_QUOTES);
     uses($model_name);
     $model_name = $search_controller->pluralize(ucwords($model_name));
     $model_object = new $model_name();
     $model_object->initSearch();
     $result = array();
     if ($model_object->amount > 0) {
         $result = $model_object->Search($pos, $limit);
     }
     //lft cat nav
     switch ($do) {
         case "product":
             $typeoption = "productsort";
             break;
         case "trade":
Example #24
0
 function Add()
 {
     global $_PB_CACHE, $memberfield, $phpb2b_auth_key, $if_need_check;
     $error_msg = array();
     if (empty($this->params['data']['member']['username']) or empty($this->params['data']['member']['userpass']) or empty($this->params['data']['member']['email'])) {
         return false;
     }
     $space_name = $this->params['data']['member']['username'];
     $userpass = $this->params['data']['member']['userpass'];
     $this->params['data']['member']['userpass'] = $this->authPasswd($this->params['data']['member']['userpass']);
     if (empty($this->params['data']['member']['space_name'])) {
         $this->params['data']['member']['space_name'] = PbController::toAlphabets($space_name);
     }
     //Todo:
     $uip = pb_ip2long(pb_getenv('REMOTE_ADDR'));
     if (empty($uip)) {
         pheader("location:" . URL . "redirect.php?message=" . urlencode(L('sys_error')));
     }
     $this->params['data']['member']['last_login'] = $this->params['data']['member']['created'] = $this->params['data']['member']['modified'] = $this->timestamp;
     $this->params['data']['member']['last_ip'] = pb_get_client_ip('str');
     $email_exists = $this->checkUserExistsByEmail($this->params['data']['member']['email']);
     if ($email_exists) {
         flash("email_exists", null, 0);
     }
     $if_exists = $this->checkUserExist($this->params['data']['member']['username']);
     if ($if_exists) {
         flash('member_has_exists', null, 0);
     } else {
         $this->save($this->params['data']['member']);
         $key = $this->table_name . "_id";
         if ($this->ins_passport) {
             $this->passport(array($this->{$key}, $this->params['data']['member']['username'], $userpass, $this->params['data']['member']['email']), "reg");
         }
         $memberfield->primaryKey = "member_id";
         $memberfield->params['data']['memberfield']['member_id'] = $this->{$key};
         $memberfield->params['data']['memberfield']['reg_ip'] = $this->params['data']['member']['last_ip'];
         $memberfield->save($memberfield->params['data']['memberfield']);
         if (!$if_need_check) {
             $user_info['id'] = $this->{$key};
             $user_info['username'] = $this->params['data']['member']['username'];
             $user_info['userpass'] = $userpass;
             $user_info['useremail'] = $this->params['data']['member']['email'];
             $user_info['lifetime'] = $this->timestamp + 86400;
             $user_info['is_admin'] = 0;
             $this->putLoginStatus($user_info);
         }
     }
     return true;
 }
Example #25
0
                $return["error"] = L("no_perm");
                $return['msg'] = L("access_denied");
            }
            ajax_exit($return);
            break;
        default:
            break;
    }
}
if (isset($_GET['action'])) {
    $action = trim($_GET['action']);
    switch ($action) {
        case "selection":
            $result = array();
            if (in_array($_GET['module'], array("industry", "area"))) {
                $sql = "SELECT id AS region_id,name AS region_name FROM " . $tb_prefix . PbController::pluralize($_GET['module']) . " WHERE parent_id='" . intval($_GET['parent_id']) . "' AND available=1";
                $result = $pdb->GetArray($sql);
                for ($i = 0; $i < count($result); $i++) {
                    $result[$i]['region_name'] = pb_lang_split($result[$i]['region_name']);
                }
            }
            ajax_exit($result);
            break;
        case "checkusername":
            if (isset($_GET['username'])) {
                $result = call_user_func_array($action, array($_GET['username']));
                if ($result == true) {
                    $return["isError"] = 1;
                } else {
                    $return["isError"] = 0;
                }
Example #26
0
        }
        $item['forbid_word'] = implode("\r\n", $tmp_str);
    }
    if ($if_check) {
        $trade->params['data']['trade']['status'] = 0;
        $msg = 'pls_wait_for_check';
    } else {
        $trade->params['data']['trade']['status'] = 1;
        $msg = 'success';
    }
    if (!empty($trade->validationErrors)) {
        setvar("item", am($trade->params['data']['trade'], $tradefield->params['data']['tradefield']));
        setvar("Errors", $validate->show($trade));
    } else {
        $trade->params['data']['trade']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
        $trade->params['data']['trade']['area_id'] = PbController::getMultiId($_POST['area']['id']);
        $result = $trade->Add();
        if ($result) {
            $smarty->flash($msg, URL . "offer/detail.php?id=" . $trade->{$trade->table_name . "_id"});
        } else {
            $smarty->flash();
        }
    }
}
$trade_types = $trade->GetArray("SELECT * FROM " . $tb_prefix . "tradetypes");
foreach ($trade_types as $key => $val) {
    if ($val['parent_id'] == 0) {
        $set_types[$val['id']] = $val;
        foreach ($trade_types as $key1 => $val1) {
            if ($val1['parent_id'] == $val['id']) {
                $set_types[$val['id']]['child'][$val1['id']] = $val1;
 function __construct($file = null)
 {
     parent::__construct();
     $this->loadCache($file);
 }
Example #28
0
 function disSubNames($id, $sep = "&raquo;")
 {
     $ids = $this->disSubOptions($id);
     $tmp_controller = new PbController();
     include CACHE_PATH . "cache_area.php";
     $datas = $tmp_controller->array_multi2single($_PB_CACHE['area']);
     foreach ($ids as $key => $val) {
         $r[] = $datas[$val];
     }
     unset($_PB_CACHE);
     return implode($sep, $r);
 }
Example #29
0
             }
         }
         if ($i > 0) {
             flash("success");
         } else {
             flash();
         }
     }
     //			@unlink($attachment->out_file_full_path);
     break;
 case "export":
     require_once LIB_PATH . "excel_export.class.php";
     $excel = new excel_xml();
     $header_style = array('bold' => 1, 'size' => '10', 'color' => '#FFFFFF', 'bgcolor' => '#4F81BD');
     $excel->add_style('header', $header_style);
     $table_name = PbController::pluralize($_POST['tb_name']);
     $record_amount = intval($_POST['record_amount']);
     if (empty($record_amount)) {
         $record_amount = 1000;
     }
     $result = $pdb->GetArray("SELECT * FROM " . $tb_prefix . $table_name . " ORDER BY id DESC LIMIT {$record_amount};");
     $xml = simplexml_to_array(simplexml_load_file(DATA_PATH . "exchange" . DS . $_POST['tb_name'] . ".xml", "SimpleXMLElement", LIBXML_NOCDATA));
     $rows = array_keys($xml['items']);
     $excel->add_row($xml['items'], 'header');
     foreach ($result as $key => $val) {
         foreach ($rows as $key1 => $val1) {
             $cols[$val1] = htmlspecialchars($val[$val1]);
         }
         $excel->add_row($cols);
     }
     $excel->create_worksheet($_POST['tb_name']);
Example #30
0
 function lists()
 {
     global $time_start, $viewhelper, $pos, $smarty, $theme_name;
     $cache_types = cache_read("type");
     $viewhelper->setTitle(L("advanced_search", 'tpl'));
     $module = trim(strtolower($_GET['module']));
     if (in_array($module, $this->allowed_search)) {
         $tpl_file = "search/list";
         setvar('highlight_str', $this->keyword);
         switch ($module) {
             case "fair":
                 $module = "expo";
                 $option = "fair";
                 break;
             case "offer":
                 $option = "offer";
                 $module = "trade";
                 break;
             default:
                 $option = $module;
                 break;
         }
         $search_controller = new PbController();
         $model_name = htmlspecialchars($module, ENT_QUOTES);
         uses($model_name);
         $model_name = $search_controller->pluralize(ucwords($model_name));
         $model_object = new $model_name();
         $model_object->initSearch();
         $result = array();
         if ($model_object->amount > 0) {
             $result = $model_object->Search($pos, $this->displaypg);
         }
         //lft cat nav
         switch ($module) {
             case "product":
                 $typeoption = "productsort";
                 break;
             case "trade":
                 $typeoption = "offertype";
                 break;
             default:
                 $typeoption = $module . "type";
                 break;
         }
         if ($module == "company") {
             $cache_options = cache_read('typeoption');
             $types = $cache_options['manage_type'];
         } else {
             $types = $cache_types[$typeoption];
         }
         if (!empty($types)) {
             setvar("cats", $types);
         }
         foreach ($this->allowed_search as $k => $v) {
             $modules[$v] = L(array_search($v, $this->allowed_search));
         }
         ksort($modules);
         setvar("top_modules", $modules);
         setvar("current_module", $option);
         unset($modules[$option]);
         array_unshift($modules, L(array_search($option, $this->allowed_search)));
         setvar("modules", $modules);
         //similar
         require CLASS_PATH . "segment.class.php";
         $segment = new Segments();
         $search_q = $similar_result = '';
         if (!empty($this->keyword)) {
             $similar_q = $segment->Split($this->keyword);
         }
         if (!empty($similar_q)) {
             $similar_result = $similar_q;
         } elseif (!empty($search_q)) {
             $similar_result = $model_object->GetArray("SELECT *,name AS title FROM " . $tb_prefix . "tags WHERE name like '%" . $search_q . "%' ORDER BY id DESC LIMIT 0,10");
         }
         setvar("similar_search", $similar_result);
         setvar("items", $result);
         $from = $pos == 0 ? 0 : $pos + 1;
         setvar("paging", array('total' => $model_object->amount, 'from' => $from, 'to' => ($to = $pos + $this->displaypg) > $model_object->amount ? $model_object->amount : $to));
         setvar("TimeSpend", number_format(getmicrotime() - $time_start, 3));
         $tpl = $theme_name . DS . $option . DS . 'list' . $smarty->tpl_ext;
         $viewhelper->setTitle(L(array_search($option, $this->allowed_search), 'tpl'));
         if ($search_q) {
             $viewhelper->setTitle($search_q);
         }
         setvar("no_result_tip", L("no_search_result_for_you", "tpl", $search_q));
         if (isset($_GET['typeid'])) {
             $viewhelper->setTitle($types[$_GET['typeid']]);
         }
         render($tpl_file);
     } else {
         unset($_GET);
         flash("record_not_exists");
     }
 }