mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 12:31:06 -05:00
commit
50c7ab7e80
@ -60,6 +60,8 @@ $route['spamadmin/blacklist/(:num)'] = 'spamadmin/blacklist';
|
||||
$route['spamadmin/blacklist'] = 'spamadmin/blacklist';
|
||||
$route['spamadmin/:any'] = 'spamadmin/spam_detail';
|
||||
$route['about'] = 'main/about';
|
||||
$route['api/paste/:any'] = 'api/paste';
|
||||
$route['api/random'] = 'api/random_paste';
|
||||
|
||||
$route['iphone/:num'] = 'iphone';
|
||||
$route['iphone/view/:any'] = 'iphone/view';
|
||||
|
@ -54,4 +54,36 @@ class Api extends Main
|
||||
$this->load->view('view/api', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function paste()
|
||||
{
|
||||
$this->load->model('pastes');
|
||||
$check = $this->pastes->checkPaste(3);
|
||||
|
||||
if ($check)
|
||||
{
|
||||
$data = $this->pastes->getPaste(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array(
|
||||
'message' => 'Not found',
|
||||
);
|
||||
}
|
||||
echo stripslashes(json_encode($data));
|
||||
}
|
||||
|
||||
function random_paste()
|
||||
{
|
||||
$this->load->model('pastes');
|
||||
$data = $this->pastes->random_paste();
|
||||
|
||||
if (!$data)
|
||||
{
|
||||
$data = array(
|
||||
'message' => 'Please try again',
|
||||
);
|
||||
}
|
||||
echo stripslashes(json_encode($data));
|
||||
}
|
||||
}
|
||||
|
@ -488,4 +488,57 @@ class Pastes extends CI_Model
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function random_paste()
|
||||
{
|
||||
$this->load->library('process');
|
||||
|
||||
$paste_id = rand(1, $this->countPastes());
|
||||
$this->db->where('id', $paste_id);
|
||||
$query = $this->db->get('pastes');
|
||||
|
||||
if ($query->num_rows() > 0)
|
||||
{
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
$data['title'] = $row['title'];
|
||||
$data['pid'] = $row['pid'];
|
||||
$data['name'] = $row['name'];
|
||||
$data['lang_code'] = $row['lang'];
|
||||
$data['lang'] = $this->languages->code_to_description($row['lang']);
|
||||
$data['paste'] = $this->process->syntax(htmlspecialchars_decode($row['raw']) , $row['lang']);
|
||||
$data['created'] = $row['created'];
|
||||
$data['url'] = $this->_get_url($row['pid']);
|
||||
$data['raw'] = $row['raw'];
|
||||
$data['hits'] = $row['hits'];
|
||||
$data['hits_updated'] = $row['hits_updated'];
|
||||
$data['snipurl'] = $row['snipurl'];
|
||||
$inreply = $row['replyto'];
|
||||
}
|
||||
|
||||
if ($inreply)
|
||||
{
|
||||
$this->db->select('name, title');
|
||||
$this->db->where('pid', $inreply);
|
||||
$query = $this->db->get('pastes');
|
||||
|
||||
if ($query->num_rows() > 0)
|
||||
{
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
$data['inreply']['title'] = $row['title'];
|
||||
$data['inreply']['name'] = $row['name'];
|
||||
$data['inreply']['url'] = site_url('view/' . $inreply);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['inreply'] = false;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user