Reformat functions
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
-- Creates the users table
|
||||
CREATE TABLE users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
uniqueid VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
8
db.php
8
db.php
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
function getConnection() {
|
||||
$host = '127.0.0.1'; // Force TCP/IP, avoids socket issues
|
||||
$port = 3306; // XAMPP default port
|
||||
$host = 'localhost';
|
||||
$port = 3306;
|
||||
$db = 'ai_email';
|
||||
$user = 'root';
|
||||
$pass = ''; // XAMPP default has no password
|
||||
$user = 'aimail';
|
||||
$pass = 'Test123';
|
||||
$charset = 'utf8mb4';
|
||||
|
||||
$dsn = "mysql:host=$host;port=$port;dbname=$db;charset=$charset";
|
||||
|
||||
61
home.php
61
home.php
@@ -6,6 +6,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php');
|
||||
$conn = getConnection();
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/php/resources.php'); // load languages
|
||||
?>
|
||||
|
||||
<body>
|
||||
@@ -15,8 +16,7 @@ include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
<h2 class="logo">📧 AI Email</h2>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/inc/php/generate.php">✍️ Generate</a></li>
|
||||
<li><a href="/saved_emails.php">💾 Saved Emails</a></li>
|
||||
<li><a href="/home.php">✍️ Generate</a></li>
|
||||
<li><a href="/settings.php">⚙️ Settings</a></li>
|
||||
<li><a href="/logout.php">🚪 Logout</a></li>
|
||||
</ul>
|
||||
@@ -28,44 +28,33 @@ include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
<header>
|
||||
<h1>Welcome to AI Email Generator</h1>
|
||||
<p>Effortlessly craft polished, professional emails in seconds.</p>
|
||||
<button id="darkModeBtn">🌙 Toggle Dark Mode</button>
|
||||
</header>
|
||||
|
||||
<section class="quick-actions">
|
||||
<h2>⚡ Quick Actions</h2>
|
||||
<div class="actions">
|
||||
<a href="/inc/php/generate.php"><button>Start Generating Emails</button></a>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="container">
|
||||
<!-- adjust action depending on vhost/subfolder -->
|
||||
<form action="/process.php" method="POST">
|
||||
<label for="email_input">Your rough text:</label><br>
|
||||
<textarea name="email_input" rows="6" cols="50" required></textarea><br><br>
|
||||
|
||||
<section class="connected-accounts">
|
||||
<h2>📧 Connected Accounts</h2>
|
||||
<p>Link your email provider to read & send directly:</p>
|
||||
<div class="connect-buttons">
|
||||
<a href="/connect/gmail.php"><button>Connect Gmail</button></a>
|
||||
<a href="/connect/outlook.php"><button>Connect Outlook</button></a>
|
||||
<a href="/connect/imap.php"><button>Other (IMAP/SMTP)</button></a>
|
||||
</div>
|
||||
</section>
|
||||
<label for="tone">Select tone:</label>
|
||||
<select name="tone" required>
|
||||
<option value="formal">Formal</option>
|
||||
<option value="casual">Casual</option>
|
||||
<option value="persuasive">Persuasive</option>
|
||||
<option value="angry">Angry</option>
|
||||
</select><br><br>
|
||||
|
||||
<section class="inbox">
|
||||
<h2>📥 Inbox</h2>
|
||||
<p>(This will show your connected emails once integration is done)</p>
|
||||
<table>
|
||||
<tr><th>From</th><th>Subject</th><th>Date</th><th>Action</th></tr>
|
||||
<tr>
|
||||
<td>Alice</td>
|
||||
<td>Hello about our meeting</td>
|
||||
<td>2025-08-20</td>
|
||||
<td><a href="/inbox/view.php?id=1"><button>View</button></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bob</td>
|
||||
<td>Invoice Reminder</td>
|
||||
<td>2025-08-19</td>
|
||||
<td><a href="/inbox/view.php?id=2"><button>View</button></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<label for="language">Language:</label>
|
||||
<select name="language" required>
|
||||
<?php foreach (getLanguages() as $lang): ?>
|
||||
<option value="<?= htmlspecialchars($lang) ?>"><?= htmlspecialchars($lang) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select><br><br>
|
||||
|
||||
<button type="submit">Generate Email</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,6 @@ form, .email-output {
|
||||
padding: 25px;
|
||||
background-color: #ffffff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 20px;
|
||||
transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
@@ -178,6 +177,19 @@ button + button {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.auth-box input{
|
||||
padding: 8px 12px;
|
||||
border-radius:4px;
|
||||
outline:none;
|
||||
border: 1px solid #c7c7c7;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.auth-box input:focus{
|
||||
box-shadow: 0px 0px 5px -1px #007bff;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
/* Navbar styling */
|
||||
.navbar {
|
||||
display: flex;
|
||||
@@ -187,6 +199,7 @@ button + button {
|
||||
padding: 15px 30px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.navbar .logo {
|
||||
|
||||
@@ -18,6 +18,7 @@ include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
<option value="formal">Formal</option>
|
||||
<option value="casual">Casual</option>
|
||||
<option value="persuasive">Persuasive</option>
|
||||
<option value="angry">Angry</option>
|
||||
</select><br><br>
|
||||
|
||||
<label for="language">Language:</label>
|
||||
|
||||
@@ -36,7 +36,7 @@ include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
<label for="login_password">Password</label>
|
||||
<input type="password" name="login_password" required>
|
||||
|
||||
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
|
||||
<div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div>
|
||||
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
@@ -69,7 +69,7 @@ include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
max="<?php echo date('Y-m-d'); ?>">
|
||||
|
||||
|
||||
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
|
||||
<div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div>
|
||||
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
header('Location: landing.php');
|
||||
exit;
|
||||
@@ -24,6 +24,7 @@ $user_id = $_SESSION['user_id'] ?? null;
|
||||
'formal' => 'Write this email in a formal tone',
|
||||
'casual' => 'Write this email in a casual tone',
|
||||
'persuasive' => 'Write this email in a persuasive tone',
|
||||
'angry' => 'Write this email in a angry but yet formal tone',
|
||||
];
|
||||
|
||||
if (empty($emailInput) || !isset($allowedTones[$tone])) {
|
||||
@@ -73,14 +74,11 @@ $user_id = $_SESSION['user_id'] ?? null;
|
||||
echo "<button id='copyBtn'>Copy Email</button>";
|
||||
echo "<button id='saveBtn'>Save Email as .txt</button>";
|
||||
echo "<a href='/home.php'><button>🏠 Back to Home</button></a>";
|
||||
echo "<a href='/inc/php/generate.php' class='back-link'>← Generate Another Email</a>";
|
||||
|
||||
// NEW: Save to DB form
|
||||
if ($user_id) {
|
||||
echo "<form method='POST' action='/inc/php/save_email.php' style='margin-top:15px;'>";
|
||||
echo "<input type='hidden' name='email_body' value=\"" . htmlspecialchars($aiEmail, ENT_QUOTES) . "\">";
|
||||
echo "<input type='text' name='subject' placeholder='Subject (optional)'>";
|
||||
echo "<button type='submit'>💾 Save to My Account</button>";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
|
||||
29
settings.php
Normal file
29
settings.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/php/auth.php');
|
||||
requireLogin(); // only logged-in users can pass
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php');
|
||||
$conn = getConnection();
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="dashboard">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<h2 class="logo">📧 AI Email</h2>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/home.php">✍️ Generate</a></li>
|
||||
<li><a href="/settings.php">⚙️ Settings</a></li>
|
||||
<li><a href="/logout.php">🚪 Logout</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<header>
|
||||
<h1>Settings</h1>
|
||||
</header>
|
||||
Reference in New Issue
Block a user