Пример #1
0
<?php

// File: gcm.php
$pdo = pdo_connect();
$sql = "select token, username from gcm";
$stmt = $pdo->prepare($sql);
$stmt->execute(array());
$gcmIds = array();
$gcmusername = arra();
foreach ($stmt as $row) {
    echo $row['token'];
    $gcmIds[] = $row['token'];
    $gcmusername[] = $row['username'];
}
// Open connection
$url = 'https://android.googleapis.com/gcm/send';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Create the HTTP header
$apiKey = "AIzaSyCrHfhrz_l-z8P2av4Hptd-zqVyhgBf8AY";
$headers[0] = 'Authorization: key=' . $apiKey;
$headers[1] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Message to send and ID's are POST data
$data['message'] = "turn";
$fields['registration_ids'] = $gcmIds;
$fields['data'] = $data;
echo '<pre>';
print_r($fields);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
Пример #2
0
	public static function ajax_bulkOperation_callback(){
		$op = sanitize_text_field($_POST['op']);
		if($op == 'del' || $op == 'repair'){
			$ids = $_POST['ids'];
			$filesWorkedOn = 0;
			$errors = array();
			$issues = new wfIssues();
			foreach($ids as $id){
				$id = intval($id); //Make sure input is a number. 
				$issue = $issues->getIssueByID($id);
				if(! $issue){
					$errors[] = "Could not delete one of the files because we could not find the issue. Perhaps it's been resolved?";
					continue;
				}
				$file = $issue['data']['file'];
				$localFile = ABSPATH . '/' . preg_replace('/^[\.\/]+/', '', $file);
				$localFile = realpath($localFile);
				if(strpos($localFile, ABSPATH) !== 0){
					$errors[] = "An invalid file was requested: " . wp_kses($file, arra());
					continue;
				}
				if($op == 'del'){
					if(@unlink($localFile)){
						$issues->updateIssue($id, 'delete');
						$filesWorkedOn++;
					} else {
						$err = error_get_last();
						$errors[] = "Could not delete file " . wp_kses($file, array()) . ". Error was: " . wp_kses($err['message'], array());
					}
				} else if($op == 'repair'){
					$dat = $issue['data'];	
					$result = self::getWPFileContent($dat['file'], $dat['cType'], $dat['cName'], $dat['cVersion']);
					if($result['cerrorMsg']){
						$errors[] = $result['cerrorMsg'];
						continue;
					} else if(! $result['fileContent']){
						$errors[] = "We could not get the original file of " . wp_kses($file, array()) . " to do a repair.";
						continue;
					}
					
					if(preg_match('/\.\./', $file)){
						$errors[] = "An invalid file " . wp_kses($file, array()) . " was specified for repair.";
						continue;
					}
					$fh = fopen($localFile, 'w');
					if(! $fh){
						$err = error_get_last();
						if(preg_match('/Permission denied/i', $err['message'])){
							$errMsg = "You don't have permission to repair " . wp_kses($file, array()) . ". You need to either fix the file manually using FTP or change the file permissions and ownership so that your web server has write access to repair the file.";
						} else {
							$errMsg = "We could not write to " . wp_kses($file, array()) . ". The error was: " . $err['message'];
						}
						$errors[] = $errMsg;
						continue;
					}
					flock($fh, LOCK_EX);
					$bytes = fwrite($fh, $result['fileContent']);
					flock($fh, LOCK_UN);
					fclose($fh);
					if($bytes < 1){
						$errors[] = "We could not write to " . wp_kses($file, array()) . ". ($bytes bytes written) You may not have permission to modify files on your WordPress server.";
						continue;
					}
					$filesWorkedOn++;
					$issues->updateIssue($id, 'delete');
				}
			}
			$verb = $op == 'del' ? 'Deleted' : 'Repaired';
			$verb2 = $op == 'del' ? 'delete' : 'repair';
			if($filesWorkedOn > 0 && sizeof($errors) > 0){
				$headMsg = "$verb some files with errors";
				$bodyMsg = "$verb $filesWorkedOn files but we encountered the following errors with other files: " . implode('<br />', $errors);
			} else if($filesWorkedOn > 0){
				$headMsg = "$verb $filesWorkedOn files successfully";
				$bodyMsg = "$verb $filesWorkedOn files successfully. No errors were encountered.";
			} else if(sizeof($errors) > 0){
				$headMsg = "Could not $verb2 files";
				$bodyMsg = "We could not $verb2 any of the files you selected. We encountered the following errors: " . implode('<br />', $errors);
			} else {
				$headMsg = "Nothing done";
				$bodyMsg = "We didn't $verb2 anything and no errors were found.";
			}

			return array('ok' => 1, 'bulkHeading' => $headMsg, 'bulkBody' => $bodyMsg);
		} else {
			return array('errorMsg' => "Invalid bulk operation selected");
		}
	}
Пример #3
0
 public function saveProduct()
 {
     $conn = new ConnectionHandler();
     $table = "Product";
     $fields = array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek", 'kep');
     $stmtCat = $conn->preparedQuery("SELECT kat_azon FROM Kiszereles WHERE kat_nev=?", arra($this->getCategory()));
     $arr = $stmtCat->fetchAll(PDO::FETCH_ASSOC);
     $category_id = $arr[0];
     foreach ($arr as $titleData) {
         echo $titleData['name'];
     }
     $values = array($this->getName(), $this->getCategory()->getId(), $this->getCategory()->getId(), $this->getWeight(), $this->getPrice(), $this->getMinStock(), $this->getMinOrder(), $this->getHighlight()->getId(), $this->getDiscount(), $this->getDescription(), $this->getImg());
     $conn->preparedInsert($table, $fields, $values);
 }