Example #1
0
 public function select()
 {
     global $LANG;
     $sql = "SELECT\n\t\t\t\tiv.*,\n                p.description\n\t\t\tFROM \n\t\t\t\t" . TB_PREFIX . "products p\n\t\t\t\tLEFT JOIN " . TB_PREFIX . "inventory iv \n\t\t\t\t\tON (p.id = iv.product_id AND p.domain_id = iv.domain_id)\n\t\t\tWHERE \n\t\t\t\tiv.domain_id = :domain_id\n\t\t\tAND iv.id = :id;";
     $sth = dbQuery($sql, ':domain_id', $this->domain_id, ':id', $this->id);
     return $sth->fetch();
 }
Example #2
0
function register($name, $email, $password)
{
    //check for user table
    //if it doesn't exist, create it (first time this script is run)
    //validation
    if (!isset($email)) {
        $response = array("status" => "fail", "resp" => "Please send afRegEmail ");
        return $response;
    }
    if (!isset($name)) {
        $response = array("status" => "fail", "resp" => "Please send a afRegName ");
        return $response;
    }
    if (!isset($password)) {
        $response = array("status" => "fail", "resp" => "Please send a afRegPassword ");
        return $response;
    }
    //encrpyt password
    $password = md5($password);
    $ipAddress = $_SERVER['REMOTE_ADDR'];
    //echo('ip='.$ipAddress);
    $allUsers = dbMassData("SELECT * FROM users WHERE email = '{$email}'");
    if ($allUsers == null) {
        dbQuery("INSERT INTO users (name, email, password, ipAddress) VALUES ('{$name}', '{$email}', '{$password}', '{$ipAddress}')");
        $resp = array("status" => "success");
        //now login user
        return $resp;
        //return $response;
    } else {
        $response = array("status" => "fail", "resp" => "emailTaken");
        return $response;
    }
}
 /**
  * Constructor
  * @param Form $form
  * @param \samson\activerecord\field $db_field
  * @param string $locale
  */
 public function __construct(Form &$form, &$db_field, $field_type)
 {
     // Set field header name
     $this->name = !empty($db_field->Description) ? $db_field->Description : $db_field->Name;
     // Save pointers to database field object
     $this->db_field =& $db_field;
     // Call parent
     parent::__construct($form);
     // Prepare locales array with one default locale by default
     $locales = array('');
     // If field supports localization - set full locales array
     if ($db_field->local == 1) {
         $locales = SamsonLocale::$locales;
     }
     // Iterate defined locales
     if (sizeof(SamsonLocale::$locales)) {
         foreach ($locales as $locale) {
             // Try to find existing CMSMaterialField record
             if (!dbQuery('\\samson\\cms\\CMSMaterialField')->MaterialID($form->material->id)->FieldID($db_field->id)->locale($locale)->first($db_mf)) {
                 // Create CMSMaterialField record
                 $db_mf = new \samson\cms\CMSMaterialField(false);
                 $db_mf->Active = 1;
                 $db_mf->MaterialID = $this->form->material->id;
                 $db_mf->FieldID = $db_field->id;
                 $db_mf->locale = $locale;
                 $db_mf->save();
             }
             //elapsed($this->name.'-'.$locale.'-'.$db_mf->Value.'-'.$db_mf->id);
             // Add child tab
             $this->tabs[] = new MaterialFieldTab($form, $this, $db_mf, $locale, $field_type);
         }
     }
 }
Example #4
0
function main()
{
    if (hasPrivilege('customer')) {
        // Check customer Loged in
        $userId = $_SESSION[getSpKey()]['customer'];
        $sql = "SELECT * FROM `customers` WHERE `id` = '{$userId}' ";
        $result = dbQuery($sql);
        while (($records = mysql_fetch_assoc($result)) !== false) {
            $customerDetails = array('id' => $records['id'], 'customer_name' => $records['customer_name'], 'customer_family' => $records['customer_family'], 'customer_email' => $records['customer_email'], 'customer_gender' => $records['customer_gender'], 'customer_mobile' => $records['customer_mobile'], 'customer_city' => $records['customer_city'], 'customer_state' => $records['customer_state'], 'customer_zipcode' => $records['customer_zipcode'], 'customer_emergency_number' => $records['customer_emergency_number'], 'customer_address' => $records['customer_address']);
        }
        mysql_free_result($result);
        // edit Customer Details
        if (isset($_POST['btnEditSubmit'])) {
            $txtDetails = array('customer_name' => isset($_POST['txtName']) ? $_POST['txtName'] : null, 'customer_family' => isset($_POST['txtFamily']) ? $_POST['txtFamily'] : null, 'customer_email' => isset($_POST['txtEmail']) ? $_POST['txtEmail'] : null, 'customer_mobile' => isset($_POST['txtMobile']) ? $_POST['txtMobile'] : null, 'customer_city' => isset($_POST['txtCity']) ? $_POST['txtCity'] : null, 'customer_state' => isset($_POST['txtState']) ? $_POST['txtState'] : null, 'customer_zipcode' => isset($_POST['txtZipCode']) ? $_POST['txtZipCode'] : null, 'customer_emergency_number' => isset($_POST['txtEmergencyNumber']) ? $_POST['txtEmergencyNumber'] : null, 'customer_address' => isset($_POST['txtAddress']) ? $_POST['txtAddress'] : null);
            $dataIsCorrect = true;
            foreach ($txtDetails as $pieceOfData) {
                if (is_null($pieceOfData)) {
                    addMessage('اطلاعات محصول به درستی وارد نشده است', FAILURE);
                    $dataIsCorrect = false;
                    break;
                }
            }
        }
    } else {
        $url = BASE_URL . 'signup';
        return array('redirect' => $url);
    }
    $resp['data'] = array('customerDetails' => $customerDetails);
    return $resp;
}
function migrate()
{
    #----------------------------------------------------------------------
    #--- Leave if we've done this migration already.
    if (!databaseTableExists('ResultsStatus')) {
        noticeBox(false, "You need to apply migation 1 first.");
        return;
    }
    #--- Leave if we are already up-to-date
    $number = dbQuery("\n              SELECT value FROM  ResultsStatus\n              WHERE  id = 'migration'\n  ");
    $number = $number[0]['value'];
    if ($number != '4') {
        noticeBox(false, "Wrong version number : " . $number . ". Must be 4");
        return;
    }
    #--- ResultsStatus table: Update migration number.
    reportAction("ResultsStatus", "Set migration number to 5");
    dbCommand("\n    UPDATE   ResultsStatus\n    SET    value = '5'\n    WHERE  id = 'migration'\n  ");
    #--- Apply the migration changes.
    alterTableCompetitions();
    alterTableCountries();
    alterTableContinents();
    #--- Yippie, we did it!
    noticeBox(true, "Migration completed.");
}
function alterTablePreregs()
{
    #----------------------------------------------------------------------
    #--- Alter the field set.
    reportAction("Preregs", "Alter field set");
    dbCommand("\n    ALTER TABLE Preregs\n      ADD    COLUMN `eventIds`  TEXT NOT NULL DEFAULT ''\n  ");
    $i = 0;
    $len = 1000;
    $preregs = dbQuery(" SELECT * FROM Preregs LIMIT {$i},{$len}");
    while (count($preregs) != 0) {
        foreach ($preregs as $prereg) {
            $id = $prereg['id'];
            $eventIds = '';
            foreach (array_merge(getAllEventIds(), getAllUnofficialEventIds()) as $eventId) {
                if ($prereg["E{$eventId}"] != 0) {
                    $eventIds .= "{$eventId} ";
                }
            }
            rtrim($eventIds);
            dbCommand("UPDATE Preregs SET eventIds='{$eventIds}' WHERE id='{$id}'");
        }
        $i += $len;
        $preregs = dbQuery(" SELECT * FROM Preregs LIMIT {$i},{$len}");
    }
    foreach (array_merge(getAllEventIds(), getAllUnofficialEventIds()) as $eventId) {
        dbCommand("ALTER TABLE Preregs\n                 DROP COLUMN `E{$eventId}`");
    }
}
function getRecentRanks($sourceId)
{
    #----------------------------------------------------------------------
    global $WHERE, $sinceDateCondition;
    #--- Get all personal records sorted by event and value
    $records = dbQuery("\n    SELECT   personId, eventId, min({$sourceId}) value\n    FROM     Results result, Competitions competition\n    {$WHERE}   competition.id=competitionId\n      AND    {$sinceDateCondition}\n      AND    {$sourceId}>0\n    GROUP BY eventId, personId\n    ORDER BY eventId, value\n  ");
    #--- Append a sentinel
    $records[] = array('nobody', 'ThisWillCauseTheFinishEventCodeForTheLastEvent');
    #--- Process the personal records, build ranks[event][person]
    foreach ($records as $record) {
        list($personId, $eventId, $value) = $record;
        #--- At new events, finish the previous and reset for the new one
        if ($eventId != $currentEventId) {
            #--- Memorize the previous event's ranks (if any, and if that event is official)
            if ($currentEventId && in_array($currentEventId, getAllEventIds())) {
                $ranks[$currentEventId] = $ranksInCurrentEvent;
            }
            #--- Reset for the new event
            $currentEventId = $eventId;
            unset($currentSize, $currentRank, $currentValue, $ranksInCurrentEvent);
        }
        #--- Update the current event ranklist status
        $currentSize++;
        if ($value != $currentValue) {
            $currentValue = $value;
            $currentRank = $currentSize;
        }
        #--- Memorize the person's rank in this event
        $ranksInCurrentEvent[$personId] = $currentRank;
    }
    #--- Return the event ranks
    return $ranks;
}
Example #8
0
 public static function rewind($node, $sub_node = 0, $domain_id = '', $sub_node_2 = 0)
 {
     $domain_id = domain_id::get($domain_id);
     $sql = "UPDATE " . TB_PREFIX . "index \n                SET id = (id - 1) \n                WHERE node = :node\n\t\t\t\tAND sub_node = :sub_node\n\t\t\t\tAND sub_node_2 = :sub_node_2\n                AND domain_id = :domain_id\n\t\t\t";
     $sth = dbQuery($sql, ':node', $node, ':sub_node', $sub_node, ':sub_node_2', $sub_node_2, ':domain_id', $domain_id);
     return $sth;
 }
Example #9
0
 function grouped($expense_id)
 {
     $sql = "select \n                    t.tax_description as tax_name, \n                    sum(et.tax_amount) as tax_amount,\n                    count(*) as count\n                from \n                    si_expense_item_tax et, \n                    si_expense e,\n                    si_tax t \n                where \n                    e.id = et.expense_id \n                AND \n                    t.tax_id = et.tax_id \n                AND\n                    e.id = :expense_id\n                GROUP BY \n                    t.tax_id;";
     $sth = dbQuery($sql, ':expense_id', $expense_id) or die(htmlsafe(end($dbh->errorInfo())));
     $result = $sth->fetchAll();
     return $result;
 }
Example #10
0
/**
 * register, and login
 *
 * @return array status
 */
function Privacy_register()
{
    $password = $_REQUEST['password'];
    $token = $_REQUEST['token'];
    $reg = @$_SESSION['privacy']['registration'];
    $email = @$reg['email'];
    $custom = @$reg['custom'];
    if (!is_array($custom)) {
        $custom = array();
    }
    $sql = 'select id from user_accounts where email="' . addslashes($email) . '"';
    if (dbOne($sql, 'id')) {
        return array('error' => __('already registered'));
    }
    if ($token && $token == @$reg['token']) {
        $latlngsql = '';
        if (@$custom['_location']) {
            $latlng = dbRow('select lat,lng from locations where id=' . (int) $custom['_location']);
            if ($latlng) {
                $latlngsql = ',location_lat=' . $latlng['lat'] . ',location_lng=' . $latlng['lng'];
            }
        }
        $sql = 'insert into user_accounts set email="' . addslashes($email) . '",' . 'password=md5("' . addslashes($password) . '"),active=1,date_created=now(),' . 'extras="' . addslashes(json_encode($custom)) . '"' . $latlngsql;
        dbQuery($sql);
        return array('ok' => 1);
    } else {
        return array('error' => __('token does not match'));
    }
}
	function getLastValue() {
		$sql = "SELECT value FROM ".TB_PREFIX."customFieldValues WHERE customFieldId = 7 ORDER BY id DESC LIMIT 1;";
		$sth = dbQuery($sql);
		$result = $sth->fetch();
		error_log($sql);
		return $result['value'];
	}
Example #12
0
/**
 * check uploaded file to see if it's acceptable
 *
 * @param array $vars list of parameters
 *
 * @return boolean
 */
function ThemesApi_filesCheck($vars)
{
    /**
     * check if this file should be handled
     * by this plugin
     */
    $file = explode('/', $vars['requested_file']);
    $dir = $file[1];
    if ($file[1] != 'themes_api') {
        return true;
    }
    /**
     * if you are a moderator, then you can download
     */
    $id = $file[3];
    $moderated = dbOne('select moderated from themes_api where id=' . $id, 'moderated');
    if ($moderated == 'no') {
        die(__('This theme is awaiting moderation and has not been deemed as safe yet.'));
    }
    // save in database
    $referrer = @$_SERVER['HTTP_REFERER'];
    $ip = @$_SERVER['REMOTE_ADDR'];
    dbQuery('insert into themes_downloads values("",' . $id . ',"' . $referrer . '","' . $ip . '",now())');
    return false;
}
Example #13
0
function orderoldfood()
{
    if (isset($_POST)) {
        $food_id = $_POST['food_id'];
        $food_name = $_POST['food_name'];
        $food_type = $_POST['food_type'];
        $add_amount = $_POST['add_amount'];
        $price_per = $_POST['price_per'];
        $total = $add_amount * $price_per;
    }
    $conn = dbConnect();
    if ($conn) {
        $sql0 = "SELECT AMOUNT FROM EMM_ZOO.FM_STOCK WHERE FOODID = {$food_id};";
        $stm = dbQuery($conn, $sql0);
        while ($row = dbFetchArray($conn, $stm)) {
            $amountx = $row[0];
        }
        $amount_now = $amountx + $add_amount;
        $sql1 = "INSERT INTO EMM_ZOO.FOODANIMAL_EXPENSE (FOODEXPENSE_ID,DATES,FOODID,COST,RESPONPERSONID) VALUES (DEFAULT,CURRENT DATE,{$food_id},{$total},'5678');";
        $cb = db2_exec($conn, $sql1);
        $sql2 = "UPDATE EMM_ZOO.FM_STOCK SET AMOUNT = {$amount_now} WHERE FOODID = {$food_id};";
        $cc = db2_exec($conn, $sql2);
        if ($cc && $cb) {
            $resultMessage = 1;
            return $resultMessage;
            header('Location: FoodStock.php#food_list');
        } else {
            $resultMessage = 0;
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    }
}
Example #14
0
function main()
{
    if (hasPrivilege('customer')) {
        //@ToDo اگر سبد خالی بود به صفحه اصلی ارسال شود
        $resp = array('data' => array(1));
        $resp['data']['shopingCart'] = array();
        $cartItems = array();
        if (isset($_SESSION['cart']) && count($_SESSION['cart']) > 0) {
            $productIds = array_keys($_SESSION['cart']);
            $temp = implode(', ', $productIds);
            $sql = "SELECT `id`, `product_name`,`product_picture_name`, `product_price` FROM `products` WHERE `id` IN ({$temp});";
            $result = dbQuery($sql);
            while (($row = mysql_fetch_assoc($result)) !== false) {
                $resp['data']['cartItems'][] = array('id' => $row['id'], 'product_name' => $row['product_name'], 'product_price' => (int) $row['product_price'], 'product_picture_name' => $row['product_picture_name'], 'count' => $_SESSION['cart'][(int) $row['id']]);
            }
            mysql_free_result($result);
        } else {
            $url = BASE_URL;
            return array('redirect' => $url);
        }
        return $resp;
    } else {
        addMessage('برای تسویه حساب وارد حساب کاربری خود شوید، چنانچه هنوز عضو نیستید ثبت نام کنید', NOTICE);
        $url = BASE_URL . 'signup';
        return array('redirect' => $url);
    }
}
Example #15
0
 function grouped($expense_id)
 {
     $sql = "SELECT \n                      t.tax_description AS tax_name \n                    , SUM(et.tax_amount) AS tax_amount\n                    , COUNT(*) AS count\n                FROM \n                    " . TB_PREFIX . "expense_item_tax et \n\t\t\t\t\tINNER JOIN " . TB_PREFIX . "expense e \n\t\t\t\t\t\tON (e.id = et.expense_id)\n\t\t\t\t\tINNER JOIN " . TB_PREFIX . "tax t \n\t\t\t\t\t\tON (t.tax_id = et.tax_id AND t.domain_id = e.domain_id)\n                WHERE \n                    e.id = :expense_id\n\t\t\t\tAND e.domain_id = :domain_id\n                GROUP BY \n                    t.tax_id;";
     $sth = dbQuery($sql, ':expense_id', $expense_id, ':domain_id', $this->domain_id);
     $result = $sth->fetchAll();
     return $result;
 }
Example #16
0
function setUser($user_id_md5)
{
    global $user;
    global $cfg;
    global $season;
    unsetUser($user);
    $user_id_md5 = stripslashes($user_id_md5);
    list($id_user, $md5_password) = unserialize($user_id_md5);
    if ($id_user != "") {
        $users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}users` WHERE `id` = {$id_user}");
        if ($users_row = dbFetch($users_ref) and $md5_password == md5($users_row['password'])) {
            $user['uid'] = $users_row['id'];
            $user['username'] = $users_row['username'];
            if (!isset($season)) {
                $season_users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}season_users` " . "WHERE `id_user` = {$users_row['id']} AND `id_season` = 0");
            } else {
                $season_users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}season_users` " . "WHERE `id_user` = {$users_row['id']} AND (`id_season` = 0 OR `id_season` = {$season['id']})");
            }
            while ($season_users_row = dbFetch($season_users_ref)) {
                if ($season_users_row['usertype_root'] == 1) {
                    $user['usertype_root'] = $season_users_row['usertype_root'];
                }
                if ($season_users_row['usertype_headadmin'] == 1) {
                    $user['usertype_headadmin'] = $season_users_row['usertype_headadmin'];
                }
                if ($season_users_row['usertype_admin'] == 1) {
                    $user['usertype_admin'] = $season_users_row['usertype_admin'];
                }
                if ($season_users_row['usertype_player'] == 1) {
                    $user['usertype_player'] = $season_users_row['usertype_player'];
                }
            }
        }
    }
}
Example #17
0
function getPrices($limit = 1, $store)
{
    $data = array();
    $rData = array();
    //$startDate = "2012-01-01";
    for ($i = 0; $i < $limit; $i++) {
        $theDate = date('Y-m-d');
        //echo($theDate);
        //echo("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9");
        $info = file_get_contents("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9");
        $tInfo = json_decode($info, true);
        $data = $tInfo['data'][0];
        $open = floatval($data[1]);
        $high = floatval($data[2]);
        $low = floatval($data[3]);
        $close = floatval($data[4]);
        $volume = floatval($data[5]);
        $volumeC = floatval($data[6]);
        $weightedPrice = floatval($data[7]);
        $avg = floatval(($high + $low) / 2);
        $rData = array("open" => $open, "high" => $high, "low" => $low, "high" => $high, "volume" => $volume, "VolumeUSD" => $volumeC, "weightedPrice" => $weightedPrice, "avg" => $avg, "close" => $close, "exchange" => "BitStamp");
        if ($store == true) {
            dbQuery("INSERT INTO btcHistory (open, high, low, close, volume, volumeUSD, weightedPrice, avg, tDate) VALUES ({$open}, {$high}, {$low}, {$close}, {$volume}, {$volumeC}, {$weightedPrice}, {$avg}, '{$theDate}')");
            //echo("INSERT INTO btcHistory (open, high, low, close, volume, volumeUSD, weightedPrice, avg, tDate) VALUES ($open, $high, $low, $close, $volume, $volumeC, $weightedPrice, $avg, '$theDate')");
        }
    }
    //return true
    return $rData;
}
Example #18
0
 public static function get_all()
 {
     global $dbh;
     global $LANG;
     global $auth_session;
     $customer = null;
     $sql = "SELECT * FROM " . TB_PREFIX . "customers WHERE domain_id = :domain_id";
     $sth = dbQuery($sql, ':domain_id', $auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo())));
     $customers = null;
     for ($i = 0; $customer = $sth->fetch(); $i++) {
         if ($customer['enabled'] == 1) {
             $customer['enabled'] = $LANG['enabled'];
         } else {
             $customer['enabled'] = $LANG['disabled'];
         }
         #invoice total calc - start
         $customer['total'] = calc_customer_total($customer['id']);
         #invoice total calc - end
         #amount paid calc - start
         $customer['paid'] = calc_customer_paid($customer['id']);
         #amount paid calc - end
         #amount owing calc - start
         $customer['owing'] = $customer['total'] - $customer['paid'];
         #amount owing calc - end
         $customers[$i] = $customer;
     }
     return $customers;
 }
function showMedia()
{
    #----------------------------------------------------------------------
    global $chosenYears, $chosenRegionId, $chosenOrder;
    #--- Prepare conditions.
    $yearCondition = yearCondition();
    $regionCondition = regionCondition('competition');
    $orderCondition = $chosenOrder == 'date' ? "ORDER BY competition.year DESC,\n                                                         competition.month DESC,\n                                                         competition.day DESC" : "ORDER BY timestampDecided DESC";
    #--- Get data of the (matching) media items.
    $media = dbQuery("\n    SELECT media.*, competition.*, cellName, country.name AS countryName\n\n    FROM CompetitionsMedia media, Competitions competition, Countries country\n    WHERE 1\n      AND competition.id = competitionId\n      AND country.id = countryId\n      {$yearCondition}\n      {$regionCondition}\n      AND status = 'accepted'\n    {$orderCondition}, cellName\n  ");
    #--- Print the data.
    tableBegin('results', 6);
    #  tableCaption( false, spaced(array( eventName($chosenEventId), chosenRegionName(), $chosenYears )));
    tableHeader(explode('|', 'Insertion Date|Competition Date|Competition|Country, City|Type|Link'), array(5 => 'class="f"'));
    foreach ($media as $data) {
        extract($data);
        #--- Print the empty row.
        if ($chosenOrder == 'submission') {
            $year = preg_replace('/-.*/', '', $timestampDecided);
        }
        if (isset($previousYear) && $year != $previousYear) {
            tableRowEmpty();
        }
        $previousYear = $year;
        tableRow(array(preg_replace('/ .*/', '', $timestampDecided), competitionDate($data), competitionLink($competitionId, $cellName), "<b>{$countryName}</b>, {$cityName}", $type, externalLink($uri, $text)));
    }
    tableEnd();
}
function buildTableCompetitionsMedia()
{
    #----------------------------------------------------------------------
    #--- CompetitionsMedia table: Create it.
    reportAction("CompetitionsMedia", "Create");
    dbCommand("\n    CREATE TABLE CompetitionsMedia (\n      id                 INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n      competitionId      VARCHAR(32)      NOT NULL,\n      type               VARCHAR(15)      NOT NULL,\n      text               VARCHAR(100)     NOT NULL,\n      uri                VARCHAR(500)     NOT NULL,\n      submitterName      VARCHAR(50)      NOT NULL,\n      submitterComment   VARCHAR(500)     NOT NULL,\n      submitterEmail     VARCHAR(45)      NOT NULL,\n      timestampSubmitted TIMESTAMP        NOT NULL DEFAULT CURRENT_TIMESTAMP,\n      timestampDecided   TIMESTAMP        NOT NULL,\n      status             VARCHAR(10)      NOT NULL,\n      PRIMARY KEY ( id )\n    )\n ");
    #--- Get the data from the Competitions table.
    $media = dbQuery("\n    SELECT id competitionId, 'report' type, reports data FROM Competitions\n    UNION\n    SELECT id competitionId, 'article' type, articles data FROM Competitions\n    UNION\n    SELECT id competitionId, 'multimedia' type, multimedia data FROM Competitions\n  ");
    #--- Fill the CompetitionsMedia table with the data.
    reportAction("CompetitionsMedia", "Fill with data from table Competitions");
    #  echo "<table>";
    foreach ($media as $data) {
        extract($data);
        # competitionId, type, data
        $competition = getFullCompetitionInfos($competitionId);
        $timestampComp = $competition['year'] . '-' . $competition['month'] . '-' . $competition['day'];
        //noticeBox( true, "One timestamp of comp $competitionId : $timestampComp" );
        preg_match_all('/\\[ \\{ ([^}]+) } \\{ ([^}]+) } ]/x', $data, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            list($all, $text, $uri) = $match;
            #--- Polish the data.
            $text = mysqlEscape($text);
            $uri = mysqlEscape($uri);
            #      echo "<tr><td>";
            #      echo implode( "</td><td>", array( $competitionId, $type, $text, $uri ));
            #      echo "</td></tr>";
            dbCommand("\n        INSERT INTO CompetitionsMedia\n          (competitionId, type, uri, text, submitterComment, submitterEmail, submitterName, timestampSubmitted, timestampDecided, status)\n        VALUES\n          ('{$competitionId}', '{$type}', '{$uri}', '{$text}', '{$comment}', '', '', '{$timestampComp}', '{$timestampComp}', 'accepted')\n      ");
        }
    }
    #  echo "</table>";
}
function addGetChat($userN, $mes)
{
    dbQuery("INSERT INTO chat (username, message) VALUES ('{$userN}', '{$mes}')");
    $chatHistory = dbMassData("SELECT * FROM chat ORDER BY timestamp DESC LIMIT 10");
    $resp = array("status" => "success", "reason" => "chat added", "data" => $chatHistory);
    return $resp;
}
Example #22
0
function Comments_adminDelete()
{
    $id = (int) $_REQUEST['id'];
    dbQuery('delete from comments where id=' . $id);
    Core_cacheClear('comments');
    return array('status' => 1, 'id' => $id);
}
Example #23
0
 /** @inheritdoc */
 public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, \samson\activerecord\field $field)
 {
     $this->name = $field->Description != '' ? $field->Description : $field->Name;
     $this->id .= '_' . $field->Name;
     // Prepare locales array with one default locale by default
     $locales = array(null);
     // If field supports localization - set full locales array
     if ($field->local == 1) {
         $locales = SamsonLocale::$locales;
     }
     /** @var MaterialField $materialField */
     $materialField = null;
     // Iterate defined locales
     if (sizeof(SamsonLocale::$locales)) {
         foreach ($locales as $locale) {
             // Try to find existing MaterialField record
             if (!dbQuery('\\samsoncms\\api\\MaterialField')->MaterialID($entity->id)->FieldID($field->id)->locale($locale)->first($materialField)) {
                 // Create MaterialField record
                 $materialField = new \samsoncms\api\MaterialField(false);
                 $materialField->Active = 1;
                 $materialField->MaterialID = $entity->id;
                 $materialField->FieldID = $field->id;
                 $materialField->locale = $locale;
                 $materialField->save();
             }
             // Add child tab
             $this->subTabs[] = new MaterialFieldLocalized($renderer, $query, $entity, $materialField, $locale);
         }
     }
     // Call parent constructor to define all class fields
     parent::__construct($renderer, $query, $entity);
     Event::fire('samsoncms.material.materialfieldtab.created', array(&$this, $field));
 }
    function run($params)
    {
        $CI = $this->CI;
        //---
        extract($params);
        ob_start();
        //-------DATA
        if ($group == 0) {
            $group = 62;
        } else {
        }
        if (!is_array($group)) {
            $group = array($group);
        }
        $valGroup = "'" . implode("','", $group) . "'";
        if ($objId != 0) {
            $SQL = "select obj_id id, obj_group `group`\n\t\tFROM " . $CI->objProduct->table . "   \n\t\twhere `obj_group` in({$valGroup})\n\t\tand obj_id=" . $objId;
            $result = dbQuery($SQL, 1);
            $row0 = $result->row_array();
            $row = $CI->objProduct->detail($row0['id']);
            $groupData = $CI->group->detail($row0['group']);
            $catData = $CI->category->detail($row['category']);
        } else {
            $row = $groupData = $catData = array();
        }
        ?>
<table class='table table-striped table-bordered'>
		<?php 
        $ar = array('id' => $objId, 'code' => $row['code'], 'name (invoice)' => $row['name'], 'name (original)' => $row['name0'], 'detail' => nl2br($row['detail']));
        foreach ($ar as $nm => $val) {
            ?>
	 <tr>
			<td><?php 
            echo $nm;
            ?>
</td>
			<td>&nbsp;:&nbsp;</td>
			<td><?php 
            echo $val;
            ?>
</td>
	 </tr>
<?php 
        }
        ?>
		</table>
		<?php 
        $link = 'stock/input/' . $objId;
        echo anchor($link, 'Update Stock', 'class="btn btn-primary"');
        ?>
		<!--http://localhost/stock/input/{id}-->
		<?php 
        $table = ob_get_contents();
        ob_end_clean();
        $responce['body'] = $responce['result'] = $table;
        $responce['footer'] = '';
        $responce['row'] = $row;
        //---
        return $responce;
    }
function showBody($eventId)
{
    #----------------------------------------------------------------------
    #--- Get the data
    $rows = dbQuery("\n    SELECT    personId, personName, min(value1+value2+value3) minSum, count(*) means, 0 minSum2, 0 means2\n    FROM      Results\n    WHERE     eventId = '{$eventId}' and (value1>0)+(value2>0)+(value3>0) = 3\n    GROUP BY  personId\n    ORDER BY  minSum, personName\n  ");
    $also2 = $eventId == '444bf' || $eventId == '555bf';
    if ($also2) {
        $rows = array_merge($rows, dbQuery("\n      SELECT    personId, personName, 0 minSum, 0 means, min(greatest(0,value1)+greatest(0,value2)+greatest(0,value3)) minSum2, count(*) means2\n      FROM      Results\n      WHERE     eventId = '{$eventId}' and (value1>0)+(value2>0)+(value3>0) = 2\n      GROUP BY  personId\n      ORDER BY  minSum2, personName\n    "));
    }
    #--- Output the table header
    TableBegin('results', 7);
    TableHeader(array('Pos', 'Name', 'Best Mean', 'Means', $also2 ? 'Best 2-Mean' : '', $also2 ? '2-Means' : '', ''), array('class="r"', 'class="p"', 'class="r"', 'class="r"', 'class="r"', 'class="r"', 'class="f"'));
    #--- Output the table contents
    $listed = array();
    $pos = 0;
    foreach ($rows as $row) {
        list($personId, $personName, $minSum, $means, $minSum2, $means2) = $row;
        if (!isset($listed[$personId])) {
            $mean = formatValue(round($minSum / 3));
            $mean2 = formatValue(round($minSum2 / 2));
            TableRow(array(++$pos, personLink($personId, $personName), $mean, $means, $mean2, $means2, ''));
        }
        $listed[$personId] = true;
    }
    #--- Output the table end
    TableEnd();
}
function getCompetitions($sortList)
{
    #----------------------------------------------------------------------
    global $chosenEventId, $chosenRegionId, $chosenPatternMysql;
    #--- Prepare stuff for the query.
    $eventCondition = "";
    $regionCondition = "";
    $nameCondition = "";
    if ($chosenEventId) {
        $eventCondition = "AND eventSpecs REGEXP '[[:<:]]{$chosenEventId}[[:>:]]'";
    }
    $yearCondition = yearCondition();
    if ($chosenRegionId && $chosenRegionId != 'World') {
        $regionCondition = "AND (competition.countryId = '{$chosenRegionId}' OR continentId = '{$chosenRegionId}')";
    }
    #TODP: remove the 'competition.' once we get countryId out of the Results table.
    foreach (explode(' ', $chosenPatternMysql) as $namePart) {
        $nameCondition .= " AND (competition.cellName like '%{$namePart}%' OR\n                             cityName             like '%{$namePart}%' OR\n                             venue                like '%{$namePart}%')";
    }
    $orderBy = $sortList ? 'year DESC, month DESC, day DESC' : 'longitude, year, month, day';
    #--- Get data of the (matching) competitions.
    $competitions = dbQuery("\n    SELECT DISTINCT\n      competition.*,\n      country.name AS countryName\n    FROM\n      Competitions competition,\n      Countries    country\n    WHERE 1\n      AND country.id = countryId\n      AND showAtAll = 1\n      {$eventCondition}\n      {$yearCondition}\n      {$regionCondition}\n      {$nameCondition}\n    ORDER BY\n      {$orderBy}\n  ");
    #--- Return them
    return $competitions;
}
 /** @inheritdoc */
 public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, Navigation $structure)
 {
     $this->name = $structure->Name;
     $this->id .= $structure->Url != '' ? '_' . $structure->Url : '_' . $structure->Name;
     $this->structure = $structure;
     // Get data about current tab
     $fieldWithMaterialCount = dbQuery('structurefield')->join('field')->cond('StructureID', $this->structure->id)->cond('field_Type', 6)->count();
     $localizedFieldsCount = dbQuery('structurefield')->join('field')->cond('StructureID', $this->structure->id)->cond('field_local', 1)->count();
     // If in this tab exists only material type field or don't exists localized fields
     if ($fieldWithMaterialCount > 0 || $localizedFieldsCount == 0) {
         // Create default sub tab
         $this->subTabs[] = new MaterialTableLocalized($renderer, $query, $entity, $structure, '');
         // If in this tab exists not material type fields and this fields localized then include their
     } else {
         //if (($fieldWithMaterialCount == 0) && ($localizedFieldsCount > 0))
         // Iterate available locales if we have localized fields
         foreach (SamsonLocale::$locales as $locale) {
             // Create child tab
             $subTab = new MaterialTableLocalized($renderer, $query, $entity, $structure, $locale);
             $this->subTabs[] = $subTab;
         }
     }
     // Call parent constructor to define all class fields
     parent::__construct($renderer, $query, $entity);
 }
Example #28
0
function getSubCustomers($customer_id)
{
    $domain_id = domain_id::get();
    $sql = "SELECT * FROM " . TB_PREFIX . "customers\n          WHERE parent_customer_id = :customer_id\n          AND domain_id = :domain_id";
    $sth = dbQuery($sql, ':customer_id', $customer_id, ':domain_id', $domain_id);
    return $sth->fetchAll();
}
Example #29
0
function getPrices()
{
    $data = array();
    $rData = array();
    //$startDate = "2012-01-01";
    $theDate = date('Y-m-d');
    //echo($theDate);
    //echo("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9");
    $info = file_get_contents("https://www.bitstamp.net/api/ticker/");
    $tInfo = json_decode($info, true);
    $data = $tInfo;
    $high = floatval($data['high']);
    $low = floatval($data['low']);
    $volume = floatval($data['volume']);
    $ask = floatval($data['ask']);
    $bid = floatval($data['bid']);
    $current = floatval($data['last']);
    dbQuery("INSERT INTO minuteCoin ( high, low,  volume, ask, bid, current, tDate) VALUES ({$high}, {$low}, {$volume}, {$ask}, {$bid}, {$current}, '{$theDate}')");
    echo "INSERT INTO minuteCoin ( high, low,  volume, ask, bid, current, tDate) VALUES ({$high}, {$low}, {$volume}, {$ask}, {$bid}, {$current}, '{$theDate}')";
    $cex = file_get_contents("https://cex.io/api/ticker/BTC/USD");
    $tInfo1 = json_decode($cex, true);
    $cexPrice = floatval($tInfo1['last']);
    $cexLow = floatval($tInfo1['low']);
    $cexHigh = floatval($tInfo1['high']);
    $cexBid = floatval($tInfo1['bid']);
    $cexAsk = floatval($tInfo1['ask']);
    dbQuery("INSERT INTO minuteCEX ( current, high, low,  bid, ask, tDate) VALUES ({$cexPrice}, {$cexHigh}, {$cexLow}, {$cexBid}, {$cexAsk}, '{$theDate}')");
    echo "INSERT INTO minuteCEX ( current, high, low,  bid, ask, tDate) VALUES ({$cexPrice}, {$cexHigh}, {$cexLow}, {$cexBid}, {$cexAsk}, '{$theDate}')";
    //return true
    return $rData;
}
Example #30
0
 function getInvoiceItems($id)
 {
     $sql = "SELECT * FROM " . TB_PREFIX . "invoice_items WHERE invoice_id = :id";
     $sth = dbQuery($sql, ':id', $id);
     $invoiceItems = null;
     for ($i = 0; $invoiceItem = $sth->fetch(); $i++) {
         $invoiceItem['quantity'] = $invoiceItem['quantity'];
         $invoiceItem['unit_price'] = $invoiceItem['unit_price'];
         $invoiceItem['tax_amount'] = $invoiceItem['tax_amount'];
         $invoiceItem['gross_total'] = $invoiceItem['gross_total'];
         $invoiceItem['total'] = $invoiceItem['total'];
         $sql = "SELECT * FROM " . TB_PREFIX . "products WHERE id = :id";
         $tth = dbQuery($sql, ':id', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['product'] = $tth->fetch();
         $attr_sql = "select \n                    CONCAT(a.display_name, '-',v.value) as display\n                from\n                    si_products_attributes a,\n                    si_products_values v\n                where\n                    a.id = v.attribute_id \n                    and\n                    v.id = :attr_id";
         $attr1 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_1']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr1'] = $attr1->fetch();
         $attr2 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_2']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr2'] = $attr2->fetch();
         $attr3 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_3']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr3'] = $attr3->fetch();
         $invoiceItems[$i] = $invoiceItem;
     }
     return $invoiceItems;
 }