Intial revision.
This commit is contained in:
commit
f87492d73e
19 changed files with 607 additions and 0 deletions
12
modules/admin.php
Normal file
12
modules/admin.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
class admin extends Module
|
||||
{
|
||||
protected $authentication = true;
|
||||
|
||||
public function __default() {
|
||||
$this->setPublic('messages', $this->db->getArray('SELECT * FROM incoming ORDER BY received_at'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
26
modules/expunge.php
Normal file
26
modules/expunge.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
class expunge extends admin
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
$this->db->execute('DELETE FROM incoming WHERE id = "' . $_REQUEST['id'] . '";');
|
||||
|
||||
$path = getcwd() . '/../incoming/' . $_REQUEST['id'] . '/';
|
||||
$files = scandir($path);
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
unlink($path . $file);
|
||||
}
|
||||
}
|
||||
|
||||
rmdir($path);
|
||||
|
||||
header('Location: /admin');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
18
modules/file.php
Normal file
18
modules/file.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
class file extends admin
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
$path = getcwd() . '/../incoming/' . $_REQUEST['id'] . '/';
|
||||
$files = scandir($path);
|
||||
$file = $path . $files[2];
|
||||
|
||||
header('Content-Type: ' . mime_content_type($file));
|
||||
$handle = fopen($file, 'rb');
|
||||
fpassthru($handle);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
11
modules/home.php
Normal file
11
modules/home.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class home extends Module
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
header('Location: http://parkmuch.com');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
28
modules/message.php
Normal file
28
modules/message.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
class message extends admin
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
$message = $this->db->getRow('SELECT * FROM incoming WHERE id = "' . $_REQUEST['id'] . '";');
|
||||
$path = getcwd() . '/../incoming/' . $_REQUEST['id'] . '/';
|
||||
$files = scandir($path);
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
$filename = $path . $file;
|
||||
}
|
||||
}
|
||||
|
||||
$size = @getimagesize($filename);
|
||||
|
||||
$message['attachment'] = $files[2];
|
||||
$message['details'] = $size;
|
||||
|
||||
$this->setPublic('message', $message);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
11
modules/post.php
Normal file
11
modules/post.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class post extends message
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
parent::__default();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
61
modules/promote.php
Normal file
61
modules/promote.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
class promote extends expunge
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
// Inserts the post into the database as a draft
|
||||
$data = array(
|
||||
'post_author' => '1',
|
||||
'post_date' => date('Y-m-d H:i:s'),
|
||||
'post_date_gmt' => gmdate('Y-m-d H:i:s'),
|
||||
'post_title' => $_REQUEST['title'],
|
||||
'post_status' => 'draft',
|
||||
'post_name' => str_replace(' ' , '-', strtolower($_REQUEST['title'])),
|
||||
'post_modified' => date('Y-m-d H:i:s'),
|
||||
'post_modified_gmt' => gmdate('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
$id = $this->db->insert('wp_posts', $data);
|
||||
|
||||
// Finds the image and extract the extension
|
||||
$path = getcwd() . '/../incoming/' . $_REQUEST['id'] . '/';
|
||||
$files = scandir($path);
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
$filename = $path . $file;
|
||||
$parts = explode('.', $file);
|
||||
end($parts);
|
||||
$extension = current($parts);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates the directory for the image and moves the original
|
||||
$public_path = '/submissions/' . date('Y/m/') . $id . '/';
|
||||
$new_path = getcwd() . $public_path;
|
||||
$original = $new_path . 'original' . $extension;
|
||||
mkdir($new_path, 0777, true);
|
||||
copy($filename, $original);
|
||||
|
||||
// Scales the image down to 500px wide
|
||||
$thumb = new Imagick($original);
|
||||
$thumb->thumbnailImage(500, 500, true);
|
||||
$thumb->writeImage($new_path . 'scaled_500.' . $extension);
|
||||
|
||||
// Updates the post content and marks it as published
|
||||
$data = array(
|
||||
'post_content' => '<img src="http://images.parkmuch.com' . $public_path . 'scaled_500.' . $extension . '" /><br /><br />' . $_REQUEST['content'],
|
||||
'post_status' => 'publish',
|
||||
'guid' => 'http://parkmuch.com/?p=' . $id
|
||||
);
|
||||
$this->db->update('wp_posts', $data, array('ID' => $id));
|
||||
|
||||
// Expunges the data
|
||||
parent::__default();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue