public function actionConsult() { // $searchModel = new LocaleSearch(); // $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $model = $this->findModel($_POST['id']); echo BaseJson::encode($model); }
/** * Push mass * array( * array( * 'field name to' => '', * 'field name subject' => '', * 'field name body' => '', * 'field name priority' => '', * 'field name from' => '', * 'field name attachs' => '', * ) * ) * @param Array $data * @return int Return int */ public function pushMass($data) { $table = Yii::$app->get('mailqueue')->modelMap['MailQueue']['class']; $model = new $table(); $prepareValues = []; $prepareKeys = []; $index = 1; foreach ($data as $item) { if (is_array($item)) { $prepareData = ArrayHelper::merge([$model->fieldFrom => '', $model->fieldTo => '', $model->fieldSubject => '', $model->fieldBody => '', $model->fieldAttachs => [], $model->fieldStatus => Yii::$app->get('mailqueue')->modelMap['MailQueue']['status']['unsended']], $item); $prepareData[$model->fieldAttachs] = BaseJson::encode($prepareData[$model->fieldAttachs]); if (in_array($model->fieldCreateDate, $model->attributes())) { $prepareData[$model->fieldCreateDate] = date("Y-m-d H:i:s"); } if (in_array($model->fieldUpdateDate, $model->attributes())) { $prepareData[$model->fieldUpdateDate] = date("Y-m-d H:i:s"); } $prepareKeys = empty($prepareKeys) ? array_keys($prepareData) : $prepareKeys; $prepareValues[] = array_values($prepareData); } if (($index % $this->partSize === 0 || $index >= count($data)) && false === empty($prepareValues)) { //Reconnect for big duration Yii::$app->db->close(); Yii::$app->db->open(); Yii::$app->db->createCommand()->batchInsert($table::tableName(), $prepareKeys, $prepareValues)->execute(); $prepareValues = []; } $index++; } //Reconnect for db stable works Yii::$app->db->close(); Yii::$app->db->open(); }
public function actionGuardarprecio() { $Producto = urldecode($_REQUEST["Producto"]); $Precio = urldecode($_REQUEST["Precio"]); $Marca = urldecode($_REQUEST["Marca"]); $NombreComercio = urldecode($_REQUEST["NombreComercio"]); $DireccionComercio = urldecode($_REQUEST["DireccionComercio"]); $Descripcion = urldecode($_REQUEST["Descripcion"]); $salida = []; $timezone = new \DateTimeZone('America/Argentina/Buenos_Aires'); $date = new \DateTime('now', $timezone); $model = new Precios(); $prod = new productos(); $prod->Nombre = $Producto; $model->Producto = $Producto; $model->Marca = $Marca; $model->Precio = $Precio; $model->FechaCarga = $date->format('Y-m-d'); $model->Descripcion = $Descripcion; $model->NombreComercio = $NombreComercio; $model->DireccionComercio = $DireccionComercio; if ($model->save() == 1) { $prod->save(); $salida["mensaje"] = "Precio guardado correctamente"; $salida["estado"] = "1"; } else { $salida["mensaje"] = $model->StringListaErrores("Revise el campo ", "<br>"); $salida["estado"] = "0"; } return BaseJson::encode($salida); }
/** * Updates an existing Providers model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $modelOptions = new OptionsProvider(); if ($modelOptions->load(Yii::$app->request->post()) && $modelOptions->validate()) { $model->name = $modelOptions->name; $model->options = BaseJson::encode($modelOptions->attributes); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'modelOptions' => $modelOptions]); } }
public function actionObtenerlista() { $arreglo_dir = scandir('../components/WebPlayer/webplayers/'); $cant_elementos = sizeof($arreglo_dir); $c = 0; for ($i = 0; $i < $cant_elementos; $i++) { if ($arreglo_dir[$i] != '.' && $arreglo_dir[$i] != '..') { $directorio[$c][0] = $arreglo_dir[$i]; $directorio[$c][1] = $c; $c++; } } return BaseJson::encode($directorio); }
public function actionDebug() { $jsonTravelerArray = array('addr' => '河南省三门峡市湖滨区会兴镇王官村', 'fax' => '86 519-85125379', 'zip' => '472000', 'mail' => '*****@*****.**'); echo BaseJson::encode($jsonTravelerArray) . '<br>'; $jsonGroupArray = array('corp' => '北京神舟国际旅行社集团有限公司', 'corpCode' => 'L-BJ-CJ00080', 'scope' => '旅行社、旅游酒店、商业、餐饮等', 'addr' => '朝阳区建外大街28号北京旅游大厦', 'tel' => '', 'fax' => '', 'zip' => '', 'mail' => ''); echo BaseJson::encode($jsonGroupArray) . '<br>'; $jsonPayArray = array('payEachAdult' => '1500', 'payEachChild' => '0', 'payTravel' => '3100', 'payDeadline' => '2016-01-11', 'payType' => '1'); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('purchases' => '1', 'insurance' => '中国人寿'); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('transAgree' => '0', 'transAgency' => '', 'delayAgree' => '0', 'changeLineAgree' => '0', 'terminateAgree' => '1', 'mergeAgree' => '1', 'mergeAgency' => '北京中旅', 'teminateDealType' => '2', 'committee' => ''); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('copys1' => '2', 'copys2' => '1', 'agencyComplaintsMobile' => '4000100808', 'lawCity' => '北京', 'lawComplaintsMobile' => '1', 'lawState' => '1', 'lawEmail' => '北京中旅', 'awAddress' => '2', 'lawZip' => '', 'addr' => ''); echo BaseJson::encode($jsonPayArray) . '<br>'; }
public function actionUpload() { $result = []; $dir = Yii::getAlias('@app/web/images/products'); if (!empty($_FILES)) { $model = new Products(); $file = UploadedFile::getInstance($model, 'upload_files[0]'); $ext = explode('.', $file->name); $ext = end($ext); $name = uniqid(); if ($file->saveAs($dir . '/' . $name . '.' . $ext)) { $result['name'] = $name . '.' . $ext; } } return BaseJson::encode($result); }
public function actionSend() { $req = Yii::$app->request; $to = "*****@*****.**"; // $to = "*****@*****.**"; $formContent = $req->post('ContactForm'); $title = $formContent['subject']; $msg = $formContent['body']; $name = $formContent['name']; $mail = $formContent['email']; $cabeceras = 'MIME-Version: 1.0' . "\r\n"; $cabeceras .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n"; $cabeceras .= 'From: ' . $mail . "\r\n"; $result = array(); $result['status'] = mail($to, $title, $msg, $cabeceras); return BaseJson::encode($result); }
public function actionMail() { # Indicamos la dirección (nombre) del servidor $server_name = "coodesoft.com.ar"; # Indicamos la dirección de correo de esa persona $person_email = "*****@*****.**"; # Las tres líneas que vienen a continuación son necesarias # para que la cabecera del mensaje esté en formato HTML $header = "MIME-Version: 1.0\n"; $header .= "Content-Type: text/html; charset=iso-8859-1\n"; $header .= "From: " . $_POST["mail"] . "\nReply-To:\n" . $_POST["mail"] . "\nX-Mailer: PHP/"; # Esto que viene es el mensaje. (Fíjate en los tags HTML) $mensaje = "\n<b>Mensaje enviado por: " . $_POST["nombre"] . "</b><br>\n<b>Mail: " . $_POST["mail"] . "</b>\n<br>\n<font face='verdana' size='2'>" . $_POST["cuerpo"] . "</font><br /><br />"; # Función de envío del mensaje mail($person_email, "[web coodesoft] " . $_POST["asunto"], $mensaje, $header); $salida["msg"] = "Pronto nos comunicaremos con usted, gracias!"; return BaseJson::encode($salida); }
function actionSetTags() { $module = Module::getInstance(); $req = Yii::$app->request; $filename = $req->post('rel'); $postTags = $req->post('SongForm'); $TextEncoding = 'UTF-8'; $getID3 = new getID3(); $getID3->setOption(array('encoding' => $TextEncoding)); $tagwriter = new getid3_writetags(); $tagwriter->filename = $module->params['music'] . "/" . htmlspecialchars_decode($filename); $tagwriter->tagformats = array('id3v2.4'); $tagwriter->tag_encoding = $TextEncoding; $tagwriter->remove_other_tags = false; $tagData = array(); foreach ($postTags as $index => $tag) { $tagData[$index] = array($tag); } $tagwriter->tag_data = $tagData; // write tags if ($tagwriter->WriteTags()) { $result['msg'] = "Se guardaron correctamente las etiquetas"; $result['status'] = 'success'; if (!empty($tagwriter->warnings)) { $result['msg'] = 'Ojo, hay algunas advertencias: ' . implode("-", $tagwriter->warnings); $result['status'] = 'warning'; } return BaseJson::encode($result); } else { $result['msg'] = 'Se produjo un error al escribir las etiquetas! ' . implode('-', $tagwriter->errors); $result['status'] = 'error'; return BaseJson::encode($result); } }
public function actionResultb() { $Model = new Busqueda(['TBusqueda' => urldecode($_REQUEST["TB"]), 'OrdenResu' => urldecode($_REQUEST["O"]), 'Desplaza' => urldecode($_REQUEST["D"]), 'CantReg' => urldecode($_REQUEST["C"]), 'Tabla' => urldecode($_REQUEST["T"]), 'CamposB' => urldecode($_REQUEST["CB"]), 'Filtros' => urldecode($_REQUEST["CO"])]); return BaseJson::encode($Model->Resultados()); }
/** * Set field attachs * @param Array $value */ public function setAttachs(array $value) { if (in_array(Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldAttachs'], $this->owner->attributes())) { $this->owner->{Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldAttachs']} = BaseJson::encode($value); } }