Esempio n. 1
0
 static function submit()
 {
     // store data posted by the form in the session so it
     // is still available in case of redirection to the same form
     $_SESSION['activation_editmap'] = $_POST;
     // retrieve model instance
     $model = ActivationModel::getInstance();
     // save or create the record
     $result = $model->save($_POST);
     $code = substr($result, 0, 2);
     if ($code == "OK") {
         $newRecord = $_POST['id'] == 0;
         // if this was a new record, show only this record in the list
         // if this was an existing record, keep the previous filter
         if ($newRecord) {
             $newId = substr($result, 2, strlen($result) - 2);
             $filter = "id=" . $newId;
         } else {
             $filter = $_SESSION['last_activations_filter'];
         }
         // redirect to the list
         ActivationsController::listRows($filter);
     } else {
         // redirect to the edit page with error message
         $result = str_replace("\n", "<br>", $result);
         // no newlines in headers!
         header("Location: activation_edit.php?error=" . $result);
     }
 }
Esempio n. 2
0
function ensureactivation($headers)
{
    $success = false;
    // retrieve informations from header
    $unique_id = $headers['Uniqueid'];
    $producer_id = $headers['Producerid'];
    $app_name = $headers['Appname'];
    $tracking_only = $headers['Trackingonly'];
    $device_info = $headers['Deviceinfo'];
    $conn = getConnection();
    // search the Activation record by $unique_id
    $query = "SELECT id FROM activation\n\tWHERE uniqueid = '{$unique_id}'";
    $resource = mysqli_query($conn, $query);
    if (mysqli_num_rows($resource) > 0) {
        $row = mysqli_fetch_array($resource);
        $id = $row['id'];
    }
    if ($id > 0) {
        $success = true;
    } else {
        $map = array();
        if (isset($unique_id)) {
            $map['uniqueid'] = $unique_id;
        }
        if (isset($producer_id)) {
            $map['producer_id'] = $producer_id;
        }
        if (isset($app_name)) {
            $map['app_name'] = $app_name;
        }
        if (isset($tracking_only)) {
            $map['tracking_only'] = $tracking_only;
        }
        if (isset($device_info)) {
            $map['device_info'] = $device_info;
        }
        include_once 'model.php';
        $model = new ActivationModel();
        $result = $model->save($map);
        $code = substr($result, 0, 2);
        if ($code == "OK") {
            $success = true;
        }
    }
    unset($conn);
    // set success header
    if ($success) {
        header('success: true');
    } else {
        header('success: false');
    }
}
Esempio n. 3
0
         // clear the last filter session variable (but don't unset it)
         $_SESSION['last_activations_filter'] = "";
     }
     // reset button was pressed
     if (isset($map['reset'])) {
         // clear the search map stored in the session
         unset($_SESSION['activation_search_map']);
         // retrieve the last filter from the session
         $filter = $_SESSION['last_activations_filter'];
     }
     // search button was pressed
     if (isset($map['search'])) {
         // store search data in the session
         $_SESSION['activation_search_map'] = $map;
         // create a filter
         $filter = ActivationModel::createFilter($map);
         // store the last filter in the session
         $_SESSION['last_activations_filter'] = $filter;
     }
     // list the rows using the filter
     ActivationsController::listRows($filter);
     break;
     // toggle the search box visibility
 // toggle the search box visibility
 case 'togglesearch':
     // invert the session variable
     if ($_SESSION['hide_activation_searchbox'] == "false") {
         $_SESSION['hide_activation_searchbox'] = "true";
     } else {
         $_SESSION['hide_activation_searchbox'] = "false";
     }
Esempio n. 4
0
function counterString()
{
    // rows to be listed
    $datamap = $_SESSION['activation_datamap'];
    $partial = count($datamap);
    // total rows
    include_once 'model.php';
    $model = ActivationModel::getInstance();
    $total = $model->countRows();
    // display counter
    $string = $partial . " of " . $total . " records";
    return $string;
}