Skip to content

Instantly share code, notes, and snippets.

View MissAllSunday's full-sized avatar

Michel Mendiola MissAllSunday

  • Ohara
  • CDMX
View GitHub Profile
protected function returnResponse()
{
global $modSettings;
// kill anything else
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@ob_start('ob_gzhandler');
filter: function(query, data, search_key) {
var _this = this;
return $.map(data, function(item, i) {
var name;
name = $.isPlainObject(item) ? item[search_key] : item;
if (name.toLowerCase().indexOf(query) >= 0) {
return item;
}
});
},
// Doctrine
$sql = "SELECT * FROM articles WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bindValue(1, $id);
$stmt->execute();
// SMF
$result = $this->_smcFunc['db_query']('', '
SELECT *
FROM articles
@MissAllSunday
MissAllSunday / gist:5554848
Created May 10, 2013 14:44
check API status
protected function getAPIStatus()
{
$apiUrl = 'https://status.github.com/api/status.json';
$check = json_decode($this->fetch_web_data($apiUrl));
if (empty($check))
return false;
if (!empty($check) && is_object($check))
before:
throw new RuntimeException(isset($content['message']) ? $content['message'] : $content, $response->getStatusCode());
now:
try
{
throw new RuntimeException(isset($content['message']) ? $content['message'] : $content, $response->getStatusCode());
}
@MissAllSunday
MissAllSunday / gist:5767907
Created June 12, 2013 18:38
Show an image on a submenu entry
// This is the normal code
function RateStats_menu(&$menu_buttons)
{
global $scripturl, $modSettings, $txt;
loadLanguage('RateStats');
$menu_buttons['profile']['sub_buttons']['rateStats'] = array(
'title' => !empty($modSettings['RateStats_menu_name']) ? $modSettings['RateStats_menu_name'] : $txt['RateStats_title_main'],
Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE b.id_board IN (2)
AND bp.id_group IN (2, 4, 3)
AND bp.permission ' at line 6
SELECT MIN(bp.add_deny) AS add_deny
FROM smf_boards AS b
INNER JOIN smf_board_permissions AS bp ON (bp.id_profile = b.id_profile)
LEFT JOIN smf_moderators AS mods ON (mods.id_board = b.id_board AND mods.id_member = 2)
LEFT JOIN smf_moderator_groups AS modgs ON (modgs.id_board = b.id_board AND b.id_group IN (2, 4)
<?php
if ($enable_only)
$query = '
SELECT th.value, th.variable, th2.id_theme, th2.variable, th2.value
FROM {db_prefix}themes AS th
INNER JOIN {db_prefix}themes AS th2 ON (th2.id_theme = th.id_theme
AND th2.variable IN ({string:theme_dir}, {string:theme_url}, {string:images_url}, {string:name}, {string:theme_layers}, {string:theme_templates}, {string:version}, {string:install_for}, {string:based_on}, {string:enable}))
WHERE th.variable = {string:enable}
AND th.value = 1
<?php
function get_all_themes($enable_only = false)
{
global $modSettings, $context, $smcFunc;
// Make our known themes a little easier to work with.
$knownThemes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
// All of them or just the enable ones? each will have a pretty different query.
<?php
foreach ($array as $var => $val)
$inserts[] = array($userID, $var, $val);
if (!empty($inserts))
$this->_smcFunc['db_insert']('replace',
'{db_prefix}' . ($this->_tables['options']['table']),
array('member_id' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
$inserts,