public function actionDefault() { $google_config = NEnvironment::getConfig()->google; require_once LIBS_DIR . '/google-api-php-client/src/apiClient.php'; require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiOauth2Service.php'; require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiAnalyticsService.php'; $client = new apiClient(); $client->setApplicationName('Google+ PHP Starter Application'); // Visit https://code.google.com/apis/console?api=plus to generate your // client id, client secret, and to register your redirect uri. // $client->setClientId( $google_config['client_id'] ); // $client->setClientSecret( $google_config['client_secret'] ); $client->setRedirectUri($google_config['redirect_url']); // $client->setDeveloperKey('AIzaSyCrViGDrmXAiLsQAoW1aOzkHddH9gHYzzs'); // [8] => Array // ( // [title] => www.propagacnepredmety.sk // [entryid] => http://www.google.com/analytics/feeds/accounts/ga:43556790 // [accountId] => 17205615 // [accountName] => www.vizion.sk // [profileId] => 43556790 // [webPropertyId] => UA-17205615-3 // [tableId] => ga:43556790 // ) $ga = new apiAnalyticsService($client); if (isset($_GET['code'])) { $ga->authenticate(); $_SESSION['token'] = $client->getAccessToken(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } if (isset($_SESSION['token'])) { $client->setAccessToken($_SESSION['token']); } if ($client->getAccessToken()) { $activities = $plus->activities->listActivities('me', 'public'); print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>'; // The access token may have been updated. $_SESSION['token'] = $client->getAccessToken(); } else { $authUrl = $client->createAuthUrl(); print "<a class='login' href='{$authUrl}'>Connect Me!</a>"; } // $_SESSION['token'] = $client->getAccessToken(); $data = $ga->data_ga; $d = $data->get('17205615', date('Y-m-d', time() - 60 * 60 * 24 * 40), date('Y-m-d', time() - 60 * 60 * 24 * 1), 'ga:visits,ga:pageviews'); print_r($d); exit; }
function __construct($id_menu = NULL, $lang = NULL) { $this->session = NEnvironment::getSession('Menu'); $this->pageModel = PageModel::init(); if ($id_menu == NULL) { if (isset($_GET["id_menu"])) { $this->session['id_menu'] = $_GET["id_menu"]; } if (!isset($this->session['id_menu'])) { $this->session['id_menu'] = NEnvironment::getVariable('ADMIN_DEFAULT_IDMENU'); } $this->id_menu = $this->session['id_menu']; } else { $this->id_menu = $id_menu; } if (@$lang == NULL) { if (!isset(NEnvironment::getSession('Page')->lang)) { $this->lang = NEnvironment::getVariable('ADMIN_DEFAULT_LANG'); } $this->lang = NEnvironment::getSession('Page')->lang; } else { $this->lang = $lang; } $this->var = NEnvironment::getConfig('ADMINMENU'); }
function startup() { parent::startup(); //vypnutie debugeru + profileru $config = NEnvironment::getConfig()->database; $config->profiler = false; $config->lazy = false; dibi::connect($config); //NDebug::enable( TRUE, LOG_DIR); }
public function removeFromCache($filename) { $list = scandir(NEnvironment::getConfig()->gallery['dir_abs'] . '/temp/'); foreach ($list as $l) { $pom = explode('|', $l); if ($filename == $pom[0]) { unlink(NEnvironment::getConfig()->gallery['dir_abs'] . '/temp/' . $l); } } }
function nodeAction() { $node = NodeModel::init(); //-------------------------------// //--------AJAX REQUEST-----------// //------------------------------// if (@$_GET['ajax_change_modul_position']) { if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['position'])) { dibi::query("UPDATE node SET position=%i", $_GET['position'], " WHERE id_node=%i", $_GET['id_node_ajax']); $node->invalidateCache(); } exit; } if (@$_GET['ajax_change_modul_visible']) { if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['modul_visible'])) { dibi::query("UPDATE node SET visible=%s", $_GET['modul_visible'], " WHERE id_node=%i", $_GET['id_node_ajax']); } $node->invalidateCache(); // echo dibi::$sql; exit; } //------SITE MAP pre premiestnenie modulu if (isset($_GET['ajax_show_site_map_for_modul'])) { $m = new MenuItem(); $m->doTreeSelectMoveModul(0, 0, $_GET['id_menu_item'], $_GET['id_type_modul']); echo '<form action="" method="post"> <select name="id_menu_item_for_change">'; echo $m->doTreeSelectMoveModulText; echo '<input type="hidden" name="id_type_modul" value="' . htmlspecialchars($_GET['id_type_modul']) . '" /> <input type="hidden" name="id_node" value="' . htmlspecialchars($_GET['id_node']) . '" /> <input type="submit" name="changeModulParent" value="Ulož" /> </form>'; exit; } if (isset($_POST['changeModulParent'])) { $this->changeModulParent(); $node->invalidateCache(); header("Location: ?id_menu_item=" . $_POST['id_menu_item_for_change'] . "&showModulsOnPage=1"); exit; } if (isset($_GET['id_menu_item']) and isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) { if (!dibi::fetchSingle("SELECT COUNT(*) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " AND id_type_modul=%i", $_GET['id_type_modul'], " AND id_node=%i", $_GET['id_modul'])) { header("Location:admin.php"); exit; } } if (isset($_GET['addnode']) and isset($_GET['id_type_modul']) or isset($_POST['addModulToMenu'])) { if (isset($_POST['addModulToMenu'])) { $id_type_modul = $_POST['id_type_modul']; } else { $id_type_modul = $_GET['id_type_modul']; } $sequence = dibi::fetchSingle("SELECT MAX(sequence) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item']) + 1; $session = NEnvironment::getSession('Authentication'); $config = NEnvironment::getConfig(); $arr = array('id_user' => NEnvironment::getUser()->getIdentity()->id, 'id_menu_item' => $_GET['id_menu_item'], 'sequence' => $sequence, 'id_type_modul' => $id_type_modul, 'visible' => $config['NODE_VISIBLE']); dibi::query("INSERT INTO node ", $arr); $this->addModul(dibi::insertId(), $id_type_modul); $node->invalidateCache(); } //zmenenie poradia if (isset($_GET['modul_id_up']) or isset($_GET['modul_id_down'])) { $this->changeOrderNode(); $node->invalidateCache(); header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&showModulsOnPage=1"); exit; } //ak je iba jeden modul, hned sa zobrazi ale iba ak nieje setnuta section a showModulsOnPage if (isset($_GET['id_menu_item']) and !isset($_GET['id_type_modul']) and !isset($_GET['section']) and !isset($_GET['showModulsOnPage']) and !isset($_GET['changeMenuItem'])) { $l = dibi::fetch("SELECT *, COUNT(*) as node_count FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " ORDER BY sequence"); if ($l['node_count'] == 1) { header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&id_type_modul=" . $l['id_type_modul'] . "&id_modul=" . $l['id_node']); exit; } } //pridanie do premenej activeModul instanciu objektu if (isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) { $this->activeModul = $this->nodeFactory($_GET['id_type_modul']); $this->activeModul->action(); } if (isset($_GET['id_modul_del']) and is_numeric($_GET['id_modul_del'])) { $this->deleteNode(NULL, $_GET['id_modul_del']); $node->invalidateCache(); header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item']); exit; } }
/** * Computes salted password hash. * @param string * @return string */ public function calculateHash($password) { $cfg = NEnvironment::getConfig(); return hash('sha512', $password . str_repeat($cfg['salt'], 10)); }
// 2b) load configuration from config.ini file $config = NEnvironment::loadConfig(APP_NETTE_DIR . '/config/config.neon'); $neon = new NConfigNeonAdapter(); $n = $neon->load(APP_NETTE_DIR . '/config/config.db.neon'); $database = $n['common']['parameters']; foreach ($database as $k => $p) { NEnvironment::setVariable($k, $p); } //var_dump($d);exit; //$config = NEnvironment::loadConfig(APP_NETTE_DIR.'/config/config.db.neon'); $session = NEnvironment::getSession(); //$session->setSavePath(APP_NETTE_DIR . '/sessions'); //$session->setExpiration("1 day"); $session->start(); try { dibi::connect(NEnvironment::getConfig()->database); } catch (Exception $e) { // echo $e->getMessage(); echo "Nepodarilo sa pripojit"; exit; } $cache = NEnvironment::getCache(); if (!isset($cache['acl'])) { $cache['acl'] = new Acl(); } //print_r($cache['acl']); NEnvironment::getUser()->setAuthorizator($cache['acl']); $user = NEnvironment::getUser(); $aclModel = new AclModel(); //NDebug::dump($aclModel->getRoles()); //NDebug::dump($aclModel->getResources());
static function duplicateFile($id_file) { $file = self::getFile($id_file); // print_r($file); $path = NEnvironment::getConfig('file')->dir_abs . '/original'; $new_filename = self::getFileNameIfExist($path, $file['src'], $file['ext']); $old = $path . '/' . $file['src'] . '.' . $file['ext']; $new = $new_filename['dir'] . '/' . $new_filename['filename']; if (copy($old, $new)) { // echo $new.' // <br >'; } return $new_file; }
/** * @access public * @param $id_node * @param $new_id_node * @static * @ParamType $id_node * @ParamType $new_id_node */ public static function duplicate($id_node, $new_id_node) { dibi::begin(); $tmp = self::get($id_node); unset($tmp['id_node']); self::add($new_id_node); self::saveGallery($tmp, $new_id_node); $vars = NEnvironment::getConfig()->gallery; $tmp = parent::getAll($id_node); $dir = $vars['dir_abs'] . '/original'; foreach ($tmp as $t) { $t['id_node'] = $new_id_node; unset($t['id_gallery_image']); $new_filename = self::doNameFile($vars['dir_abs'] . '/original', $t['src'], $t['ext']); //duplikovanie suboru $source = $t['src'] . '.' . $t['ext']; if (!copy($dir . '/' . $source, $dir . '/' . $new_filename . '.' . $t['ext'])) { echo 'Nepodarilo sa subor skopirovat: ' . $dir . '/' . $source . ' do :' . $dir . '/' . $new_filename . '.' . $t['ext']; } $t['src'] = $new_filename; Files::addFile($t); } dibi::commit(); }
/** * My NApplication bootstrap file. * * @copyright Copyright (c) 2010 John Doe * @package MyApplication */ // Step 1: Load Nette Framework // this allows load Nette Framework classes automatically so that // you don't have to litter your code with 'require' statements require LIBS_DIR . '/Nette/loader.php'; // Step 2: Configure environment // 2a) enable NDebug for better exception and error visualisation NDebug::enable(NDebug::DETECT, APP_DIR . '/log/php_error.log', '*****@*****.**'); NEnvironment::getHttpResponse()->enableCompression(); // Load dibi dibi::connect(NEnvironment::getConfig('database')); dibi::addSubst('graweb', 'gw2010__'); // Step 3: Configure application NEnvironment::setVariable("sizes", array(0 => array(880, 330), 1 => array(263, 174), 2 => array(600, 510))); // 3a) get and setup a front controller $application = NEnvironment::getApplication(); $application->errorPresenter = 'Front:Error'; $application->catchExceptions = TRUE; // Step 4: Setup application router $router = $application->getRouter(); $router[] = new NRoute('index.php', array('module' => 'Front', 'presenter' => 'Default'), NRoute::ONE_WAY); $router[] = new NRoute('', array('module' => 'Front', 'presenter' => 'Default', 'action' => 'default')); // Presmerovani starych URL $router[] = new NRoute('internet/<? ceny|postup|sluzby|vyroba>', array('module' => 'Front', 'presenter' => 'Page', 'action' => 'webdesign'), NRoute::ONE_WAY); $router[] = new NRoute('graficke-navrhy', array('module' => 'Front', 'presenter' => 'Reklama', 'action' => 'grafikaDesign'), NRoute::ONE_WAY); $router[] = new NRoute('<? venkovni-reklama|reklama/reference/>', array('module' => 'Front', 'presenter' => 'Reklama', 'action' => 'reklama'), NRoute::ONE_WAY);