Example #1
0
 function execute($params)
 {
     //
     // F**K! Due limitations of STUPID Smarty I forced to use
     // HTML_RESULT... DAMN!
     //
     $this->set_result_type(HTML_RESULT);
     $this->set_result_tpl('bitpackage:debug/debug_sql.tpl');
     // Init result
     $result = '';
     //
     global $debugger;
     $debugger->msg('SQL query: "' . $params . '"');
     //
     vd($params);
     if (preg_match("/^select/i", trim($params))) {
         global $gBitDb;
         $qr = $gBitDb->mDb->query($params);
         if (!$qr) {
             $result = '<span class="dbgerror">' . $gBitDb->mDb->ErrorMsg() . '</span>';
         } else {
             // Check if result value an array or smth else
             if (is_object($qr)) {
                 // Looks like 'SELECT...' return table to us...
                 // So our result will be 2 dimentional array
                 // with elements count and fields number for element
                 // as dimensions...
                 $first_time = true;
                 $result = '<table id="data">';
                 $result .= '<caption>SQL Results</caption>';
                 while ($res = $qr->fetchRow()) {
                     if ($first_time) {
                         // Form 1st element with field names
                         foreach ($res as $key => $val) {
                             $result .= '<td class="heading">' . $key . '</td>';
                         }
                         $first_time = false;
                     }
                     $result .= '<tr>';
                     // Repack one element into result array
                     $td_eo_class = true;
                     foreach ($res as $val) {
                         $result .= '<td class=' . ($td_eo_class ? "even" : "odd") . '>' . $val . '</td>';
                         $td_eo_class = !$td_eo_class;
                     }
                     //
                     $result .= '</tr>';
                 }
                 $result .= '</table>';
             } else {
                 // Let PHP to dump result :)
                 $result = 'Query result: ' . print_r($qr, true);
             }
         }
     } else {
         $result = "Empty query to tiki DB";
     }
     //
     return $result;
 }
Example #2
0
 public function send($ids, $message)
 {
     $url = 'https://android.googleapis.com/gcm/send';
     $fields = ['registration_ids' => $ids, 'data' => $message];
     $headers = ['Authorization: key=' . Config::get('gcm.key.android'), 'Content-Type: application/json'];
     // Open connection
     $ch = curl_init();
     // Set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Disabling SSL Certificate support temporarly
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     // Execute post
     $result = curl_exec($ch);
     if ($result === false) {
         return false;
     }
     $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     vd($result);
     vd(Config::get('gcm.key.android'));
     return $status;
 }
Example #3
0
 public function write($id, $data)
 {
     $key = $this->normalize($id);
     vd($key);
     $row = $this->db->firstOrCreate(['key' => $key])->setValue($data)->save();
     return true;
 }
Example #4
0
 public function getUser()
 {
     $dbTableUser = new Application_Model_DbTable_User();
     $a = $this->self->select('id')->where('id == 33')->order('id ASC');
     $a->fetchAll()->toArray();
     vd($a);
 }
Example #5
0
 public function init()
 {
     // Define some CLI options
     $getopt = new Zend_Console_Getopt(array('withdata|w' => 'Load database with sample data', 'env|e-s' => 'Application environment for which to create database (defaults to development)', 'help|h' => 'Help -- usage message'));
     try {
         $getopt->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         // Bad options passed: report usage
         echo $e->getUsageMessage();
         return false;
     }
     // Initialize Zend_Application
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     // Initialize and retrieve DB resource
     $bootstrap = $application->getBootstrap();
     $bootstrap->bootstrap('db');
     $dbAdapter = $bootstrap->getResource('db');
     // let the user know whats going on (we are actually creating a
     // database here)
     if ('testing' != APPLICATION_ENV) {
         echo 'Writing Database Guestbook in (control-c to cancel): ' . PHP_EOL;
         for ($x = 5; $x > 0; $x--) {
             echo $x . "\r";
             sleep(1);
         }
     }
     vd(1);
 }
 public function sendWelcomeEmail(Request $request, $id)
 {
     $user = User::findOrFail($id);
     $job = (new SendWelcomeEmail($user))->onQueue('emails');
     $this->dispatch($job);
     vd($user);
 }
Example #7
0
 public function postAction()
 {
     $requestType = $this->getRequest()->getParam('requestType');
     if ($params = $this->getRequest()->getParam('params')) {
         foreach ($params as $key => $value) {
             if (!$value) {
                 unset($params[$key]);
             }
         }
     } else {
         $params = array();
     }
     if ($options = $this->getRequest()->getParam('options')) {
         foreach ($options as $key => $value) {
             if (!$value) {
                 unset($options[$key]);
             }
         }
     } else {
         $options = array();
     }
     $time = microtime(true);
     Mage::register('vd', 1);
     $html = vd(Mage::helper('fitment/api')->request($requestType, $params, $options), true);
     $time = round(microtime(true) - $time, 3);
     $responseData = array('dump' => $html, 'time' => $time);
     echo json_encode($responseData);
     die;
 }
Example #8
0
 public function action_index()
 {
     $entries = $this->size->find_all();
     vd($entries);
     $view = View::factory('admin/size-list');
     $view->bind('entries', $entries);
     $this->template->content = $view;
 }
Example #9
0
 public function action_status()
 {
     $push = new PushConnection($this->config['gg']['number'], $this->config['gg']['login'], $this->config['gg']['password']);
     vd($push);
     $status = $push->setStatus('trwają testy, wkrótce zapraszam');
     vd($status);
     exit;
 }
Example #10
0
 public function action_players()
 {
     $Player = new Model_Player();
     $players = $Player->find_all(0, 0, array(array("status", '=', 1)), array("role"));
     vd($players, 1);
     $view = View::factory('panel/war_list');
     $view->bind('wars', $wars);
     $this->template->content = $view;
 }
Example #11
0
 public function action_save()
 {
     $post = $this->request->post();
     if (count($post)) {
         vd($post);
         $Oceny = new Model_Oceny();
         $Oceny->add(array("points" => $post['points'], "steps" => json_encode($post['steps']), "created" => date("Y-m-d H:i:s")));
     }
     exit;
 }
Example #12
0
 public function __call($method, $arguments)
 {
     vd($method);
     $function = [$this->cursor, $method];
     $result = call_user_func_array($function, $arguments);
     if ($result instanceof \MongoCursor) {
         return $this;
     }
     return $result;
 }
Example #13
0
 public function actionIndex()
 {
     $url = 'http://liverss.ru/';
     //$url = 'https://news.yandex.ru/world.html';
     //$url = 'https://news.yandex.ru/world.rss';
     $rss = file_get_contents($url);
     //$rss = simplexml_load_file($url);       //Интерпретирует XML-файл в объект
     vd($rss);
     return $this->render('index', ['rss' => $rss]);
 }
Example #14
0
function vdob(&$v, $replace_n = false)
{
    ob_start();
    vd($v);
    if ($replace_n) {
        return str_replace("\n", '<br />', ob_get_clean());
    } else {
        return ob_get_clean();
    }
}
Example #15
0
 public function register(Request $request)
 {
     vd($request);
     die;
     $filePath = '/img/avatar/' . uniqid() . $request->file['name'];
     move_uploaded_file($request->file['tmp_name'], app()->basepath . '/public/' . $filePath);
     $user = new User(['name' => $request->name, 'role' => $request->role, 'avatar' => $filePath]);
     vd($user);
     if ($user->save()) {
         echo 'Hallo ' . $request->name;
     } else {
         echo 'Da lief was schief';
     }
 }
Example #16
0
 function generateWord($word)
 {
     if (!$this->isMatch($word)) {
         return false;
     }
     if ($this->remove_len && mb_strlen($word) >= $this->remove_len) {
         $tail = mb_substr($word, -$this->remove_len);
         if ($tail != $this->remove) {
             vd("Try to remove {$tail} from {$word}");
             vd($this);
             exit;
         }
         $word = mb_substr($word, 0, -$this->remove_len);
     }
     return "{$word}{$this->append}";
 }
Example #17
0
 /**
  * Call after dispatcher is executed
  *
  * @param \Tk\FrontController $obs
  * @throws \Tk\Exception
  */
 public function update($obs)
 {
     tklog($this->getClassName() . '::update()');
     if (!$this->getConfig()->isLti()) {
         return;
     }
     if (preg_match('/^\\/lti\\/launch.html/', $this->getUri()->getPath(true))) {
         $toolProvider = $this->getConfig()->getLtiToolProvider(array('connect' => array($this, 'doLaunch')));
         $toolProvider->execute();
         if ($this->reason) {
             throw new \Tk\Exception($this->reason);
         }
         throw new \Tk\Exception('Access Error: Please check your `Key` and `Secret` values are correct.');
     }
     vd($this->getConfig()->getLtiSession());
 }
Example #18
0
 public function postAction()
 {
     $requestType = $this->getRequest()->getParam('requestType');
     if ($params = $this->getRequest()->getParam('params')) {
         foreach ($params as $key => $value) {
             if (!$value) {
                 unset($params[$key]);
             }
         }
     } else {
         $params = array();
     }
     if ($options = $this->getRequest()->getParam('options')) {
         foreach ($options as $key => $value) {
             if (!$value) {
                 unset($options[$key]);
             }
         }
     } else {
         $options = array();
     }
     $time = microtime(true);
     Mage::register('vd', 1);
     $data = Mage::helper('arioem/api')->setApiMode('check')->request($requestType, $params, $options);
     $time = round(microtime(true) - $time, 3);
     if (isset($data['responseType']) && $data['responseType'] == 'image') {
         $fileName = 'arioem-check-images/' . implode('-', $params) . '.gif';
         $filePath = Mage::getModel('core/config')->getBaseDir('media') . '/' . $fileName;
         $imageDirPath = dirname($filePath);
         if (!file_exists($imageDirPath)) {
             mkdir($imageDirPath, 0777, true);
         }
         if ($f = fopen($filePath, 'w')) {
             fwrite($f, $data['image']);
             fclose($f);
         } else {
             Mage::log("Cannot open file '{$filePath}' for writing");
         }
         $responseData = array('requestType' => $requestType, 'responseType' => 'image', 'time' => $time, 'imageURL' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $fileName);
     } else {
         $responseData = array('requestType' => $requestType, 'responseType' => 'data', 'time' => $time, 'dump' => vd($data, true));
     }
     echo json_encode($responseData);
     die;
 }
Example #19
0
 public function actionSuccesspay()
 {
     //      vd(['get' => Yii::$app->request->getQueryParams() ,
     //          'post' => Yii::$app->request->getBodyParams()],1);
     $r = new Request();
     //Yii::info(\yii\helpers\Json::encode($requestData), 'apiRequest');
     \Yii::info('[DEBUG_ME]' . print_r(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], true), 'appDebug');
     if ($r->post('action')) {
         vd(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], 1);
     }
     $order = Order::findOne($r->post('orderNumber'));
     if ($order) {
     } else {
         vd($order);
     }
     $project = $order->project;
     return $this->render('successpay', ['project' => $project]);
 }
 /**
  * 发送邮件方法
  * 
  * 发送邮件给用户,全站公用方法
  * 
  * @author  NJ <*****@*****.**>
  * @ctime 2016年03月19日11:58:47
  * @return mixed 发送是否成功,不成功的话,则返回错误信息,上线后需要屏蔽
  * 
  */
 public function send_email($email_address = '*****@*****.**', $subject = '系统邮件', $content = '测试邮件')
 {
     $this->load->library('email');
     // $this->email->initialize($config);
     $this->email->from('*****@*****.**', 'NingerJohn');
     $this->email->to($email_address);
     // $this->email->cc('*****@*****.**');
     // $this->email->bcc('*****@*****.**');
     $this->email->subject($subject);
     $this->email->message($content);
     $result = $this->email->send();
     if ($result) {
         // vd($result);
         return true;
     } else {
         vd($this->email->print_debugger());
         return $this->email->print_debugger();
     }
 }
Example #21
0
 public function loginAction()
 {
     $db = $this->_getParam('db');
     $loginForm = new Application_Form_Auth_Login();
     if ($loginForm->isValid($_POST)) {
         $adapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'MD5(CONCAT(?, password_salt))');
         $adapter->setIdentity($loginForm->getValue('username'));
         $adapter->setCredential($loginForm->getValue('password'));
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $this->_helper->FlashMessenger('Successful Login');
             vd(1);
             $this->_redirect('/');
             return;
         }
         vd(2);
     }
     $this->view->loginForm = $loginForm;
 }
Example #22
0
 public function actionForm()
 {
     //vd(1);
     $model = Profile::find()->where(['user_id' => Yii::$app->user->id])->one();
     if (!$model) {
         $model = new Profile();
     }
     if ($model->load(Yii::$app->request->post())) {
         //vd($_POST);
         if ($model->validate()) {
             $model->gender = $_POST['gender'];
             $model->user_id = Yii::$app->user->id;
             $model->login = User::getLoginById(Yii::$app->user->id);
             $model->save();
             return $this->render('form', ['model' => $model]);
         } else {
             vd($model->getErrors());
         }
     }
     return $this->render('form', ['model' => $model]);
 }
Example #23
0
 public function request($url, $params = array())
 {
     $ch = curl_init();
     if (count($params)) {
         $url .= (false === strpos($url, '?') ? '?' : '&') . http_build_query($params);
     }
     if (@$_GET['debug'] == 'print') {
         vd($url);
     }
     if (@$_GET['debug'] || Mage::registry('vd')) {
         Mage::log($url);
     }
     curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_VERBOSE => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2));
     $response = curl_exec($ch);
     if (curl_exec($ch) === false) {
         $error = curl_error($ch);
         curl_close($ch);
         throw new Exception('CURL error: ' . $error);
     }
     curl_close($ch);
     return $response;
 }
 public function post($url, $params = [], $body = "")
 {
     //this functionality is part of addtrack for endomondo, and not working yet.
     if (!$this->auth) {
         return null;
     }
     if (!$params) {
         $params = [];
     }
     $params["authToken"] = $this->auth;
     $path = self::BASE_URL . $url . "?" . http_build_query($params);
     $process = curl_init($path);
     //        $process = curl_init("http://localhost/~jem/EddingtonAndMore/j.php". "?" . http_build_query($params));
     curl_setopt($process, CURLOPT_HEADER, 0);
     vd("about to curl");
     vd($body);
     curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type' => 'application/octet-stream'));
     curl_setopt($process, CURLOPT_TIMEOUT, 30);
     curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($process, CURLOPT_POST, 1);
     curl_setopt($process, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($process, CURLOPT_POSTFIELDS, $body);
     $page = curl_exec($process);
     $this->error = curl_error($process);
     log_msg("endomondo post " . $path);
     log_msg($params);
     log_msg($page);
     if ($this->error) {
         log_msg("ERROR: " . $this->error);
     }
     log_msg("Total time: " . curl_getinfo($process)["total_time"]);
     curl_close($process);
     if ($page) {
         return $page;
     } else {
         return $this->error;
     }
 }
Example #25
0
 public function action_prepare()
 {
     $path = DOCROOT . 'media/files/yt/';
     //output
     $out = ' > ' . $path . 'out.log 2>&1';
     vd($_POST);
     $dir = opendir($path . 'mp4');
     while (false != ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             $filename = $file;
         }
     }
     if ($_POST['end'] == "końca") {
         $duration = '';
     } else {
         $duration = '-to ' . $_POST['end'];
     }
     $pathinfo = pathinfo($filename);
     $command = '/usr/local/bin/ffmpeg -i ' . $path . 'mp4/' . $filename . ' -y -acodec mp3 -ss ' . $_POST['start'] . ' ' . $duration . ' ' . $path . 'mp3/' . $pathinfo['filename'] . '.mp3';
     Log::instance()->add(Log::ERROR, $command);
     exec($command . $out);
     exit;
 }
Example #26
0
 public function indexAction()
 {
     // Welcome to the test controller!
     // It is available at http://tmsparts.com/evoc/test/ or http://tmsparts.com/evoc/test/index/ , whichever looks better for you.
     // You're inside of the standard Magento environment with all the configuration initialized and applied, as it is regular Magento controller.
     // Below is a standard code retrieving certain information from an additional database.
     // As far as you'll see in the output, $_resource->getConnection('oemdb_read') returns false that's not correct.
     //
     // vd() function widely used here is just an analogue of famous var_dump(), but more sophisticated one
     try {
         //			$collection = Mage::getModel('catalog/product')->getCollection()->setPageSize(10)->load();
         //			vd($collection);
         $dbh = new PDO('mysql:dbname=tms_oem;host=127.0.0.1', 'tms_magento', 'skey2Coll!#');
         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $sql = "SELECT * FROM sku WHERE sku='4473167'";
         sql($sql);
         foreach ($dbh->query($sql) as $row) {
             vd($row);
         }
         /*
         				try {
         		//			vd($_resource = Mage::getSingleton('core/resource'));
         		//			vd($_connection = $_resource->getConnection('oemdb_read'));
         
         		//			vd(Vikont_ARIOEM_Helper_OEM::getPartNumbers('4473167')); // you can use value '4473167' as it's from a real DB record
         
         				} catch (PDOException $e) {
         					echo 'OMG, it is PDO exception!';
         					vd($e->getMessage());
         				} catch(Exception $e) {
         					vd($e->getMessage());
         				}
         				/**/
     } catch (PDOException $e) {
         echo 'Connection failed: ' . $e->getMessage();
     }
 }
 /**
  * @todo insert individu from posted data
  * */
 public function insertIndiv()
 {
     global $basedomain, $CONFIG;
     $data = $_POST;
     //get data user from session
     $session = new Session();
     //$login = $session->get_session();
     //$userData = $login['ses_user'];
     $userData = $session->get_session();
     $personID = $userData['login']['id'];
     $data['personID'] = $personID;
     //pr($personID);exit;
     $insertData = $this->insertonebyone->insertTransaction('indiv', $data);
     if ($insertData) {
         if ($insertData['status']) {
             $sess_onebyone = array('indivID' => $insertData['lastid']);
             $session->set_session($sess_onebyone, 'onebyone');
             //Email notif
             $html = "Data telah diperbaharui";
             $data_email = $this->insertonebyone->get_email();
             pr($html);
             // $send = sendGlobalMail(trim($data_email),$CONFIG['email']['EMAIL_FROM_DEFAULT'],$html);
             $send = sendGlobalMail('*****@*****.**', $CONFIG['email']['EMAIL_FROM_DEFAULT'], $html);
             vd($send);
             exit;
             exit;
             $this->msg->add('s', 'Sukses Memperbarui Individu');
             // header('Location: ../onebyone/detContent');
             redirect($basedomain . 'onebyone/detContent');
         } else {
             $this->msg->add('e', 'Gagal Memperbarui Individu');
             // header('Location: ../onebyone/indivContent');
             redirect($basedomain . 'onebyone/indivContent');
         }
     } else {
         $this->msg->add('e', 'Gagal Memperbarui Individu');
         // header('Location: ../onebyone/indivContent');
         redirect($basedomain . 'onebyone/indivContent');
     }
 }
Example #28
0
function url_post($url, $data, $cookie_jar_file, $fperm, $header, $proxy = false, $proxyauth = false, $debug = 0, $img = false)
{
    if (!file_exists($cookie_jar_file)) {
        $fperm = "wb";
    }
    if (!$img) {
        $fields = '';
        foreach ($data as $key => $value) {
            $fields .= $key . '=' . $value . '&';
            rtrim($fields, '&');
        }
    } else {
        $img = new CURLFile($data["filename"], 'image/jpg', $data["name"]);
        $fields["profile_pic"] = $img;
    }
    $fp = fopen($cookie_jar_file, $fperm);
    $options = array(CURLOPT_HEADER => 1, CURLOPT_HTTPHEADER => $header, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_VERBOSE => $debug, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => count($data), CURLOPT_POSTFIELDS => $fields, CURLOPT_COOKIEJAR => $cookie_jar_file, CURLOPT_COOKIEFILE => $cookie_jar_file, CURLOPT_SSL_VERIFYHOST => 0);
    //vd($options);
    //die;
    //echo $cookie_jar_file;
    //vd($options);
    //die;
    //vd($url);
    //die;
    $ch = curl_init($url);
    curl_setopt_array($ch, $options);
    if ($proxy) {
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        if ($proxyauth) {
            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
        }
    }
    $content = curl_exec($ch);
    $err = curl_errno($ch);
    $errmsg = curl_error($ch);
    $header = curl_getinfo($ch);
    curl_close($ch);
    fclose($fp);
    $header['errno'] = $err;
    $header['errmsg'] = $errmsg;
    $header['content'] = $content;
    //vd($header);
    $info["header"] = $header;
    $info["content"] = $content;
    //vd($header['http_code']);
    if ($header['http_code'] == 200) {
        return $info;
    } else {
        vd($info);
        return $info;
    }
}
Example #29
0
 public function dumpAction()
 {
     $this->_authenticate();
     $order = Mage::getModel('sales/order')->loadByIncrementId($this->getRequest()->getParam('order'));
     if (!$order->getId()) {
         echo 'No such order';
         die;
     }
     vd($order->getData());
     foreach ($order->getItemsCollection() as $item) {
         vd($item->getData());
     }
 }
Example #30
0
                 $adminUser->addUserToRole($adminUser->mUserId, 1);
                 // set admin role as default
                 $adminUser->storeUserDefaultRole($adminUser->mUserId, 1);
             } else {
                 vd($adminUser->mErrors);
                 die;
             }
         } else {
             $adminUser = new BitPermUser();
             if ($adminUser->store($storeHash)) {
                 // add user to admin group
                 $adminUser->addUserToGroup($adminUser->mUserId, 1);
                 // set admin group as default
                 $adminUser->storeUserDefaultGroup($adminUser->mUserId, 1);
             } else {
                 vd($adminUser->mErrors);
                 die;
             }
         }
         // kill admin info in $_SESSION
         //				unset( $_SESSION['real_name'] );
         //				unset( $_SESSION['login'] );
         //				unset( $_SESSION['password'] );
         //				unset( $_SESSION['email'] );
     }
 }
 // ---------------------- 8. ----------------------
 // woo! we're done with the installation bit - below here is some generic installer stuff
 $gBitSmarty->assign('next_step', $step + 1);
 // display list of installed packages
 asort($packageList);