Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/devfemibadmus/ebrc-php

This repository houses the server side for the ebrc-flutter (UI/UX). This app is design basically for tutorials about streaming data from Api and running admob
https://github.com/devfemibadmus/ebrc-php

php php-flutter phpmyadmin

Last synced: about 7 hours ago
JSON representation

This repository houses the server side for the ebrc-flutter (UI/UX). This app is design basically for tutorials about streaming data from Api and running admob

Awesome Lists containing this project

README

        

# EBRC App - PHP Backend Repository


This repository houses the server side for the [ebrc-flutter](https://github.com/devfemibadmus/ebrc-flutter) (UI/UX). This app is design basically to watch ads and make money.


**ADVANTAGES OF WATCHING ADS ON EBRC AND MINIMIZING COSTS**


1. **Monetize Your Time:**

- Users can turn their time into valuable rewards by watching ads on [App Name], creating an opportunity to earn money.

2. **Receive Regular Updates:**

- Stay informed about the latest news, trends, and updates while watching ads, enhancing users' knowledge and awareness.

3. **Entertainment Rewards:**

- Enjoy entertainment while earning rewards; users can watch ads and receive incentives for their time spent on the app.

4. **Cost Minimization with Free Data Bonuses:**

- Users can maximize their benefits by utilizing free data bonuses from their Internet Service Provider (ISP) to watch ads, minimizing data costs.

5. **Optimize Costs with Cheap Night Browsing:**

- Take advantage of cost-effective night browsing options to watch ads during off-peak hours, ensuring users maximize their rewards efficiently.

7. **Reward Flexibility:**

- The reward system offers flexibility, allowing users to choose from a variety of options such as cash, gift cards, or discounts based on their preferences.

9. **Seamless Redemption Process:**

- Enjoy a hassle-free redemption process within the app, making it easy for users to claim their rewards and enjoy the fruits of their engagement.

9. **Diversify Earnings:**

- Users can diversify their earnings by engaging with different types of ads, ensuring a dynamic and rewarding experience.

[![Download on Google Play](https://cloud.githubusercontent.com/assets/5692567/10923351/6b688a92-8278-11e5-9973-8ffbf3c5cc52.png)](https://play.google.com/store/apps/details?id=com.blackstackhub.ebrc)

## PHP (code review).

1. **Database Configuration**
- (config/database.php)
```php
conn = null;
try {
// Connect to your database
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->db_name;
$this->conn = new PDO($dsn, $this->username, $this->password);

// Set PDO attributes
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

// Create tables if they do not exist
$this->createAccountsTable();
$this->createNotificationsTable();

return $this->conn;
} catch (PDOException $exception) {
$response = array(
"status" => "error",
"message" => $exception->getMessage(),
);
header("Content-Type: application/json; charset=UTF-8");
echo json_encode($response);
}
return $this->conn;
}

// method to create the accounts table if it does not exist
private function createAccountsTable() {
$sql = "
CREATE TABLE IF NOT EXISTS accounts (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255),
referral VARCHAR(255),
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
paidReferral VARCHAR(255),
accountName VARCHAR(255),
accountUname VARCHAR(255),
accountNumber INT DEFAULT 0,
accountBalance DECIMAL(10, 2) DEFAULT 0.00,
earnBalance DECIMAL(10, 2) DEFAULT 0.00,
accountEditable TINYINT(1) DEFAULT 1,
coinBalance INT DEFAULT 0,
pendingCashout TINYINT(1) DEFAULT 0,
cashoutAmount DECIMAL(10, 2) DEFAULT 0.00
);
";

$this->conn->exec($sql);
}

// method to create the notifications table if it does not exist
private function createNotificationsTable() {
$sql = "
CREATE TABLE IF NOT EXISTS notifications (
id INT AUTO_INCREMENT PRIMARY KEY,
date TIMESTAMP NOT NULL,
type VARCHAR(255) NOT NULL,
amount DECIMAL(10, 2) DEFAULT 0.00,
referral VARCHAR(255),
comment TEXT,
accountId INT NOT NULL
);
";

$this->conn->exec($sql);
}
}

```

2. **Path Configuration**
- (.htaccess)
```php
# Enable symbolic links for the specified directory
Options +FollowSymLinks

# Enable the Apache mod_rewrite engine
RewriteEngine On

# Disable directory listing (indexes)
Options -Indexes

# Custom error document for 403 Forbidden error
ErrorDocument 403 https://github.com/devfemibadmus/ebrc-php

# Check if the requested URL does not point to an existing file
RewriteCond %{REQUEST_FILENAME} !-f

# Check if the requested URL does not point to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite the URL to index.php and pass the path as a parameter
RewriteRule ^(.*)$ index.php?path=$1 [L,QSA]

```

3. **Url routing(including static files)**
- (index.php)

```php
getConnection();

// Create instances of Account and Notifications classes
$account = new Account($db);
$notifications = new Notifications($db);

// Decode the JSON data received from the client-side form
$_POST = json_decode(file_get_contents("php://input"), true);

// Check if username and password are provided in the POST data
if (empty($_POST['username']) || empty($_POST['password'])) {
// If not provided, return an error response
$response = array(
"status" => "error",
"message" => "Username and password are required"
);
header("Content-Type: application/json; charset=UTF-8");
echo json_encode($response, JSON_NUMERIC_CHECK);
exit;
}

// Set the username and password from the POST data
$account->username = $_POST['username'];
$account->password = $_POST['password'];

// Attempt to sign in by calling the 'signin' method of the Account class
$stmt = $account->signin();

// Check if sign-in was successful
if ($stmt != false) {
// If successful, retrieve notifications for the signed-in user
$list = $notifications->listNotifications($stmt['id']);
// Prepare a success response with account information and notifications
$response = array(
"status" => "success",
"message" => "Sign in successful",
"account" => $stmt,
"notifications" => $list
);
} else {
// If sign-in was not successful, return an error response
$response = array(
"status" => "error",
"message" => $stmt
);
}

// Set the response header and echo the JSON-encoded response
header("Content-Type: application/json");
echo json_encode($response, JSON_NUMERIC_CHECK);

```

[![Download on Google Play](https://cloud.githubusercontent.com/assets/5692567/10923351/6b688a92-8278-11e5-9973-8ffbf3c5cc52.png)](https://play.google.com/store/apps/details?id=com.blackstackhub.ebrc)

![working terminal](readme/Screenshot%20(1118).png?raw=true)