Example #1
0
    public static function getOne($id)
    {
        $data = array();
        $sql = '
			SELECT * FROM {{translator}}
			WHERE id=' . $id . '
		';
        $item = DB::getRow($sql);
        $sql = '
			SELECT * FROM {{translator}}
			WHERE parent=' . $item['id'] . '
		';
        $rows = DB::getALL($sql);
        foreach (Translator::getLanguage() as $ii => $lang) {
            if ($ii == 0) {
                $data[$item['lang']] = $item;
            } else {
                foreach ($rows as $row) {
                    if ($row['lang'] == $lang['value']) {
                        $data[$row['lang']] = $row;
                    }
                }
            }
        }
        return $data;
    }
Example #2
0
    public static function getValuesNumber($path)
    {
        $data = array();
        $tree = Tree::getTreeByUrl();
        $ids[] = $tree['id'];
        $ids = array_merge($ids, Tree::getChilds($tree['id']));
        $sql = '
			SELECT DISTINCT type FROM {{data}}
			WHERE path=\'' . $path . '\' AND tree IN (' . implode(',', $ids) . ')
		';
        $type = DB::getOne($sql);
        if ($type) {
            $sql = '
				SELECT MAX(' . Fields::$fieldsName[$type] . ') AS maxv, MIN(' . Fields::$fieldsName[$type] . ') AS minv FROM {{data}}
				WHERE path=\'' . $path . '\' AND tree IN (' . implode(',', $ids) . ')
			';
            $data = DB::getRow($sql);
            $data['type'] = substr($type, 0, 1);
        }
        if ($data['maxv'] > 0) {
            return $data;
        } else {
            return array();
        }
    }
 public function login()
 {
     $pass = new Password($this->password);
     $db = new DB();
     $db->where(['email' => $this->email, 'username' => $this->username], 'AND', "OR");
     $db->where(['password' => $this->password], 'AND');
     $data = $db->getRow($this->table);
     //_print_r($data);
     if (count($data) > 0 && $pass->verifyPassword()) {
         if ($n = $pass->needRehash()) {
             $newHash = $pass->reHashPassword();
             $db->where(['email' => $this->email, 'username' => $this->username], 'AND', "OR");
             $db->where(['password' => $this->password], 'AND');
             $res = $db->update($this->table, ['hash' => $newHash]);
         }
         /************ SET SESSION VARIABLES HERE **************/
         //session_start();
         $_SESSION['logged'] = TRUE;
         $_SESSION['userid'] = $data->id;
         $_SESSION['username'] = $data->username ? $data->username : "";
         /****************** END SESSION SETTINGS **************/
         return $data;
     } else {
         return FALSE;
     }
 }
 public function indexAction()
 {
     //get the aff_camapaign_id
     $mysql['use_pixel_payout'] = 0;
     //see if it has the cookie in the campaign id, then the general match, then do whatever we can to grab SOMETHING to tie this lead to
     if ($_COOKIE['btclickid']) {
         $click_pid = $_COOKIE['btclickid'];
     } else {
         //ok grab the last click from this ip_id
         $mysql['ip_address'] = DB::quote($_SERVER['REMOTE_ADDR']);
         $daysago = time() - 2592000;
         // 30 days ago
         $click_sql1 = "\tSELECT \tbt_s_clicks.click_id\n\t\t\t\t\t\t\tFROM \t\tbt_s_clicks\n\t\t\t\t\t\t\tLEFT JOIN\tbt_s_clicks_advanced USING (click_id)\n\t\t\t\t\t\t\tLEFT JOIN \tbt_s_ips USING (ip_id)\n\t\t\t\t\t\t\tWHERE \tbt_s_ips.ip_address='" . $mysql['ip_address'] . "'\n\t\t\t\t\t\t\tAND\t\tbt_s_clicks.time >= '" . $daysago . "'\n\t\t\t\t\t\t\tORDER BY \tbt_s_clicks.click_id DESC\n\t\t\t\t\t\t\tLIMIT \t\t1";
         $click_row1 = DB::getRow($click_sql1);
         $click_pid = base_convert($click_row1['click_id'], 10, 36);
         $mysql['ad_account_id'] = DB::quote($click_row1['ad_account_id']);
     }
     $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($click_pid, 36, 10))));
     if (!$click) {
         BTApp::end();
     }
     if ($click->get('ad_account_id')) {
         if (getArrayVar($_GET, 'amount') && is_numeric($_GET['amount'])) {
             $mysql['use_pixel_payout'] = 1;
         }
         if ($mysql['use_pixel_payout'] == 1) {
             $click->convert(0, $_GET['amount']);
         } else {
             $click->convert();
         }
         if ($click->campaign->option('pixel_type')->value) {
             $sql = "select v1.var_value as v1, v2.var_value as v2, v3.var_value as v3, v4.var_value as v4 from bt_s_clicks_advanced adv\n\t\t\t\t\tleft join bt_s_variables v1 on (v1.var_id=adv.v1_id)\n\t\t\t\t\tleft join bt_s_variables v2 on (v2.var_id=adv.v2_id)\n\t\t\t\t\tleft join bt_s_variables v3 on (v3.var_id=adv.v3_id)\n\t\t\t\t\tleft join bt_s_variables v4 on (v4.var_id=adv.v4_id)\n\t\t\t\t\twhere adv.click_id=?";
             $st = DB::prepare($sql);
             $st->execute(array($click->id()));
             $row = $st->fetch();
             $data['v1'] = $row['v1'];
             $data['v2'] = $row['v2'];
             $data['v3'] = $row['v3'];
             $data['v4'] = $row['v4'];
             $data['clickid'] = $click->id();
             $data['keyword'] = '';
             $data['amount'] = $click->payout;
             $code = replaceTrackerPlaceholders($click->campaign->option('pixel_code')->value, $data);
             $code = str_replace('[[amount]]', $data['amount'], $code);
             switch ($click->campaign->option('pixel_type')->value) {
                 case 1:
                 case 2:
                 case 3:
                     echo $code;
                     break;
                 case 4:
                     $ch = curl_init($code);
                     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 Postback-Bot v1.0');
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                     curl_exec($ch);
                     break;
             }
         }
     }
 }
Example #5
0
 public function __construct()
 {
     if ($_GET['ref']) {
         $sql = 'SELECT iuser FROM {{iusers_options}} WHERE selfcode=\'' . $_GET['ref'] . '\'';
         $iuser = DB::getOne($sql);
         if ($iuser) {
             $_SESSION['referal'] = $iuser;
         }
     }
     $sql = 'SELECT * FROM {{tree}} WHERE parent=410 AND visible=1 ORDER BY num';
     $list = DB::getAll($sql);
     foreach ($list as $item) {
         $fields = Fields::getFieldsByTree($item['id'], 'wide');
         $item['pic'] = $fields['files_gal']['image'][0]['path'];
         $multi = Fields::getMultiFields($item['id']);
         foreach ($multi['color'] as $row) {
             $item['list'][$row] = Funcs::$referenceId['color'][$row]['name'];
         }
         Run::$colors[$item['id']] = $item;
     }
     //print '<pre>';print_r(Run::$colors);die;
     $sql = 'SELECT * FROM {{tree}} WHERE id=1';
     $row = DB::getRow($sql);
     Run::$socTitle = $row['seo_title'];
     Run::$socDescription = $row['seo_description'];
 }
Example #6
0
 public static function getCity($name)
 {
     $data = array();
     $sql = 'SELECT * FROM {{regions}} WHERE visible=1 AND parent<>0 AND name=\'' . $name . '\'';
     $data = DB::getRow($sql);
     return $data;
 }
Example #7
0
 function getEdit()
 {
     $sql = 'SELECT * FROM {{cron}} WHERE id=' . $_GET['id'] . '';
     $data = DB::getRow($sql);
     $data['timing'] = explode(' ', $data['timing']);
     return $data;
 }
Example #8
0
    function forgot()
    {
        if ($_POST) {
            DB::escapePost();
            $sql = '
				SELECT * FROM {{users}} WHERE login=\'' . $_POST['login'] . '\'
			';
            $return = DB::getRow($sql);
            if ($return) {
                $pass = Funcs::generate_password(8);
                $sql = '
					UPDATE {{users}}
					SET pass=MD5(\'' . $pass . '\')
					WHERE login=\'' . $_POST['login'] . '\'
				';
                DB::exec($sql);
                $text = '
					Здравствуйте, ' . $return["login"] . '.<br />
					Ваш новый пароль ' . $pass . '.<br />
					Сменить пароль Вы можете в личном кабинете. 
				';
                $mail = new Email();
                $mail->To($return['email']);
                $mail->Subject('Восстановление пароля на сайте www.' . str_replace("www.", "", $_SERVER["HTTP_HOST"]));
                $mail->Text($text);
                $mail->Send();
            }
            $this->redirect('/');
        } else {
            View::$layout = 'empty';
            View::render('site/forgot');
        }
    }
Example #9
0
 function run($path)
 {
     $sql = 'SELECT * FROM {{forms}} WHERE path=\'' . $path . '\'';
     $form = DB::getRow($sql);
     $sql = 'SELECT * FROM {{forms_fields}} WHERE forms=' . $form['id'] . ' ORDER BY num';
     $fields = DB::getAll($sql);
     foreach ($fields as $item) {
         $item['required'] = $item['required'] == 1 ? 'required' : '';
         switch ($item['type']) {
             case 'string':
                 $text .= FormWidget::getString($item);
                 break;
             case 'text':
                 $text .= FormWidget::getText($item);
                 break;
             case 'select':
                 $text .= FormWidget::getSelect($item);
                 break;
             case 'radio':
                 $text .= FormWidget::getRadio($item);
                 break;
             case 'hidden':
                 $text .= FormWidget::getString($item);
                 break;
             case '':
                 break;
         }
     }
     return str_replace('{content}', $text, View::getWidget('form', $form));
 }
Example #10
0
 /**
  * Returns information for a virtual id.
  *
  * @param integer $virtual_id  The virtual id for which to return
  *                             information.
  *
  * @return array  The virtual email information.
  */
 public function getVirtual($virtual_id)
 {
     $sql = 'SELECT ' . $this->_getTableFields('virtuals') . ' FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_id') . ' = ?';
     Horde::log($sql, 'DEBUG');
     $virtual = $this->_db->getRow($sql, array((int) $virtual_id), DB_FETCHMODE_ASSOC);
     $virtual['stripped_email'] = Vilma::stripUser($virtual['virtual_email']);
     return $virtual;
 }
Example #11
0
    public function getLang($id)
    {
        $sql = '
			SELECT * FROM {{lang}}
			WHERE id=' . $id . '
		';
        return DB::getRow($sql);
    }
Example #12
0
 /**
  * Read function must return string value always to make save handler work as expected. Return empty string if there is no data to read. 
  * Return values from other handlers are converted to boolean expression. TRUE for success, FALSE for failure.
  *
  * @param string $id 
  * @return string
  * @author Ken Mickles
  */
 public static function read($id)
 {
     $sql = 'SELECT `data` FROM ' . SESSION_DB . '.sessions WHERE id=' . DB::s($id);
     if ($row = DB::getRow($sql, __LINE__, __FILE__)) {
         return (string) $row['data'];
     }
     return '';
 }
Example #13
0
    function getBindModule()
    {
        $sql = '
			SELECT * FROM {{relations}}
			WHERE modul1=\'tree\' AND id1=\'' . Funcs::$uri[1] . '\'
		';
        return DB::getRow($sql);
    }
Example #14
0
 static function getOne(array $where, $select = '*', $order = '')
 {
     if (!$where) {
         return false;
     }
     self::_init();
     return DB::getRow($where, static::$_table, $select, $order);
 }
Example #15
0
 public static function getVar($sql, $default = '')
 {
     $row = DB::getRow($sql);
     if (!$row) {
         return $default;
     }
     return array_shift($row);
 }
 /**
  * Returns associative array of values from the first row
  * 
  * The returned value will be based upon the sql specified by $sql. This is 
  * basically a wrapper for the 
  * {@link http://pear.php.net/manual/en/package.database.db.db-common.getrow.php DB_common::getCol}
  * method of the Pear DB module, but DB_FETCHMODE_ASSOC is always used.
  * 
  * @param string $sql The SQL code to be executed
  * @param array $data If $sql is a paramatised query, then the data for each parameter goes in this array
  * @return array
  * 
  */
 public function getRow($sql, $data = array())
 {
     $result = $this->conn->getRow($sql, $data, DB_FETCHMODE_ASSOC);
     self::logQuery();
     if (DB::isError($result)) {
         throw new LoggedException($result->getMessage() . ". SQL: {$sql}", $result->getCode(), self::module);
     }
     return $result;
 }
Example #17
0
 public static function getModuleById($id = '')
 {
     if (is_numeric($id)) {
         $sql = 'SELECT * FROM {{modules}} WHERE id=' . $id . '';
         return DB::getRow($sql);
     } else {
         return false;
     }
 }
Example #18
0
    public static function getOne($id)
    {
        $sql = '
			SELECT {{requests}}.*, {{iusers}}.name, {{iusers}}.balance FROM {{requests}} 
			INNER JOIN {{iusers}} ON {{requests}}.iuser={{iusers}}.id
			WHERE {{requests}}.id=' . $id . '
		';
        $data = DB::getRow($sql);
        return $data;
    }
Example #19
0
 /**
  * we use a special method m() to create new models, this allows us to among other 
  * things lazy load the include file for that model
  *
  * @depends testCreateAndSave
  */
 public function testBuildNewModel()
 {
     // fetch a real planet id from the database
     $row = DB::getRow('select planetID from hotscot_test.planet limit 1');
     $planetID = $row['planetID'];
     $planet = m('planet', $planetID);
     // assert that this is a planet object
     $this->assertTrue($planet instanceof PlanetModel);
     // assert that this planet object was built as expected
     $this->assertEquals($planet->getID(), $planetID);
 }
Example #20
0
File: sql.php Project: horde/horde
 /**
  * Get user profile
  *
  * @param string $user   Username
  */
 protected function _getProfile($user)
 {
     $query = 'SELECT user_email, user_status, user_url, user_description, user_comments, ' . ' user_city, user_country, user_gender, user_birthday, user_video, ' . ' last_online, last_online_on, activity_log, user_vacation, activity, popularity, ' . ' user_picture, count_classifieds, count_news, count_videos, ' . ' count_attendances, count_wishes, count_galleries, count_blogs ' . ' FROM  ' . $this->_params['table'] . ' WHERE user_uid = ?';
     $result = $this->_db->getRow($query, array(strval($user)), DB_FETCHMODE_ASSOC);
     if ($result instanceof PEAR_Error) {
         return $result;
     } elseif (empty($result)) {
         return PEAR::raiseError(sprintf(_("User \"%s\" does not exists."), $user));
     }
     return $result;
 }
    public static function makeAuth($args) {

        $md5pass = md5($args[1].Config::$Security['passwordsalt']);
        $table = Config::$DBConf['prefix'].Authorization::$table;
        $row = DB::getRow("Select * From $table Where `login`='$args[0]' and `password`='$md5pass'");
        if($row != NULL && $row['status'] == '0' ){
            self::$user = $row;
            DB::exec( "UPDATE $table SET `status` = 1 WHERE `login` = '".$args[0]."'" );
            setcookie("user_name",$row['name'], time()+60*60*24*365);
            setcookie("user_id",$row['id'], time()+60*60*24*365);
            return $row['category'];
        }else return NULL;
    }
Example #22
0
 function getEdit()
 {
     $data = array();
     $sql = 'SELECT * FROM {{reference}} WHERE id=' . $_GET['id'] . '';
     $data = DB::getRow($sql);
     $sql = 'SELECT * FROM {{reference_files}} WHERE reference=' . $_GET['id'] . '';
     $files = DB::getAll($sql);
     foreach ($files as $file) {
         $file['info'] = Funcs::getFileInfo($file['path']);
         $data['files'][] = $file;
     }
     return $data;
 }
Example #23
0
 public static function getList()
 {
     $data = array();
     $row = 0;
     $is_catalog = false;
     foreach (Impexp::$treeFieldsRus as $item) {
         $data[$row][] = $item;
     }
     $sql = 'SELECT * FROM {{tree}} WHERE parent=' . Funcs::$uri[3] . ' ORDER BY num';
     $list = DB::getAll($sql);
     $module = Module::getModuleByTree($list[0]['id']);
     $moduleFields = Module::getFieldList($module['id'], 'all');
     foreach ($moduleFields as $item) {
         if (in_array($item['type'], Impexp::$usingFieldsByType)) {
             $data[$row][] = $item['name'];
         }
     }
     $row++;
     $sql = 'SELECT id FROM {{catalog}} WHERE tree=' . $list[0]['id'];
     if (DB::getOne($sql)) {
         $is_catalog = true;
     }
     foreach ($list as $item) {
         foreach (Impexp::$treeFields as $field) {
             $data[$row][] = $item[$field];
         }
         $fields = Impexp::getFieldsByTree($item['id']);
         if ($is_catalog) {
             $sql = 'SELECT * FROM {{catalog}} WHERE tree=' . $item['id'];
             $item = DB::getRow($sql);
             foreach ($moduleFields as $field) {
                 if (in_array($field['type'], Impexp::$usingFieldsByType)) {
                     if (in_array($field['path'], OneSSA::$catalogStandart)) {
                         $data[$row][] = $item[$field['path']];
                     } else {
                         $data[$row][] = $fields[$field['path']];
                     }
                 }
             }
         } else {
             foreach ($moduleFields as $field) {
                 if (in_array($field['type'], Impexp::$usingFieldsByType)) {
                     $data[$row][] = $fields[$field['path']];
                 }
             }
         }
         $row++;
     }
     return $data;
 }
Example #24
0
 /**
  * Gets the latest released story from a given internal channel
  *
  * @param int $channel_id  The channel id.
  *
  * @return int  The story id.
  * @throws Jonah_Exception
  * @throws Horde_Exception_NotFound
  */
 public function getLatestStoryId($channel_id)
 {
     $sql = 'SELECT story_id FROM jonah_stories' . ' WHERE channel_id = ? AND story_published <= ?' . ' ORDER BY story_updated DESC';
     $values = array((int) $channel_id, time());
     Horde::log('SQL Query by Jonah_Driver_sql::getLatestStoryId(): ' . $sql, 'DEBUG');
     $result = $this->_db->getRow($sql, $values, DB_FETCHMODE_ASSOC);
     if ($result instanceof PEAR_Error) {
         Horde::log($result, 'ERR');
         throw new Jonah_Exception($result);
     } elseif (empty($result)) {
         return Horde_Exception_NotFound(sprintf(_("Channel \"%s\" not found."), $channel_id));
     }
     return $result['story_id'];
 }
Example #25
0
    public static function calcSale($orderId)
    {
        $order = DealersOrders::getOrderProp($orderId);
        $sql = '
			SELECT {{dealers}},*, {{dealers_status}}.sale as statussale FROM {{dealers}}
			LEFT JOIN ((dealers_status)) ON {{dealers}}.status = {{dealers_status}}.id
			WHERE {{dealers}}.id=' . $order['dealer'] . '
		';
        $dealer = DB::getRow($dealerId);
        $sale_status = $dealer['statussale'];
        $sale_one = self::calc($order['sum'], 'sale_one');
        $sale_year = self::calc($order['sum'], 'sale_year');
        $sale_total = $sale_status + max($sale_year, $sale) + $order['add_sale'];
        return $sale_total;
    }
 /**
  * Constructor
  * @return void
  */
 function __construct($var = 0)
 {
     if ($var > 0) {
         $db = new DB();
         $obj = $db->getRow($this->table, '*');
         if (is_object($obj)) {
             $this->id = stripslashes($obj->id);
             $this->username = stripslashes($obj->username);
             $this->password = stripslashes($obj->password);
             $this->hash = stripslashes($obj->hash);
             $this->email = stripslashes($obj->email);
             $this->display_name = stripslashes($obj->display_name);
             $this->status = stripslashes($obj->status);
             $this->updated_on = stripslashes($obj->updated_on);
         }
     }
 }
Example #27
0
 /**
  * Fetches a gateway from the backend.
  *
  * @param int $gateway_id  The gateway id to fetch.
  *
  * @return array  An array containing the gateway settings and parameters.
  */
 function &getGateway($gateway_id)
 {
     /* Get the gateways. */
     $sql = 'SELECT * FROM swoosh_gateways WHERE gateway_id = ?';
     $values = array((int) $gateway_id);
     Horde::log('SQL Query by Hylax_Storage_sql::getGateway(): ' . $sql, 'DEBUG');
     $gateway = $this->_db->getRow($sql, $values, DB_FETCHMODE_ASSOC);
     if (is_a($gateway, 'PEAR_Error')) {
         Horde::log($gateway, 'ERR');
         return $gateway;
     }
     /* Unserialize the gateway params. */
     $gateway['gateway_params'] = Horde_Serialize::unserialize($gateway['gateway_params'], Horde_Serialize::UTF7_BASIC);
     /* Unserialize the gateway send params. */
     $gateway['gateway_sendparams'] = Horde_Serialize::unserialize($gateway['gateway_sendparams'], Horde_Serialize::UTF7_BASIC);
     return $gateway;
 }
Example #28
0
 function run($id = '')
 {
     $fullURI = Funcs::$uri;
     if ($id) {
         $fullURI = explode('/', Tree::getPathToTree($id));
         unset($fullURI[0]);
         unset($fullURI[count($fullURI)]);
     }
     $data = array();
     $parent = Funcs::$siteDB;
     $path = '';
     foreach ($fullURI as $uri) {
         $path = $path . '/' . $uri;
         if (is_numeric($uri)) {
             $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND id=' . $uri . '';
         } else {
             $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND path=\'' . $uri . '\'';
         }
         $row = DB::getRow($sql);
         $row['path'] = $path . '/';
         $parent = $row['id'];
         if ($parent == '') {
             $parent = 0;
         }
         $data[] = $row;
     }
     if ($fullURI[0] == 'catalog' && is_numeric($fullURI[count(Funcs::$uri) - 1])) {
         $uri = explode('/', $_SERVER['REQUEST_URI']);
         $num = count($data);
         $data[count($data)] = $data[count($data) - 1];
         $path = $data;
         unset($path[count($path) - 1]);
         unset($path[count($path) - 1]);
         $items = array();
         foreach ($path as $item) {
             $items[] = $item['path'];
         }
         Funcs::$reference['vendor'][$uri[$num]]['path'] = $items[count($items) - 1] . Funcs::$reference['vendor'][$uri[$num]]['path'] . '/';
         $data[count($data) - 2] = Funcs::$reference['vendor'][$uri[$num]];
     } elseif (isset($_GET['ve'])) {
         $path = $items[count($items)] . Funcs::$reference['vendor'][$uri[$num]]['path'] . '/';
         $data[] = array('name' => Funcs::$referenceId['vendor'][$_GET['ve']]['name'], 'path' => $path);
     }
     View::widget('crumbs', array('list' => $data));
 }
Example #29
0
 public static function getOrders()
 {
     $data = array();
     $sql = 'SELECT MAX(cdate) AS maxdate, MIN(cdate) AS mindate FROM {{orders}} WHERE status=\'done\'';
     $dates = DB::getRow($sql);
     for ($i = date('Y', strtotime($dates['mindate'])); $i <= date('Y', strtotime($dates['maxdate'])); $i++) {
         for ($num = 0; $num < 12; $num++) {
             $db = date('Y-m-d 00:00:01', strtotime($i . '-' . str_repeat('0', 2 - strlen($num + 1)) . ($num + 1) . '-01 00:00:01'));
             $de = date('Y-m-d 00:00:01', strtotime($i . '-' . str_repeat('0', 2 - strlen($num + 1)) . ($num + 1) . '-01 00:00:01 +1 month'));
             $sql = 'SELECT SUM(price) FROM {{orders}} WHERE status=\'done\' AND (cdate BETWEEN \'' . $db . '\' AND \'' . $de . '\' )';
             $sum = DB::getOne($sql);
             if ($sum != '') {
                 $data[$i][str_repeat('0', 2 - strlen($num + 1)) . ($num + 1)] = array('name' => Funcs::$monthsRusB[$num], 'sum' => $sum);
             }
         }
     }
     return $data;
 }
 public static function get_keyword_id($keyword)
 {
     //only grab the first 255 charactesr of keyword
     $keyword = substr($keyword, 0, 255);
     $mysql['keyword'] = DB::quote($keyword);
     $keyword_sql = "SELECT keyword_id FROM bt_s_keywords WHERE keyword='" . $mysql['keyword'] . "'";
     $keyword_row = DB::getRow($keyword_sql);
     if ($keyword_row) {
         //if this already exists, return the id for it
         $keyword_id = $keyword_row['keyword_id'];
         return $keyword_id;
     } else {
         //else if this ip doesn't exist, insert the row and grab the id for it
         $keyword_sql = "INSERT INTO bt_s_keywords SET keyword='" . $mysql['keyword'] . "'";
         $keyword_result = DB::query($keyword_sql);
         //($keyword_sql);
         $keyword_id = DB::insertId();
         return $keyword_id;
     }
 }