function msg($arg) { echo Pre($arg); }
public function SyncCategories($categories) { if (!is_array($categories)) { $categories[] = $categories; } Pre($categories); // Get all the items in the database $in_categories = $this->Category()->Items(); Pre($in_categories); // If the item is not in the DB already add them foreach ($categories as $category) { if (!in_array($category, $in_categories)) { Pre($category); } } // If the item is not in the new list remove it // Return the count of items now associated }
d('API_KEY', $_SESSION['api_mode'] == 'dev' ? 'bcppxparnj' : 'vnjjhwwtrp'); // i.wayne.edu // Include the API include_once ROOT . '/lib/phpcms/phpcms.php'; include_once ROOT . '/lib/functions.php'; // Initialize the API $c = new Phpcms(API_KEY, MODE); $c->debug = false; //$c->parser = 'raw'; //$c->sendRequest('api/information/version', 'get'); //Pre($c); // If trying to login if (isset($_POST['accessid']) && isset($_POST['password'])) { $login_credentials = array('accessid' => strtolower($_POST['accessid']), 'password' => $_POST['password']); $login_response = $c->sendRequest('api/user/auth', $login_credentials, 'post', true); Pre($login_response); // Store the session ID in the session if (isset($login_response['response']['auth']['sessionid'])) { $_SESSION['sessionid'] = $login_response['response']['auth']['sessionid']; // Get the users information $user_details = $c->sendRequest('api/user/info', array('accessid' => $_POST['accessid'])); // Save the basic information about this user $_SESSION['user_details'] = $user_details['response']['user']; // Set the user message Flash('Welcome back ' . $_SESSION['user_details']['first_name'] . '!', 'success'); } else { // Set the user error message Flash('Incorrect AccessID/password. Please try again', 'error'); } //Pre($login_response); }
define('ROOT', dirname(__FILE__)); include_once ROOT . '/lib/define.php'; // oAuth stuff include_once ROOT . '/lib/themattharris/tmhOAuth.php'; include_once ROOT . '/lib/themattharris/tmhUtilities.php'; // Page stuff $page_title = 'Stats'; $page_url = $_SERVER['PHP_SELF']; // Get a list of all the account this user has access to $stats_params = array('utm_campaign' => 'social'); $stats_response = $c->sendRequest('go/url/listing', $stats_params, 'get'); include_once ROOT . '/_header.php'; ?> <div class="row-fluid" id="content"> <form accept-charset="UTF-8" action="" method="post"> <div class="span12"> <div class="list-view"> <div class="list-header well"> <h2>Recent URL's</h2> </div> <?php Pre($stats_response['response']['urls']); ?> </div> </div> </form> </div> <?php include_once ROOT . '/_footer.php';
$page_css = array(PATH . 'vendor/datepicker/css/datepicker.css', PATH . 'vendor/timepicker/css/timepicker.css'); $page_js = array(PATH . 'vendor/datepicker/js/bootstrap-datepicker.js', PATH . 'vendor/timepicker/js/bootstrap-timepicker.js'); // If submitting a new tweet if (isset($_POST) && count($_POST) > 0) { // Make sure there is an account selected if (array_key_exists('from_account', $_POST) && is_array($_POST['from_account'])) { foreach ($_POST['from_account'] as $account) { Pre($account); $date_scheduled = date('Y-m-d H:i:s', strtotime($_POST['tweet-date'] . ' ' . $_POST['tweet-time'])); // Create the params array $tweet_params = array('message' => $_POST['new_message'], 'account_id' => $account, 'user_id' => $_SESSION['user_details']['user_id'], 'date_scheduled' => $date_scheduled); Pre($tweet_params); // Get a list of all the account this user has access to $tweet_status[] = $c->sendRequest('socialy/tweet/schedule', $tweet_params, 'post'); } Pre($tweet_status); foreach ($tweet_status as $tweeted) { if (array_key_exists('error', $tweeted['response'])) { Flash('Error posting to [account name].', 'error'); } else { Flash('Successfully tweeted from [account name] account.'); } } } else { Flash('Please select an account.', 'error'); } } // Get a list of all the account this user has access to $account_list = $c->sendRequest('socialy/account/access', array(), 'get'); include_once ROOT . '/_header.php'; ?>
function access_token($tmhOAuth) { global $c; $params = uri_params(); if ($params['oauth_token'] !== $_SESSION['oauth']['oauth_token']) { Flash('The oauth token you started with doesn\'t match the one you\'ve been redirected with. do you have multiple tabs open?'); unset($_SESSION['oauth']); //session_unset(); return; } if (!isset($params['oauth_verifier'])) { Flash('The oauth verifier is missing so we cannot continue. did you deny the appliction access?'); unset($_SESSION['oauth']); //session_unset(); return; } // update with the temporary token and secret $tmhOAuth->reconfigure(array_merge($tmhOAuth->config, array('token' => $_SESSION['oauth']['oauth_token'], 'secret' => $_SESSION['oauth']['oauth_token_secret']))); $code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('oauth/access_token', ''), 'params' => array('oauth_verifier' => trim($params['oauth_verifier'])))); if ($code == 200) { $oauth_creds = $tmhOAuth->extract_params($tmhOAuth->response['response']); // Save the credentials in the DB $socialy_params = $oauth_creds; $socialy_params['owner_id'] = $_SESSION['user_details']['user_id']; $socialy_params['type'] = 'twitter'; $socialy_params['is_active'] = '1'; $social_response = $c->sendRequest('socialy/account/add', $socialy_params, 'post', true); // If there was an error saving the account to the API if (array_key_exists('error', $social_response['response']) && is_array($social_response['response']['error'])) { Flash($social_response['response']['error']['message'], 'error'); } // Try to get the info for the account $tmhOAuth->config['user_token'] = $oauth_creds['oauth_token']; $tmhOAuth->config['user_secret'] = $oauth_creds['oauth_token_secret']; $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/account/verify_credentials')); Pre($code); // If this user is valid if ($code == 200) { // Get the response $resp = json_decode($tmhOAuth->response['response'], true); Pre($resp); // Update it in the twitter account table $account_params = $resp; $account_params['account_id'] = $social_response['response']['account']['account_id']; $account_params['owner_id'] = $_SESSION['user_details']['user_id']; unset($account_params['status']); $account_response = $c->sendRequest('socialy/twitterinfo/add', $account_params, 'post', true); Pre($account_response); // If there was an error saving the account to the API if (is_array($account_response['response']['error'])) { Flash($account_response['response']['error']['message'], 'error'); } else { Flash('Account "' . $account_response['response']['twitter']['screen_name'] . '" added successfully!'); } } //header('Location: ' . php_self()); //die(); } }
function perf() { static $t; unset($_ENV['header'], $_ENV['c']); GT('perf1'); if (preg_match('~(js|css)$|(js|lastmod)\\.php~', SU) || isset($_POST['ajax'])) { return; } # //todo:ne pas executer cette fonction si header<>200 sur la page $x = $GLOBALS['pi']; if ($x['extension']) { #peut être vide.. if (in_Array($x['extension'], explode(',', 'php,htm,html,fr,org,com,info,ch,tv'))) { } else { return; } #extension non autorisée } #cl('perf,j9:'.J9.','.$t.','.SU.','.print_r(,1)); #if(!preg_match('~\.(html?|php)$~',U))return; if (Preg_Match("~glob=~", Q)) { $t = 7; } elseif (e(',forceperf', 1) or J9) { null; } elseif (is_numeric(H) || $t || RS == 404 || e('noperf', 1) || isset($_ENV['noperf']) || $_GET['re'] . $_GET['noperf'] . $_GET['np'] || strpos(U, '%2B%2B') || strlen(U) > 80) { $t = 1; } elseif (Preg_Match("~(js|jsr|css|rss|sm|redir)\$~", Q)) { $t = 2; } elseif (preg_match("~Tag\\.php|url(\\.|\\()data|image(/|-)png|base64|\\.(png|js|css|jsx?|jpe?g|gif|bmp|gif|ico|htc|sm)\$~", U)) { $t = 3; } elseif (!isgoodurl()) { $t = 4; } elseif (Preg_Match("~editor\\.php|officia|Tag|rss|data|xml|/(CIEL|admin|2001|adm)/|(gss|css.*)\$~i", SU) || preg_Match('~/z/~i', SU) && !preg_Match('~\\/sex|video~i', U)) { $t = 5; } if (preg_match("~base64|%27|\\+~", u)) { $t = 6; } if ($t) { Av('t', $t); return; } #FPC(ERLOGS,"noperf:$t\n",1); GT('fin'); $t = 1; if (in_array(H, array('ben', 'localhost', '127.0.0.1'))) { av('H', $_ENV); kill(); } #even if cached,if(j9)return; if (q) { null; } else { $f0 = TMP . "perf/" . trim(str_replace(array('http://', '/'), array('', '§'), SU), '§') . ".db"; $f = TMP . "perf/" . mu . ".db"; if (is_file($f0)) { rename($f0, $f); } #transition, beaucoup plus simple au final $x = FGC($f); #Faire correspondre avec fichier "mu" plutôt !!! @todo if (isset($_ENV['yt']['mots'])) { $x['mots'] = $_ENV['yt']['mots']; } $x['Memo'] = Memuse(); #; $def = array('tim', 'nb', 'db'); foreach ($def as $v) { if (!isset($x[$v])) { $x[$v] = 0; } } if ($x['tim'] > 9999999999) { $x['tim'] = $x['nb'] = 0; } #si bug gettime #if(!is_numeric($x['tim']))$x['tim']=0;$x['tim']+=$time;#err if (!is_numeric($x['nb'])) { $x['nb'] = 1; } $x['nb'] = $x['nb'] + 1; $x['avg'] = ceil($x['tim'] / $x['nb']); unset($x['calc'], $x['gen']); #if avg>800 db(,'prio'); et on peut créer fichier fpdata avec cette valeur avg afin de charger plus souvent, plus durablement le système de cache pour soulager les pages mettant bcp de temps à être pondues !!!! $x['db'] = explode(',', str_replace('Array', '', $x['db'])); $x['db'] = Array_unique($x['db']); $x['db'] = implode(',', $x['db']); if (function_exists('sys_getloadavg')) { $sysload = implode('#', sys_getloadavg()); $x['sys'] = date("H:i:s") . ">" . $sysload; } if (e('erver:pre', 1)) { } else { FPC($f, $x); Touch($f, $x['avg']); } } $x['db'] .= ",fin:" . $_ENV['lasttime']; $x['cachepath'] = CACHEPATH; if (!j9) { return; } Addurl(); #les urls dont on s'en tape $edit = $y2 = null; #FAP(logs.'Vitale.db',Array('cp'=>cachepath,'sfn'=>$_SERVER['SCRIPT_FILENAME'])); #$x=FGC(TMP.'cont/'.$mu.'.contenu'); $f = TMP . 'cont/' . MU . '.contenu'; if (is_file($f)) { $y = FGC($f); $_ENV['args'] .= " :muc:{$y['id']},len:" . $_ENV['x']; $edit .= "<button onclick=\"edt('?zp={$y['id']}');return false;\">e:muc:{$y['id']}</button>"; } elseif (is_file(TMP . 'cont/' . MU)) { $y = FGC(TMP . 'cont/' . MU); e("e:mu:{$y}"); #contient l'identifiant de la page $t = sql5("select sql_cache * from p.zpages2 where id={$y}"); if ($t) { $edit .= "<button onclick=\"edt('?zp={$y}');return false;\">e:mu:{$y}</button>"; } else { unlink(TMP . 'cont/' . MU); } #unlink si l'identifiant sql n'existe pas :) } elseif (isset($_POST['create'])) { #£todo:bad: right, that's bad, we're checking in this function, globally, if we have some postdata to edit this page contents $y = sql5("select id from p.zpages2 where url=\"" . SU . "\""); if (!$y) { $y = sql5("insert into p.zpages2(url)values(\"" . SU . "\")"); if ($y) { FPC(TMP . 'cont/' . mu, $y); } } } elseif (!RU) { $edit .= "<form method=post><input type=hidden name=create value=1><input type=submit value=create></form>"; } if (1) { $edit .= "<button accesskey='e' onclick=\"edt('?sfn=1');return false;\">kod</button>"; } Arsort($_ENV['dbt']); unset($_ENV['c'], $_ENV['Adbt']); $x = Array_merge($_ENV, $x); if (is_file(CACHEPATH)) { $dif = " age:" . (filemtime(CACHEPATH) - NOW) . ""; } if (is_Array($x['Memo'])) { $x['Memo'] = implode(',', $x['Memo']); } #$y=Pre($x,'nude=1');pre2console($y); if (isset($_ENV['debug'])) { $y2 = Pre($_ENV['debug'], 'nude=1'); pre2console($y2); } #if(J11)$y=print_r(debug_backtrace(),1).$y; if (!strpos($_ENV['args'], 'nocss') && !AJAX) { $base = $x; header('Bs: ' . fixSer($x), 1); header('Cdebug: ' . str_replace(array("\r", "\n"), array('', '*'), print_r($base, 1)), 1); echo "\n\n<script>var y='" . jsonEnc($base) . "';var cinfo=JSON.parse(y);console.info('cinfo',cinfo);</script>"; //todo JS debugging into header } #y.replace(/\"\"/gi,'*'),if(z2)console.info(\"%c\"+z2,'color:blue;font:10px Trebuchet MS'); #[\"Perf:$sysload:$_ENV[lasttime] ms-\"+z] #.replace(/\\n +\(\\n/g,'(\\n').replace(/\\nArray\\n\(\\n\[/g,'\\nArray:\['),z2=\"$y2\".replace(/\\n +\(\\n/g,'(\\n').replace(/\\nArray\\n\(\\n\[/g,'\\nArray:\['); #console.info([%cPerf:$sysload:$_ENV[lasttime] ms-\"+z,'color:blue;font:10px Consolas'); if (e('shutd')) { Null; } else { kill(); } #Si une autre fonction de shutdown a été rajoutée par dessus - sinon fin de tout ( appel à die recursif dans foncshutdown ) ! }