function getworkfromstratumproxy($data_string) { $stratumProxy = "http://www.goodu.info:8332"; $workerName = "martinking.js"; $workerPass = "******"; tolog($data_string); $ch = curl_init($stratumProxy); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_USERPWD, $workerName . ":" . $workerPass); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); $rs = curl_exec($ch); tolog($rs); return $rs; }
function write_dao_get_list($handle, $table) { $text = "" . PHP_EOL; tolog($table); $className = $table['name']; $object = "\$" . strtolower(substr($className, 0, 1)) . substr($className, 1); $schema_name = $table['table_data']['schemaname']; $table_name = $table['table_data']['tablename']; $full_table_name = $schema_name == 'public' ? $table_name : $schema_name . '.' . $table_name; $first_primary_key_column = $table['first_primary_key_column']; $first_primary_key_variable = "\$" . $table['first_primary_key_attribute_name']; $columns = ''; $first = true; $values = ''; $variables = ''; foreach ($table['attributes'] as $attribute) { $column_name = $attribute['name_as_column']; $name_ucfirst = $attribute['name_ucfirst']; if ($first) { $columns .= " {$column_name}" . PHP_EOL; $variables .= " %s" . PHP_EOL; $first = !$first; } else { $columns .= " , {$column_name}" . PHP_EOL; $variables .= " , %s" . PHP_EOL; } $values .= " , nulo({$object}->get{$name_ucfirst}()) " . PHP_EOL; } $text .= " public function getLista{$className}() {" . PHP_EOL; $text .= " \$qry = sprintf(\"" . PHP_EOL; $text .= " SELECT {$columns}" . PHP_EOL; $text .= " FROM {$full_table_name}" . PHP_EOL; $text .= " \"" . PHP_EOL; $text .= " );" . PHP_EOL; $text .= " \$result = \$this->select(\$qry);" . PHP_EOL; $text .= " return \$result;" . PHP_EOL; $text .= " }" . PHP_EOL; fwrite($handle, $text); }
function loadExcel($fname) { try { require_once '/www/plugins/PHPExcel.php'; require_once '/www/plugins/PHPExcel/IOFactory.php'; $objPHPExcel = PHPExcel_IOFactory::load($fname); $sheets = array(); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $worksheetTitle = $worksheet->getTitle(); $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $nrColumns = ord($highestColumn) - 64; $data = array(); for ($row = 1; $row <= $highestRow; ++$row) { $record = array(); for ($col = 0; $col < $highestColumnIndex; ++$col) { $cell = $worksheet->getCellByColumnAndRow($col, $row); $val = $cell->getValue(); $record[] = $val; // $dataType = PHPExcel_Cell_DataType::dataTypeForValue($val); } $data[] = $record; } $sheets[] = array("title" => $worksheetTitle, "row" => $highestRow, "col" => $highestColumnIndex, "data" => $data); } return $sheets; } catch (Exception $e) { tolog($e->getMessage()); } return null; }